diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e731192..131cee2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -135,17 +135,32 @@ jobs: mv XrayR XrayR.exe - name: Prepare to release - run: | - cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md - cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE - cp ${GITHUB_WORKSPACE}/main/dns.json ./build_assets/dns.json - cp ${GITHUB_WORKSPACE}/main/route.json ./build_assets/route.json - cp ${GITHUB_WORKSPACE}/main/custom_outbound.json ./build_assets/custom_outbound.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/config.yml.example ./build_assets/config.yml - 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" + uses: nick-fields/retry@v2 + with: + timeout_minutes: 60 + retry_wait_seconds: 60 + max_attempts: 5 + command: | + cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md + cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + cp ${GITHUB_WORKSPACE}/main/dns.json ./build_assets/dns.json + cp ${GITHUB_WORKSPACE}/main/route.json ./build_assets/route.json + cp ${GITHUB_WORKSPACE}/main/custom_outbound.json ./build_assets/custom_outbound.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/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}')) + DOWNLOAD_URL="https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" + FILE_NAME="${INFO[2]}.dat" + echo -e "Downloading ${DOWNLOAD_URL}..." + curl -L "${DOWNLOAD_URL}" -o ./build_assets/${FILE_NAME} + echo -e "Verifying HASH key..." + HASH="$(curl -sL "${DOWNLOAD_URL}.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 shell: bash run: | diff --git a/service/controller/controller.go b/service/controller/controller.go index 047f8ae..902f295 100644 --- a/service/controller/controller.go +++ b/service/controller/controller.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "reflect" + "sync" "time" "github.com/xtls/xray-core/common/protocol" @@ -30,6 +31,7 @@ type LimitInfo struct { } type Controller struct { + sync.Mutex server *core.Instance config *Config clientInfo api.ClientInfo @@ -46,6 +48,7 @@ type Controller struct { stm stats.Manager dispatcher *mydispatcher.DefaultDispatcher startAt time.Time + dnsFeature *features.Feature } type periodicTask struct { @@ -660,8 +663,14 @@ func (c *Controller) addNewDNS(newNodeInfo *api.NodeInfo) error { return err } if feature, ok := obj.(features.Feature); ok { - if err := c.server.AddFeature(feature); err != nil { - return err + // todo fix memory leak + c.Lock() + defer c.Unlock() + if c.dnsFeature == nil { + c.dnsFeature = &feature + c.server.AddFeature(feature) + } else { + *c.dnsFeature = feature } }