update: release.yml

fix: typo
This commit is contained in:
Senis John 2022-12-27 12:42:00 +08:00
parent a8742426b3
commit 8ddf257aa4
No known key found for this signature in database
GPG Key ID: 845E9E4727C3E1A4
3 changed files with 22 additions and 38 deletions

View File

@ -144,18 +144,8 @@ jobs:
cp ${GITHUB_WORKSPACE}/main/custom_inbound.json ./build_assets/custom_inbound.json cp ${GITHUB_WORKSPACE}/main/custom_inbound.json ./build_assets/custom_inbound.json
cp ${GITHUB_WORKSPACE}/main/rulelist ./build_assets/rulelist cp ${GITHUB_WORKSPACE}/main/rulelist ./build_assets/rulelist
cp ${GITHUB_WORKSPACE}/main/config.yml.example ./build_assets/config.yml cp ${GITHUB_WORKSPACE}/main/config.yml.example ./build_assets/config.yml
LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') wget -O ./build_assets/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
for i in "${LIST[@]}" wget -O ./build_assets/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"
do
INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}'))
LASTEST_TAG="$(curl -sL "https://api.github.com/repos/v2fly/${INFO[0]}/releases" | jq -r ".[0].tag_name" || echo "latest")"
FILE_NAME="${INFO[2]}.dat"
echo -e "Downloading ${FILE_NAME}..."
curl -L "https://github.com/v2fly/${INFO[0]}/releases/download/${LASTEST_TAG}/${INFO[1]}.dat" -o ./build_assets/${FILE_NAME}
echo -e "Verifying HASH key..."
HASH="$(curl -sL "https://github.com/v2fly/${INFO[0]}/releases/download/${LASTEST_TAG}/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')"
[ "$(sha256sum "./build_assets/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; }
done
- name: Create ZIP archive - name: Create ZIP archive
shell: bash shell: bash
run: | run: |

View File

@ -30,7 +30,7 @@ type serverConfig struct {
// trojan // trojan
Host string `json:"host"` Host string `json:"host"`
ServerName *string `json:"server_name"` ServerName string `json:"server_name"`
} }
type route struct { type route struct {

View File

@ -84,7 +84,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
if path != "" { if path != "" {
// open the file // open the file
file, err := os.Open(path) file, err := os.Open(path)
defer file.Close()
// handle errors while opening // handle errors while opening
if err != nil { if err != nil {
log.Printf("Error when opening file: %s", err) log.Printf("Error when opening file: %s", err)
@ -105,8 +105,6 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) {
log.Fatalf("Error while reading file: %s", err) log.Fatalf("Error while reading file: %s", err)
return return
} }
file.Close()
} }
return LocalRuleList return LocalRuleList
@ -132,8 +130,7 @@ func (c *APIClient) parseServerConfig(res *resty.Response, path string, err erro
} }
if res.StatusCode() > 399 { if res.StatusCode() > 399 {
body := res.Body() return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), res.String(), err)
return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), string(body), err)
} }
s := new(serverConfig) s := new(serverConfig)
@ -153,19 +150,18 @@ func (c *APIClient) parseUsers(res *resty.Response, path string, err error) ([]*
} }
if res.StatusCode() > 399 { if res.StatusCode() > 399 {
body := res.Body() return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), res.String(), err)
return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), string(body), err)
} }
var u []*user var users []*user
if data, err := simplejson.NewJson(res.Body()); err != nil { if data, err := simplejson.NewJson(res.Body()); err != nil {
return nil, fmt.Errorf("ret %s invalid", res.String()) return nil, fmt.Errorf("ret %s invalid", res.String())
} else { } else {
b, _ := data.Get("users").MarshalJSON() b, _ := data.Get("users").MarshalJSON()
json.Unmarshal(b, &u) json.Unmarshal(b, &users)
} }
return u, nil return users, nil
} }
// GetNodeInfo will pull NodeInfo Config from panel // GetNodeInfo will pull NodeInfo Config from panel
@ -191,11 +187,11 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) {
case "Shadowsocks": case "Shadowsocks":
nodeInfo, err = c.parseSSNodeResponse(server) nodeInfo, err = c.parseSSNodeResponse(server)
default: default:
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType) return nil, fmt.Errorf("unsupported node type: %s", c.NodeType)
} }
if err != nil { if err != nil {
return nil, fmt.Errorf("Parse node info failed: %s, \nError: %s", res.String(), err) return nil, fmt.Errorf("parse node info failed: %s, \nError: %s", res.String(), err)
} }
return nodeInfo, nil return nodeInfo, nil
@ -209,7 +205,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) {
case "V2ray", "Trojan", "Shadowsocks": case "V2ray", "Trojan", "Shadowsocks":
break break
default: default:
return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType) return nil, fmt.Errorf("unsupported node type: %s", c.NodeType)
} }
res, err := c.client.R(). res, err := c.client.R().
@ -327,8 +323,8 @@ func (c *APIClient) parseTrojanNodeResponse(s *serverConfig) (*api.NodeInfo, err
EnableTLS: true, EnableTLS: true,
TLSType: TLSType, TLSType: TLSType,
Host: s.Host, Host: s.Host,
ServiceName: *s.ServerName, ServiceName: s.ServerName,
NameServerConfig: parseDNSConfig(s), NameServerConfig: s.parseDNSConfig(),
} }
return nodeInfo, nil return nodeInfo, nil
} }
@ -356,7 +352,7 @@ func (c *APIClient) parseSSNodeResponse(s *serverConfig) (*api.NodeInfo, error)
TransportProtocol: "tcp", TransportProtocol: "tcp",
CypherMethod: s.Cipher, CypherMethod: s.Cipher,
ServerKey: s.ServerKey, // shadowsocks2022 share key ServerKey: s.ServerKey, // shadowsocks2022 share key
NameServerConfig: parseDNSConfig(s), NameServerConfig: s.parseDNSConfig(),
Header: header, Header: header,
}, nil }, nil
} }
@ -411,18 +407,16 @@ func (c *APIClient) parseV2rayNodeResponse(s *serverConfig) (*api.NodeInfo, erro
EnableVless: c.EnableVless, EnableVless: c.EnableVless,
ServiceName: serviceName, ServiceName: serviceName,
Header: header, Header: header,
NameServerConfig: parseDNSConfig(s), NameServerConfig: s.parseDNSConfig(),
}, nil }, nil
} }
func parseDNSConfig(s *serverConfig) (nameServerList []*conf.NameServerConfig) { func (s *serverConfig) parseDNSConfig() (nameServerList []*conf.NameServerConfig) {
routes := s.Routes for i := range s.Routes {
if s.Routes[i].Action == "dns" {
for i := range routes {
if routes[i].Action == "dns" {
nameServerList = append(nameServerList, &conf.NameServerConfig{ nameServerList = append(nameServerList, &conf.NameServerConfig{
Address: &conf.Address{Address: net.ParseAddress(routes[i].ActionValue)}, Address: &conf.Address{Address: net.ParseAddress(s.Routes[i].ActionValue)},
Domains: routes[i].Match, Domains: s.Routes[i].Match,
}) })
} }
} }