Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: XTLS/Xray-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v24.11.21
Choose a base ref
...
head repository: XTLS/Xray-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 3,124 additions and 3,164 deletions.
  1. +117 −0 .github/workflows/release-win7.yml
  2. +20 −79 .github/workflows/release.yml
  3. +65 −0 .github/workflows/scheduled-assets-update.yml
  4. +2 −14 .github/workflows/test.yml
  5. +0 −37 Makefile
  6. +15 −6 README.md
  7. +1 −1 app/dispatcher/default.go
  8. +13 −7 app/dns/nameserver.go
  9. +55 −40 app/dns/nameserver_doh.go
  10. +4 −8 app/dns/nameserver_fakedns.go
  11. +11 −4 app/dns/nameserver_local.go
  12. +1 −1 app/dns/nameserver_local_test.go
  13. +1 −3 app/dns/nameserver_quic.go
  14. +18 −9 app/metrics/config.pb.go
  15. +1 −0 app/metrics/config.proto
  16. +21 −1 app/metrics/metrics.go
  17. +5 −2 app/observatory/burst/burstobserver.go
  18. +8 −4 app/observatory/burst/healthping.go
  19. +5 −4 app/observatory/burst/ping.go
  20. +1 −1 app/observatory/command/command.go
  21. +11 −6 app/observatory/observer.go
  22. +1 −1 app/proxyman/command/command.go
  23. +3 −3 app/proxyman/inbound/dynamic.go
  24. +4 −0 app/proxyman/inbound/inbound.go
  25. +1 −2 app/proxyman/inbound/worker.go
  26. +10 −1 app/proxyman/outbound/handler.go
  27. +6 −6 app/router/balancing.go
  28. +1 −1 app/router/command/command.go
  29. +24 −9 app/router/condition_geoip_test.go
  30. +6 −16 app/router/condition_test.go
  31. +8 −6 app/router/strategy_leastload.go
  32. +7 −6 app/router/strategy_leastping.go
  33. +6 −6 app/router/strategy_random.go
  34. +18 −0 app/stats/command/command.go
  35. +135 −57 app/stats/command/command.pb.go
  36. +6 −0 app/stats/command/command.proto
  37. +42 −4 app/stats/command/command_grpc.pb.go
  38. +10 −0 app/stats/online_map.go
  39. +3 −3 common/common.go
  40. +3 −3 common/log/logger.go
  41. +4 −6 common/net/destination.go
  42. +2 −1 common/net/system.go
  43. +2 −1 common/protocol/tls/cert/.gitignore
  44. +2 −2 common/protocol/tls/cert/cert_test.go
  45. +9 −1 common/reflect/marshal.go
  46. +116 −87 common/reflect/marshal_test.go
  47. +24 −0 common/session/context.go
  48. +6 −8 core/config.go
  49. +2 −2 core/core.go
  50. +87 −44 core/xray.go
  51. +1 −1 core/xray_test.go
  52. +1 −1 features/inbound/inbound.go
  53. +1 −1 features/routing/context.go
  54. +3 −0 features/stats/stats.go
  55. +21 −21 go.mod
  56. +58 −42 go.sum
  57. +31 −0 infra/conf/common.go
  58. +7 −7 infra/conf/dns.go
  59. +18 −23 infra/conf/freedom.go
  60. +9 −3 infra/conf/metrics.go
  61. +137 −181 infra/conf/transport_internet.go
  62. +4 −1 infra/conf/xray.go
  63. +1 −6 infra/conf/xray_test.go
  64. +4 −3 infra/vformat/main.go
  65. +7 −7 infra/vprotogen/main.go
  66. +1 −0 main/commands/all/api/api.go
  67. +5 −10 main/commands/all/api/balancer_info.go
  68. +11 −15 main/commands/all/api/balancer_override.go
  69. +15 −7 main/commands/all/api/inbound_user.go
  70. +13 −7 main/commands/all/api/inbound_user_count.go
  71. +9 −4 main/commands/all/api/inbounds_add.go
  72. +9 −4 main/commands/all/api/inbounds_remove.go
  73. +10 −3 main/commands/all/api/logger_restart.go
  74. +9 −4 main/commands/all/api/outbounds_add.go
  75. +9 −4 main/commands/all/api/outbounds_remove.go
  76. +9 −4 main/commands/all/api/rules_add.go
  77. +10 −5 main/commands/all/api/rules_remove.go
  78. +2 −1 main/commands/all/api/shared.go
  79. +19 −10 main/commands/all/api/source_ip_block.go
  80. +14 −7 main/commands/all/api/stats_get.go
  81. +14 −10 main/commands/all/api/stats_online.go
  82. +51 −0 main/commands/all/api/stats_online_ip_list.go
  83. +12 −5 main/commands/all/api/stats_query.go
  84. +12 −5 main/commands/all/api/stats_sys.go
  85. +3 −3 main/commands/all/convert/json.go
  86. +2 −2 main/commands/all/convert/protobuf.go
  87. +2 −1 main/commands/all/curve25519.go
  88. +2 −2 main/commands/all/tls/cert.go
  89. +0 −1 main/distro/all/all.go
  90. +1 −0 main/run.go
  91. +1 −1 proxy/dns/dns.go
  92. +26 −17 proxy/dokodemo/dokodemo.go
  93. +46 −46 proxy/freedom/config.pb.go
  94. +1 −1 proxy/freedom/config.proto
  95. +6 −3 proxy/freedom/freedom.go
  96. +1 −0 proxy/http/client.go
  97. +1 −0 proxy/http/server.go
  98. +138 −60 proxy/proxy.go
  99. +2 −0 proxy/socks/client.go
  100. +10 −1 proxy/socks/server.go
  101. +2 −2 proxy/vless/encoding/addons.go
  102. +14 −10 proxy/vless/encoding/encoding.go
  103. +6 −6 proxy/vless/inbound/inbound.go
  104. +4 −4 proxy/vless/outbound/outbound.go
  105. +1 −1 proxy/wireguard/gvisortun/tun.go
  106. +4 −3 proxy/wireguard/server.go
  107. +1 −1 proxy/wireguard/tun.go
  108. +2 −0 testing/scenarios/common.go
  109. +12 −0 testing/scenarios/main_test.go
  110. +0 −123 testing/scenarios/tls_test.go
  111. +69 −11 transport/internet/browser_dialer/dialer.go
  112. +47 −23 transport/internet/browser_dialer/dialer.html
  113. +34 −34 transport/internet/config.pb.go
  114. +2 −2 transport/internet/config.proto
  115. +0 −48 transport/internet/http/config.go
  116. +0 −193 transport/internet/http/config.pb.go
  117. +0 −18 transport/internet/http/config.proto
  118. +0 −311 transport/internet/http/dialer.go
  119. +0 −3 transport/internet/http/http.go
  120. +0 −172 transport/internet/http/http_test.go
  121. +0 −252 transport/internet/http/hub.go
  122. +11 −5 transport/internet/httpupgrade/dialer.go
  123. +6 −6 transport/internet/reality/reality.go
  124. +0 −6 transport/internet/sockopt_darwin.go
  125. +0 −5 transport/internet/sockopt_linux.go
  126. +0 −5 transport/internet/sockopt_windows.go
  127. +16 −11 transport/internet/splithttp/browser_client.go
  128. +84 −102 transport/internet/splithttp/client.go
  129. +72 −46 transport/internet/splithttp/config.go
  130. +251 −217 transport/internet/splithttp/config.pb.go
  131. +24 −21 transport/internet/splithttp/config.proto
  132. +193 −106 transport/internet/splithttp/dialer.go
  133. +159 −105 transport/internet/splithttp/hub.go
  134. +0 −47 transport/internet/splithttp/lazy_reader.go
  135. +80 −69 transport/internet/splithttp/mux.go
  136. +35 −31 transport/internet/splithttp/mux_test.go
  137. +15 −15 transport/internet/splithttp/splithttp_test.go
  138. +19 −11 transport/internet/splithttp/upload_queue.go
  139. +38 −18 transport/internet/system_listener.go
  140. +2 −1 transport/internet/tagged/tagged.go
  141. +1 −8 transport/internet/tagged/taggedimpl/impl.go
  142. +58 −2 transport/internet/tcp/dialer.go
  143. +57 −7 transport/internet/tls/config.go
  144. +29 −16 transport/internet/tls/config.pb.go
  145. +10 −6 transport/internet/tls/config.proto
  146. +10 −15 transport/internet/tls/tls.go
  147. +0 −1 transport/internet/websocket/config.go
  148. +26 −15 transport/internet/websocket/config.pb.go
  149. +1 −0 transport/internet/websocket/config.proto
  150. +12 −1 transport/internet/websocket/connection.go
  151. +14 −5 transport/internet/websocket/dialer.go
  152. +1 −1 transport/internet/websocket/hub.go
