From 8ddf257aa4ca8fa80cb795e80b635f4d8e5cd1ec Mon Sep 17 00:00:00 2001 From: Senis John Date: Tue, 27 Dec 2022 12:42:00 +0800 Subject: [PATCH] update: release.yml fix: typo --- .github/workflows/release.yml | 14 ++---------- api/newV2board/model.go | 4 ++-- api/newV2board/v2board.go | 42 +++++++++++++++-------------------- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a9cfff..e731192 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -144,18 +144,8 @@ jobs: cp ${GITHUB_WORKSPACE}/main/custom_inbound.json ./build_assets/custom_inbound.json cp ${GITHUB_WORKSPACE}/main/rulelist ./build_assets/rulelist cp ${GITHUB_WORKSPACE}/main/config.yml.example ./build_assets/config.yml - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') - for i in "${LIST[@]}" - 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 + wget -O ./build_assets/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat" + wget -O ./build_assets/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat" - name: Create ZIP archive shell: bash run: | diff --git a/api/newV2board/model.go b/api/newV2board/model.go index dc6a22f..55c8dd8 100644 --- a/api/newV2board/model.go +++ b/api/newV2board/model.go @@ -29,8 +29,8 @@ type serverConfig struct { Tls int `json:"tls"` // trojan - Host string `json:"host"` - ServerName *string `json:"server_name"` + Host string `json:"host"` + ServerName string `json:"server_name"` } type route struct { diff --git a/api/newV2board/v2board.go b/api/newV2board/v2board.go index 1462eea..fd92ebb 100644 --- a/api/newV2board/v2board.go +++ b/api/newV2board/v2board.go @@ -84,7 +84,7 @@ func readLocalRuleList(path string) (LocalRuleList []api.DetectRule) { if path != "" { // open the file file, err := os.Open(path) - + defer file.Close() // handle errors while opening if err != nil { 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) return } - - file.Close() } return LocalRuleList @@ -132,8 +130,7 @@ func (c *APIClient) parseServerConfig(res *resty.Response, path string, err erro } if res.StatusCode() > 399 { - body := res.Body() - return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), string(body), err) + return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), res.String(), err) } s := new(serverConfig) @@ -153,19 +150,18 @@ func (c *APIClient) parseUsers(res *resty.Response, path string, err error) ([]* } if res.StatusCode() > 399 { - body := res.Body() - return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), string(body), err) + return nil, fmt.Errorf("request %s failed: %s, %s", c.assembleURL(path), res.String(), err) } - var u []*user + var users []*user if data, err := simplejson.NewJson(res.Body()); err != nil { return nil, fmt.Errorf("ret %s invalid", res.String()) } else { 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 @@ -191,11 +187,11 @@ func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error) { case "Shadowsocks": nodeInfo, err = c.parseSSNodeResponse(server) default: - return nil, fmt.Errorf("unsupported Node type: %s", c.NodeType) + return nil, fmt.Errorf("unsupported node type: %s", c.NodeType) } 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 @@ -209,7 +205,7 @@ func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error) { case "V2ray", "Trojan", "Shadowsocks": break 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(). @@ -327,8 +323,8 @@ func (c *APIClient) parseTrojanNodeResponse(s *serverConfig) (*api.NodeInfo, err EnableTLS: true, TLSType: TLSType, Host: s.Host, - ServiceName: *s.ServerName, - NameServerConfig: parseDNSConfig(s), + ServiceName: s.ServerName, + NameServerConfig: s.parseDNSConfig(), } return nodeInfo, nil } @@ -356,7 +352,7 @@ func (c *APIClient) parseSSNodeResponse(s *serverConfig) (*api.NodeInfo, error) TransportProtocol: "tcp", CypherMethod: s.Cipher, ServerKey: s.ServerKey, // shadowsocks2022 share key - NameServerConfig: parseDNSConfig(s), + NameServerConfig: s.parseDNSConfig(), Header: header, }, nil } @@ -411,18 +407,16 @@ func (c *APIClient) parseV2rayNodeResponse(s *serverConfig) (*api.NodeInfo, erro EnableVless: c.EnableVless, ServiceName: serviceName, Header: header, - NameServerConfig: parseDNSConfig(s), + NameServerConfig: s.parseDNSConfig(), }, nil } -func parseDNSConfig(s *serverConfig) (nameServerList []*conf.NameServerConfig) { - routes := s.Routes - - for i := range routes { - if routes[i].Action == "dns" { +func (s *serverConfig) parseDNSConfig() (nameServerList []*conf.NameServerConfig) { + for i := range s.Routes { + if s.Routes[i].Action == "dns" { nameServerList = append(nameServerList, &conf.NameServerConfig{ - Address: &conf.Address{Address: net.ParseAddress(routes[i].ActionValue)}, - Domains: routes[i].Match, + Address: &conf.Address{Address: net.ParseAddress(s.Routes[i].ActionValue)}, + Domains: s.Routes[i].Match, }) } }