fix: Try to fix dns memory leak

update: release.yml
This commit is contained in:
Senis John 2022-12-30 22:19:48 +08:00
parent 40c65a86fc
commit 21e0ebc428
No known key found for this signature in database
GPG Key ID: 845E9E4727C3E1A4
2 changed files with 37 additions and 13 deletions

View File

@ -135,7 +135,12 @@ jobs:
mv XrayR XrayR.exe mv XrayR XrayR.exe
- name: Prepare to release - name: Prepare to release
run: | 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}/README.md ./build_assets/README.md
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
cp ${GITHUB_WORKSPACE}/main/dns.json ./build_assets/dns.json cp ${GITHUB_WORKSPACE}/main/dns.json ./build_assets/dns.json
@ -144,8 +149,18 @@ 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
wget -O ./build_assets/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat" LIST=('geoip geoip geoip' 'domain-list-community dlc geosite')
wget -O ./build_assets/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat" 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 - name: Create ZIP archive
shell: bash shell: bash
run: | run: |

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"reflect" "reflect"
"sync"
"time" "time"
"github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/protocol"
@ -30,6 +31,7 @@ type LimitInfo struct {
} }
type Controller struct { type Controller struct {
sync.Mutex
server *core.Instance server *core.Instance
config *Config config *Config
clientInfo api.ClientInfo clientInfo api.ClientInfo
@ -46,6 +48,7 @@ type Controller struct {
stm stats.Manager stm stats.Manager
dispatcher *mydispatcher.DefaultDispatcher dispatcher *mydispatcher.DefaultDispatcher
startAt time.Time startAt time.Time
dnsFeature *features.Feature
} }
type periodicTask struct { type periodicTask struct {
@ -660,8 +663,14 @@ func (c *Controller) addNewDNS(newNodeInfo *api.NodeInfo) error {
return err return err
} }
if feature, ok := obj.(features.Feature); ok { if feature, ok := obj.(features.Feature); ok {
if err := c.server.AddFeature(feature); err != nil { // todo fix memory leak
return err c.Lock()
defer c.Unlock()
if c.dnsFeature == nil {
c.dnsFeature = &feature
c.server.AddFeature(feature)
} else {
*c.dnsFeature = feature
} }
} }