mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-20 16:49:12 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa570b7825 | ||
|
|
c456141815 | ||
|
|
f082058590 | ||
|
|
e184d774a2 | ||
|
|
14df0738f3 | ||
|
|
36cc9ff510 | ||
|
|
c43ee98ec7 |
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"android-arm64": { "friendlyName": "android-arm64-v8a" },
|
"android-arm64": { "friendlyName": "android-arm64-v8a" },
|
||||||
|
"android-amd64": { "friendlyName": "android-amd64" },
|
||||||
"darwin-amd64": { "friendlyName": "macos-64" },
|
"darwin-amd64": { "friendlyName": "macos-64" },
|
||||||
"darwin-arm64": { "friendlyName": "macos-arm64-v8a" },
|
"darwin-arm64": { "friendlyName": "macos-arm64-v8a" },
|
||||||
"freebsd-386": { "friendlyName": "freebsd-32" },
|
"freebsd-386": { "friendlyName": "freebsd-32" },
|
||||||
@@ -14,9 +15,7 @@
|
|||||||
"linux-arm7": { "friendlyName": "linux-arm32-v7a" },
|
"linux-arm7": { "friendlyName": "linux-arm32-v7a" },
|
||||||
"linux-mips64le": { "friendlyName": "linux-mips64le" },
|
"linux-mips64le": { "friendlyName": "linux-mips64le" },
|
||||||
"linux-mips64": { "friendlyName": "linux-mips64" },
|
"linux-mips64": { "friendlyName": "linux-mips64" },
|
||||||
"linux-mipslesoftfloat": { "friendlyName": "linux-mips32le-softfloat" },
|
|
||||||
"linux-mipsle": { "friendlyName": "linux-mips32le" },
|
"linux-mipsle": { "friendlyName": "linux-mips32le" },
|
||||||
"linux-mipssoftfloat": { "friendlyName": "linux-mips32-softfloat" },
|
|
||||||
"linux-mips": { "friendlyName": "linux-mips32" },
|
"linux-mips": { "friendlyName": "linux-mips32" },
|
||||||
"linux-ppc64le": { "friendlyName": "linux-ppc64le" },
|
"linux-ppc64le": { "friendlyName": "linux-ppc64le" },
|
||||||
"linux-ppc64": { "friendlyName": "linux-ppc64" },
|
"linux-ppc64": { "friendlyName": "linux-ppc64" },
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
name: Build and Release for Windows 7
|
name: Build and Release for Windows 7
|
||||||
|
# Pre-compiling support removal since 1.29
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, synchronize, reopened]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-assets:
|
check-assets:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
|
|
||||||
steps:
|
steps:
|
||||||
- name: Restore Geodat Cache
|
- name: Restore Geodat Cache
|
||||||
uses: actions/cache/restore@v6
|
uses: actions/cache/restore@v6
|
||||||
@@ -115,8 +112,6 @@ jobs:
|
|||||||
COMMID=$(git describe --always --dirty)
|
COMMID=$(git describe --always --dirty)
|
||||||
echo 'Building Xray for Windows 7...'
|
echo 'Building Xray for Windows 7...'
|
||||||
go build -o build_assets/xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
go build -o build_assets/xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
||||||
# 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 -gcflags="all=-l=4" -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
|
||||||
|
|
||||||
- name: Restore Geodat Cache
|
- name: Restore Geodat Cache
|
||||||
uses: actions/cache/restore@v6
|
uses: actions/cache/restore@v6
|
||||||
@@ -152,6 +147,13 @@ jobs:
|
|||||||
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
|
||||||
|
|
||||||
|
- name: Upload files to Artifacts
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: Xray-${{ env.ASSET_NAME }}
|
||||||
|
path: |
|
||||||
|
./build_assets/*
|
||||||
|
|
||||||
- name: Create ZIP archive
|
- name: Create ZIP archive
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -175,10 +177,3 @@ jobs:
|
|||||||
file: ./Xray-${{ env.ASSET_NAME }}.zip*
|
file: ./Xray-${{ env.ASSET_NAME }}.zip*
|
||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file_glob: true
|
file_glob: true
|
||||||
|
|
||||||
- name: Upload files to Artifacts
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: Xray-${{ env.ASSET_NAME }}
|
|
||||||
path: |
|
|
||||||
./build_assets/*
|
|
||||||
|
|||||||
+178
-85
@@ -79,86 +79,23 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# Include amd64 on all platforms.
|
# Include amd64 and arm64 on all platforms.
|
||||||
goos: [windows, freebsd, openbsd, linux, darwin]
|
goos: [windows, freebsd, openbsd, linux, darwin, android]
|
||||||
goarch: [amd64, 386]
|
goarch: [amd64, arm64]
|
||||||
patch-assetname: [""]
|
patch-assetname: [""]
|
||||||
exclude:
|
|
||||||
# Exclude i386 on darwin
|
|
||||||
- goarch: 386
|
|
||||||
goos: darwin
|
|
||||||
include:
|
include:
|
||||||
# BEGIN MacOS ARM64
|
# BEGIN Linux specified
|
||||||
- goos: darwin
|
|
||||||
goarch: arm64
|
|
||||||
# END MacOS ARM64
|
|
||||||
# BEGIN Linux ARM 5 6 7
|
|
||||||
- goos: linux
|
|
||||||
goarch: arm
|
|
||||||
goarm: 7
|
|
||||||
- goos: linux
|
|
||||||
goarch: arm
|
|
||||||
goarm: 6
|
|
||||||
- goos: linux
|
|
||||||
goarch: arm
|
|
||||||
goarm: 5
|
|
||||||
# END Linux ARM 5 6 7
|
|
||||||
# BEGIN Android ARM 8
|
|
||||||
- goos: android
|
|
||||||
goarch: arm64
|
|
||||||
# END Android ARM 8
|
|
||||||
# BEGIN Android AMD64
|
|
||||||
- goos: android
|
|
||||||
goarch: amd64
|
|
||||||
patch-assetname: android-amd64
|
|
||||||
# END Android AMD64
|
|
||||||
# Windows ARM
|
|
||||||
- goos: windows
|
|
||||||
goarch: arm64
|
|
||||||
# BEGIN Other architectures
|
|
||||||
# BEGIN riscv64 & ARM64 & LOONG64
|
|
||||||
- goos: linux
|
|
||||||
goarch: arm64
|
|
||||||
- goos: linux
|
|
||||||
goarch: riscv64
|
|
||||||
- goos: linux
|
|
||||||
goarch: loong64
|
|
||||||
# END riscv64 & ARM64 & LOONG64
|
|
||||||
# BEGIN MIPS
|
|
||||||
- goos: linux
|
|
||||||
goarch: mips64
|
|
||||||
- goos: linux
|
|
||||||
goarch: mips64le
|
|
||||||
- goos: linux
|
|
||||||
goarch: mipsle
|
|
||||||
- goos: linux
|
|
||||||
goarch: mips
|
|
||||||
# END MIPS
|
|
||||||
# BEGIN PPC
|
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: ppc64
|
goarch: ppc64
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: ppc64le
|
goarch: ppc64le
|
||||||
# END PPC
|
|
||||||
# BEGIN FreeBSD ARM
|
|
||||||
- goos: freebsd
|
|
||||||
goarch: arm64
|
|
||||||
- goos: freebsd
|
|
||||||
goarch: arm
|
|
||||||
goarm: 7
|
|
||||||
# END FreeBSD ARM
|
|
||||||
# BEGIN S390X
|
|
||||||
- goos: linux
|
- goos: linux
|
||||||
goarch: s390x
|
goarch: s390x
|
||||||
# END S390X
|
- goos: linux
|
||||||
# END Other architectures
|
goarch: riscv64
|
||||||
# BEGIN OPENBSD ARM
|
- goos: linux
|
||||||
- goos: openbsd
|
goarch: loong64
|
||||||
goarch: arm64
|
# END Linux specified
|
||||||
- goos: openbsd
|
|
||||||
goarch: arm
|
|
||||||
goarm: 7
|
|
||||||
# END OPENBSD ARM
|
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -166,7 +103,6 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GOOS: ${{ matrix.goos }}
|
GOOS: ${{ matrix.goos }}
|
||||||
GOARCH: ${{ matrix.goarch }}
|
GOARCH: ${{ matrix.goarch }}
|
||||||
GOARM: ${{ matrix.goarm }}
|
|
||||||
CGO_ENABLED: 0
|
CGO_ENABLED: 0
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout codebase
|
- name: Checkout codebase
|
||||||
@@ -188,8 +124,8 @@ jobs:
|
|||||||
- name: Show workflow information
|
- name: Show workflow information
|
||||||
run: |
|
run: |
|
||||||
_NAME=${{ matrix.patch-assetname }}
|
_NAME=${{ matrix.patch-assetname }}
|
||||||
[ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json)
|
[ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH\"].friendlyName" -r < .github/build/friendly-filenames.json)
|
||||||
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME"
|
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
|
||||||
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
@@ -203,6 +139,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Xray
|
- name: Build Xray
|
||||||
run: |
|
run: |
|
||||||
|
case "${GOARCH}:${GOOS}" in
|
||||||
|
# Special processing for x86-64 and ARM64
|
||||||
|
amd64:windows|amd64:darwin)
|
||||||
|
GOAMD64="v2"
|
||||||
|
;;
|
||||||
|
arm64:windows)
|
||||||
|
GOARM64="v8.2"
|
||||||
|
;;
|
||||||
|
arm64:darwin)
|
||||||
|
GOARM64="v8.4"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
mkdir -p build_assets
|
mkdir -p build_assets
|
||||||
COMMID=$(git describe --always --dirty)
|
COMMID=$(git describe --always --dirty)
|
||||||
if [[ ${GOOS} == 'windows' ]]; then
|
if [[ ${GOOS} == 'windows' ]]; then
|
||||||
@@ -215,13 +163,7 @@ jobs:
|
|||||||
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid= -checklinkname=0 -extldflags=-Wl,--pack-dyn-relocs=android" -v ./main
|
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid= -checklinkname=0 -extldflags=-Wl,--pack-dyn-relocs=android" -v ./main
|
||||||
else
|
else
|
||||||
echo 'Building Xray...'
|
echo 'Building Xray...'
|
||||||
if [[ ${GOARCH} == 'mips' || ${GOARCH} == 'mipsle' ]]; then
|
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
||||||
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
|
||||||
echo 'Building soft-float Xray for MIPS/MIPSLE 32-bit...'
|
|
||||||
GOMIPS=softfloat go build -o build_assets/xray_softfloat -trimpath -buildvcs=false -gcflags="-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
|
||||||
else
|
|
||||||
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Restore Geodat Cache
|
- name: Restore Geodat Cache
|
||||||
@@ -248,9 +190,6 @@ jobs:
|
|||||||
if [[ ${GOARCH} == 'amd64' ]]; then
|
if [[ ${GOARCH} == 'amd64' ]]; then
|
||||||
mv resources/wintun/bin/amd64/wintun.dll build_assets/
|
mv resources/wintun/bin/amd64/wintun.dll build_assets/
|
||||||
fi
|
fi
|
||||||
if [[ ${GOARCH} == '386' ]]; then
|
|
||||||
mv resources/wintun/bin/x86/wintun.dll build_assets/
|
|
||||||
fi
|
|
||||||
if [[ ${GOARCH} == 'arm64' ]]; then
|
if [[ ${GOARCH} == 'arm64' ]]; then
|
||||||
mv resources/wintun/bin/arm64/wintun.dll build_assets/
|
mv resources/wintun/bin/arm64/wintun.dll build_assets/
|
||||||
fi
|
fi
|
||||||
@@ -262,6 +201,13 @@ jobs:
|
|||||||
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
|
||||||
|
|
||||||
|
- name: Upload files to Artifacts
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: Xray-${{ env.ASSET_NAME }}
|
||||||
|
path: |
|
||||||
|
./build_assets/*
|
||||||
|
|
||||||
- name: Create ZIP archive
|
- name: Create ZIP archive
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -286,9 +232,156 @@ jobs:
|
|||||||
tag: ${{ github.ref }}
|
tag: ${{ github.ref }}
|
||||||
file_glob: true
|
file_glob: true
|
||||||
|
|
||||||
|
build-release-only:
|
||||||
|
needs: check-assets
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# First batch (since Go 1.29) of removal:
|
||||||
|
# x86: windows, linux, freebsd, openbsd
|
||||||
|
# arm: linux(v5), linux(v6)
|
||||||
|
# other: linux(mips), linux(mips64), linux(mips64le)
|
||||||
|
# Second batch (needs discussion) of removal
|
||||||
|
# arm(v7): freebsd, openbsd, linux
|
||||||
|
# other: linux(mipsle)
|
||||||
|
goos: [windows, freebsd, openbsd, linux]
|
||||||
|
goarch: [arm, 386]
|
||||||
|
goarm: [7]
|
||||||
|
exclude:
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
include:
|
||||||
|
# Second batch of removal [In the future]
|
||||||
|
- goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
# END of second batch
|
||||||
|
# First batch of removal [Go 1.29]
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 5
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 6
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64le
|
||||||
|
# END of first batch
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOARM: ${{ matrix.goarm }}
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
steps:
|
||||||
|
- name: Checkout codebase
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- name: Show workflow information
|
||||||
|
run: |
|
||||||
|
_NAME=${{ matrix.patch-assetname }}
|
||||||
|
if [[ ${GOARCH} == 'arm' ]]; then
|
||||||
|
[ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < .github/build/friendly-filenames.json)
|
||||||
|
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
|
||||||
|
else
|
||||||
|
echo "GOARM=''" >> $GITHUB_ENV
|
||||||
|
[ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH\"].friendlyName" -r < .github/build/friendly-filenames.json)
|
||||||
|
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
|
||||||
|
fi
|
||||||
|
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v7
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Get project dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Build Xray
|
||||||
|
run: |
|
||||||
|
mkdir -p build_assets
|
||||||
|
COMMID=$(git describe --always --dirty)
|
||||||
|
if [[ ${GOOS} == 'windows' ]]; then
|
||||||
|
echo 'Building Xray for Windows...'
|
||||||
|
go build -o build_assets/xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
||||||
|
else
|
||||||
|
echo 'Building Xray...'
|
||||||
|
if [[ ${GOARCH} == 'mips' || ${GOARCH} == 'mipsle' ]]; then
|
||||||
|
go build -o build_assets/xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
|
||||||
|
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
|
||||||
|
else
|
||||||
|
go build -o build_assets/xray -trimpath -buildvcs=false -gcflags="all=-l=4" -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@v6
|
||||||
|
with:
|
||||||
|
path: resources
|
||||||
|
key: xray-geodat-
|
||||||
|
|
||||||
|
- name: Restore Wintun Cache
|
||||||
|
if: matrix.goos == 'windows'
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: resources
|
||||||
|
key: xray-wintun-
|
||||||
|
|
||||||
|
- name: Add additional assets into package
|
||||||
|
run: |
|
||||||
|
mv -f resources/geo* build_assets/
|
||||||
|
if [[ ${GOOS} == 'windows' ]]; then
|
||||||
|
cp .github/build/windows/* build_assets/
|
||||||
|
fi
|
||||||
|
if [[ ${GOOS} == 'windows' ]]; then
|
||||||
|
echo 'Adding Wintun into packages'
|
||||||
|
if [[ ${GOARCH} == '386' ]]; then
|
||||||
|
mv resources/wintun/bin/x86/wintun.dll build_assets/
|
||||||
|
fi
|
||||||
|
mv resources/wintun/LICENSE.txt build_assets/LICENSE-Wintun
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Copy README.md & LICENSE
|
||||||
|
run: |
|
||||||
|
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
|
||||||
|
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
|
||||||
|
|
||||||
- name: Upload files to Artifacts
|
- name: Upload files to Artifacts
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Xray-${{ env.ASSET_NAME }}
|
name: Xray-${{ env.ASSET_NAME }}
|
||||||
path: |
|
path: |
|
||||||
./build_assets/*
|
./build_assets/*
|
||||||
|
|
||||||
|
- 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: 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
|
||||||
|
|||||||
@@ -231,6 +231,20 @@ Make sure that you are using the same Go version, and remember to set the git co
|
|||||||
CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For Windows (x86-64 and AArch64, not win7):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GOOS=windows GOARCH=amd64 GOAMD64=v2 CGO_ENABLED=0 go build -o xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
GOOS=windows GOARCH=arm64 GOARM64=v8.2 CGO_ENABLED=0 go build -o xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
```
|
||||||
|
|
||||||
|
For macOS:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GOOS=darwin GOARCH=amd64 GOAMD64=v2 CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
GOOS=darwin GOARCH=arm64 GOARM64=v8.4 CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
```
|
||||||
|
|
||||||
For Android:
|
For Android:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -238,10 +252,13 @@ GOOS=android GOARCH=arm64 CGO_ENABLED=1 CC=/path/to/aarch64-linux-android24-clan
|
|||||||
GOOS=android GOARCH=amd64 CGO_ENABLED=1 CC=/path/to/x86_64-linux-android24-clang go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid= -checklinkname=0 -extldflags=-Wl,--pack-dyn-relocs=android" -v ./main
|
GOOS=android GOARCH=amd64 CGO_ENABLED=1 CC=/path/to/x86_64-linux-android24-clang go build -o xray -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid= -checklinkname=0 -extldflags=-Wl,--pack-dyn-relocs=android" -v ./main
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are compiling a 32-bit MIPS/MIPSLE target, use this command instead:
|
For Linux (MIPS32 and MIPS32LE):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -gcflags="-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
GOOS=linux GOARCH=mips GOMIPS=hardfloat CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
GOOS=linux GOARCH=mipsle GOMIPS=hardfloat CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
|
GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main
|
||||||
```
|
```
|
||||||
|
|
||||||
## Stargazers over time
|
## Stargazers over time
|
||||||
|
|||||||
+13
-5
@@ -29,6 +29,7 @@ type MetricsHandler struct {
|
|||||||
listen string
|
listen string
|
||||||
tcpListener xnet.Listener
|
tcpListener xnet.Listener
|
||||||
listener *OutboundListener
|
listener *OutboundListener
|
||||||
|
server *http.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMetricsHandler creates a new MetricsHandler based on the given config.
|
// NewMetricsHandler creates a new MetricsHandler based on the given config.
|
||||||
@@ -50,7 +51,8 @@ func (p *MetricsHandler) Type() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *MetricsHandler) Start() error {
|
func (p *MetricsHandler) Start() error {
|
||||||
handler := p.httpHandler()
|
server := &http.Server{Handler: p.httpHandler()}
|
||||||
|
p.server = server
|
||||||
|
|
||||||
// direct listen a port if listen is set
|
// direct listen a port if listen is set
|
||||||
if p.listen != "" {
|
if p.listen != "" {
|
||||||
@@ -61,7 +63,7 @@ func (p *MetricsHandler) Start() error {
|
|||||||
p.tcpListener = TCPlistener
|
p.tcpListener = TCPlistener
|
||||||
errors.LogInfo(context.Background(), "Metrics server listening on ", p.listen)
|
errors.LogInfo(context.Background(), "Metrics server listening on ", p.listen)
|
||||||
|
|
||||||
go p.serve(TCPlistener, handler)
|
go p.serve(TCPlistener, server)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.tag == "" {
|
if p.tag == "" {
|
||||||
@@ -77,7 +79,7 @@ func (p *MetricsHandler) Start() error {
|
|||||||
}
|
}
|
||||||
p.listener = listener
|
p.listener = listener
|
||||||
|
|
||||||
go p.serve(listener, handler)
|
go p.serve(listener, server)
|
||||||
|
|
||||||
if err := p.ohm.RemoveHandler(context.Background(), p.tag); err != nil {
|
if err := p.ohm.RemoveHandler(context.Background(), p.tag); err != nil {
|
||||||
errors.LogInfo(context.Background(), "failed to remove existing handler")
|
errors.LogInfo(context.Background(), "failed to remove existing handler")
|
||||||
@@ -106,6 +108,12 @@ func (p *MetricsHandler) Close() error {
|
|||||||
errs = append(errs, p.listener.Close())
|
errs = append(errs, p.listener.Close())
|
||||||
p.listener = nil
|
p.listener = nil
|
||||||
}
|
}
|
||||||
|
if p.server != nil {
|
||||||
|
if err := p.server.Close(); !isClosedListenerError(err) {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
p.server = nil
|
||||||
|
}
|
||||||
if p.ohm != nil && p.tag != "" {
|
if p.ohm != nil && p.tag != "" {
|
||||||
if err := p.ohm.RemoveHandler(context.Background(), p.tag); err != nil {
|
if err := p.ohm.RemoveHandler(context.Background(), p.tag); err != nil {
|
||||||
errors.LogInfo(context.Background(), "failed to remove metrics handler")
|
errors.LogInfo(context.Background(), "failed to remove metrics handler")
|
||||||
@@ -114,8 +122,8 @@ func (p *MetricsHandler) Close() error {
|
|||||||
return errors.Combine(errs...)
|
return errors.Combine(errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *MetricsHandler) serve(listener xnet.Listener, handler http.Handler) {
|
func (p *MetricsHandler) serve(listener xnet.Listener, server *http.Server) {
|
||||||
if err := http.Serve(listener, handler); err != nil && !isClosedListenerError(err) {
|
if err := server.Serve(listener); err != nil && !isClosedListenerError(err) {
|
||||||
errors.LogErrorInner(context.Background(), err, "failed to start metrics server")
|
errors.LogErrorInner(context.Background(), err, "failed to start metrics server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,10 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou
|
|||||||
if config.Concurrency < 0 {
|
if config.Concurrency < 0 {
|
||||||
h.mux = &mux.ClientManager{Enabled: false}
|
h.mux = &mux.ClientManager{Enabled: false}
|
||||||
}
|
}
|
||||||
if config.Concurrency >= 0 && config.Concurrency <= 128 {
|
if config.Concurrency == 0 {
|
||||||
|
config.Concurrency = 8 // same as before
|
||||||
|
}
|
||||||
|
if config.Concurrency > 0 && config.Concurrency < 128 && h.streamSettings != nil && h.streamSettings.ProtocolName == "xdrive" {
|
||||||
config.Concurrency = 128
|
config.Concurrency = 128
|
||||||
}
|
}
|
||||||
if config.Concurrency > 0 {
|
if config.Concurrency > 0 {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !windows && !wasm && !illumos && !openbsd
|
//go:build !windows && !openbsd
|
||||||
// +build !windows,!wasm,!illumos,!openbsd
|
|
||||||
|
|
||||||
package buf
|
package buf
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !wasm && !openbsd
|
//go:build !openbsd
|
||||||
// +build !wasm,!openbsd
|
|
||||||
|
|
||||||
package buf
|
package buf
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build wasm || openbsd
|
//go:build openbsd
|
||||||
// +build wasm openbsd
|
|
||||||
|
|
||||||
package buf
|
package buf
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !wasm && !openbsd
|
//go:build !openbsd
|
||||||
// +build !wasm,!openbsd
|
|
||||||
|
|
||||||
package buf_test
|
package buf_test
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
//go:build illumos
|
|
||||||
// +build illumos
|
|
||||||
|
|
||||||
package buf
|
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
type unixReader struct {
|
|
||||||
iovs [][]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *unixReader) Init(bs []*Buffer) {
|
|
||||||
iovs := r.iovs
|
|
||||||
if iovs == nil {
|
|
||||||
iovs = make([][]byte, 0, len(bs))
|
|
||||||
}
|
|
||||||
for _, b := range bs {
|
|
||||||
iovs = append(iovs, b.v)
|
|
||||||
}
|
|
||||||
r.iovs = iovs
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *unixReader) Read(fd uintptr) int32 {
|
|
||||||
n, e := unix.Readv(int(fd), r.iovs)
|
|
||||||
if e != nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
return int32(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *unixReader) Clear() {
|
|
||||||
r.iovs = r.iovs[:0]
|
|
||||||
}
|
|
||||||
|
|
||||||
func newMultiReader() multiReader {
|
|
||||||
return &unixReader{}
|
|
||||||
}
|
|
||||||
@@ -236,6 +236,10 @@ func (w *BufferedWriter) Close() error {
|
|||||||
return common.Close(w.writer)
|
return common.Close(w.writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *BufferedWriter) Interrupt() {
|
||||||
|
common.Interrupt(w.writer)
|
||||||
|
}
|
||||||
|
|
||||||
// SequentialWriter is a Writer that writes MultiBuffer sequentially into the underlying io.Writer.
|
// SequentialWriter is a Writer that writes MultiBuffer sequentially into the underlying io.Writer.
|
||||||
type SequentialWriter struct {
|
type SequentialWriter struct {
|
||||||
io.Writer
|
io.Writer
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build generate
|
//go:build generate
|
||||||
// +build generate
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,9 @@ var (
|
|||||||
|
|
||||||
// NewClientWorker creates a new mux.Client.
|
// NewClientWorker creates a new mux.Client.
|
||||||
func NewClientWorker(stream transport.Link, s ClientStrategy) (*ClientWorker, error) {
|
func NewClientWorker(stream transport.Link, s ClientStrategy) (*ClientWorker, error) {
|
||||||
stream.Writer = &MutexWriter{Writer: stream.Writer}
|
writer := buf.NewBufferedWriter(stream.Writer)
|
||||||
|
writer.SetBuffered(false)
|
||||||
|
stream.Writer = writer
|
||||||
c := &ClientWorker{
|
c := &ClientWorker{
|
||||||
sessionManager: NewSessionManager(),
|
sessionManager: NewSessionManager(),
|
||||||
link: stream,
|
link: stream,
|
||||||
|
|||||||
@@ -93,9 +93,11 @@ type ServerWorker struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewServerWorker(ctx context.Context, d routing.Dispatcher, link *transport.Link) (*ServerWorker, error) {
|
func NewServerWorker(ctx context.Context, d routing.Dispatcher, link *transport.Link) (*ServerWorker, error) {
|
||||||
|
writer := buf.NewBufferedWriter(link.Writer)
|
||||||
|
writer.SetBuffered(false)
|
||||||
worker := &ServerWorker{
|
worker := &ServerWorker{
|
||||||
dispatcher: d,
|
dispatcher: d,
|
||||||
link: &transport.Link{Reader: link.Reader, Writer: &MutexWriter{Writer: link.Writer}},
|
link: &transport.Link{Reader: link.Reader, Writer: writer},
|
||||||
sessionManager: NewSessionManager(),
|
sessionManager: NewSessionManager(),
|
||||||
done: done.New(),
|
done: done.New(),
|
||||||
timer: time.NewTicker(60 * time.Second),
|
timer: time.NewTicker(60 * time.Second),
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package mux
|
package mux
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
"github.com/xtls/xray-core/common/buf"
|
"github.com/xtls/xray-core/common/buf"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
@@ -11,17 +9,6 @@ import (
|
|||||||
"github.com/xtls/xray-core/common/session"
|
"github.com/xtls/xray-core/common/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MutexWriter struct {
|
|
||||||
sync.Mutex
|
|
||||||
buf.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *MutexWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
|
|
||||||
w.Lock()
|
|
||||||
defer w.Unlock()
|
|
||||||
return w.Writer.WriteMultiBuffer(mb)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Writer struct {
|
type Writer struct {
|
||||||
dest net.Destination
|
dest net.Destination
|
||||||
writer buf.Writer
|
writer buf.Writer
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !windows
|
//go:build !windows
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package platform
|
package platform
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package platform
|
package platform
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ module github.com/xtls/xray-core
|
|||||||
go 1.27
|
go 1.27
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/apernet/quic-go v0.61.1-0.20260806010916-184d081eef3e
|
github.com/apernet/quic-go v0.63.1-0.20261004180939-a10df75c260c
|
||||||
github.com/bufbuild/protocompile v0.14.1
|
github.com/bufbuild/protocompile v0.14.1
|
||||||
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344
|
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344
|
||||||
github.com/golang/mock v1.7.0-rc.1
|
github.com/golang/mock v1.7.0-rc.1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
github.com/apernet/quic-go v0.61.1-0.20260806010916-184d081eef3e h1:5mgtR5gwIgBKMiGI1QdXldZZ+SNor06Nbu1wCBulQBg=
|
github.com/apernet/quic-go v0.63.1-0.20261004180939-a10df75c260c h1:cxK8qTA0YCsj68A7zLYDCfPgMTOyt3ePkHh+oXEmYU0=
|
||||||
github.com/apernet/quic-go v0.61.1-0.20260806010916-184d081eef3e/go.mod h1:x7qxEvX6MCVtDuBKHj3E+88+BtrbEMuAL5qGUKItjW8=
|
github.com/apernet/quic-go v0.63.1-0.20261004180939-a10df75c260c/go.mod h1:J7UZVOMF2M1LiE3iiUZWPuy8YCPAcLJOwVURrfJCvc0=
|
||||||
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
|
github.com/bufbuild/protocompile v0.14.1 h1:iA73zAf/fyljNjQKwYzUHD6AD4R8KMasmwa/FBatYVw=
|
||||||
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
|
github.com/bufbuild/protocompile v0.14.1/go.mod h1:ppVdAIhbr2H8asPk6k4pY7t9zB1OU5DoEw9xY/FUi1c=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
|
|||||||
@@ -697,10 +697,10 @@ func (c *HttpUpgradeConfig) Build() (proto.Message, error) {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Byte = 1
|
Byte = 1
|
||||||
Kilobyte = 1024 * Byte
|
Kilobyte = 1000 * Byte
|
||||||
Megabyte = 1024 * Kilobyte
|
Megabyte = 1000 * Kilobyte
|
||||||
Gigabyte = 1024 * Megabyte
|
Gigabyte = 1000 * Megabyte
|
||||||
Terabyte = 1024 * Gigabyte
|
Terabyte = 1000 * Gigabyte
|
||||||
)
|
)
|
||||||
|
|
||||||
type Bandwidth string
|
type Bandwidth string
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build coveragemain
|
//go:build coveragemain
|
||||||
// +build coveragemain
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package dokodemo
|
package dokodemo
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package dokodemo
|
package dokodemo
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !linux && !openbsd
|
//go:build !linux && !openbsd
|
||||||
// +build !linux,!openbsd
|
|
||||||
|
|
||||||
package dokodemo
|
package dokodemo
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build coverage
|
//go:build coverage
|
||||||
// +build coverage
|
|
||||||
|
|
||||||
package scenarios
|
package scenarios
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !coverage
|
//go:build !coverage
|
||||||
// +build !coverage
|
|
||||||
|
|
||||||
package scenarios
|
package scenarios
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !windows
|
//go:build !windows
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package internet
|
package internet
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !amd64
|
//go:build !amd64
|
||||||
// +build !amd64
|
|
||||||
|
|
||||||
package original
|
package original
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,15 @@ func NewDomain(domain string, lenLimit int, labelLimit int, types []uint16, edns
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ascii = strings.Trim(ascii, ".")
|
ascii = strings.Trim(ascii, ".")
|
||||||
|
if ascii == "" {
|
||||||
name, err := dnsmessage.NewName(domain + ".")
|
return nil, errors.New("empty domain")
|
||||||
|
}
|
||||||
|
for _, label := range strings.Split(ascii, ".") {
|
||||||
|
if len(label) == 0 || len(label) > 63 {
|
||||||
|
return nil, errors.New("invalid domain")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name, err := dnsmessage.NewName(ascii + ".")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package xdns
|
package xdns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"context"
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/xtls/xray-core/common/errors"
|
||||||
"github.com/xtls/xray-core/common/net"
|
"github.com/xtls/xray-core/common/net"
|
||||||
"github.com/xtls/xray-core/transport/internet/finalmask"
|
"github.com/xtls/xray-core/transport/internet/finalmask"
|
||||||
)
|
)
|
||||||
@@ -14,11 +14,9 @@ type TCPResolver struct {
|
|||||||
dest net.Destination
|
dest net.Destination
|
||||||
dialer *finalmask.Dialer
|
dialer *finalmask.Dialer
|
||||||
|
|
||||||
conn net.Conn
|
|
||||||
tcpAddr *net.TCPAddr
|
|
||||||
udpAddr *net.UDPAddr
|
udpAddr *net.UDPAddr
|
||||||
|
|
||||||
readCh chan []byte
|
readCh chan []byte
|
||||||
|
sendCh chan []byte
|
||||||
closeCh chan struct{}
|
closeCh chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
@@ -33,12 +31,10 @@ func NewTCPResolver(config *ResolverProto, dialer *finalmask.Dialer) (Resolver,
|
|||||||
dest: dest,
|
dest: dest,
|
||||||
dialer: dialer,
|
dialer: dialer,
|
||||||
readCh: make(chan []byte),
|
readCh: make(chan []byte),
|
||||||
|
sendCh: make(chan []byte),
|
||||||
closeCh: make(chan struct{}),
|
closeCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
if err := r.dial(); err != nil {
|
go r.run(config.Worker)
|
||||||
r.Close()
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,60 +47,113 @@ func (r *TCPResolver) closed() bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *TCPResolver) dial() error {
|
func (r *TCPResolver) setaddr(addr net.Addr) {
|
||||||
if r.closed() {
|
r.mu.Lock()
|
||||||
return errors.New("closed")
|
defer r.mu.Unlock()
|
||||||
|
switch v := addr.(type) {
|
||||||
|
case *net.TCPAddr:
|
||||||
|
r.udpAddr = &net.UDPAddr{IP: v.IP, Port: v.Port}
|
||||||
|
case *net.UDPAddr:
|
||||||
|
r.udpAddr = v
|
||||||
|
default:
|
||||||
|
panic(v)
|
||||||
}
|
}
|
||||||
if r.conn != nil {
|
}
|
||||||
return nil
|
|
||||||
|
func (r *TCPResolver) read(reader io.Reader, p []byte) (l int, err error) {
|
||||||
|
if _, err := io.ReadFull(reader, p[:2]); err != nil {
|
||||||
|
return 0, err
|
||||||
}
|
}
|
||||||
conn, err := r.dialer.DialTCP(r.dest)
|
l = int(p[0])<<8 | int(p[1])
|
||||||
|
if l == 0 || l > 4096 {
|
||||||
|
return 0, errors.New("err resp len ", l)
|
||||||
|
}
|
||||||
|
if _, err = io.ReadFull(reader, p[:l]); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return l, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *TCPResolver) do(conn *net.Conn, buf *[4096 + 2]byte, p []byte) error {
|
||||||
|
var err error
|
||||||
|
if *conn == nil {
|
||||||
|
*conn, err = r.dialer.DialTCP(r.dest)
|
||||||
|
if err != nil {
|
||||||
|
*conn = nil
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
r.setaddr((*conn).RemoteAddr())
|
||||||
|
}
|
||||||
|
|
||||||
|
c := *conn
|
||||||
|
l := len(p)
|
||||||
|
buf[0] = byte(l >> 8)
|
||||||
|
buf[1] = byte(l)
|
||||||
|
copy(buf[2:], p)
|
||||||
|
_, err = c.Write(buf[:2+len(p)])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
c.Close()
|
||||||
|
*conn = nil
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.conn = conn
|
|
||||||
r.tcpAddr = conn.RemoteAddr().(*net.TCPAddr)
|
b := pool4K.Get().([]byte)
|
||||||
r.udpAddr = &net.UDPAddr{IP: r.tcpAddr.IP, Port: r.tcpAddr.Port}
|
l, err = r.read(c, b)
|
||||||
r.wg.Add(1)
|
if err != nil {
|
||||||
go r.recv(conn)
|
c.Close()
|
||||||
|
*conn = nil
|
||||||
|
pool4K.Put(b[:cap(b)])
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-r.closeCh:
|
||||||
|
pool4K.Put(b[:cap(b)])
|
||||||
|
case r.readCh <- b[:l]:
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *TCPResolver) recv(conn net.Conn) {
|
func (r *TCPResolver) worker() {
|
||||||
defer r.wg.Done()
|
defer r.wg.Done()
|
||||||
|
|
||||||
var buf [4096]byte
|
var conn net.Conn
|
||||||
|
defer func() {
|
||||||
|
if conn != nil {
|
||||||
|
_ = conn.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
var buf [4096 + 2]byte
|
||||||
|
var p []byte
|
||||||
for {
|
for {
|
||||||
_, err := io.ReadFull(conn, buf[:2])
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
n := binary.BigEndian.Uint16(buf[:2])
|
|
||||||
if n == 0 || n > 4096 {
|
|
||||||
io.CopyN(io.Discard, conn, int64(n))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
_, err = io.ReadFull(conn, buf[:n])
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
p := pool4K.Get().([]byte)
|
|
||||||
copy(p, buf[:n])
|
|
||||||
select {
|
select {
|
||||||
case <-r.closeCh:
|
case <-r.closeCh:
|
||||||
pool4K.Put(p[:cap(p)])
|
return
|
||||||
case r.readCh <- p[:n]:
|
default:
|
||||||
|
select {
|
||||||
|
case <-r.closeCh:
|
||||||
|
return
|
||||||
|
case p = <-r.sendCh:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := r.do(&conn, &buf, p); err != nil {
|
||||||
|
errors.LogErrorInner(context.Background(), err, "do err")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
r.mu.Lock()
|
func (r *TCPResolver) run(worker int32) {
|
||||||
defer r.mu.Unlock()
|
for range worker {
|
||||||
|
r.wg.Add(1)
|
||||||
_ = conn.Close()
|
go r.worker()
|
||||||
r.conn = nil
|
}
|
||||||
|
r.wg.Wait()
|
||||||
|
close(r.readCh)
|
||||||
|
// close(r.sendCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *TCPResolver) Addr() *net.UDPAddr {
|
func (r *TCPResolver) Addr() *net.UDPAddr {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
return r.udpAddr
|
return r.udpAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,27 +168,25 @@ func (r *TCPResolver) Read(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *TCPResolver) Send(p []byte) {
|
func (r *TCPResolver) Send(p []byte) {
|
||||||
r.mu.Lock()
|
select {
|
||||||
defer r.mu.Unlock()
|
case <-r.closeCh:
|
||||||
if r.dial() != nil {
|
|
||||||
return
|
return
|
||||||
|
default:
|
||||||
|
b := make([]byte, len(p))
|
||||||
|
copy(b, p)
|
||||||
|
select {
|
||||||
|
case <-r.closeCh:
|
||||||
|
return
|
||||||
|
case r.sendCh <- b:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ = binary.Write(r.conn, binary.BigEndian, len(p))
|
|
||||||
_, _ = r.conn.Write(p)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *TCPResolver) Close() {
|
func (r *TCPResolver) Close() {
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
if r.closed() {
|
if r.closed() {
|
||||||
r.mu.Unlock()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
close(r.closeCh)
|
close(r.closeCh)
|
||||||
conn := r.conn
|
|
||||||
r.mu.Unlock()
|
|
||||||
if conn != nil {
|
|
||||||
_ = conn.Close()
|
|
||||||
}
|
|
||||||
r.wg.Wait()
|
|
||||||
close(r.readCh)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *
|
|||||||
|
|
||||||
err = req.Write(conn)
|
err = req.Write(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +124,7 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *
|
|||||||
if transportConfiguration.Ed == 0 {
|
if transportConfiguration.Ed == 0 {
|
||||||
_, err = connRF.Read([]byte{})
|
_, err = connRF.Read([]byte{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
conn.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,8 @@ func (c *client) dial(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// udp, _ := strconv.ParseBool(resp.Header.Get(ResponseHeaderUDPEnabled))
|
// udp, _ := strconv.ParseBool(resp.Header.Get(ResponseHeaderUDPEnabled))
|
||||||
down, _ := strconv.ParseUint(resp.Header.Get(CommonHeaderCCRX), 10, 64)
|
remote_rx, _ := strconv.ParseUint(resp.Header.Get(CommonHeaderCCRX), 10, 64)
|
||||||
|
tx := quicParams.BrutalUp
|
||||||
errors.LogDebug(context.Background(), "ECHAccepted ", conn.ConnectionState().TLS.ECHAccepted)
|
errors.LogDebug(context.Background(), "ECHAccepted ", conn.ConnectionState().TLS.ECHAccepted)
|
||||||
|
|
||||||
switch quicParams.Congestion {
|
switch quicParams.Congestion {
|
||||||
@@ -205,10 +206,13 @@ func (c *client) dial(ctx context.Context) error {
|
|||||||
case "bbr":
|
case "bbr":
|
||||||
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
||||||
case "", "brutal":
|
case "", "brutal":
|
||||||
if quicParams.BrutalUp == 0 || down == 0 {
|
if tx == 0 {
|
||||||
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
||||||
} else {
|
} else {
|
||||||
congestion.UseBrutal(conn, min(quicParams.BrutalUp, down), quicParams.BrutalDisableLossCompensation)
|
if remote_rx > 0 {
|
||||||
|
tx = min(tx, remote_rx)
|
||||||
|
}
|
||||||
|
congestion.UseBrutal(conn, tx, quicParams.BrutalDisableLossCompensation)
|
||||||
}
|
}
|
||||||
case "force-brutal":
|
case "force-brutal":
|
||||||
congestion.UseBrutal(conn, quicParams.BrutalUp, quicParams.BrutalDisableLossCompensation)
|
congestion.UseBrutal(conn, quicParams.BrutalUp, quicParams.BrutalDisableLossCompensation)
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ func (h *httpHandler) AuthHTTP(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auth := r.Header.Get(RequestHeaderAuth)
|
auth := r.Header.Get(RequestHeaderAuth)
|
||||||
down, _ := strconv.ParseUint(r.Header.Get(CommonHeaderCCRX), 10, 64)
|
remote_rx, _ := strconv.ParseUint(r.Header.Get(CommonHeaderCCRX), 10, 64)
|
||||||
|
tx := h.quicParams.BrutalUp
|
||||||
|
|
||||||
var user *protocol.MemoryUser
|
var user *protocol.MemoryUser
|
||||||
var ok bool
|
var ok bool
|
||||||
@@ -76,10 +77,13 @@ func (h *httpHandler) AuthHTTP(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
case "bbr":
|
case "bbr":
|
||||||
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
||||||
case "", "brutal":
|
case "", "brutal":
|
||||||
if quicParams.BrutalUp == 0 || down == 0 {
|
if remote_rx == 0 {
|
||||||
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
congestion.UseBBR(conn, bbr.Profile(quicParams.BbrProfile))
|
||||||
} else {
|
} else {
|
||||||
congestion.UseBrutal(conn, min(quicParams.BrutalUp, down), quicParams.BrutalDisableLossCompensation)
|
if tx > 0 {
|
||||||
|
remote_rx = min(remote_rx, tx)
|
||||||
|
}
|
||||||
|
congestion.UseBrutal(conn, remote_rx, quicParams.BrutalDisableLossCompensation)
|
||||||
}
|
}
|
||||||
case "force-brutal":
|
case "force-brutal":
|
||||||
congestion.UseBrutal(conn, quicParams.BrutalUp, quicParams.BrutalDisableLossCompensation)
|
congestion.UseBrutal(conn, quicParams.BrutalUp, quicParams.BrutalDisableLossCompensation)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package internet
|
package internet
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build js || netbsd || solaris
|
//go:build !windows && !darwin && !linux && !freebsd && !openbsd
|
||||||
// +build js netbsd solaris
|
|
||||||
|
|
||||||
package internet
|
package internet
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package tcp_test
|
package tcp_test
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !linux && !freebsd && !darwin
|
//go:build !linux && !freebsd && !darwin
|
||||||
// +build !linux,!freebsd,!darwin
|
|
||||||
|
|
||||||
package tcp
|
package tcp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !windows
|
//go:build !windows
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package tls
|
package tls
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build windows
|
//go:build windows
|
||||||
// +build windows
|
|
||||||
|
|
||||||
package tls
|
package tls
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build darwin
|
//go:build darwin
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build freebsd
|
//go:build freebsd
|
||||||
// +build freebsd
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build linux
|
//go:build linux
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build openbsd
|
//go:build openbsd
|
||||||
// +build openbsd
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
//go:build !linux && !freebsd && !darwin && !openbsd
|
//go:build !linux && !freebsd && !darwin && !openbsd
|
||||||
// +build !linux,!freebsd,!darwin,!openbsd
|
|
||||||
|
|
||||||
package udp
|
package udp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user