117 changes: 117 additions & 0 deletions .github/workflows/release-win7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Build and Release for Windows 7

on:
workflow_dispatch:
release:
types: [published]
push:
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
permissions:
contents: write
strategy:
matrix:
include:
# BEGIN Windows 7
- goos: windows
goarch: amd64
assetname: win7-64
- goos: windows
goarch: 386
assetname: win7-32
# END Windows 7
fail-fast: false

runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos}}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
steps:
- name: Checkout codebase
uses: actions/checkout@v4

- name: Show workflow information
run: |
_NAME=${{ matrix.assetname }}
echo "GOOS: ${{ matrix.goos }}, GOARCH: ${{ matrix.goarch }}, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true

- name: Setup patched builder
run: |
GOSDK=$(go env GOROOT)
rm -r $GOSDK/*
cd $GOSDK
curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip
unzip ./go-for-win7-linux-amd64.zip -d $GOSDK
rm ./go-for-win7-linux-amd64.zip
- name: Get project dependencies
run: go mod download

- name: Build Xray
run: |
mkdir -p build_assets
COMMID=$(git describe --always --dirty)
echo 'Building Xray for Windows 7...'
go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
# The line below is for without running conhost.exe version. Commented for not being used. Provided for reference.
# go build -o build_assets/wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
- name: Restore Geodat Cache
uses: actions/cache/restore@v4
with:
path: resources
key: xray-geodat-

- name: Copy README.md & LICENSE
run: |
mv -f resources/* build_assets
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
- name: Create ZIP archive
if: github.event_name == 'release'
shell: bash
run: |
pushd build_assets || exit 1
touch -mt $(date +%Y01010000) *
zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip .
popd || exit 1
FILE=./Xray-${{ env.ASSET_NAME }}.zip
DGST=$FILE.dgst
for METHOD in {"md5","sha1","sha256","sha512"}
do
openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
done
- name: Change the name
run: |
mv build_assets Xray-${{ env.ASSET_NAME }}
- name: Upload files to Artifacts
uses: actions/upload-artifact@v4
with:
name: Xray-${{ env.ASSET_NAME }}
path: |
./Xray-${{ env.ASSET_NAME }}/*
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
if: github.event_name == 'release'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./Xray-${{ env.ASSET_NAME }}.zip*
tag: ${{ github.ref }}
file_glob: true
99 changes: 20 additions & 79 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,23 @@
name: Build and Release

# NOTE: This Github Actions file depends on the Makefile.
# Building the correct package requires the correct binaries generated by the Makefile. To
# ensure the correct output, the Makefile must accept the appropriate input and compile the
# correct file with the correct name. If you need to modify this file, please ensure it won't
# disrupt the Makefile.

on:
workflow_dispatch:
release:
types: [published]
push:
branches:
- main
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/release.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/release.yml"
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Restore Cache
uses: actions/cache/restore@v4
with:
path: resources
key: xray-geodat-

- name: Update Geodat
id: update
uses: nick-fields/retry@v3
with:
timeout_minutes: 60
retry_wait_seconds: 60
max_attempts: 60
command: |
[ -d 'resources' ] || mkdir resources
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}'))
FILE_NAME="${INFO[2]}.dat"
echo -e "Verifying HASH key..."
HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')"
if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then
continue
else
echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..."
curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME}
echo -e "Verifying HASH key..."
[ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; }
echo "unhit=true" >> $GITHUB_OUTPUT
fi
done
- name: Save Cache
uses: actions/cache/save@v4
if: ${{ steps.update.outputs.unhit }}
with:
path: resources
key: xray-geodat-${{ github.sha }}-${{ github.run_number }}

jobs:
build:
needs: prepare
permissions:
contents: write
strategy:
matrix:
# Include amd64 on all platforms.
goos: [windows, freebsd, openbsd, linux, darwin]
goarch: [amd64, 386]
gotoolchain: [""]
patch-assetname: [""]

exclude:
# Exclude i386 on darwin
- goarch: 386
@@ -155,16 +92,6 @@ jobs:
goarch: arm
goarm: 7
# END OPENBSD ARM
# BEGIN Windows 7
- goos: windows
goarch: amd64
gotoolchain: 1.21.4
patch-assetname: win7-64
- goos: windows
goarch: 386
gotoolchain: 1.21.4
patch-assetname: win7-32
# END Windows 7
fail-fast: false

runs-on: ubuntu-latest
@@ -187,7 +114,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.gotoolchain || '1.23' }}
go-version-file: go.mod
check-latest: true

- name: Get project dependencies
@@ -196,10 +123,24 @@ jobs:
- name: Build Xray
run: |
mkdir -p build_assets
make
find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \;
- name: Restore Cache
COMMID=$(git describe --always --dirty)
if [[ ${GOOS} == 'windows' ]]; then
echo 'Building Xray for Windows...'
go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
# The line below is for without running conhost.exe version. Commented for not being used. Provided for reference.
# go build -o build_assets/wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
else
echo 'Building Xray...'
go build -o build_assets/xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
if [[ ${GOARCH} == 'mips' || ${GOARCH} == 'mipsle' ]]; then
echo 'Building soft-float Xray for MIPS/MIPSLE 32-bit...'
GOMIPS=softfloat go build -o build_assets/xray_softfloat -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
fi
fi
- name: Restore Geodat Cache
uses: actions/cache/restore@v4
with:
path: resources
65 changes: 65 additions & 0 deletions .github/workflows/scheduled-assets-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Scheduled assets update

# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a
# routine manner, for example: GeoIP/GeoSite.
# Currently updating:
# - Geodat (GeoIP/Geosite)

on:
workflow_dispatch:
schedule:
# Update GeoData on every day (22:30 UTC)
- cron: '30 22 * * *'
push:
# Prevent triggering update request storm
paths:
- ".github/workflows/scheduled-assets-update.yml"
pull_request:
# Prevent triggering update request storm
paths:
- ".github/workflows/scheduled-assets-update.yml"

jobs:
geodat:
if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Restore Geodat Cache
uses: actions/cache/restore@v4
with:
path: resources
key: xray-geodat-

- name: Update Geodat
id: update
uses: nick-fields/retry@v3
with:
timeout_minutes: 60
retry_wait_seconds: 60
max_attempts: 60
command: |
[ -d 'resources' ] || mkdir resources
LIST=('Loyalsoldier v2ray-rules-dat geoip geoip' 'Loyalsoldier v2ray-rules-dat geosite geosite')
for i in "${LIST[@]}"
do
INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3,$4}'))
FILE_NAME="${INFO[3]}.dat"
echo -e "Verifying HASH key..."
HASH="$(curl -sL "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat.sha256sum" | awk -F ' ' '{print $1}')"
if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then
continue
else
echo -e "Downloading https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat..."
curl -L "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat" -o ./resources/${FILE_NAME}
echo -e "Verifying HASH key..."
[ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; }
echo "unhit=true" >> $GITHUB_OUTPUT
fi
done
- name: Save Geodat Cache
uses: actions/cache/save@v4
if: ${{ steps.update.outputs.unhit }}
with:
path: resources
key: xray-geodat-${{ github.sha }}-${{ github.run_number }}
16 changes: 2 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -2,20 +2,8 @@ name: Test

on:
push:
branches:
- main
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"

jobs:
test:
@@ -32,9 +20,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
go-version-file: go.mod
check-latest: true
- name: Restore Cache
- name: Restore Geodat Cache
uses: actions/cache/restore@v4
with:
path: resources
37 changes: 0 additions & 37 deletions Makefile

This file was deleted.

Loading