mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-18 08:34:35 +03:00
Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eee43288a4 | |||
| 61ff871dd2 | |||
| f8bc706cda | |||
| e7973840ce | |||
| 212071681d | |||
| 0f9bfeb275 | |||
| f5059f1165 | |||
| 2dc967bc04 | |||
| 75ea81dd69 | |||
| d13f7a4db6 | |||
| f073b14fcc | |||
| 1a44af33d0 | |||
| 8450f2e420 | |||
| 37ef25cbfe | |||
| 0fac18ba95 | |||
| 3ccd59d1dc | |||
| 6c38a08f12 | |||
| f8f7fee461 | |||
| 3e157b0d62 | |||
| 49d197e37f | |||
| b6f2912f29 | |||
| 05e349e45c | |||
| ae662a628d | |||
| 6e85f79852 | |||
| 0af29f50c0 | |||
| ee6ae3d91d | |||
| c4e071cac3 | |||
| 798831128a | |||
| a2de087aef | |||
| 89bc012c95 | |||
| 39ef5d8174 | |||
| 90b055e364 | |||
| d67321eed0 | |||
| 67592d1922 | |||
| c5db319e0e | |||
| 6a7b359fcc | |||
| 25d7f393b6 | |||
| 171ed6f58f | |||
| b604a5b787 | |||
| 35b98f945f | |||
| cabd0df282 | |||
| eeecef4db9 | |||
| 021e64e20b | |||
| 452478434c | |||
| 5305b0843b | |||
| 9f0ef36cc0 | |||
| 494b35c1f7 | |||
| 177ad7db3d | |||
| 3bda022574 | |||
| 2ea9c5a2ff | |||
| 3cb2869920 | |||
| 43dcb90632 | |||
| e56fca05fc | |||
| 495b5db4f1 | |||
| dea143b20d | |||
| 0db611b7a9 | |||
| c3d67d186a | |||
| 6b07ca63a0 | |||
| 6c8f22ab86 | |||
| 49f65579aa | |||
| a69e407bda | |||
| 96e5c11fc7 | |||
| 53041906b3 | |||
| f2d929f40e | |||
| 1160d8c154 | |||
| 75f2cbaef9 | |||
| 55b08de5fe | |||
| 14d598a232 | |||
| b3102b34b3 | |||
| b556adaa09 | |||
| fce86e1434 | |||
| 70003e8a81 | |||
| e19b000081 | |||
| 7329dbae11 | |||
| 695a073cd6 | |||
| 01c85adedf | |||
| 2caf8ea14f | |||
| 1090afd774 | |||
| c758c5abf9 | |||
| c61b023ab3 | |||
| 80178aeb2f | |||
| 005cb620ec | |||
| 7ddb46e74d | |||
| ad11a7e6a5 | |||
| 92c8c1463c | |||
| 661affd6a5 | |||
| 14c5b92423 | |||
| 74e5ead1ed | |||
| 2caec729fc | |||
| 194c240243 | |||
| db9fe9c5ea | |||
| bbfd93f5a3 | |||
| 04783ecf44 |
@@ -7,13 +7,16 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Trigger build windows
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
@@ -22,12 +25,12 @@ jobs:
|
||||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build linux
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
@@ -36,12 +39,12 @@ jobs:
|
||||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build osx
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
@@ -50,12 +53,12 @@ jobs:
|
||||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build windows desktop
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
@@ -64,6 +67,6 @@ jobs:
|
||||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
}"
|
||||
|
||||
@@ -13,73 +13,29 @@ on:
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
OutputArch: "linux-64"
|
||||
OutputArchArm: "linux-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/linux-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/linux-arm64"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
runs-on: ubuntu-24.04
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: linux
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-x64 -p:SelfContained=true -o "$OutputPath64"
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r linux-arm64 -p:SelfContained=true -o "$OutputPathArm64"
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-x64 -p:SelfContained=true -p:PublishTrimmed=true -o "$OutputPath64"
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r linux-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o "$OutputPathArm64"
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-linux
|
||||
path: |
|
||||
${{ github.workspace }}/v2rayN/Release/linux*
|
||||
|
||||
# release zip archive
|
||||
- name: Package release zip archive
|
||||
if: github.event.inputs.release_tag != ''
|
||||
run: |
|
||||
chmod 755 package-release-zip.sh
|
||||
./package-release-zip.sh "$OutputArch" "$OutputPath64"
|
||||
./package-release-zip.sh "$OutputArchArm" "$OutputPathArm64"
|
||||
|
||||
- name: Upload zip archive to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.zip
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: linux
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
deb:
|
||||
needs: build
|
||||
name: build and release deb x64 & arm64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: debian:13
|
||||
container: debian:13
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
|
||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||
|
||||
steps:
|
||||
- name: Prepare tools (Debian)
|
||||
@@ -115,12 +71,6 @@ jobs:
|
||||
echo "==== Dist tree ===="
|
||||
ls -R "$GITHUB_WORKSPACE/dist/deb" || true
|
||||
|
||||
- name: Upload DEB artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-deb
|
||||
path: dist/deb/**/*.deb
|
||||
|
||||
- name: Upload DEBs to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
@@ -130,15 +80,14 @@ jobs:
|
||||
prerelease: true
|
||||
|
||||
rpm:
|
||||
needs: build
|
||||
name: build and release rpm x64 & arm64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: registry.access.redhat.com/ubi10/ubi
|
||||
container: registry.access.redhat.com/ubi10/ubi
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
|
||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||
|
||||
steps:
|
||||
- name: Prepare tools (Red Hat)
|
||||
@@ -207,12 +156,6 @@ jobs:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: v2rayN-linux
|
||||
path: ${{ github.workspace }}/v2rayN/Release
|
||||
|
||||
- name: Ensure script permissions
|
||||
run: chmod 755 package-rhel.sh
|
||||
|
||||
@@ -228,12 +171,6 @@ jobs:
|
||||
echo "==== Dist tree ===="
|
||||
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true
|
||||
|
||||
- name: Upload RPM artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-rpm
|
||||
path: dist/rpm/**/*.rpm
|
||||
|
||||
- name: Upload RPMs to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
@@ -241,3 +178,76 @@ jobs:
|
||||
tag: ${{ env.RELEASE_TAG }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
|
||||
rpm-riscv64:
|
||||
name: build and release rpm riscv64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04-riscv
|
||||
container: rockylinux/rockylinux:10
|
||||
env:
|
||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||
|
||||
steps:
|
||||
- name: Prepare tools (Red Hat)
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
dnf -y makecache
|
||||
dnf -y install \
|
||||
sudo git rpm-build rpmdevtools dnf-plugins-core \
|
||||
rsync findutils tar gzip unzip which jq
|
||||
|
||||
- name: Checkout repo (for scripts)
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -rf ./*
|
||||
git init .
|
||||
git config --global --add safe.directory "$PWD"
|
||||
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
|
||||
git fetch --depth=1 origin "${GITHUB_SHA}"
|
||||
git checkout FETCH_HEAD
|
||||
git submodule update --init --recursive
|
||||
|
||||
- name: Ensure script permissions
|
||||
run: chmod 755 package-rhel-riscv.sh
|
||||
|
||||
- name: Package RPM (RHEL-family)
|
||||
run: ./package-rhel-riscv.sh "${RELEASE_TAG}"
|
||||
|
||||
- name: Collect RPMs into workspace
|
||||
run: |
|
||||
mkdir -p "$GITHUB_WORKSPACE/dist/rpm-riscv64"
|
||||
rsync -av "$HOME/rpmbuild/RPMS/" "$GITHUB_WORKSPACE/dist/rpm-riscv64/" || true
|
||||
find "$GITHUB_WORKSPACE/dist/rpm-riscv64" -name "*.riscv64.rpm" \
|
||||
-exec mv {} "$GITHUB_WORKSPACE/dist/rpm-riscv64/v2rayN-linux-rhel-riscv64.rpm" \; || true
|
||||
echo "==== Dist tree ===="
|
||||
ls -R "$GITHUB_WORKSPACE/dist/rpm-riscv64" || true
|
||||
|
||||
- name: Upload RPMs to release
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
shopt -s globstar nullglob
|
||||
|
||||
files=(dist/rpm-riscv64/**/*.rpm)
|
||||
(( ${#files[@]} )) || { echo "No RPMs found."; exit 1; }
|
||||
|
||||
api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}"
|
||||
upload_url="$(curl -fsSL -H "Authorization: Bearer ${GITHUB_TOKEN}" "$api" | jq -r '.upload_url // empty' | sed 's/{?name,label}//')"
|
||||
[[ "$upload_url" ]] || { echo "Release upload URL not found: ${RELEASE_TAG}"; exit 1; }
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
echo "Uploading ${f##*/}"
|
||||
curl -fsSL -X POST \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
|
||||
-H "Content-Type: application/x-rpm" \
|
||||
--data-binary @"$f" \
|
||||
"${upload_url}?name=${f##*/}"
|
||||
done
|
||||
|
||||
@@ -10,78 +10,65 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "macos-64"
|
||||
OutputArchArm: "macos-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/macos-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/macos-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: macos
|
||||
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: macos
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
dmg:
|
||||
name: package and release macOS dmg
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
|
||||
arch: [ x64, arm64 ]
|
||||
runs-on: macos-latest
|
||||
|
||||
env:
|
||||
Arch: |-
|
||||
${{
|
||||
case(
|
||||
matrix.arch == 'x64', '64',
|
||||
matrix.arch
|
||||
)
|
||||
}}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-x64 -p:SelfContained=true -o $OutputPath64
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-arm64 -p:SelfContained=true -o $OutputPathArm64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-x64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPath64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-macos
|
||||
path: |
|
||||
${{ github.workspace }}/v2rayN/Release/macos*
|
||||
name: ${{ matrix.arch }}
|
||||
path: v2rayN-macos-${{ env.Arch }}
|
||||
|
||||
# release osx package
|
||||
- name: Package osx
|
||||
if: github.event.inputs.release_tag != ''
|
||||
run: |
|
||||
brew install create-dmg
|
||||
chmod 755 package-osx.sh
|
||||
./package-osx.sh $OutputArch $OutputPath64 ${{ github.event.inputs.release_tag }}
|
||||
./package-osx.sh $OutputArchArm $OutputPathArm64 ${{ github.event.inputs.release_tag }}
|
||||
- name: Setup create-dmg
|
||||
run: brew install create-dmg
|
||||
|
||||
- name: Ensure script permissions
|
||||
run: chmod 755 package-osx.sh
|
||||
|
||||
- name: Package dmg
|
||||
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
||||
|
||||
- name: Sleep for race condition between matrix jobs
|
||||
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
||||
|
||||
- name: Upload dmg to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.dmg
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
tag: ${{ inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
|
||||
# release zip archive
|
||||
- name: Package release zip archive
|
||||
if: github.event.inputs.release_tag != ''
|
||||
run: |
|
||||
chmod 755 package-release-zip.sh
|
||||
./package-release-zip.sh $OutputArch $OutputPath64
|
||||
./package-release-zip.sh $OutputArchArm $OutputPathArm64
|
||||
|
||||
- name: Upload zip archive to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.zip
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
@@ -10,62 +10,19 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "windows-64"
|
||||
OutputArchArm: "windows-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: windows
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPath64
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPath64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-windows-desktop
|
||||
path: |
|
||||
${{ github.workspace }}/v2rayN/Release/windows*
|
||||
|
||||
# release zip archive
|
||||
- name: Package release zip archive
|
||||
if: github.event.inputs.release_tag != ''
|
||||
run: |
|
||||
chmod 755 package-release-zip.sh
|
||||
./package-release-zip.sh $OutputArch $OutputPath64
|
||||
mv "v2rayN-${OutputArch}.zip" "v2rayN-${OutputArch}-desktop.zip"
|
||||
./package-release-zip.sh $OutputArchArm $OutputPathArm64
|
||||
mv "v2rayN-${OutputArchArm}.zip" "v2rayN-${OutputArchArm}-desktop.zip"
|
||||
|
||||
- name: Upload zip archive to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.zip
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: windows-desktop
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
@@ -10,57 +10,20 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "windows-64"
|
||||
OutputArchArm: "windows-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: windows
|
||||
project: ./v2rayN/v2rayN.csproj
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPath64
|
||||
dotnet publish ./v2rayN/v2rayN.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -o $OutputPathArm64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-x64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPath64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r win-arm64 -p:SelfContained=true -p:EnableWindowsTargeting=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-windows
|
||||
path: |
|
||||
${{ github.workspace }}/v2rayN/Release/windows*
|
||||
|
||||
# release zip archive
|
||||
- name: Package release zip archive
|
||||
if: github.event.inputs.release_tag != ''
|
||||
run: |
|
||||
chmod 755 package-release-zip.sh
|
||||
./package-release-zip.sh $OutputArch $OutputPath64
|
||||
./package-release-zip.sh $OutputArchArm $OutputPathArm64
|
||||
|
||||
- name: Upload zip archive to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.zip
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: windows
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
target: # windows linux macos
|
||||
required: true
|
||||
type: string
|
||||
project:
|
||||
required: false
|
||||
type: string
|
||||
default: './v2rayN.Desktop/v2rayN.Desktop.csproj'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: build x64 arm64
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [ x64, arm64 ]
|
||||
runs-on: |-
|
||||
${{
|
||||
case(
|
||||
inputs.target == 'macos', 'macos-latest',
|
||||
inputs.target == 'linux', 'ubuntu-24.04',
|
||||
'ubuntu-latest'
|
||||
)
|
||||
}}
|
||||
env:
|
||||
Output: "${{ github.workspace }}/${{ matrix.arch }}"
|
||||
RID: |-
|
||||
${{
|
||||
case(
|
||||
inputs.target == 'macos', format('osx-{0}', matrix.arch),
|
||||
inputs.target == 'windows', format('win-{0}', matrix.arch),
|
||||
format('{0}-{1}', inputs.target, matrix.arch)
|
||||
)
|
||||
}}
|
||||
Project: ${{ inputs.project }}
|
||||
ExtOpt: |-
|
||||
${{
|
||||
case(
|
||||
inputs.target == 'windows', '-p:EnableWindowsTargeting=true',
|
||||
''
|
||||
)
|
||||
}}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Build v2rayN
|
||||
working-directory: ./v2rayN
|
||||
run: dotnet publish $Project -c Release -r $RID -p:SelfContained=true $ExtOpt -o $Output
|
||||
|
||||
- name: Build AmazTool
|
||||
working-directory: ./v2rayN
|
||||
run: dotnet publish ./AmazTool/AmazTool.csproj -c Release -r $RID -p:SelfContained=true -p:PublishTrimmed=true $ExtOpt -o $Output
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.1
|
||||
with:
|
||||
name: ${{ matrix.arch }}
|
||||
path: ${{ matrix.arch }}
|
||||
@@ -0,0 +1,67 @@
|
||||
name: package and release Zip
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release_tag:
|
||||
required: true
|
||||
type: string
|
||||
target: # windows linux macos windows-desktop
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
package:
|
||||
name: package x64 arm64
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [ x64, arm64 ]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Target: |-
|
||||
${{
|
||||
case(
|
||||
inputs.target == 'windows-desktop', 'windows',
|
||||
inputs.target
|
||||
)
|
||||
}}
|
||||
Arch: |-
|
||||
${{
|
||||
case(
|
||||
matrix.arch == 'x64', '64',
|
||||
matrix.arch
|
||||
)
|
||||
}}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: ${{ matrix.arch }}
|
||||
path: v2rayN-${{ env.Target }}-${{ env.Arch }}
|
||||
|
||||
- name: Get v2rayN-core-bin
|
||||
run: wget -nv -O v2rayN-$Target-$Arch.zip "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/v2rayN-$Target-$Arch.zip"
|
||||
|
||||
- name: Package zip archive
|
||||
run: 7z a -tZip v2rayN-$Target-$Arch.zip v2rayN-$Target-$Arch -mx1
|
||||
|
||||
- name: Rename windows-desktop
|
||||
if: inputs.target == 'windows-desktop'
|
||||
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
||||
|
||||
- name: Sleep for race condition between matrix jobs
|
||||
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
||||
|
||||
- name: Upload zip archive to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.zip
|
||||
tag: ${{ inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
@@ -0,0 +1,29 @@
|
||||
name: Code Test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'v2rayN/ServiceLib/Services/CoreConfig/**'
|
||||
- 'v2rayN/ServiceLib/Handler/Fmt/**'
|
||||
- '.github/workflows/test.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Test Code
|
||||
working-directory: ./v2rayN
|
||||
run: dotnet test ./ServiceLib.Tests
|
||||
+7
-2
@@ -253,11 +253,14 @@ download_xray() {
|
||||
}
|
||||
|
||||
download_singbox() {
|
||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin
|
||||
# Download sing-box
|
||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin cronet
|
||||
mkdir -p "$outdir"
|
||||
if [[ -z "$ver" ]]; then
|
||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' | sed -E 's/.*"v([^"]+)".*/\1/' | head -n1)" || true
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||
| head -n1)" || true
|
||||
fi
|
||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||
if [[ "$rid" == "linux-arm64" ]]; then
|
||||
@@ -272,6 +275,8 @@ download_singbox() {
|
||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||
install -m 755 "$bin" "$outdir/sing-box"
|
||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
Arch="$1"
|
||||
OutputPath="$2"
|
||||
|
||||
OutputArch="v2rayN-${Arch}"
|
||||
FileName="v2rayN-${Arch}.zip"
|
||||
|
||||
wget -nv -O $FileName "https://github.com/2dust/v2rayN-core-bin/raw/refs/heads/master/$FileName"
|
||||
|
||||
ZipPath64="./$OutputArch"
|
||||
mkdir $ZipPath64
|
||||
|
||||
cp -rf $OutputPath "$ZipPath64/$OutputArch"
|
||||
7z a -tZip $FileName "$ZipPath64/$OutputArch" -mx1
|
||||
@@ -0,0 +1,703 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Require Red Hat base branch
|
||||
. /etc/os-release
|
||||
|
||||
case "${ID:-}" in
|
||||
rhel|rocky|almalinux|fedora|centos)
|
||||
echo "Detected supported system: ${NAME:-$ID} ${VERSION_ID:-}"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported system: ${NAME:-unknown} (${ID:-unknown})."
|
||||
echo "This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Kernel version
|
||||
MIN_KERNEL="5.10"
|
||||
CURRENT_KERNEL="$(uname -r)"
|
||||
|
||||
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$CURRENT_KERNEL" | sort -V | head -n1)"
|
||||
|
||||
if [[ "$lowest" != "$MIN_KERNEL" ]]; then
|
||||
echo "Kernel $CURRENT_KERNEL is below $MIN_KERNEL"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[OK] Kernel $CURRENT_KERNEL verified."
|
||||
|
||||
# Config & Parse arguments
|
||||
VERSION_ARG="${1:-}" # Pass version number like 7.13.8, or leave empty
|
||||
WITH_CORE="both" # Default: bundle both xray+sing-box
|
||||
FORCE_NETCORE=0 # --netcore => skip archive bundle, use separate downloads
|
||||
BUILD_FROM="" # --buildfrom 1|2|3 to select channel non-interactively
|
||||
DOTNET_RISCV_VERSION="10.0.105"
|
||||
DOTNET_RISCV_BASE="https://github.com/filipnavara/dotnet-riscv/releases/download"
|
||||
DOTNET_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
||||
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
||||
SKIA_VER="${SKIA_VER:-3.119.2}"
|
||||
HARFBUZZ_VER="${HARFBUZZ_VER:-8.3.1.1}"
|
||||
|
||||
# If the first argument starts with --, do not treat it as a version number
|
||||
if [[ "${VERSION_ARG:-}" == --* ]]; then
|
||||
VERSION_ARG=""
|
||||
fi
|
||||
# Take the first non --* argument as version, discard it
|
||||
if [[ -n "${VERSION_ARG:-}" ]]; then shift || true; fi
|
||||
|
||||
# Parse remaining optional arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--with-core) WITH_CORE="${2:-both}"; shift 2;;
|
||||
--xray-ver) XRAY_VER="${2:-}"; shift 2;;
|
||||
--singbox-ver) SING_VER="${2:-}"; shift 2;;
|
||||
--netcore) FORCE_NETCORE=1; shift;;
|
||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2;;
|
||||
*)
|
||||
if [[ -z "${VERSION_ARG:-}" ]]; then VERSION_ARG="$1"; fi
|
||||
shift;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Conflict: version number AND --buildfrom cannot be used together
|
||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||
echo "You cannot specify both an explicit version and --buildfrom at the same time."
|
||||
echo " Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
apply_riscv_patch() {
|
||||
# Upgrade net8.0 -> net10.0
|
||||
find . -type f \( -name "*.csproj" -o -name "*.props" -o -name "*.targets" \) \
|
||||
-exec sed -i 's/net8\.0/net10.0/g' {} +
|
||||
|
||||
# Patch all Directory.Packages.props for SkiaSharp/HarfBuzzSharp
|
||||
while IFS= read -r -d '' f; do
|
||||
# replace existing versions if present
|
||||
sed -i \
|
||||
-e "s#<PackageVersion Include=\"SkiaSharp\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"SkiaSharp\" Version=\"$SKIA_VER\" />#g" \
|
||||
-e "s#<PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"$SKIA_VER\" />#g" \
|
||||
-e "s#<PackageVersion Include=\"HarfBuzzSharp\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"HarfBuzzSharp\" Version=\"$HARFBUZZ_VER\" />#g" \
|
||||
-e "s#<PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"$HARFBUZZ_VER\" />#g" \
|
||||
"$f"
|
||||
|
||||
grep -q 'PackageVersion Include="SkiaSharp"' "$f" || \
|
||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"SkiaSharp\" Version=\"$SKIA_VER\" />" "$f"
|
||||
|
||||
grep -q 'PackageVersion Include="SkiaSharp.NativeAssets.Linux"' "$f" || \
|
||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"$SKIA_VER\" />" "$f"
|
||||
|
||||
grep -q 'PackageVersion Include="HarfBuzzSharp"' "$f" || \
|
||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"HarfBuzzSharp\" Version=\"$HARFBUZZ_VER\" />" "$f"
|
||||
|
||||
grep -q 'PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux"' "$f" || \
|
||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"$HARFBUZZ_VER\" />" "$f"
|
||||
done < <(find . -type f -name 'Directory.Packages.props' -print0)
|
||||
|
||||
# Patch SDK bundled RIDs
|
||||
f="$(find "$DOTNET_ROOT/sdk/$(dotnet --version)" -type f -name 'Microsoft.NETCoreSdk.BundledVersions.props' | head -n1 || true)"
|
||||
[[ -f "$f" ]] && sed -i \
|
||||
-e 's/linux-arm64/&;linux-riscv64/g' \
|
||||
-e 's/linux-musl-arm64/&;linux-musl-riscv64/g' \
|
||||
"$f"
|
||||
}
|
||||
|
||||
build_sqlite_native_riscv64() {
|
||||
local outdir="$1"
|
||||
local workdir sqlite_year sqlite_ver sqlite_zip srcdir
|
||||
|
||||
mkdir -p "$outdir"
|
||||
workdir="$(mktemp -d)"
|
||||
|
||||
# SQLite 3.51.3 amalgamation
|
||||
sqlite_year="2026"
|
||||
sqlite_ver="3510300"
|
||||
sqlite_zip="sqlite-amalgamation-${sqlite_ver}.zip"
|
||||
|
||||
echo "[+] Download SQLite amalgamation: ${sqlite_zip}"
|
||||
curl -fL "https://www.sqlite.org/${sqlite_year}/${sqlite_zip}" -o "${workdir}/${sqlite_zip}"
|
||||
|
||||
unzip -q "${workdir}/${sqlite_zip}" -d "$workdir"
|
||||
srcdir="$(find "$workdir" -maxdepth 1 -type d -name 'sqlite-amalgamation-*' | head -n1 || true)"
|
||||
[[ -n "$srcdir" ]] || { echo "[!] SQLite source unpack failed"; rm -rf "$workdir"; return 1; }
|
||||
|
||||
echo "[+] Build libe_sqlite3.so for riscv64"
|
||||
gcc -shared -fPIC -O2 \
|
||||
-DSQLITE_THREADSAFE=1 \
|
||||
-DSQLITE_ENABLE_FTS5 \
|
||||
-DSQLITE_ENABLE_RTREE \
|
||||
-DSQLITE_ENABLE_JSON1 \
|
||||
-o "${outdir}/libe_sqlite3.so" "${srcdir}/sqlite3.c" -ldl -lpthread
|
||||
|
||||
rm -rf "$workdir"
|
||||
}
|
||||
|
||||
copy_skiasharp_native_riscv64() {
|
||||
local outdir="$1"
|
||||
local skia_so=""
|
||||
local harfbuzz_so=""
|
||||
|
||||
mkdir -p "$outdir"
|
||||
|
||||
skia_so="$(find "$HOME/.nuget/packages" -path "*/skiasharp.nativeassets.linux/${SKIA_VER}/runtimes/linux-riscv64/native/libSkiaSharp.so" | head -n1 || true)"
|
||||
if [[ -z "$skia_so" ]]; then
|
||||
skia_so="$(find "$HOME/.nuget/packages" -path "*/runtimes/linux-riscv64/native/libSkiaSharp.so" | head -n1 || true)"
|
||||
fi
|
||||
|
||||
harfbuzz_so="$(find "$HOME/.nuget/packages" -path "*/harfbuzzsharp.nativeassets.linux/${HARFBUZZ_VER}/runtimes/linux-riscv64/native/libHarfBuzzSharp.so" | head -n1 || true)"
|
||||
if [[ -z "$harfbuzz_so" ]]; then
|
||||
harfbuzz_so="$(find "$HOME/.nuget/packages" -path "*/runtimes/linux-riscv64/native/libHarfBuzzSharp.so" | head -n1 || true)"
|
||||
fi
|
||||
|
||||
if [[ -n "$skia_so" && -f "$skia_so" ]]; then
|
||||
echo "[+] Copy libSkiaSharp.so from NuGet cache"
|
||||
install -m 755 "$skia_so" "$outdir/libSkiaSharp.so"
|
||||
else
|
||||
echo "[WARN] libSkiaSharp.so for linux-riscv64 not found in NuGet cache"
|
||||
fi
|
||||
|
||||
if [[ -n "$harfbuzz_so" && -f "$harfbuzz_so" ]]; then
|
||||
echo "[+] Copy libHarfBuzzSharp.so from NuGet cache"
|
||||
install -m 755 "$harfbuzz_so" "$outdir/libHarfBuzzSharp.so"
|
||||
else
|
||||
echo "[WARN] libHarfBuzzSharp.so for linux-riscv64 not found in NuGet cache"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check and install dependencies
|
||||
host_arch="$(uname -m)"
|
||||
[[ "$host_arch" == "riscv64" ]] || { echo "Only supports riscv64"; exit 1; }
|
||||
|
||||
install_ok=0
|
||||
|
||||
if command -v dnf >/dev/null 2>&1; then
|
||||
sudo dnf -y install \
|
||||
rpm-build rpmdevtools curl unzip tar jq rsync git python3 gcc make \
|
||||
glibc-devel kernel-headers libatomic file ca-certificates libicu\
|
||||
&& install_ok=1
|
||||
|
||||
mkdir -p "$HOME/.dotnet"
|
||||
tmp_dotnet="$(mktemp -d)"
|
||||
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
||||
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_RISCV_FILE"
|
||||
rm -rf "$tmp_dotnet"
|
||||
|
||||
export PATH="$HOME/.dotnet:$PATH"
|
||||
export DOTNET_ROOT="$HOME/.dotnet"
|
||||
|
||||
dotnet --info >/dev/null 2>&1 || install_ok=0
|
||||
fi
|
||||
|
||||
if [[ "$install_ok" -ne 1 ]]; then
|
||||
echo "Could not auto-install dependencies for '$ID'. Make sure these are available:"
|
||||
echo "dotnet-riscv SDK, curl, unzip, tar, rsync, git, python3, gcc, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Root directory
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
# Git submodules (best effort)
|
||||
if [[ -f .gitmodules ]]; then
|
||||
git submodule sync --recursive || true
|
||||
git submodule update --init --recursive || true
|
||||
fi
|
||||
|
||||
# Locate project
|
||||
PROJECT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||
if [[ ! -f "$PROJECT" ]]; then
|
||||
PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||
fi
|
||||
[[ -f "$PROJECT" ]] || { echo "v2rayN.Desktop.csproj not found"; exit 1; }
|
||||
|
||||
choose_channel() {
|
||||
# If --buildfrom provided, map it directly and skip interaction.
|
||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||
case "$BUILD_FROM" in
|
||||
1) echo "latest"; return 0;;
|
||||
2) echo "prerelease"; return 0;;
|
||||
3) echo "keep"; return 0;;
|
||||
*) echo "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." >&2; exit 1;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Print menu to stderr and read from /dev/tty so stdout only carries the token.
|
||||
local ch="latest" sel=""
|
||||
|
||||
if [[ -t 0 ]]; then
|
||||
echo "[?] Choose v2rayN release channel:" >&2
|
||||
echo " 1) Latest (stable) [default]" >&2
|
||||
echo " 2) Pre-release (preview)" >&2
|
||||
echo " 3) Keep current (do nothing)" >&2
|
||||
printf "Enter 1, 2 or 3 [default 1]: " >&2
|
||||
|
||||
if read -r sel </dev/tty; then
|
||||
case "${sel:-}" in
|
||||
2) ch="prerelease" ;;
|
||||
3) ch="keep" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$ch"
|
||||
}
|
||||
|
||||
get_latest_tag_latest() {
|
||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases/latest" \
|
||||
| jq -re '.tag_name' \
|
||||
| sed 's/^v//'
|
||||
}
|
||||
|
||||
get_latest_tag_prerelease() {
|
||||
curl -fsSL "https://api.github.com/repos/2dust/v2rayN/releases?per_page=20" \
|
||||
| jq -re 'first(.[] | select(.prerelease == true) | .tag_name)' \
|
||||
| sed 's/^v//'
|
||||
}
|
||||
|
||||
git_try_checkout() {
|
||||
# Try a series of refs and checkout when found.
|
||||
local want="$1" ref=""
|
||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
git fetch --tags --force --prune --depth=1 || true
|
||||
if git rev-parse "refs/tags/${want}" >/dev/null 2>&1; then
|
||||
ref="${want}"
|
||||
fi
|
||||
if [[ -n "$ref" ]]; then
|
||||
echo "[OK] Found ref '${ref}', checking out..."
|
||||
git checkout -f "${ref}"
|
||||
if [[ -f .gitmodules ]]; then
|
||||
git submodule sync --recursive || true
|
||||
git submodule update --init --recursive || true
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
apply_channel_or_keep() {
|
||||
local ch="$1" tag
|
||||
|
||||
if [[ "$ch" == "keep" ]]; then
|
||||
echo "[*] Keep current repository state (no checkout)."
|
||||
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo '0.0.0+git')"
|
||||
VERSION="${VERSION#v}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
||||
if [[ "$ch" == "prerelease" ]]; then
|
||||
tag="$(get_latest_tag_prerelease || true)"
|
||||
else
|
||||
tag="$(get_latest_tag_latest || true)"
|
||||
fi
|
||||
|
||||
[[ -n "$tag" ]] || { echo "Failed to resolve latest tag for channel '${ch}'."; exit 1; }
|
||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||
git_try_checkout "$tag" || { echo "Failed to checkout '${tag}'."; exit 1; }
|
||||
VERSION="${tag#v}"
|
||||
}
|
||||
|
||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||
clean_ver="${VERSION_ARG#v}"
|
||||
if git_try_checkout "$clean_ver"; then
|
||||
VERSION="$clean_ver"
|
||||
else
|
||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||
ch="$(choose_channel)"
|
||||
apply_channel_or_keep "$ch"
|
||||
fi
|
||||
else
|
||||
ch="$(choose_channel)"
|
||||
apply_channel_or_keep "$ch"
|
||||
fi
|
||||
else
|
||||
echo "Current directory is not a git repo; proceeding on current tree."
|
||||
VERSION="${VERSION_ARG:-0.0.0}"
|
||||
fi
|
||||
|
||||
VERSION="${VERSION#v}"
|
||||
echo "[*] GUI version resolved as: ${VERSION}"
|
||||
|
||||
# riscv64 patch
|
||||
apply_riscv_patch
|
||||
|
||||
# Helpers for core
|
||||
download_xray() {
|
||||
# Download Xray core
|
||||
local outdir="$1" rid="$2" ver="${XRAY_VER:-}" url="" tmp zipname="xray.zip"
|
||||
mkdir -p "$outdir"
|
||||
if [[ -z "$ver" ]]; then
|
||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' | sed -E 's/.*"v([^"]+)".*/\1/' | head -n1)" || true
|
||||
fi
|
||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
||||
url="https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip"
|
||||
fi
|
||||
[[ -n "$url" ]] || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||
echo "[+] Download xray: $url"
|
||||
tmp="$(mktemp -d)"
|
||||
curl -fL "$url" -o "$tmp/$zipname"
|
||||
unzip -q "$tmp/$zipname" -d "$tmp"
|
||||
install -m 755 "$tmp/xray" "$outdir/xray"
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
download_singbox() {
|
||||
# Download sing-box
|
||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url="" tmp tarname="singbox.tar.gz" bin cronet
|
||||
mkdir -p "$outdir"
|
||||
if [[ -z "$ver" ]]; then
|
||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||
| head -n1)" || true
|
||||
fi
|
||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
||||
url="https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz"
|
||||
fi
|
||||
[[ -n "$url" ]] || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||
echo "[+] Download sing-box: $url"
|
||||
tmp="$(mktemp -d)"
|
||||
curl -fL "$url" -o "$tmp/$tarname"
|
||||
tar -C "$tmp" -xzf "$tmp/$tarname"
|
||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||
install -m 755 "$bin" "$outdir/sing-box"
|
||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# Move geo files to outroot/bin
|
||||
unify_geo_layout() {
|
||||
local outroot="$1"
|
||||
mkdir -p "$outroot/bin"
|
||||
local names=( \
|
||||
"geosite.dat" \
|
||||
"geoip.dat" \
|
||||
"geoip-only-cn-private.dat" \
|
||||
"Country.mmdb" \
|
||||
"geoip.metadb" \
|
||||
)
|
||||
for n in "${names[@]}"; do
|
||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Download geo/rule assets
|
||||
download_geo_assets() {
|
||||
local outroot="$1"
|
||||
local bin_dir="$outroot/bin"
|
||||
local srss_dir="$bin_dir/srss"
|
||||
mkdir -p "$bin_dir" "$srss_dir"
|
||||
|
||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
||||
curl -fsSL -o "$bin_dir/geosite.dat" \
|
||||
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geosite.dat"
|
||||
curl -fsSL -o "$bin_dir/geoip.dat" \
|
||||
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
||||
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" \
|
||||
"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
||||
curl -fsSL -o "$bin_dir/Country.mmdb" \
|
||||
"https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
||||
|
||||
echo "[+] Download sing-box rule DB & rule-sets"
|
||||
curl -fsSL -o "$bin_dir/geoip.metadb" \
|
||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb" || true
|
||||
|
||||
for f in \
|
||||
geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs \
|
||||
geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
||||
curl -fsSL -o "$srss_dir/$f" \
|
||||
"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-geoip/$f" || true
|
||||
done
|
||||
for f in \
|
||||
geosite-cn.srs geosite-gfw.srs geosite-google.srs geosite-greatfire.srs \
|
||||
geosite-geolocation-cn.srs geosite-category-ads-all.srs geosite-private.srs; do
|
||||
curl -fsSL -o "$srss_dir/$f" \
|
||||
"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-geosite/$f" || true
|
||||
done
|
||||
|
||||
# Unify to bin
|
||||
unify_geo_layout "$outroot"
|
||||
}
|
||||
|
||||
# Prefer the prebuilt v2rayN core bundle; then unify geo layout
|
||||
download_v2rayn_bundle() {
|
||||
local outroot="$1" rid="$2"
|
||||
local url=""
|
||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip"
|
||||
fi
|
||||
[[ -n "$url" ]] || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||
echo "[+] Try v2rayN bundle archive: $url"
|
||||
local tmp zipname
|
||||
tmp="$(mktemp -d)"; zipname="$tmp/v2rayn.zip"
|
||||
curl -fL "$url" -o "$zipname" || { echo "[!] Bundle download failed"; return 1; }
|
||||
unzip -q "$zipname" -d "$tmp" || { echo "[!] Bundle unzip failed"; return 1; }
|
||||
|
||||
if [[ -d "$tmp/bin" ]]; then
|
||||
mkdir -p "$outroot/bin"
|
||||
rsync -a "$tmp/bin/" "$outroot/bin/"
|
||||
else
|
||||
rsync -a "$tmp/" "$outroot/"
|
||||
fi
|
||||
|
||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 2>/dev/null || true
|
||||
|
||||
local nested_dir
|
||||
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
||||
mkdir -p "$outroot/bin"
|
||||
rsync -a "$nested_dir/bin/" "$outroot/bin/"
|
||||
rm -rf "$nested_dir"
|
||||
fi
|
||||
|
||||
# Unify to bin/
|
||||
unify_geo_layout "$outroot"
|
||||
|
||||
echo "[+] Bundle extracted to $outroot"
|
||||
}
|
||||
|
||||
# ===== Build results collection ========================================================
|
||||
BUILT_RPMS=()
|
||||
|
||||
# ===== Build (single-arch) function ====================================================
|
||||
build_for_arch() {
|
||||
# $1: target short arch: riscv64
|
||||
local short="$1"
|
||||
local rid rpm_target archdir
|
||||
case "$short" in
|
||||
riscv64) rid="linux-riscv64"; rpm_target="riscv64"; archdir="riscv64" ;;
|
||||
*) echo "Unknown arch '$short' (use riscv64)"; return 1;;
|
||||
esac
|
||||
|
||||
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
||||
|
||||
# .NET publish (self-contained) for this RID
|
||||
dotnet clean "$PROJECT" -c Release -p:TargetFramework=net10.0
|
||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||
|
||||
dotnet restore "$PROJECT" -r "$rid" -p:TargetFramework=net10.0
|
||||
dotnet publish "$PROJECT" \
|
||||
-c Release -r "$rid" \
|
||||
-p:TargetFramework=net10.0 \
|
||||
-p:PublishSingleFile=false \
|
||||
-p:SelfContained=true
|
||||
|
||||
# Per-arch variables (scoped)
|
||||
local RID_DIR="$rid"
|
||||
local PUBDIR
|
||||
PUBDIR="$(dirname "$PROJECT")/bin/Release/net10.0/${RID_DIR}/publish"
|
||||
[[ -d "$PUBDIR" ]] || { echo "Publish directory not found: $PUBDIR"; return 1; }
|
||||
|
||||
# Per-arch working area
|
||||
local PKGROOT="v2rayN-publish"
|
||||
local WORKDIR
|
||||
WORKDIR="$(mktemp -d)"
|
||||
trap '[[ -n "${WORKDIR:-}" ]] && rm -rf "$WORKDIR"' RETURN
|
||||
|
||||
# rpmbuild topdir selection
|
||||
local TOPDIR SPECDIR SOURCEDIR PROJECT_DIR
|
||||
rpmdev-setuptree
|
||||
TOPDIR="${HOME}/rpmbuild"
|
||||
SPECDIR="${TOPDIR}/SPECS"
|
||||
SOURCEDIR="${TOPDIR}/SOURCES"
|
||||
|
||||
# Stage publish content
|
||||
mkdir -p "$WORKDIR/$PKGROOT"
|
||||
cp -a "$PUBDIR/." "$WORKDIR/$PKGROOT/"
|
||||
|
||||
copy_skiasharp_native_riscv64 "$WORKDIR/$PKGROOT" || echo "[!] SkiaSharp native copy failed (skipped)"
|
||||
build_sqlite_native_riscv64 "$WORKDIR/$PKGROOT" || echo "[!] sqlite native build failed (skipped)"
|
||||
|
||||
# Required icon
|
||||
local ICON_CANDIDATE
|
||||
PROJECT_DIR="$(cd "$(dirname "$PROJECT")" && pwd)"
|
||||
ICON_CANDIDATE="$PROJECT_DIR/v2rayN.png"
|
||||
[[ -f "$ICON_CANDIDATE" ]] || { echo "Required icon not found: $ICON_CANDIDATE"; return 1; }
|
||||
cp "$ICON_CANDIDATE" "$WORKDIR/$PKGROOT/v2rayn.png"
|
||||
|
||||
# Prepare bin structure
|
||||
mkdir -p "$WORKDIR/$PKGROOT/bin/xray" "$WORKDIR/$PKGROOT/bin/sing_box"
|
||||
|
||||
# Bundle / cores per-arch
|
||||
fetch_separate_cores_and_rules() {
|
||||
local outroot="$1"
|
||||
|
||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||
download_xray "$outroot/bin/xray" "$RID_DIR" || echo "[!] xray download failed (skipped)"
|
||||
fi
|
||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||
download_singbox "$outroot/bin/sing_box" "$RID_DIR" || echo "[!] sing-box download failed (skipped)"
|
||||
fi
|
||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||
}
|
||||
|
||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||
if download_v2rayn_bundle "$WORKDIR/$PKGROOT" "$RID_DIR"; then
|
||||
echo "[*] Using v2rayN bundle archive."
|
||||
else
|
||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
||||
fi
|
||||
else
|
||||
echo "[*] --netcore specified: use separate core + rules."
|
||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
||||
fi
|
||||
|
||||
# Tarball
|
||||
mkdir -p "$SOURCEDIR"
|
||||
tar -C "$WORKDIR" -czf "$SOURCEDIR/$PKGROOT.tar.gz" "$PKGROOT"
|
||||
|
||||
# SPEC
|
||||
local SPECFILE="$SPECDIR/v2rayN.spec"
|
||||
mkdir -p "$SPECDIR"
|
||||
cat > "$SPECFILE" <<'SPEC'
|
||||
%global debug_package %{nil}
|
||||
%undefine _debuginfo_subpackages
|
||||
%undefine _debugsource_packages
|
||||
# Ignore outdated LTTng dependencies incorrectly reported by the .NET runtime (to avoid installation failures)
|
||||
%global __requires_exclude ^liblttng-ust\.so\..*$
|
||||
|
||||
Name: v2rayN
|
||||
Version: __VERSION__
|
||||
Release: 1%{?dist}
|
||||
Summary: v2rayN (Avalonia) GUI client for Linux (riscv64)
|
||||
License: GPL-3.0-only
|
||||
URL: https://github.com/2dust/v2rayN
|
||||
BugURL: https://github.com/2dust/v2rayN/issues
|
||||
ExclusiveArch: riscv64
|
||||
Source0: __PKGROOT__.tar.gz
|
||||
|
||||
# Runtime dependencies (Avalonia / X11 / Fonts / GL)
|
||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
||||
Requires: glibc >= 2.34
|
||||
Requires: fontconfig >= 2.13.1
|
||||
Requires: desktop-file-utils >= 0.26
|
||||
Requires: xdg-utils >= 1.1.3
|
||||
Requires: coreutils >= 8.32
|
||||
Requires: bash >= 5.1
|
||||
Requires: freetype >= 2.10
|
||||
|
||||
%description
|
||||
v2rayN Linux for Red Hat Enterprise Linux
|
||||
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 / Shadowsocks / tuic / WireGuard
|
||||
Support Red Hat Enterprise Linux / Fedora Linux / Rocky Linux / AlmaLinux / CentOS
|
||||
For more information, Please visit our website
|
||||
https://github.com/2dust/v2rayN
|
||||
|
||||
%prep
|
||||
%setup -q -n __PKGROOT__
|
||||
|
||||
%build
|
||||
# no build
|
||||
|
||||
%install
|
||||
install -dm0755 %{buildroot}/opt/v2rayN
|
||||
cp -a * %{buildroot}/opt/v2rayN/
|
||||
|
||||
# Normalize permissions
|
||||
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
||||
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
||||
[ -f %{buildroot}/opt/v2rayN/v2rayN ] && chmod 0755 %{buildroot}/opt/v2rayN/v2rayN || :
|
||||
[ -f %{buildroot}/opt/v2rayN/libSkiaSharp.so ] && chmod 0755 %{buildroot}/opt/v2rayN/libSkiaSharp.so || :
|
||||
[ -f %{buildroot}/opt/v2rayN/libHarfBuzzSharp.so ] && chmod 0755 %{buildroot}/opt/v2rayN/libHarfBuzzSharp.so || :
|
||||
[ -f %{buildroot}/opt/v2rayN/libe_sqlite3.so ] && chmod 0755 %{buildroot}/opt/v2rayN/libe_sqlite3.so || :
|
||||
|
||||
# Launcher (prefer native ELF first, then DLL fallback)
|
||||
install -dm0755 %{buildroot}%{_bindir}
|
||||
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
||||
#!/usr/bin/bash
|
||||
set -euo pipefail
|
||||
DIR="/opt/v2rayN"
|
||||
export LD_LIBRARY_PATH="$DIR:${LD_LIBRARY_PATH:-}"
|
||||
|
||||
# Prefer native apphost
|
||||
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
||||
|
||||
# DLL fallback
|
||||
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
||||
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
||||
done
|
||||
|
||||
echo "v2rayN launcher: no executable found in $DIR" >&2
|
||||
ls -l "$DIR" >&2 || true
|
||||
exit 1
|
||||
EOF
|
||||
|
||||
# Desktop file
|
||||
install -dm0755 %{buildroot}%{_datadir}/applications
|
||||
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=v2rayN
|
||||
Comment=v2rayN for Red Hat Enterprise Linux
|
||||
Exec=v2rayn
|
||||
Icon=v2rayn
|
||||
Terminal=false
|
||||
Categories=Network;
|
||||
EOF
|
||||
|
||||
# Icon
|
||||
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
||||
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||
|
||||
%post
|
||||
/usr/bin/update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || true
|
||||
/usr/bin/gtk-update-icon-cache -f %{_datadir}/icons/hicolor >/dev/null 2>&1 || true
|
||||
|
||||
%postun
|
||||
/usr/bin/update-desktop-database %{_datadir}/applications >/dev/null 2>&1 || true
|
||||
/usr/bin/gtk-update-icon-cache -f %{_datadir}/icons/hicolor >/dev/null 2>&1 || true
|
||||
|
||||
%files
|
||||
%{_bindir}/v2rayn
|
||||
/opt/v2rayN
|
||||
%{_datadir}/applications/v2rayn.desktop
|
||||
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||
SPEC
|
||||
|
||||
# Replace placeholders
|
||||
sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE"
|
||||
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE"
|
||||
|
||||
# Build RPM for this arch
|
||||
rpmbuild -ba "$SPECFILE" --target "$rpm_target"
|
||||
|
||||
echo "Build done for $short. RPM at:"
|
||||
local f
|
||||
for f in "${TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
||||
[[ -e "$f" ]] || continue
|
||||
echo " $f"
|
||||
BUILT_RPMS+=("$f")
|
||||
done
|
||||
}
|
||||
|
||||
# ===== Arch selection and build orchestration =========================================
|
||||
targets=(riscv64)
|
||||
|
||||
for arch in "${targets[@]}"; do
|
||||
build_for_arch "$arch"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "================ Build Summary ================"
|
||||
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
||||
for rp in "${BUILT_RPMS[@]}"; do
|
||||
echo "$rp"
|
||||
done
|
||||
else
|
||||
echo "No RPMs detected in summary (check build logs above)."
|
||||
fi
|
||||
echo "=============================================="
|
||||
+6
-2
@@ -232,11 +232,13 @@ download_xray() {
|
||||
|
||||
download_singbox() {
|
||||
# Download sing-box
|
||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin
|
||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin cronet
|
||||
mkdir -p "$outdir"
|
||||
if [[ -z "$ver" ]]; then
|
||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' | sed -E 's/.*"v([^"]+)".*/\1/' | head -n1)" || true
|
||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||
| head -n1)" || true
|
||||
fi
|
||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||
if [[ "$rid" == "linux-arm64" ]]; then
|
||||
@@ -251,6 +253,8 @@ download_singbox() {
|
||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||
install -m 755 "$bin" "$outdir/sing-box"
|
||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.19.5</Version>
|
||||
<Version>7.21.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -6,26 +6,30 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="11.4.1" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.12" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.12" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.12" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.13" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.13" />
|
||||
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
|
||||
<PackageVersion Include="DialogHost.Avalonia" Version="0.11.0" />
|
||||
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
||||
<PackageVersion Include="CliWrap" Version="3.10.0" />
|
||||
<PackageVersion Include="Downloader" Version="5.1.0" />
|
||||
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
||||
<PackageVersion Include="Downloader" Version="5.2.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
|
||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.3.1.1" />
|
||||
<PackageVersion Include="QRCoder" Version="1.7.0" />
|
||||
<PackageVersion Include="ReactiveUI" Version="23.1.8" />
|
||||
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
||||
<PackageVersion Include="ReactiveUI" Version="23.2.1" />
|
||||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||
<PackageVersion Include="ReactiveUI.WPF" Version="23.1.8" />
|
||||
<PackageVersion Include="ReactiveUI.WPF" Version="23.2.1" />
|
||||
<PackageVersion Include="Semi.Avalonia" Version="11.3.7.3" />
|
||||
<PackageVersion Include="Semi.Avalonia.AvaloniaEdit" Version="11.2.0.2" />
|
||||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.3.7.3" />
|
||||
<PackageVersion Include="NLog" Version="6.1.1" />
|
||||
<PackageVersion Include="NLog" Version="6.1.2" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
||||
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||
<PackageVersion Include="xunit.v3" Version="3.2.2" />
|
||||
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
||||
</ItemGroup>
|
||||
|
||||
+1
-1
Submodule v2rayN/GlobalHotKeys updated: ffb2850df0...488f1e69ea
@@ -0,0 +1,113 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Handler.Builder;
|
||||
using ServiceLib.Helper;
|
||||
using ServiceLib.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.CoreConfig.Context;
|
||||
|
||||
public class CoreConfigContextBuilderTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task ResolveNodeAsync_DirectCycleDependency_ShouldFailWithCycleError()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig();
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var groupAId = NewId("group-a");
|
||||
var groupBId = NewId("group-b");
|
||||
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId]);
|
||||
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupAId]);
|
||||
|
||||
await UpsertProfilesAsync(groupA, groupB);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||
context.AllProxiesMap.Clear();
|
||||
|
||||
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||
|
||||
validatorResult.Success.Should().BeFalse();
|
||||
validatorResult.Errors.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||
context.AllProxiesMap.Should().NotContainKey(groupA.IndexId);
|
||||
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ResolveNodeAsync_IndirectCycleDependency_ShouldFailWithCycleError()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig();
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var groupAId = NewId("group-a");
|
||||
var groupBId = NewId("group-b");
|
||||
var groupCId = NewId("group-c");
|
||||
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId]);
|
||||
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupCId]);
|
||||
var groupC = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupCId, "group-c", [groupAId]);
|
||||
|
||||
await UpsertProfilesAsync(groupA, groupB, groupC);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||
context.AllProxiesMap.Clear();
|
||||
|
||||
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||
|
||||
validatorResult.Success.Should().BeFalse();
|
||||
validatorResult.Errors.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||
context.AllProxiesMap.Should().NotContainKey(groupA.IndexId);
|
||||
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||
context.AllProxiesMap.Should().NotContainKey(groupC.IndexId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ResolveNodeAsync_CycleWithValidBranch_ShouldSkipCycleAndKeepValidChild()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig();
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var groupAId = NewId("group-a");
|
||||
var groupBId = NewId("group-b");
|
||||
var leafId = NewId("leaf");
|
||||
var groupA = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupAId, "group-a", [groupBId, leafId]);
|
||||
var groupB = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, groupBId, "group-b", [groupAId]);
|
||||
var leaf = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, leafId, "leaf");
|
||||
|
||||
await UpsertProfilesAsync(groupA, groupB, leaf);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, groupA, ECoreType.Xray);
|
||||
context.AllProxiesMap.Clear();
|
||||
|
||||
var (_, validatorResult) = await CoreConfigContextBuilder.ResolveNodeAsync(context, groupA, false);
|
||||
|
||||
validatorResult.Success.Should().BeTrue();
|
||||
validatorResult.Errors.Should().BeEmpty();
|
||||
validatorResult.Warnings.Should().Contain(msg => ContainsCycleDependencyMessage(msg));
|
||||
|
||||
context.AllProxiesMap.Should().ContainKey(leaf.IndexId);
|
||||
context.AllProxiesMap.Should().ContainKey(groupA.IndexId);
|
||||
context.AllProxiesMap.Should().NotContainKey(groupB.IndexId);
|
||||
groupA.GetProtocolExtra().ChildItems.Should().Be(leaf.IndexId);
|
||||
}
|
||||
|
||||
private static string NewId(string prefix)
|
||||
{
|
||||
return $"{prefix}-{Guid.NewGuid():N}";
|
||||
}
|
||||
|
||||
private static bool ContainsCycleDependencyMessage(string message)
|
||||
{
|
||||
return message.Contains("cycle dependency", StringComparison.OrdinalIgnoreCase)
|
||||
|| message.Contains("循环依赖", StringComparison.Ordinal)
|
||||
|| message.Contains("循環依賴", StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static async Task UpsertProfilesAsync(params ProfileItem[] profiles)
|
||||
{
|
||||
SQLiteHelper.Instance.CreateTable<ProfileItem>();
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
await SQLiteHelper.Instance.ReplaceAsync(profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
using System.Reflection;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Manager;
|
||||
using ServiceLib.Models;
|
||||
|
||||
namespace ServiceLib.Tests.CoreConfig;
|
||||
|
||||
internal static class CoreConfigTestFactory
|
||||
{
|
||||
public static void BindAppManagerConfig(Config config)
|
||||
{
|
||||
var field = typeof(AppManager).GetField("_config", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
field?.SetValue(AppManager.Instance, config);
|
||||
}
|
||||
|
||||
public static Config CreateConfig(ECoreType vmessCoreType = ECoreType.Xray)
|
||||
{
|
||||
return new Config
|
||||
{
|
||||
CoreBasicItem = new CoreBasicItem { Loglevel = "warning", MuxEnabled = false },
|
||||
TunModeItem = new TunModeItem { EnableTun = false, IcmpRouting = "default" },
|
||||
KcpItem = new KcpItem(),
|
||||
GrpcItem = new GrpcItem(),
|
||||
RoutingBasicItem =
|
||||
new RoutingBasicItem
|
||||
{
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
RoutingIndexId = string.Empty,
|
||||
},
|
||||
GuiItem = new GUIItem { EnableStatistics = false, DisplayRealTimeSpeed = false, EnableLog = false },
|
||||
MsgUIItem = new MsgUIItem(),
|
||||
UiItem =
|
||||
new UIItem
|
||||
{
|
||||
CurrentLanguage = "en",
|
||||
CurrentFontFamily = "sans",
|
||||
MainColumnItem = [],
|
||||
WindowSizeItem = []
|
||||
},
|
||||
ConstItem = new ConstItem(),
|
||||
SpeedTestItem = new SpeedTestItem
|
||||
{
|
||||
SpeedPingTestUrl = Global.SpeedPingTestUrls.First(),
|
||||
SpeedTestUrl = Global.SpeedTestUrls.First(),
|
||||
SpeedTestTimeout = 10,
|
||||
MixedConcurrencyCount = 1,
|
||||
IPAPIUrl = string.Empty,
|
||||
},
|
||||
Mux4RayItem = new Mux4RayItem { Concurrency = 8, XudpConcurrency = 16, XudpProxyUDP443 = "reject" },
|
||||
Mux4SboxItem = new Mux4SboxItem { Protocol = Global.SingboxMuxs.First(), MaxConnections = 8 },
|
||||
HysteriaItem = new HysteriaItem { UpMbps = 100, DownMbps = 100 },
|
||||
ClashUIItem = new ClashUIItem { ConnectionsColumnItem = [] },
|
||||
SystemProxyItem =
|
||||
new SystemProxyItem
|
||||
{
|
||||
SystemProxyExceptions = string.Empty,
|
||||
SystemProxyAdvancedProtocol = string.Empty
|
||||
},
|
||||
WebDavItem = new WebDavItem(),
|
||||
CheckUpdateItem = new CheckUpdateItem(),
|
||||
Fragment4RayItem = new Fragment4RayItem { Packets = "tlshello", Length = "100-200", Interval = "10-20" },
|
||||
Inbound =
|
||||
[
|
||||
new InItem
|
||||
{
|
||||
Protocol = nameof(EInboundProtocol.socks),
|
||||
LocalPort = 10808,
|
||||
UdpEnabled = true,
|
||||
SniffingEnabled = true,
|
||||
RouteOnly = false,
|
||||
DestOverride = ["http", "tls"],
|
||||
}
|
||||
],
|
||||
GlobalHotkeys = [],
|
||||
CoreTypeItem =
|
||||
[
|
||||
new CoreTypeItem { ConfigType = EConfigType.VMess, CoreType = vmessCoreType }
|
||||
],
|
||||
SimpleDNSItem = new SimpleDNSItem
|
||||
{
|
||||
BootstrapDNS = Global.DomainPureIPDNSAddress.FirstOrDefault(),
|
||||
ServeStale = false,
|
||||
ParallelQuery = false,
|
||||
Strategy4Freedom = Global.AsIs,
|
||||
Strategy4Proxy = Global.AsIs,
|
||||
},
|
||||
IndexId = string.Empty,
|
||||
SubIndexId = string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
public static ProfileItem CreateVmessNode(ECoreType coreType, string indexId = "node-1", string remarks = "demo")
|
||||
{
|
||||
var node = new ProfileItem
|
||||
{
|
||||
IndexId = indexId,
|
||||
ConfigType = EConfigType.VMess,
|
||||
CoreType = coreType,
|
||||
Remarks = remarks,
|
||||
Address = "example.com",
|
||||
Port = 443,
|
||||
Password = Guid.NewGuid().ToString(),
|
||||
Network = nameof(ETransport.raw),
|
||||
StreamSecurity = string.Empty,
|
||||
Subid = string.Empty,
|
||||
};
|
||||
|
||||
node.SetProtocolExtra(node.GetProtocolExtra() with { AlterId = "0", VmessSecurity = Global.DefaultSecurity, });
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public static ProfileItem CreateSocksNode(ECoreType coreType, string indexId = "node-socks-1",
|
||||
string remarks = "demo-socks")
|
||||
{
|
||||
return new ProfileItem
|
||||
{
|
||||
IndexId = indexId,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
CoreType = coreType,
|
||||
Remarks = remarks,
|
||||
Address = "127.0.0.1",
|
||||
Port = 1080,
|
||||
Password = "pass",
|
||||
Username = "user",
|
||||
Network = nameof(ETransport.raw),
|
||||
StreamSecurity = string.Empty,
|
||||
Subid = string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
public static ProfileItem CreatePolicyGroupNode(ECoreType coreType, string indexId, string remarks,
|
||||
IEnumerable<string> childIndexIds)
|
||||
{
|
||||
var node = new ProfileItem
|
||||
{
|
||||
IndexId = indexId,
|
||||
ConfigType = EConfigType.PolicyGroup,
|
||||
CoreType = coreType,
|
||||
Remarks = remarks,
|
||||
};
|
||||
node.SetProtocolExtra(node.GetProtocolExtra() with
|
||||
{
|
||||
GroupType = nameof(EConfigType.PolicyGroup),
|
||||
ChildItems = string.Join(",", childIndexIds),
|
||||
});
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public static ProfileItem CreateProxyChainNode(ECoreType coreType, string indexId, string remarks,
|
||||
IEnumerable<string> childIndexIds)
|
||||
{
|
||||
var node = new ProfileItem
|
||||
{
|
||||
IndexId = indexId,
|
||||
ConfigType = EConfigType.ProxyChain,
|
||||
CoreType = coreType,
|
||||
Remarks = remarks,
|
||||
};
|
||||
node.SetProtocolExtra(node.GetProtocolExtra() with
|
||||
{
|
||||
GroupType = nameof(EConfigType.ProxyChain),
|
||||
ChildItems = string.Join(",", childIndexIds),
|
||||
});
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public static CoreConfigContext CreateContext(Config config, ProfileItem node, ECoreType runCoreType)
|
||||
{
|
||||
return new CoreConfigContext
|
||||
{
|
||||
Node = node,
|
||||
RunCoreType = runCoreType,
|
||||
AppConfig = config,
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r1",
|
||||
Remarks = "default",
|
||||
RuleSet = "[]",
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
},
|
||||
RawDnsItem = null,
|
||||
SimpleDnsItem = config.SimpleDNSItem,
|
||||
AllProxiesMap = new Dictionary<string, ProfileItem> { [node.IndexId] = node },
|
||||
FullConfigTemplate = null,
|
||||
IsTunEnabled = false,
|
||||
ProtectDomainList = [],
|
||||
};
|
||||
}
|
||||
|
||||
public static Config CreateConfigWithDirectExpectedIPs(ECoreType coreType,
|
||||
string directExpectedIPs = "192.168.0.0/16,geoip:cn")
|
||||
{
|
||||
var config = CreateConfig(coreType);
|
||||
config.SimpleDNSItem.DirectExpectedIPs = directExpectedIPs;
|
||||
return config;
|
||||
}
|
||||
|
||||
public static Config CreateConfigWithBootstrapDNS(ECoreType coreType, string bootstrapDns = "8.8.8.8")
|
||||
{
|
||||
var config = CreateConfig(coreType);
|
||||
config.SimpleDNSItem.BootstrapDNS = bootstrapDns;
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Common;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Manager;
|
||||
using ServiceLib.Models;
|
||||
using ServiceLib.Services.CoreConfig;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.CoreConfig.Singbox;
|
||||
|
||||
public class CoreConfigSingboxServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ShouldGenerateBasicProxyConfig()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box);
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
result.Data.Should().NotBeNull();
|
||||
|
||||
var singboxConfig = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString());
|
||||
singboxConfig.Should().NotBeNull();
|
||||
singboxConfig!.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "socks");
|
||||
singboxConfig.inbounds.Should().Contain(i => i.type == nameof(EInboundProtocol.mixed));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_TunWithLoopbackPreSocks_ShouldKeepMixedInbound()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box);
|
||||
node.Address = Global.Loopback;
|
||||
node.Port = 1080;
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
IsTunEnabled = true,
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.inbounds.Should().Contain(i =>
|
||||
i.type == nameof(EInboundProtocol.mixed)
|
||||
&& i.listen == Global.Loopback
|
||||
&& i.listen_port == AppManager.Instance.GetLocalPort(EInboundProtocol.socks));
|
||||
cfg.inbounds.Should().Contain(i => i.type == "tun");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_BindInterface_ShouldUseDialBindInterface()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
config.CoreBasicItem.BindInterface = "eth0";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.sing_box);
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
IsTunEnabled = true,
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
var proxy = cfg.outbounds.First(o => o.tag == Global.ProxyTag);
|
||||
|
||||
proxy.bind_interface.Should().Be("eth0");
|
||||
proxy.detour.Should().BeNullOrEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_PolicyGroup_ShouldExpandChildrenAndBuildSelector()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.sing_box);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ProxyChain_ShouldBuildDetourChain()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.sing_box);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "socks");
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o =>
|
||||
o.tag == Global.ProxyTag &&
|
||||
(o.detour ?? string.Empty).StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_PolicyGroupWithProxyChain_ShouldBuildCombinedOutbounds()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n3", "node-3");
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||
[chain.IndexId, n3.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.sing_box);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[n3.IndexId] = n3;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ProxyChainWithPolicyGroup_ShouldBuildClonedChainBranches()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n2", "node-2");
|
||||
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n3", "node-3");
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.sing_box, "g1", "group",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.sing_box, "c1", "chain",
|
||||
[group.IndexId, n3.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.sing_box);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[n3.IndexId] = n3;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.type == "selector");
|
||||
cfg.outbounds.Should().Contain(o => o.tag == $"{Global.ProxyTag}-auto" && o.type == "urltest");
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-2-", StringComparison.Ordinal));
|
||||
|
||||
var proxyCloneCount = cfg.outbounds.Count(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal));
|
||||
proxyCloneCount.Should().Be(2);
|
||||
|
||||
var allCloneDetoursPointToGroupBranches = cfg.outbounds
|
||||
.Where(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal))
|
||||
.All(o => (o.detour ?? string.Empty).StartsWith("chain-proxy-1-group-", StringComparison.Ordinal));
|
||||
allCloneDetoursPointToGroupBranches.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RoutingSplit_DirectAndBlock_ShouldApplyRules()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-split-1",
|
||||
Remarks = "split-direct-block",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["full:direct.example.com"],
|
||||
},
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.BlockTag,
|
||||
Domain = ["full:block.example.com"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hasDirectRule = cfg.route.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("direct.example.com")
|
||||
&& r.outbound == Global.DirectTag);
|
||||
hasDirectRule.Should().BeTrue();
|
||||
|
||||
var hasBlockRule = cfg.route.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("block.example.com")
|
||||
&& r.action == "reject");
|
||||
hasBlockRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RoutingSplit_ByRemark_ShouldGenerateTargetOutbound()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var routeNode = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-route", "route-node");
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-split-2",
|
||||
Remarks = "split-remark",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = routeNode.Remarks,
|
||||
Domain = ["full:route.example.com"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
context.AllProxiesMap[$"remark:{routeNode.Remarks}"] = routeNode;
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
var expectedPrefix = $"{routeNode.IndexId}-{Global.ProxyTag}-{routeNode.Remarks}";
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||
|
||||
var hasRouteRule = cfg.route.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("route.example.com")
|
||||
&& (r.outbound ?? string.Empty).StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||
hasRouteRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_ShouldApplyGeoipAndCidrToDirectDnsRule()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(
|
||||
ECoreType.sing_box,
|
||||
"192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-expected",
|
||||
Remarks = "dns-direct-expected",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.DNS,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["geosite:cn"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||
r.server == Global.SingboxDirectDNSTag
|
||||
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||
&& r.rule_set?.Contains("geosite-cn") == true
|
||||
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||
|
||||
hasExpectedRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_BootstrapDNS_ShouldConfigurePureIPResolver()
|
||||
{
|
||||
var bootstrapDns = "8.8.8.8";
|
||||
var config = CoreConfigTestFactory.CreateConfigWithBootstrapDNS(ECoreType.sing_box, bootstrapDns);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
config.SimpleDNSItem.BootstrapDNS.Should().Be(bootstrapDns);
|
||||
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
var bootstrapServer = cfg.dns.servers?.FirstOrDefault(s => s.tag == Global.SingboxLocalDNSTag);
|
||||
bootstrapServer.Should().NotBeNull();
|
||||
(bootstrapServer?.server ?? string.Empty).Should().Contain(bootstrapDns);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DnsFallback_LastRuleDirect_ShouldUseDirectFinalDns()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
config.SimpleDNSItem.DirectDNS = "1.1.1.1";
|
||||
config.SimpleDNSItem.RemoteDNS = "9.9.9.9";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-direct-final",
|
||||
Remarks = "direct-final",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Ip = ["0.0.0.0/0"],
|
||||
Port = "0-65535",
|
||||
Network = "tcp,udp",
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.dns.final.Should().Be(Global.SingboxDirectDNSTag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_NonMatchingRegion_ShouldNotApplyExpectedRule()
|
||||
{
|
||||
var config =
|
||||
CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.sing_box, "192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-unmatched",
|
||||
Remarks = "dns-direct-unmatched",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.DNS,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["geosite:us"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||
r.server == Global.SingboxDirectDNSTag
|
||||
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||
hasExpectedRule.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("geosite:cn", "geosite-cn")]
|
||||
[InlineData("geosite:geolocation-cn", "geosite-geolocation-cn")]
|
||||
[InlineData("geosite:tld-cn", "geosite-tld-cn")]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_RegionVariant_ShouldApplyExpectedRule(string domainTag,
|
||||
string expectedRuleSetTag)
|
||||
{
|
||||
var config =
|
||||
CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.sing_box, "192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-variant",
|
||||
Remarks = "dns-direct-variant",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true, RuleType = ERuleType.DNS, OutboundTag = Global.DirectTag, Domain = [domainTag],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hasExpectedRule = cfg.dns.rules?.Any(r =>
|
||||
r.server == Global.SingboxDirectDNSTag
|
||||
&& r.ip_cidr?.Contains("192.168.0.0/16") == true
|
||||
&& r.rule_set?.Contains(expectedRuleSetTag) == true
|
||||
&& r.rule_set?.Contains("geoip-cn") == true) ?? false;
|
||||
hasExpectedRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_Hosts_ShouldPopulateHostsServerAndDomainResolver()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
config.SimpleDNSItem.Hosts = "resolver.example 1.1.1.1";
|
||||
config.SimpleDNSItem.DirectDNS = "https://resolver.example/dns-query";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box);
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hostsServer = cfg.dns.servers.FirstOrDefault(s => s.tag == Global.SingboxHostsDNSTag);
|
||||
hostsServer.Should().NotBeNull();
|
||||
hostsServer!.predefined.Should().ContainKey("resolver.example");
|
||||
hostsServer.predefined!["resolver.example"].Should().Contain("1.1.1.1");
|
||||
|
||||
var directServer = cfg.dns.servers.FirstOrDefault(s => s.tag == Global.SingboxDirectDNSTag);
|
||||
directServer.Should().NotBeNull();
|
||||
directServer!.domain_resolver.Should().Be(Global.SingboxHostsDNSTag);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RawDnsEnabled_ShouldUseCustomDnsAndInjectLocalResolver()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box, "n-main", "main");
|
||||
var rawDns = new Dns4Sbox
|
||||
{
|
||||
servers =
|
||||
[
|
||||
new Server4Sbox { tag = "remote", type = "udp", server = "8.8.8.8", detour = Global.ProxyTag, }
|
||||
],
|
||||
rules = [],
|
||||
};
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with
|
||||
{
|
||||
RawDnsItem = new DNSItem
|
||||
{
|
||||
Id = "dns-raw-1",
|
||||
Remarks = "raw",
|
||||
Enabled = true,
|
||||
CoreType = ECoreType.sing_box,
|
||||
NormalDNS = JsonUtils.Serialize(rawDns),
|
||||
DomainDNSAddress = "1.1.1.1",
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue($"ret msg: {result.Msg}");
|
||||
var cfg = JsonUtils.Deserialize<SingboxConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.dns.servers.Should().Contain(s => s.tag == "remote" && s.type == "udp" && s.server == "8.8.8.8");
|
||||
cfg.dns.servers.Should().Contain(s => s.tag == Global.SingboxLocalDNSTag);
|
||||
cfg.dns.rules.Should().Contain(r => r.clash_mode == ERuleMode.Global.ToString());
|
||||
cfg.dns.rules.Should().Contain(r => r.clash_mode == ERuleMode.Direct.ToString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Common;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Models;
|
||||
using ServiceLib.Services.CoreConfig;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.CoreConfig.V2ray;
|
||||
|
||||
public class CoreConfigV2rayServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ShouldGenerateBasicProxyConfig()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray);
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
result.Data.Should().NotBeNull();
|
||||
|
||||
var v2rayConfig = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString());
|
||||
v2rayConfig.Should().NotBeNull();
|
||||
v2rayConfig!.outbounds.Should().Contain(o => o.tag == Global.ProxyTag && o.protocol == "vmess");
|
||||
v2rayConfig.inbounds.Should().Contain(i => i.protocol == nameof(EInboundProtocol.mixed));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_PolicyGroup_ShouldExpandChildrenAndBuildBalancer()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.Xray);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||
cfg.routing.balancers.Should().NotBeNull();
|
||||
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ProxyChain_ShouldBuildDialerProxyChain()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain", [n1.IndexId, n2.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.Xray);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||
var hasDialerChain = cfg.outbounds.Any(o =>
|
||||
o.tag == Global.ProxyTag
|
||||
&& o.streamSettings is not null
|
||||
&& o.streamSettings.sockopt is not null
|
||||
&& (o.streamSettings.sockopt.dialerProxy ?? string.Empty).StartsWith("chain-proxy-1-",
|
||||
StringComparison.Ordinal));
|
||||
hasDialerChain.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_PolicyGroupWithProxyChain_ShouldBuildCombinedOutbounds()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n3", "node-3");
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain", [n1.IndexId, n2.IndexId]);
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||
[chain.IndexId, n3.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, group, ECoreType.Xray);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[n3.IndexId] = n3;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("proxy-2-", StringComparison.Ordinal));
|
||||
cfg.routing.balancers.Should().NotBeNull();
|
||||
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_ProxyChainWithPolicyGroup_ShouldBuildClonedChainBranches()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var n1 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n1", "node-1");
|
||||
var n2 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n2", "node-2");
|
||||
var n3 = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n3", "node-3");
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "g1", "group",
|
||||
[n1.IndexId, n2.IndexId]);
|
||||
var chain = CoreConfigTestFactory.CreateProxyChainNode(ECoreType.Xray, "c1", "chain",
|
||||
[group.IndexId, n3.IndexId]);
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, chain, ECoreType.Xray);
|
||||
context.AllProxiesMap[n1.IndexId] = n1;
|
||||
context.AllProxiesMap[n2.IndexId] = n2;
|
||||
context.AllProxiesMap[n3.IndexId] = n3;
|
||||
context.AllProxiesMap[group.IndexId] = group;
|
||||
context.AllProxiesMap[chain.IndexId] = chain;
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-1-", StringComparison.Ordinal));
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith("chain-proxy-1-group-2-", StringComparison.Ordinal));
|
||||
|
||||
var proxyCloneCount = cfg.outbounds.Count(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal));
|
||||
proxyCloneCount.Should().Be(2);
|
||||
|
||||
var allCloneDialersPointToGroupBranches = cfg.outbounds
|
||||
.Where(o => o.tag.StartsWith("proxy-clone-", StringComparison.Ordinal))
|
||||
.All(o => (o.streamSettings?.sockopt?.dialerProxy ?? string.Empty).StartsWith("chain-proxy-1-group-",
|
||||
StringComparison.Ordinal));
|
||||
allCloneDialersPointToGroupBranches.Should().BeTrue();
|
||||
|
||||
cfg.routing.balancers.Should().NotBeNull();
|
||||
cfg.routing.balancers!.Should().Contain(b => b.tag == Global.ProxyTag + Global.BalancerTagSuffix);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RoutingSplit_DirectAndBlock_ShouldApplyRules()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-split-1",
|
||||
Remarks = "split-direct-block",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["full:direct.example.com"],
|
||||
},
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.BlockTag,
|
||||
Domain = ["full:block.example.com"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
|
||||
var hasDirectRule = cfg.routing.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("full:direct.example.com")
|
||||
&& r.outboundTag == Global.DirectTag);
|
||||
hasDirectRule.Should().BeTrue();
|
||||
|
||||
var hasBlockRule = cfg.routing.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("full:block.example.com")
|
||||
&& r.outboundTag == Global.BlockTag);
|
||||
hasBlockRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RoutingSplit_ByRemark_ShouldGenerateTargetOutbound()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var routeNode = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "n-route", "route-node");
|
||||
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-split-2",
|
||||
Remarks = "split-remark",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = routeNode.Remarks,
|
||||
Domain = ["full:route.example.com"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
context.AllProxiesMap[$"remark:{routeNode.Remarks}"] = routeNode;
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var expectedPrefix = $"{routeNode.IndexId}-{Global.ProxyTag}-{routeNode.Remarks}";
|
||||
|
||||
cfg.outbounds.Should().Contain(o => o.tag.StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||
var hasRouteRule = cfg.routing.rules.Any(r =>
|
||||
r.domain != null
|
||||
&& r.domain.Contains("full:route.example.com")
|
||||
&& (r.outboundTag ?? string.Empty).StartsWith(expectedPrefix, StringComparison.Ordinal));
|
||||
hasRouteRule.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_ShouldApplyExpectedIPsToDirectDnsServer()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-expected",
|
||||
Remarks = "dns-direct-expected",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.DNS,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["geosite:cn"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
|
||||
var dnsServers = dns.servers
|
||||
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||
.Where(s => s is not null)
|
||||
.Cast<DnsServer4Ray>()
|
||||
.ToList();
|
||||
|
||||
var hasExpectedServer = dnsServers.Any(s =>
|
||||
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||
&& s.domains?.Contains("geosite:cn") == true
|
||||
&& s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||
&& s.expectedIPs?.Contains("geoip:cn") == true);
|
||||
hasExpectedServer.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_BootstrapDNS_ShouldApplyToDnsServerDomains()
|
||||
{
|
||||
var bootstrapDns = "8.8.8.8";
|
||||
var config = CoreConfigTestFactory.CreateConfigWithBootstrapDNS(ECoreType.Xray, bootstrapDns);
|
||||
config.SimpleDNSItem.DirectDNS = "https://dns-direct.example/dns-query";
|
||||
config.SimpleDNSItem.RemoteDNS = "https://dns-remote.example/dns-query";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
|
||||
var dnsServers = dns.servers
|
||||
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||
.Where(s => s is not null)
|
||||
.Cast<DnsServer4Ray>()
|
||||
.ToList();
|
||||
|
||||
var hasBootstrapServer = dnsServers.Any(s =>
|
||||
s.address == bootstrapDns
|
||||
&& s.domains?.Contains("full:dns-direct.example") == true
|
||||
&& s.domains?.Contains("full:dns-remote.example") == true);
|
||||
hasBootstrapServer.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DnsFallback_LastRuleDirect_ShouldUseDirectDnsServers()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
config.SimpleDNSItem.DirectDNS = "1.1.1.1";
|
||||
config.SimpleDNSItem.RemoteDNS = "9.9.9.9";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-direct-final",
|
||||
Remarks = "direct-final",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.Routing,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Ip = ["0.0.0.0/0"],
|
||||
Port = "0-65535",
|
||||
Network = "tcp,udp",
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
var dnsServers = dns.servers
|
||||
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||
.Where(s => s is not null)
|
||||
.Cast<DnsServer4Ray>()
|
||||
.ToList();
|
||||
|
||||
var hasDirectFallback = dnsServers.Any(s =>
|
||||
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||
&& s.address == "1.1.1.1");
|
||||
hasDirectFallback.Should().BeTrue();
|
||||
|
||||
var hasRemoteFallback = dnsServers.Any(s => s.address == "9.9.9.9");
|
||||
hasRemoteFallback.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_NonMatchingRegion_ShouldNotApplyExpectedIPs()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-unmatched",
|
||||
Remarks = "dns-direct-unmatched",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true,
|
||||
RuleType = ERuleType.DNS,
|
||||
OutboundTag = Global.DirectTag,
|
||||
Domain = ["geosite:us"],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
var dnsServers = dns.servers
|
||||
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||
.Where(s => s is not null)
|
||||
.Cast<DnsServer4Ray>()
|
||||
.ToList();
|
||||
|
||||
var hasExpectedIPs = dnsServers.Any(s =>
|
||||
s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||
|| s.expectedIPs?.Contains("geoip:cn") == true);
|
||||
hasExpectedIPs.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("geosite:cn")]
|
||||
[InlineData("geosite:geolocation-cn")]
|
||||
[InlineData("geosite:tld-cn")]
|
||||
public void GenerateClientConfigContent_DirectExpectedIPs_RegionVariant_ShouldApplyExpectedIPs(string domainTag)
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfigWithDirectExpectedIPs(ECoreType.Xray, "192.168.0.0/16,geoip:cn");
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RoutingItem = new RoutingItem
|
||||
{
|
||||
Id = "r-dns-direct-variant",
|
||||
Remarks = "dns-direct-variant",
|
||||
RuleSet = JsonUtils.Serialize(new List<RulesItem>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Enabled = true, RuleType = ERuleType.DNS, OutboundTag = Global.DirectTag, Domain = [domainTag],
|
||||
}
|
||||
}),
|
||||
DomainStrategy = Global.AsIs,
|
||||
DomainStrategy4Singbox = string.Empty,
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
var dnsServers = dns.servers
|
||||
.Select(s => JsonUtils.Deserialize<DnsServer4Ray>(JsonUtils.Serialize(s)))
|
||||
.Where(s => s is not null)
|
||||
.Cast<DnsServer4Ray>()
|
||||
.ToList();
|
||||
|
||||
var hasExpectedServer = dnsServers.Any(s =>
|
||||
(s.tag ?? string.Empty).StartsWith(Global.DirectDnsTag, StringComparison.Ordinal)
|
||||
&& s.domains?.Contains(domainTag) == true
|
||||
&& s.expectedIPs?.Contains("192.168.0.0/16") == true
|
||||
&& s.expectedIPs?.Contains("geoip:cn") == true);
|
||||
hasExpectedServer.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_Hosts_ShouldPopulateDnsHosts()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
config.SimpleDNSItem.Hosts = "resolver.example 1.1.1.1";
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray);
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
|
||||
dns.hosts.Should().NotBeNull();
|
||||
dns.hosts!.Should().ContainKey("resolver.example");
|
||||
JsonUtils.Serialize(dns.hosts!["resolver.example"]).Should().Contain("1.1.1.1");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateClientConfigContent_RawDnsEnabled_ShouldUseCustomDnsConfig()
|
||||
{
|
||||
var config = CoreConfigTestFactory.CreateConfig(ECoreType.Xray);
|
||||
CoreConfigTestFactory.BindAppManagerConfig(config);
|
||||
|
||||
var node = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "n-main", "main");
|
||||
var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.Xray) with
|
||||
{
|
||||
RawDnsItem = new DNSItem
|
||||
{
|
||||
Id = "dns-raw-1",
|
||||
Remarks = "raw",
|
||||
Enabled = true,
|
||||
CoreType = ECoreType.Xray,
|
||||
NormalDNS = "{\"servers\":[\"8.8.8.8\"],\"hosts\":{\"raw.example\":\"1.1.1.1\"}}",
|
||||
DomainStrategy4Freedom = "UseIPv4",
|
||||
}
|
||||
};
|
||||
|
||||
var result = new CoreConfigV2rayService(context).GenerateClientConfigContent();
|
||||
|
||||
result.Success.Should().BeTrue();
|
||||
var cfg = JsonUtils.Deserialize<V2rayConfig>(result.Data!.ToString())!;
|
||||
var dns = JsonUtils.Deserialize<Dns4Ray>(JsonUtils.Serialize(cfg.dns))!;
|
||||
|
||||
JsonUtils.Serialize(dns.servers).Should().Contain("8.8.8.8");
|
||||
dns.hosts.Should().NotBeNull();
|
||||
dns.hosts!.Should().ContainKey("raw.example");
|
||||
JsonUtils.Serialize(dns.hosts!["raw.example"]).Should().Contain("1.1.1.1");
|
||||
|
||||
var directOutbound = cfg.outbounds.FirstOrDefault(o => o.tag == Global.DirectTag && o.protocol == "freedom");
|
||||
directOutbound.Should().NotBeNull();
|
||||
directOutbound!.settings.domainStrategy.Should().Be("UseIPv4");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Handler.Fmt;
|
||||
using ServiceLib.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.Fmt;
|
||||
|
||||
public class FmtHandlerTests
|
||||
{
|
||||
[Fact]
|
||||
public void GetShareUriAndResolveConfig_Vmess_ShouldRoundTripBasicFields()
|
||||
{
|
||||
var source = CreateVmessProfile();
|
||||
|
||||
var resolved = ExportThenImport(source);
|
||||
|
||||
resolved.ConfigType.Should().Be(EConfigType.VMess);
|
||||
resolved.Remarks.Should().Be(source.Remarks);
|
||||
resolved.Address.Should().Be(source.Address);
|
||||
resolved.Port.Should().Be(source.Port);
|
||||
resolved.Password.Should().Be(source.Password);
|
||||
resolved.GetProtocolExtra().AlterId.Should().Be(source.GetProtocolExtra().AlterId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetShareUriAndResolveConfig_Vless_ShouldRoundTripBasicFields()
|
||||
{
|
||||
var source = CreateVlessProfile();
|
||||
|
||||
var resolved = ExportThenImport(source);
|
||||
|
||||
resolved.ConfigType.Should().Be(EConfigType.VLESS);
|
||||
resolved.Remarks.Should().Be(source.Remarks);
|
||||
resolved.Address.Should().Be(source.Address);
|
||||
resolved.Port.Should().Be(source.Port);
|
||||
resolved.Password.Should().Be(source.Password);
|
||||
resolved.GetProtocolExtra().VlessEncryption.Should().Be(Global.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetShareUriAndResolveConfig_Shadowsocks_ShouldRoundTripBasicFields()
|
||||
{
|
||||
var source = CreateShadowsocksProfile();
|
||||
|
||||
var resolved = ExportThenImport(source);
|
||||
|
||||
resolved.ConfigType.Should().Be(EConfigType.Shadowsocks);
|
||||
resolved.Remarks.Should().Be(source.Remarks);
|
||||
resolved.Address.Should().Be(source.Address);
|
||||
resolved.Port.Should().Be(source.Port);
|
||||
resolved.Password.Should().Be(source.Password);
|
||||
resolved.GetProtocolExtra().SsMethod.Should().Be(source.GetProtocolExtra().SsMethod);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetShareUriAndResolveConfig_Socks_ShouldRoundTripBasicFields()
|
||||
{
|
||||
var source = CreateSocksProfile();
|
||||
|
||||
var resolved = ExportThenImport(source);
|
||||
|
||||
resolved.ConfigType.Should().Be(EConfigType.SOCKS);
|
||||
resolved.Remarks.Should().Be(source.Remarks);
|
||||
resolved.Address.Should().Be(source.Address);
|
||||
resolved.Port.Should().Be(source.Port);
|
||||
resolved.Username.Should().Be(source.Username);
|
||||
resolved.Password.Should().Be(source.Password);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResolveConfig_UnsupportedProtocol_ShouldReturnNull()
|
||||
{
|
||||
var resolved = FmtHandler.ResolveConfig("not-a-share-uri", out var msg);
|
||||
|
||||
resolved.Should().BeNull();
|
||||
msg.Should().NotBeNullOrWhiteSpace();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetShareUri_UnsupportedConfigType_ShouldReturnNull()
|
||||
{
|
||||
var item = new ProfileItem { ConfigType = EConfigType.PolicyGroup, Remarks = "group", };
|
||||
|
||||
var uri = FmtHandler.GetShareUri(item);
|
||||
|
||||
uri.Should().BeNull();
|
||||
}
|
||||
|
||||
private static ProfileItem ExportThenImport(ProfileItem source)
|
||||
{
|
||||
var uri = FmtHandler.GetShareUri(source);
|
||||
|
||||
uri.Should().NotBeNullOrWhiteSpace();
|
||||
uri!.StartsWith(Global.ProtocolShares[source.ConfigType], StringComparison.OrdinalIgnoreCase).Should()
|
||||
.BeTrue();
|
||||
|
||||
var resolved = FmtHandler.ResolveConfig(uri, out var msg);
|
||||
|
||||
resolved.Should().NotBeNull($"uri: {uri}, msg: {msg}");
|
||||
return resolved!;
|
||||
}
|
||||
|
||||
private static ProfileItem CreateVmessProfile()
|
||||
{
|
||||
var item = new ProfileItem
|
||||
{
|
||||
ConfigType = EConfigType.VMess,
|
||||
Remarks = "vmess demo",
|
||||
Address = "example.com",
|
||||
Port = 443,
|
||||
Password = Guid.NewGuid().ToString(),
|
||||
Network = nameof(ETransport.raw),
|
||||
StreamSecurity = string.Empty,
|
||||
};
|
||||
|
||||
item.SetProtocolExtra(new ProtocolExtraItem { AlterId = "0", VmessSecurity = Global.DefaultSecurity, });
|
||||
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ProfileItem CreateVlessProfile()
|
||||
{
|
||||
var item = new ProfileItem
|
||||
{
|
||||
ConfigType = EConfigType.VLESS,
|
||||
Remarks = "vless demo",
|
||||
Address = "vless.example",
|
||||
Port = 8443,
|
||||
Password = Guid.NewGuid().ToString(),
|
||||
Network = nameof(ETransport.raw),
|
||||
StreamSecurity = string.Empty,
|
||||
};
|
||||
|
||||
item.SetProtocolExtra(new ProtocolExtraItem { VlessEncryption = Global.None, });
|
||||
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ProfileItem CreateShadowsocksProfile()
|
||||
{
|
||||
var item = new ProfileItem
|
||||
{
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Remarks = "ss demo",
|
||||
Address = "1.2.3.4",
|
||||
Port = 8388,
|
||||
Password = "pass123",
|
||||
Network = nameof(ETransport.raw),
|
||||
StreamSecurity = string.Empty,
|
||||
};
|
||||
|
||||
item.SetProtocolExtra(new ProtocolExtraItem { SsMethod = "aes-128-gcm", });
|
||||
item.SetTransportExtra(new TransportExtraItem { RawHeaderType = Global.None, });
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ProfileItem CreateSocksProfile()
|
||||
{
|
||||
return new ProfileItem
|
||||
{
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Remarks = "socks demo",
|
||||
Address = "127.0.0.1",
|
||||
Port = 1080,
|
||||
Username = "user",
|
||||
Password = "pass",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Enums;
|
||||
using ServiceLib.Handler.Fmt;
|
||||
using ServiceLib.Tests.CoreConfig;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.Fmt;
|
||||
|
||||
public class InnerFmtTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToUriAndResolve_ShouldRoundTripPolicyGroupReferences()
|
||||
{
|
||||
var childA = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "child-a", "child-a");
|
||||
var childB = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "child-b", "child-b");
|
||||
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "group-1", "group-1",
|
||||
[childA.IndexId, childB.IndexId]);
|
||||
group.SetProtocolExtra(group.GetProtocolExtra() with { SubChildItems = "original-sub" });
|
||||
|
||||
var uri = InnerFmt.ToUri([group, childA, childB]);
|
||||
|
||||
uri.Should().NotBeNullOrWhiteSpace();
|
||||
|
||||
var resolved = InnerFmt.Resolve(uri!, "sub-123");
|
||||
|
||||
resolved.Should().NotBeNull();
|
||||
resolved.Should().HaveCount(3);
|
||||
|
||||
var resolvedGroup = resolved!.Single(x => x.Remarks == group.Remarks);
|
||||
var resolvedChildA = resolved.Single(x => x.Remarks == childA.Remarks);
|
||||
var resolvedChildB = resolved.Single(x => x.Remarks == childB.Remarks);
|
||||
|
||||
resolvedGroup.ConfigType.Should().Be(EConfigType.PolicyGroup);
|
||||
resolvedGroup.GetProtocolExtra().SubChildItems.Should().Be("sub-123");
|
||||
resolvedGroup.GetProtocolExtra().ChildItems.Should().Be($"{resolvedChildA.IndexId},{resolvedChildB.IndexId}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using AwesomeAssertions;
|
||||
using ServiceLib.Handler.Fmt;
|
||||
using Xunit;
|
||||
|
||||
namespace ServiceLib.Tests.Fmt;
|
||||
|
||||
public class WireguardFmtTests
|
||||
{
|
||||
[Fact]
|
||||
public void ResolveConfig_ShouldParsePeersAndIgnoreInlineComments()
|
||||
{
|
||||
const string config =
|
||||
"""
|
||||
[Interface]
|
||||
PrivateKey = interface-private-key
|
||||
Address = 10.0.0.2/32, fd00::2/128 ; inline comment
|
||||
MTU = 1420
|
||||
|
||||
[Peer]
|
||||
PublicKey = peer-public-key
|
||||
PresharedKey = peer-preshared-key
|
||||
Reserved = 1, 2, 3 # inline comment
|
||||
Endpoint = [2001:db8::1]:51820 # inline comment
|
||||
|
||||
[Peer]
|
||||
PublicKey = peer-public-key-2
|
||||
Endpoint = example.com:12345
|
||||
""";
|
||||
|
||||
var resolved = WireguardFmt.ResolveConfig(config);
|
||||
|
||||
resolved.Should().NotBeNull();
|
||||
resolved.Should().HaveCount(2);
|
||||
|
||||
var first = resolved![0];
|
||||
first.Address.Should().Be("2001:db8::1");
|
||||
first.Port.Should().Be(51820);
|
||||
first.Password.Should().Be("interface-private-key");
|
||||
first.GetProtocolExtra().WgReserved.Should().Be("1, 2, 3");
|
||||
first.GetProtocolExtra().WgInterfaceAddress.Should().Be("10.0.0.2/32, fd00::2/128");
|
||||
first.GetProtocolExtra().WgMtu.Should().Be(1420);
|
||||
|
||||
var second = resolved[1];
|
||||
second.Address.Should().Be("example.com");
|
||||
second.Port.Should().Be(12345);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AwesomeAssertions" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.v3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ServiceLib\ServiceLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,5 @@
|
||||
global using System.Buffers.Binary;
|
||||
global using System.Diagnostics;
|
||||
global using System.Net;
|
||||
global using System.Net.Sockets;
|
||||
global using System.Text;
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,420 @@
|
||||
namespace ServiceLib.UdpTest;
|
||||
|
||||
public class Socks5UdpChannel(string socks5Host, int socks5TcpPort) : IDisposable
|
||||
{
|
||||
private TcpClient _tcpClient;
|
||||
private UdpClient _udpClient;
|
||||
private IPEndPoint _relayEndPoint;
|
||||
|
||||
private bool _initialized = false;
|
||||
|
||||
/// <summary>
|
||||
/// Send UDP data to a remote endpoint (IP address)
|
||||
/// </summary>
|
||||
public async Task SendAsync(IPEndPoint remote, byte[] data)
|
||||
{
|
||||
var addrData = new Socks5AddressData
|
||||
{
|
||||
AddressType = remote.Address.AddressFamily == AddressFamily.InterNetwork
|
||||
? Socks5AddressData.AddrTypeIPv4
|
||||
: Socks5AddressData.AddrTypeIPv6,
|
||||
Host = remote.Address.ToString(),
|
||||
Port = (ushort)remote.Port
|
||||
};
|
||||
var packet = BuildSocks5UdpPacket(addrData, data);
|
||||
await _udpClient.SendAsync(packet, packet.Length, _relayEndPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send UDP data to a remote endpoint (domain name or IP address)
|
||||
/// </summary>
|
||||
/// <param name="host">Domain name or IP address</param>
|
||||
/// <param name="port">Port number</param>
|
||||
/// <param name="data">Data to send</param>
|
||||
public async Task SendAsync(string host, ushort port, byte[] data)
|
||||
{
|
||||
var addrData = new Socks5AddressData();
|
||||
|
||||
// Try to parse as IP address first
|
||||
if (IPAddress.TryParse(host, out var ipAddr))
|
||||
{
|
||||
addrData.AddressType = ipAddr.AddressFamily == AddressFamily.InterNetwork
|
||||
? Socks5AddressData.AddrTypeIPv4
|
||||
: Socks5AddressData.AddrTypeIPv6;
|
||||
addrData.Host = ipAddr.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Treat as domain name
|
||||
addrData.AddressType = Socks5AddressData.AddrTypeDomain;
|
||||
addrData.Host = host;
|
||||
}
|
||||
|
||||
addrData.Port = port;
|
||||
|
||||
var packet = BuildSocks5UdpPacket(addrData, data);
|
||||
await _udpClient.SendAsync(packet, packet.Length, _relayEndPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Receive UDP data from remote endpoint
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token to cancel the receive operation</param>
|
||||
/// <returns>Remote endpoint information and received data</returns>
|
||||
public async Task<(Socks5RemoteEndpoint Remote, byte[] Data)> ReceiveAsync(
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await _udpClient.ReceiveAsync(cancellationToken).ConfigureAwait(false);
|
||||
var (remote, payload) = ParseSocks5UdpPacket(result.Buffer);
|
||||
return (remote, payload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a remote endpoint that can be either an IP address or a domain name
|
||||
/// </summary>
|
||||
public class Socks5RemoteEndpoint(string host, ushort port, bool isDomain)
|
||||
{
|
||||
public string Host { get; set; } = host;
|
||||
public ushort Port { get; set; } = port;
|
||||
public bool IsDomain { get; set; } = isDomain;
|
||||
}
|
||||
|
||||
private static byte[] BuildSocks5UdpPacket(Socks5AddressData addressData, byte[] data)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
|
||||
// RSV (2 bytes) + FRAG (1 byte) - Reserved and Fragment fields
|
||||
ms.WriteByte(0x00);
|
||||
ms.WriteByte(0x00);
|
||||
ms.WriteByte(0x00);
|
||||
|
||||
// Write address (ATYP + address + port)
|
||||
ms.Write(addressData.ToBytes());
|
||||
|
||||
// User data payload
|
||||
ms.Write(data);
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
private static (Socks5RemoteEndpoint Remote, byte[] Data) ParseSocks5UdpPacket(byte[] packet)
|
||||
{
|
||||
if (packet.Length < 10) // Minimum length: RSV(2) + FRAG(1) + ATYP(1) + IPv4(4) + Port(2) = 10
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: too short");
|
||||
}
|
||||
|
||||
var offset = 0;
|
||||
|
||||
// RSV (2 bytes) - Reserved field, skip
|
||||
offset += 2;
|
||||
|
||||
// FRAG (1 byte) - Fragment number, currently only support 0 (no fragmentation)
|
||||
var frag = packet[offset++];
|
||||
if (frag != 0x00)
|
||||
{
|
||||
throw new NotSupportedException("SOCKS5 UDP fragmentation is not supported");
|
||||
}
|
||||
|
||||
// ATYP (1 byte) - Address type
|
||||
var addressType = packet[offset++];
|
||||
|
||||
string host;
|
||||
int addressLength;
|
||||
bool isDomain;
|
||||
|
||||
switch (addressType)
|
||||
{
|
||||
case Socks5AddressData.AddrTypeIPv4:
|
||||
if (packet.Length < offset + 4)
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: IPv4 address incomplete");
|
||||
}
|
||||
|
||||
var ipv4Bytes = new byte[4];
|
||||
Array.Copy(packet, offset, ipv4Bytes, 0, 4);
|
||||
host = new IPAddress(ipv4Bytes).ToString();
|
||||
addressLength = 4;
|
||||
isDomain = false;
|
||||
break;
|
||||
|
||||
case Socks5AddressData.AddrTypeIPv6:
|
||||
if (packet.Length < offset + 16)
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: IPv6 address incomplete");
|
||||
}
|
||||
|
||||
var ipv6Bytes = new byte[16];
|
||||
Array.Copy(packet, offset, ipv6Bytes, 0, 16);
|
||||
host = new IPAddress(ipv6Bytes).ToString();
|
||||
addressLength = 16;
|
||||
isDomain = false;
|
||||
break;
|
||||
|
||||
case Socks5AddressData.AddrTypeDomain:
|
||||
if (packet.Length < offset + 1)
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: domain length missing");
|
||||
}
|
||||
|
||||
var domainLength = packet[offset++];
|
||||
if (packet.Length < offset + domainLength)
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: domain incomplete");
|
||||
}
|
||||
|
||||
host = Encoding.ASCII.GetString(packet, offset, domainLength);
|
||||
addressLength = domainLength;
|
||||
isDomain = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException($"Unsupported SOCKS5 address type: {addressType}");
|
||||
}
|
||||
|
||||
offset += addressLength;
|
||||
|
||||
// Port (2 bytes, big-endian)
|
||||
if (packet.Length < offset + 2)
|
||||
{
|
||||
throw new ArgumentException("Invalid SOCKS5 UDP packet: port incomplete");
|
||||
}
|
||||
|
||||
var port = BinaryPrimitives.ReadUInt16BigEndian(packet.AsSpan(offset, 2));
|
||||
offset += 2;
|
||||
|
||||
// Data (remaining bytes)
|
||||
var dataLength = packet.Length - offset;
|
||||
var data = new byte[dataLength];
|
||||
if (dataLength > 0)
|
||||
{
|
||||
Array.Copy(packet, offset, data, 0, dataLength);
|
||||
}
|
||||
|
||||
// Create remote endpoint without DNS resolution
|
||||
var remote = new Socks5RemoteEndpoint(host, port, isDomain);
|
||||
return (remote, data);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_tcpClient.Dispose();
|
||||
_udpClient.Dispose();
|
||||
}
|
||||
|
||||
#region SOCKS5 Connection Handling
|
||||
|
||||
private const byte Socks5Version = 0x05;
|
||||
private const byte SocksCmdUdpAssociate = 0x03;
|
||||
|
||||
public async Task<bool> EstablishUdpAssociationAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_initialized)
|
||||
{
|
||||
Dispose();
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
_udpClient = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
|
||||
_tcpClient = new TcpClient();
|
||||
try
|
||||
{
|
||||
await _tcpClient.ConnectAsync(socks5Host, socks5TcpPort, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var tcpControlStream = _tcpClient.GetStream();
|
||||
|
||||
byte[] handshakeRequest = [Socks5Version, 0x01, 0x00];
|
||||
await tcpControlStream.WriteAsync(handshakeRequest, cancellationToken).ConfigureAwait(false);
|
||||
var handshakeResponse = new byte[2];
|
||||
if (await tcpControlStream.ReadAsync(handshakeResponse, cancellationToken).ConfigureAwait(false) < 2 ||
|
||||
handshakeResponse[0] != Socks5Version || handshakeResponse[1] != 0x00)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var clientAddrForSocks = new Socks5AddressData
|
||||
{
|
||||
AddressType = Socks5AddressData.AddrTypeIPv4,
|
||||
Host = "0.0.0.0",
|
||||
Port = 0
|
||||
};
|
||||
using var udpAssociateReqMs = new MemoryStream();
|
||||
udpAssociateReqMs.WriteByte(Socks5Version);
|
||||
udpAssociateReqMs.WriteByte(SocksCmdUdpAssociate);
|
||||
udpAssociateReqMs.WriteByte(0x00);
|
||||
udpAssociateReqMs.Write(clientAddrForSocks.ToBytes());
|
||||
await tcpControlStream.WriteAsync(udpAssociateReqMs.ToArray(), cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var verRepRsv = new byte[3];
|
||||
if (await tcpControlStream.ReadAsync(verRepRsv, cancellationToken).ConfigureAwait(false) < 3 ||
|
||||
verRepRsv[0] != Socks5Version || verRepRsv[1] != 0x00)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var proxyRelaySocksAddr =
|
||||
await Socks5AddressData.ParseAsync(tcpControlStream, cancellationToken).ConfigureAwait(false);
|
||||
if (proxyRelaySocksAddr == null || !IPAddress.TryParse(proxyRelaySocksAddr.Host, out var proxyRelayIp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_relayEndPoint = new IPEndPoint(proxyRelayIp, proxyRelaySocksAddr.Port);
|
||||
_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion SOCKS5 Connection Handling
|
||||
|
||||
#region SOCKS5 Address Handling
|
||||
|
||||
private class Socks5AddressData
|
||||
{
|
||||
public const byte AddrTypeIPv4 = 0x01;
|
||||
public const byte AddrTypeDomain = 0x03;
|
||||
public const byte AddrTypeIPv6 = 0x04;
|
||||
|
||||
public byte AddressType { get; set; }
|
||||
public string Host { get; set; } = string.Empty;
|
||||
public ushort Port { get; set; }
|
||||
|
||||
public byte[] ToBytes()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
ms.WriteByte(AddressType);
|
||||
switch (AddressType)
|
||||
{
|
||||
case AddrTypeIPv4:
|
||||
if (IPAddress.TryParse(Host, out var ip) && ip.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
ms.Write(ip.GetAddressBytes(), 0, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
ms.Write([0, 0, 0, 0]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AddrTypeDomain:
|
||||
if (string.IsNullOrEmpty(Host))
|
||||
{
|
||||
ms.WriteByte(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
var domainBytes = Encoding.ASCII.GetBytes(Host);
|
||||
ms.WriteByte((byte)domainBytes.Length);
|
||||
ms.Write(domainBytes);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AddrTypeIPv6:
|
||||
if (IPAddress.TryParse(Host, out var ip6) && ip6.AddressFamily == AddressFamily.InterNetworkV6)
|
||||
{
|
||||
ms.Write(ip6.GetAddressBytes(), 0, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
ms.Write(new byte[16]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException($"SOCKS5 address type {AddressType} not supported.");
|
||||
}
|
||||
|
||||
var portBytes = new byte[2];
|
||||
BinaryPrimitives.WriteUInt16BigEndian(portBytes, Port);
|
||||
ms.Write(portBytes);
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
public static async Task<Socks5AddressData?> ParseAsync(Stream stream, CancellationToken ct)
|
||||
{
|
||||
var addr = new Socks5AddressData();
|
||||
var typeByte = new byte[1];
|
||||
try
|
||||
{
|
||||
if (await stream.ReadAsync(typeByte.AsMemory(0, 1), ct).ConfigureAwait(false) < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
addr.AddressType = typeByte[0];
|
||||
switch (addr.AddressType)
|
||||
{
|
||||
case AddrTypeIPv4:
|
||||
var ipv4Bytes = new byte[4];
|
||||
if (await stream.ReadAsync(ipv4Bytes.AsMemory(0, 4), ct).ConfigureAwait(false) < 4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
addr.Host = new IPAddress(ipv4Bytes).ToString();
|
||||
break;
|
||||
|
||||
case AddrTypeDomain:
|
||||
var lenByte = new byte[1];
|
||||
if (await stream.ReadAsync(lenByte.AsMemory(0, 1), ct).ConfigureAwait(false) < 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (lenByte[0] == 0)
|
||||
{
|
||||
addr.Host = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
var domainBytes = new byte[lenByte[0]];
|
||||
if (await stream.ReadAsync(domainBytes.AsMemory(0, domainBytes.Length), ct)
|
||||
.ConfigureAwait(false) < domainBytes.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
addr.Host = Encoding.ASCII.GetString(domainBytes);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AddrTypeIPv6:
|
||||
var ipv6Bytes = new byte[16];
|
||||
if (await stream.ReadAsync(ipv6Bytes.AsMemory(0, 16), ct).ConfigureAwait(false) < 16)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
addr.Host = new IPAddress(ipv6Bytes).ToString();
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
var portBytes = new byte[2];
|
||||
if (await stream.ReadAsync(portBytes.AsMemory(0, 2), ct).ConfigureAwait(false) < 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
addr.Port = BinaryPrimitives.ReadUInt16BigEndian(portBytes);
|
||||
return addr;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or ObjectDisposedException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion SOCKS5 Address Handling
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
namespace ServiceLib.UdpTest.Tester;
|
||||
|
||||
public class DnsService : IUdpTest
|
||||
{
|
||||
private const int DnsDefaultPort = 53;
|
||||
private const string DnsDefaultServer = "8.8.8.8"; // Google Public DNS
|
||||
|
||||
private static readonly byte[] DnsQueryPacket =
|
||||
[
|
||||
// Header: ID=0x1234, Standard query with RD set, QDCOUNT=1
|
||||
0x12, 0x34, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
// Question: www.google.com, Type A, Class IN
|
||||
0x03, 0x77, 0x77, 0x77, 0x06, 0x67, 0x6F, 0x6F,
|
||||
0x67, 0x6C, 0x65, 0x03, 0x63, 0x6F, 0x6D, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01
|
||||
];
|
||||
|
||||
public byte[] BuildUdpRequestPacket()
|
||||
{
|
||||
return (byte[])DnsQueryPacket.Clone();
|
||||
}
|
||||
|
||||
public bool VerifyAndExtractUdpResponse(byte[] dnsResponseBytes)
|
||||
{
|
||||
if (dnsResponseBytes.Length < 12)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Check transaction ID (should match 0x1234)
|
||||
var transactionId = BinaryPrimitives.ReadUInt16BigEndian(dnsResponseBytes.AsSpan(0, 2));
|
||||
if (transactionId != 0x1234)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check flags - should be a response (QR=1)
|
||||
var flags = BinaryPrimitives.ReadUInt16BigEndian(dnsResponseBytes.AsSpan(2, 2));
|
||||
if ((flags & 0x8000) == 0)
|
||||
{
|
||||
return false; // Not a response
|
||||
}
|
||||
|
||||
// Check response code (RCODE) - should be 0 (no error)
|
||||
if ((flags & 0x000F) != 0)
|
||||
{
|
||||
return false; // DNS error
|
||||
}
|
||||
|
||||
// Check answer count
|
||||
var answerCount = BinaryPrimitives.ReadUInt16BigEndian(dnsResponseBytes.AsSpan(6, 2));
|
||||
if (answerCount == 0)
|
||||
{
|
||||
return false; // No answers
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ushort GetDefaultTargetPort()
|
||||
{
|
||||
return DnsDefaultPort;
|
||||
}
|
||||
|
||||
public string GetDefaultTargetHost()
|
||||
{
|
||||
return DnsDefaultServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace ServiceLib.UdpTest.Tester;
|
||||
|
||||
public interface IUdpTest
|
||||
{
|
||||
public byte[] BuildUdpRequestPacket();
|
||||
|
||||
public bool VerifyAndExtractUdpResponse(byte[] udpResponseBytes);
|
||||
|
||||
public ushort GetDefaultTargetPort();
|
||||
|
||||
public string GetDefaultTargetHost();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
namespace ServiceLib.UdpTest.Tester;
|
||||
|
||||
public class McBeService : IUdpTest
|
||||
{
|
||||
private const int McBeDefaultPort = 19132;
|
||||
private const string McBeDefaultServer = "pms.mc-complex.com";
|
||||
|
||||
// 0x01 | client alive time in ms (unsigned long long) | magic | client GUID
|
||||
private static readonly byte[] McBeQueryPacket =
|
||||
[
|
||||
// 0x01
|
||||
0x01,
|
||||
// Client alive time (1000 ms)
|
||||
0x27, 0xC4, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
// Magic
|
||||
0x00, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFD, 0xFD, 0xFD, 0xFD, 0x12, 0x34, 0x56, 0x78,
|
||||
// Client GUID (random 16 bytes)
|
||||
0x66, 0x0E, 0xAB, 0xBC, 0x61, 0x0D, 0x1F, 0x4E,
|
||||
0xA4, 0x40, 0x8C, 0x65, 0xC1, 0xBE, 0xF5, 0x4B
|
||||
];
|
||||
|
||||
private static readonly byte[] McBeMagicBytes =
|
||||
[
|
||||
0x00, 0xFF, 0xFF, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFD, 0xFD, 0xFD, 0xFD, 0x12, 0x34, 0x56, 0x78
|
||||
];
|
||||
|
||||
private static readonly List<string> ValidGameModes =
|
||||
[
|
||||
"Survival",
|
||||
"Creative",
|
||||
"Adventure",
|
||||
"Spectator"
|
||||
];
|
||||
|
||||
public byte[] BuildUdpRequestPacket()
|
||||
{
|
||||
return (byte[])McBeQueryPacket.Clone();
|
||||
}
|
||||
|
||||
public bool VerifyAndExtractUdpResponse(byte[] mcbeResponseBytes)
|
||||
{
|
||||
// 0x1c | client alive time in ms (recorded from previous ping) |
|
||||
// server GUID | Magic | string length | Edition
|
||||
//
|
||||
// Edition Example:
|
||||
//
|
||||
// MCPE;Dedicated Server;527;1.19.1;0;10;13253860892328930865;Bedrock level;Survival;1;19132;19133;
|
||||
if (mcbeResponseBytes.Length < 48)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (mcbeResponseBytes[0] != 0x1C)
|
||||
{
|
||||
return false; // Invalid packet type
|
||||
}
|
||||
var pongMagic = mcbeResponseBytes.Skip(17).Take(16).ToArray();
|
||||
if (!pongMagic.SequenceEqual(McBeMagicBytes))
|
||||
{
|
||||
return false; // Magic bytes do not match
|
||||
}
|
||||
var stringLength = (ushort)((mcbeResponseBytes[33] << 8) | mcbeResponseBytes[34]);
|
||||
var stringData = Encoding.UTF8.GetString(mcbeResponseBytes.Skip(35).Take(stringLength).ToArray());
|
||||
var stringParts = stringData.Split(';');
|
||||
// check Game Mode str
|
||||
var gameMode = stringParts.Length > 8 ? stringParts[8] : "";
|
||||
if (!ValidGameModes.Contains(gameMode))
|
||||
{
|
||||
return false; // Invalid game mode
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort GetDefaultTargetPort()
|
||||
{
|
||||
return McBeDefaultPort;
|
||||
}
|
||||
|
||||
public string GetDefaultTargetHost()
|
||||
{
|
||||
return McBeDefaultServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace ServiceLib.UdpTest.Tester;
|
||||
|
||||
public class NtpService : IUdpTest
|
||||
{
|
||||
private const int NtpDefaultPort = 123;
|
||||
private const string NtpDefaultServer = "pool.ntp.org";
|
||||
|
||||
public byte[] BuildUdpRequestPacket()
|
||||
{
|
||||
var ntpReq = new byte[48];
|
||||
ntpReq[0] = 0x23; // LI=0, VN=4, Mode=3
|
||||
return ntpReq;
|
||||
}
|
||||
|
||||
public bool VerifyAndExtractUdpResponse(byte[] ntpResponseBytes)
|
||||
{
|
||||
if (ntpResponseBytes.Length < 48)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((ntpResponseBytes[0] & 0x07) != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort GetDefaultTargetPort()
|
||||
{
|
||||
return NtpDefaultPort;
|
||||
}
|
||||
|
||||
public string GetDefaultTargetHost()
|
||||
{
|
||||
return NtpDefaultServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
namespace ServiceLib.UdpTest.Tester;
|
||||
|
||||
public class StunService : IUdpTest
|
||||
{
|
||||
private const int StunDefaultPort = 3478;
|
||||
private const string StunDefaultServer = "stun.voztovoice.org";
|
||||
|
||||
private static readonly byte[] StunBindingRequestPacket =
|
||||
[
|
||||
// STUN Binding Request
|
||||
0x00, 0x01, // Message Type: Binding Request (0x0001)
|
||||
0x00, 0x00, // Message Length: 0 (no attributes)
|
||||
0x21, 0x12, 0xA4, 0x42, // Magic Cookie: 0x2112A442
|
||||
// Transaction ID: 96 bits (12 bytes) random
|
||||
0x66, 0x0E, 0xAB, 0xBC, 0x61, 0x0D,
|
||||
0xA4, 0x40, 0x8C, 0x65, 0xC1, 0xBE,
|
||||
];
|
||||
|
||||
public byte[] BuildUdpRequestPacket()
|
||||
{
|
||||
return (byte[])StunBindingRequestPacket.Clone();
|
||||
}
|
||||
|
||||
public bool VerifyAndExtractUdpResponse(byte[] stunResponseBytes)
|
||||
{
|
||||
if (stunResponseBytes.Length < 20)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stunResponseBytes.Length >= 2)
|
||||
{
|
||||
var messageType = (stunResponseBytes[0] << 8) | stunResponseBytes[1];
|
||||
if (messageType is 0x0101 or 0x0111)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ushort GetDefaultTargetPort()
|
||||
{
|
||||
return StunDefaultPort;
|
||||
}
|
||||
|
||||
public string GetDefaultTargetHost()
|
||||
{
|
||||
return StunDefaultServer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
using ServiceLib.UdpTest.Tester;
|
||||
|
||||
namespace ServiceLib.UdpTest;
|
||||
|
||||
public class UdpTestService
|
||||
{
|
||||
private const string DefaultUdpTestType = "ntp";
|
||||
private readonly IUdpTest _udpTest;
|
||||
|
||||
private static readonly IReadOnlyDictionary<string, Func<IUdpTest>> UdpTestFactories =
|
||||
new Dictionary<string, Func<IUdpTest>>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["ntp"] = () => new NtpService(),
|
||||
["dns"] = () => new DnsService(),
|
||||
["stun"] = () => new StunService(),
|
||||
["mcbe"] = () => new McBeService(),
|
||||
};
|
||||
|
||||
private UdpTestService(IUdpTest udpTest)
|
||||
{
|
||||
_udpTest = udpTest;
|
||||
}
|
||||
|
||||
public static UdpTestService Create(string? udpTestType)
|
||||
{
|
||||
if (string.IsNullOrEmpty(udpTestType))
|
||||
{
|
||||
return new UdpTestService(UdpTestFactories[DefaultUdpTestType]());
|
||||
}
|
||||
|
||||
return UdpTestFactories.TryGetValue(udpTestType, out var factory)
|
||||
? new UdpTestService(factory())
|
||||
: new UdpTestService(UdpTestFactories[DefaultUdpTestType]());
|
||||
}
|
||||
|
||||
public static UdpTestService CreateFromTarget(string? udpTestTarget, out string targetServerHost)
|
||||
{
|
||||
var parts = udpTestTarget?.Split(':', 2);
|
||||
var udpTestType = parts?.Length > 0 ? parts[0] : DefaultUdpTestType;
|
||||
|
||||
var udpService = Create(udpTestType);
|
||||
targetServerHost = parts?.Length > 1 && !string.IsNullOrEmpty(parts[1])
|
||||
? parts[1]
|
||||
: udpService._udpTest.GetDefaultTargetHost();
|
||||
|
||||
return udpService;
|
||||
}
|
||||
|
||||
private (string host, ushort port) ParseHostAndPort(string targetServerHost)
|
||||
{
|
||||
if (string.IsNullOrEmpty(targetServerHost))
|
||||
{
|
||||
return (_udpTest.GetDefaultTargetHost(), _udpTest.GetDefaultTargetPort());
|
||||
}
|
||||
|
||||
// Handle IPv6 format: [::1]:port or [2001:db8::1]:port
|
||||
if (targetServerHost.StartsWith('['))
|
||||
{
|
||||
var closeBracketIndex = targetServerHost.IndexOf(']');
|
||||
if (closeBracketIndex > 0)
|
||||
{
|
||||
var host = targetServerHost.Substring(1, closeBracketIndex - 1);
|
||||
if (closeBracketIndex < targetServerHost.Length - 1 && targetServerHost[closeBracketIndex + 1] == ':')
|
||||
{
|
||||
var portStr = targetServerHost.Substring(closeBracketIndex + 2);
|
||||
if (ushort.TryParse(portStr, out var port))
|
||||
{
|
||||
return (host, port);
|
||||
}
|
||||
}
|
||||
return (host, _udpTest.GetDefaultTargetPort());
|
||||
}
|
||||
}
|
||||
|
||||
// Handle IPv4 or domain format: 1.1.1.1:53 or exam.com:333
|
||||
var lastColonIndex = targetServerHost.LastIndexOf(':');
|
||||
if (lastColonIndex > 0)
|
||||
{
|
||||
var host = targetServerHost.Substring(0, lastColonIndex);
|
||||
var portStr = targetServerHost.Substring(lastColonIndex + 1);
|
||||
if (ushort.TryParse(portStr, out var port))
|
||||
{
|
||||
return (host, port);
|
||||
}
|
||||
}
|
||||
|
||||
// No port specified, use default
|
||||
return (targetServerHost, _udpTest.GetDefaultTargetPort());
|
||||
}
|
||||
|
||||
public async Task<TimeSpan> SendUdpRequestAsync(string targetServerHost, int socks5Port, TimeSpan operationTimeout)
|
||||
{
|
||||
using var cts = new CancellationTokenSource(operationTimeout);
|
||||
var cancellationToken = cts.Token;
|
||||
var udpRequestPacket = _udpTest.BuildUdpRequestPacket();
|
||||
if (udpRequestPacket == null || udpRequestPacket.Length == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Failed to build UDP request packet.");
|
||||
}
|
||||
using var channel = new Socks5UdpChannel("127.0.0.1", socks5Port);
|
||||
if (!await channel.EstablishUdpAssociationAsync(cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
throw new Exception("Failed to establish UDP association with SOCKS5 proxy.");
|
||||
}
|
||||
|
||||
var (targetHost, targetPort) = ParseHostAndPort(targetServerHost);
|
||||
|
||||
byte[] udpReceiveResult = null;
|
||||
|
||||
// Get minimum round trip time from two attempts
|
||||
var roundTripTime = TimeSpan.MaxValue;
|
||||
|
||||
for (var attempt = 0; attempt < 2; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
await channel.SendAsync(targetHost, targetPort, udpRequestPacket).ConfigureAwait(false);
|
||||
var (_, receiveResult) = await channel.ReceiveAsync(cancellationToken).ConfigureAwait(false);
|
||||
stopwatch.Stop();
|
||||
|
||||
udpReceiveResult = receiveResult;
|
||||
|
||||
var currentRoundTripTime = stopwatch.Elapsed;
|
||||
if (currentRoundTripTime < roundTripTime)
|
||||
{
|
||||
roundTripTime = currentRoundTripTime;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (attempt == 1 && roundTripTime == TimeSpan.MaxValue)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((udpReceiveResult?.Length ?? 0) < 4 + 1 + 4 + 2)
|
||||
{
|
||||
throw new Exception("Received NTP response is too short.");
|
||||
}
|
||||
|
||||
if (udpReceiveResult != null && _udpTest.VerifyAndExtractUdpResponse(udpReceiveResult))
|
||||
{
|
||||
return roundTripTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Failed to verify and extract UDP response.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,13 @@ public class JsonUtils
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
||||
private static readonly JsonSerializerOptions _defaultSerializeNoIndentedOptions = new()
|
||||
{
|
||||
WriteIndented = false,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
||||
private static readonly JsonSerializerOptions _nullValueSerializeOptions = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
@@ -24,6 +31,13 @@ public class JsonUtils
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
||||
private static readonly JsonSerializerOptions _nullValueSerializeNoIndentedOptions = new()
|
||||
{
|
||||
WriteIndented = false,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
};
|
||||
|
||||
private static readonly JsonDocumentOptions _defaultDocumentOptions = new()
|
||||
{
|
||||
CommentHandling = JsonCommentHandling.Skip
|
||||
@@ -104,7 +118,13 @@ public class JsonUtils
|
||||
{
|
||||
return result;
|
||||
}
|
||||
var options = nullValue ? _nullValueSerializeOptions : _defaultSerializeOptions;
|
||||
var options = (nullValue, indented) switch
|
||||
{
|
||||
(true, true) => _nullValueSerializeOptions,
|
||||
(true, false) => _nullValueSerializeNoIndentedOptions,
|
||||
(false, true) => _defaultSerializeOptions,
|
||||
_ => _defaultSerializeNoIndentedOptions
|
||||
};
|
||||
result = JsonSerializer.Serialize(obj, options);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -46,7 +46,7 @@ public static class ProcUtils
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void RebootAsAdmin(bool blAdmin = true)
|
||||
public static bool RebootAsAdmin(bool blAdmin = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -58,11 +58,12 @@ public static class ProcUtils
|
||||
FileName = Utils.GetExePath().AppendQuotes(),
|
||||
Verb = blAdmin ? "runas" : null,
|
||||
};
|
||||
_ = Process.Start(startInfo);
|
||||
return Process.Start(startInfo) != null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,6 +522,23 @@ public class Utils
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsIpv4(string? ip)
|
||||
{
|
||||
if (ip.IsNullOrEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ip = ip.Trim();
|
||||
if (!IPAddress.TryParse(ip, out var address))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return address.AddressFamily == AddressFamily.InterNetwork
|
||||
&& ip.Count(c => c == '.') == 3;
|
||||
}
|
||||
|
||||
public static bool IsIpAddress(string? ip)
|
||||
{
|
||||
if (ip.IsNullOrEmpty())
|
||||
|
||||
@@ -53,19 +53,23 @@ internal static class WindowsUtils
|
||||
|
||||
public static async Task RemoveTunDevice()
|
||||
{
|
||||
try
|
||||
var tunNameList = new List<string> { "wintunsingbox_tun", "xray_tun" };
|
||||
foreach (var tunName in tunNameList)
|
||||
{
|
||||
var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun"));
|
||||
var guid = new Guid(sum);
|
||||
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe";
|
||||
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
|
||||
try
|
||||
{
|
||||
var sum = MD5.HashData(Encoding.UTF8.GetBytes(tunName));
|
||||
var guid = new Guid(sum);
|
||||
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe";
|
||||
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
|
||||
|
||||
// Try to remove the device
|
||||
_ = await Utils.GetCliWrapOutput(pnpUtilPath, arg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
// Try to remove the device
|
||||
_ = await Utils.GetCliWrapOutput(pnpUtilPath, arg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum EConfigType
|
||||
WireGuard = 9,
|
||||
HTTP = 10,
|
||||
Anytls = 11,
|
||||
Naive = 12,
|
||||
PolicyGroup = 101,
|
||||
ProxyChain = 102,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ public enum ESpeedActionType
|
||||
{
|
||||
Tcping,
|
||||
Realping,
|
||||
UdpTest,
|
||||
Speedtest,
|
||||
Mixedtest,
|
||||
FastRealping
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace ServiceLib.Enums;
|
||||
|
||||
public enum ETransport
|
||||
{
|
||||
tcp,
|
||||
raw,
|
||||
kcp,
|
||||
ws,
|
||||
httpupgrade,
|
||||
|
||||
+72
-29
@@ -24,6 +24,8 @@ public class Global
|
||||
public const string V2raySampleHttpResponseFileName = NamespaceSample + "SampleHttpResponse";
|
||||
public const string V2raySampleInbound = NamespaceSample + "SampleInbound";
|
||||
public const string V2raySampleOutbound = NamespaceSample + "SampleOutbound";
|
||||
public const string V2raySampleTunInbound = NamespaceSample + "SampleTunInbound";
|
||||
public const string V2raySampleTunRules = NamespaceSample + "SampleTunRules";
|
||||
public const string SingboxSampleOutbound = NamespaceSample + "SingboxSampleOutbound";
|
||||
public const string CustomRoutingFileName = NamespaceSample + "custom_routing_";
|
||||
public const string TunSingboxDNSFileName = NamespaceSample + "tun_singbox_dns";
|
||||
@@ -42,12 +44,15 @@ public class Global
|
||||
public const string SingboxFakeIPFilterFileName = NamespaceSample + "singbox_fakeip_filter";
|
||||
|
||||
public const string DefaultSecurity = "auto";
|
||||
public const string DefaultNetwork = "tcp";
|
||||
public const string TcpHeaderHttp = "http";
|
||||
public const string DefaultNetwork = "raw";
|
||||
public const string RawHeaderHttp = "http";
|
||||
public const string None = "none";
|
||||
public const string RawNetworkAlias = "tcp";
|
||||
public const string DefaultXhttpMode = "auto";
|
||||
public const string ProxyTag = "proxy";
|
||||
public const string DirectTag = "direct";
|
||||
public const string BlockTag = "block";
|
||||
public const string DnsOutboundTag = "dns";
|
||||
public const string DnsTag = "dns-module";
|
||||
public const string DirectDnsTag = "direct-dns";
|
||||
public const string BalancerTagSuffix = "-round";
|
||||
@@ -59,9 +64,12 @@ public class Global
|
||||
public const string HttpsProtocol = "https://";
|
||||
public const string SocksProtocol = "socks://";
|
||||
public const string Socks5Protocol = "socks5://";
|
||||
public const string InnerUriProtocol = "v2rayn://";
|
||||
public const string AsIs = "AsIs";
|
||||
public const string IPIfNonMatch = "IPIfNonMatch";
|
||||
public const string IPOnDemand = "IPOnDemand";
|
||||
public const string GeoSitePrefix = "geosite:";
|
||||
public const string GeoIPPrefix = "geoip:";
|
||||
|
||||
public const string UserEMail = "t@t.tt";
|
||||
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
|
||||
@@ -89,7 +97,7 @@ public class Global
|
||||
public const string SingboxHostsDNSTag = "hosts_dns";
|
||||
public const string SingboxFakeDNSTag = "fake_dns";
|
||||
|
||||
public const int Hysteria2DefaultHopInt = 10;
|
||||
public const int Hysteria2DefaultHopInt = 30;
|
||||
|
||||
public const string PolicyGroupExcludeKeywords = @"剩余|过期|到期|重置|[Rr]emaining|[Ee]xpir|[Rr]eset";
|
||||
|
||||
@@ -143,7 +151,7 @@ public class Global
|
||||
@"https://cachefly.cachefly.net/50mb.test",
|
||||
@"https://speed.cloudflare.com/__down?bytes=10000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=50000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=100000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=99999999",
|
||||
];
|
||||
|
||||
public static readonly List<string> SpeedPingTestUrls =
|
||||
@@ -182,17 +190,23 @@ public class Global
|
||||
@"https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/main/v2rayN/"
|
||||
];
|
||||
|
||||
public static readonly Dictionary<string, string> UserAgentTexts = new()
|
||||
public static readonly Dictionary<string, string> RawHttpUserAgentTexts = new()
|
||||
{
|
||||
{"chrome","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" },
|
||||
{"firefox","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0" },
|
||||
{"safari","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15" },
|
||||
{"edge","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70" },
|
||||
{"none",""}
|
||||
{"none",""},
|
||||
{"golang","Go-http-client/1.1"},
|
||||
{"curl","curl/7.68.0"},
|
||||
};
|
||||
|
||||
public const string Hysteria2ProtocolShare = "hy2://";
|
||||
|
||||
public const string NaiveHttpsProtocolShare = "naive+https://";
|
||||
|
||||
public const string NaiveQuicProtocolShare = "naive+quic://";
|
||||
|
||||
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
||||
{
|
||||
{ EConfigType.VMess, "vmess://" },
|
||||
@@ -203,7 +217,8 @@ public class Global
|
||||
{ EConfigType.Hysteria2, "hysteria2://" },
|
||||
{ EConfigType.TUIC, "tuic://" },
|
||||
{ EConfigType.WireGuard, "wireguard://" },
|
||||
{ EConfigType.Anytls, "anytls://" }
|
||||
{ EConfigType.Anytls, "anytls://" },
|
||||
{ EConfigType.Naive, "naive://" }
|
||||
};
|
||||
|
||||
public static readonly Dictionary<EConfigType, string> ProtocolTypes = new()
|
||||
@@ -217,7 +232,8 @@ public class Global
|
||||
{ EConfigType.Hysteria2, "hysteria2" },
|
||||
{ EConfigType.TUIC, "tuic" },
|
||||
{ EConfigType.WireGuard, "wireguard" },
|
||||
{ EConfigType.Anytls, "anytls" }
|
||||
{ EConfigType.Anytls, "anytls" },
|
||||
{ EConfigType.Naive, "naive" }
|
||||
};
|
||||
|
||||
public static readonly List<string> VmessSecurities =
|
||||
@@ -285,14 +301,12 @@ public class Global
|
||||
|
||||
public static readonly List<string> Networks =
|
||||
[
|
||||
"tcp",
|
||||
"kcp",
|
||||
"ws",
|
||||
"httpupgrade",
|
||||
"raw",
|
||||
"xhttp",
|
||||
"h2",
|
||||
"quic",
|
||||
"grpc"
|
||||
"kcp",
|
||||
"grpc",
|
||||
"ws",
|
||||
"httpupgrade"
|
||||
];
|
||||
|
||||
public static readonly List<string> KcpHeaderTypes =
|
||||
@@ -342,6 +356,7 @@ public class Global
|
||||
EConfigType.Hysteria2,
|
||||
EConfigType.TUIC,
|
||||
EConfigType.Anytls,
|
||||
EConfigType.Naive,
|
||||
EConfigType.WireGuard,
|
||||
EConfigType.SOCKS,
|
||||
EConfigType.HTTP,
|
||||
@@ -384,9 +399,9 @@ public class Global
|
||||
[
|
||||
"chrome",
|
||||
"firefox",
|
||||
"safari",
|
||||
"edge",
|
||||
"none"
|
||||
"curl",
|
||||
"golang",
|
||||
];
|
||||
|
||||
public static readonly List<string> XhttpMode =
|
||||
@@ -417,11 +432,12 @@ public class Global
|
||||
|
||||
public static readonly List<string> DomainDirectDNSAddress =
|
||||
[
|
||||
"https://dns.alidns.com/dns-query",
|
||||
"https://doh.pub/dns-query",
|
||||
"https://dns.alidns.com/dns-query,https://doh.pub/dns-query",
|
||||
"223.5.5.5",
|
||||
"119.29.29.29",
|
||||
"223.5.5.5",
|
||||
"119.29.29.29,223.5.5.5,https://doh.pub/dns-query",
|
||||
"https://doh.pub/dns-query",
|
||||
"https://dns.alidns.com/dns-query",
|
||||
"https://doh.pub/dns-query,https://dns.alidns.com/dns-query",
|
||||
"localhost"
|
||||
];
|
||||
|
||||
@@ -433,7 +449,7 @@ public class Global
|
||||
"https://dns.cloudflare.com/dns-query",
|
||||
"https://doh.dns.sb/dns-query",
|
||||
"https://doh.opendns.com/dns-query",
|
||||
"https://common.dot.dns.yandex.net",
|
||||
"https://common.dot.dns.yandex.net/dns-query",
|
||||
"8.8.8.8",
|
||||
"1.1.1.1",
|
||||
"185.222.222.222",
|
||||
@@ -443,8 +459,8 @@ public class Global
|
||||
|
||||
public static readonly List<string> DomainPureIPDNSAddress =
|
||||
[
|
||||
"223.5.5.5",
|
||||
"119.29.29.29",
|
||||
"223.5.5.5",
|
||||
"localhost"
|
||||
];
|
||||
|
||||
@@ -498,6 +514,7 @@ public class Global
|
||||
[
|
||||
"http",
|
||||
"tls",
|
||||
"quic",
|
||||
"bittorrent"
|
||||
];
|
||||
|
||||
@@ -515,7 +532,6 @@ public class Global
|
||||
"tls",
|
||||
"quic",
|
||||
"fakedns",
|
||||
"fakedns+others"
|
||||
];
|
||||
|
||||
public static readonly List<int> TunMtus =
|
||||
@@ -558,6 +574,14 @@ public class Global
|
||||
"bbr"
|
||||
];
|
||||
|
||||
public static readonly List<string> NaiveCongestionControls =
|
||||
[
|
||||
"bbr",
|
||||
"bbr2",
|
||||
"cubic",
|
||||
"reno"
|
||||
];
|
||||
|
||||
public static readonly List<string> allowSelectType =
|
||||
[
|
||||
"selector",
|
||||
@@ -619,6 +643,24 @@ public class Global
|
||||
@""
|
||||
];
|
||||
|
||||
public static readonly List<string> UdpTestTargets =
|
||||
[
|
||||
"ntp:pool.ntp.org",
|
||||
"ntp:time.google.com",
|
||||
"dns:1.1.1.1",
|
||||
"dns:8.8.8.8",
|
||||
"dns:dns.google",
|
||||
"stun:stun.voztovoice.org",
|
||||
"stun:stun.cloudflare.com",
|
||||
"stun:stun.l.google.com:19302",
|
||||
"mcbe:pms.mc-complex.com",
|
||||
"mcbe:bedrock.opblocks.com",
|
||||
"mcbe:opsucht.net",
|
||||
"mcbe:play.craftersmc.net",
|
||||
"mcbe:mps.lemoncloud.net",
|
||||
"mcbe:bedrock.talonmc.net",
|
||||
];
|
||||
|
||||
public static readonly List<string> OutboundTags =
|
||||
[
|
||||
ProxyTag,
|
||||
@@ -652,12 +694,13 @@ public class Global
|
||||
""
|
||||
];
|
||||
|
||||
public static readonly List<string> EchForceQuerys =
|
||||
public static readonly List<string> TunIcmpRoutingPolicies =
|
||||
[
|
||||
"none",
|
||||
"half",
|
||||
"full",
|
||||
""
|
||||
"rule",
|
||||
"direct",
|
||||
"unreachable",
|
||||
"drop",
|
||||
"reply",
|
||||
];
|
||||
|
||||
#endregion const
|
||||
|
||||
@@ -23,19 +23,6 @@ public record CoreConfigContextBuilderAllResult(
|
||||
public NodeValidatorResult CombinedValidatorResult => new(
|
||||
[.. MainResult.ValidatorResult.Errors, .. PreSocksResult?.ValidatorResult.Errors ?? []],
|
||||
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]);
|
||||
|
||||
/// <summary>
|
||||
/// The main context with TunProtectSsPort/ProxyRelaySsPort and ProtectDomainList merged in
|
||||
/// from the pre-socks result (if any). Pass this to the core runner.
|
||||
/// </summary>
|
||||
public CoreConfigContext ResolvedMainContext => PreSocksResult is not null
|
||||
? MainResult.Context with
|
||||
{
|
||||
TunProtectSsPort = PreSocksResult.Context.TunProtectSsPort,
|
||||
ProxyRelaySsPort = PreSocksResult.Context.ProxyRelaySsPort,
|
||||
ProtectDomainList = [.. MainResult.Context.ProtectDomainList ?? [], .. PreSocksResult.Context.ProtectDomainList ?? []],
|
||||
}
|
||||
: MainResult.Context;
|
||||
}
|
||||
|
||||
public class CoreConfigContextBuilder
|
||||
@@ -58,10 +45,10 @@ public class CoreConfigContextBuilder
|
||||
IsTunEnabled = config.TunModeItem.EnableTun,
|
||||
SimpleDnsItem = config.SimpleDNSItem,
|
||||
ProtectDomainList = [],
|
||||
TunProtectSsPort = 0,
|
||||
ProxyRelaySsPort = 0,
|
||||
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
|
||||
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
|
||||
IsWindows = Utils.IsWindows(),
|
||||
IsMacOS = Utils.IsMacOS(),
|
||||
};
|
||||
var validatorResult = NodeValidatorResult.Empty();
|
||||
var (actNode, nodeValidatorResult) = await ResolveNodeAsync(context, node);
|
||||
@@ -122,7 +109,20 @@ public class CoreConfigContextBuilder
|
||||
}
|
||||
|
||||
var preResult = await BuildPreSocksIfNeeded(mainResult.Context);
|
||||
return new CoreConfigContextBuilderAllResult(mainResult, preResult);
|
||||
if (preResult is null)
|
||||
{
|
||||
return new CoreConfigContextBuilderAllResult(mainResult, null);
|
||||
}
|
||||
|
||||
var resolvedMainResult = mainResult with
|
||||
{
|
||||
Context = mainResult.Context with
|
||||
{
|
||||
IsTunEnabled = false, // main core doesn't handle tun directly when pre-socks is used
|
||||
ProtectDomainList = [.. mainResult.Context.ProtectDomainList, .. preResult.Context.ProtectDomainList],
|
||||
}
|
||||
};
|
||||
return new CoreConfigContextBuilderAllResult(resolvedMainResult, preResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,37 +148,7 @@ public class CoreConfigContextBuilder
|
||||
};
|
||||
}
|
||||
|
||||
if (!nodeContext.IsTunEnabled
|
||||
|| coreType != ECoreType.Xray
|
||||
|| node.ConfigType == EConfigType.Custom)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var tunProtectSsPort = Utils.GetFreePort();
|
||||
var proxyRelaySsPort = Utils.GetFreePort();
|
||||
var preItem = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Address = Global.Loopback,
|
||||
Port = proxyRelaySsPort,
|
||||
Password = Global.None,
|
||||
};
|
||||
preItem.SetProtocolExtra(preItem.GetProtocolExtra() with
|
||||
{
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
var preResult2 = await Build(nodeContext.AppConfig, preItem);
|
||||
return preResult2 with
|
||||
{
|
||||
Context = preResult2.Context with
|
||||
{
|
||||
ProtectDomainList = [.. nodeContext.ProtectDomainList ?? [], .. preResult2.Context.ProtectDomainList ?? []],
|
||||
TunProtectSsPort = tunProtectSsPort,
|
||||
ProxyRelaySsPort = proxyRelaySsPort,
|
||||
}
|
||||
};
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -309,6 +279,11 @@ public class CoreConfigContextBuilder
|
||||
}
|
||||
|
||||
var nodeValidatorResult = NodeValidator.Validate(node, context.RunCoreType);
|
||||
var msgs = new List<string>([.. nodeValidatorResult.Errors, .. nodeValidatorResult.Warnings]);
|
||||
if (msgs.Count > 0)
|
||||
{
|
||||
Logging.SaveLog($"{node.Remarks}: {string.Join("; ", msgs)}");
|
||||
}
|
||||
if (!nodeValidatorResult.Success)
|
||||
{
|
||||
return nodeValidatorResult;
|
||||
@@ -322,6 +297,7 @@ public class CoreConfigContextBuilder
|
||||
context.ProtectDomainList.Add(address);
|
||||
}
|
||||
|
||||
// ech query server name protect
|
||||
if (!node.EchConfigList.IsNullOrEmpty())
|
||||
{
|
||||
var echQuerySni = node.Sni;
|
||||
@@ -338,6 +314,21 @@ public class CoreConfigContextBuilder
|
||||
}
|
||||
}
|
||||
|
||||
// xhttp downloadSettings address protect
|
||||
var xhttpExtra = node.GetTransportExtra().XhttpExtra;
|
||||
if (!string.IsNullOrEmpty(xhttpExtra)
|
||||
&& JsonUtils.ParseJson(xhttpExtra) is JsonObject extra
|
||||
&& extra.TryGetPropertyValue("downloadSettings", out var dsNode)
|
||||
&& dsNode is JsonObject downloadSettings
|
||||
&& downloadSettings.TryGetPropertyValue("address", out var dAddrNode)
|
||||
&& dAddrNode is JsonValue dAddrValue
|
||||
&& dAddrValue.TryGetValue(out string? dAddr)
|
||||
&& !string.IsNullOrEmpty(dAddr)
|
||||
&& Utils.IsDomain(dAddr))
|
||||
{
|
||||
context.ProtectDomainList.Add(dAddr);
|
||||
}
|
||||
|
||||
return nodeValidatorResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class NodeValidator
|
||||
[EConfigType.VMess, EConfigType.VLESS, EConfigType.Trojan, EConfigType.Shadowsocks];
|
||||
|
||||
private static readonly HashSet<string> SingboxShadowsocksAllowedTransports =
|
||||
[nameof(ETransport.tcp), nameof(ETransport.ws), nameof(ETransport.quic)];
|
||||
[nameof(ETransport.raw), nameof(ETransport.ws)];
|
||||
|
||||
public static NodeValidatorResult Validate(ProfileItem item, ECoreType coreType)
|
||||
{
|
||||
@@ -141,13 +141,22 @@ public class NodeValidator
|
||||
v.Assert(!item.PublicKey.IsNullOrEmpty(), string.Format(ResUI.MsgInvalidProperty, "PublicKey"));
|
||||
}
|
||||
|
||||
if (item.Network == nameof(ETransport.xhttp) && !item.Extra.IsNullOrEmpty())
|
||||
var transport = item.GetTransportExtra();
|
||||
if (item.Network == nameof(ETransport.xhttp) && !transport.XhttpExtra.IsNullOrEmpty())
|
||||
{
|
||||
if (JsonUtils.ParseJson(item.Extra) is null)
|
||||
if (JsonUtils.ParseJson(transport.XhttpExtra) is not JsonObject)
|
||||
{
|
||||
v.Error(string.Format(ResUI.MsgInvalidProperty, "XHTTP Extra"));
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.Finalmask.IsNullOrEmpty())
|
||||
{
|
||||
if (JsonUtils.ParseJson(item.Finalmask) is not JsonObject)
|
||||
{
|
||||
v.Error(string.Format(ResUI.MsgInvalidProperty, "Finalmask"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string? ValidateSingboxTransport(EConfigType configType, string net)
|
||||
@@ -159,7 +168,7 @@ public class NodeValidator
|
||||
}
|
||||
|
||||
// sing-box does not support non-tcp transports for protocols other than vmess/trojan/vless/shadowsocks
|
||||
if (!SingboxTransportSupportedProtocols.Contains(configType) && net != nameof(ETransport.tcp))
|
||||
if (!SingboxTransportSupportedProtocols.Contains(configType) && net != nameof(ETransport.raw))
|
||||
{
|
||||
return string.Format(ResUI.MsgCoreNotSupportProtocolTransport,
|
||||
nameof(ECoreType.sing_box), configType.ToString(), net);
|
||||
|
||||
@@ -76,10 +76,11 @@ public static class ConfigHandler
|
||||
Tti = 50,
|
||||
UplinkCapacity = 12,
|
||||
DownlinkCapacity = 100,
|
||||
ReadBufferSize = 2,
|
||||
WriteBufferSize = 2,
|
||||
Congestion = false
|
||||
CwndMultiplier = 1,
|
||||
MaxSendingWindow = 2 * 1024 * 1024,
|
||||
};
|
||||
config.KcpItem.CwndMultiplier = config.KcpItem.CwndMultiplier <= 0 ? 1 : config.KcpItem.CwndMultiplier;
|
||||
config.KcpItem.MaxSendingWindow = config.KcpItem.MaxSendingWindow <= 0 ? (2 * 1024 * 1024) : config.KcpItem.MaxSendingWindow;
|
||||
config.GrpcItem ??= new GrpcItem
|
||||
{
|
||||
IdleTimeout = 60,
|
||||
@@ -91,6 +92,8 @@ public static class ConfigHandler
|
||||
{
|
||||
EnableTun = false,
|
||||
Mtu = 9000,
|
||||
IcmpRouting = Global.TunIcmpRoutingPolicies.First(),
|
||||
EnableLegacyProtect = false,
|
||||
};
|
||||
config.GuiItem ??= new();
|
||||
config.MsgUIItem ??= new();
|
||||
@@ -131,6 +134,10 @@ public static class ConfigHandler
|
||||
{
|
||||
config.SpeedTestItem.MixedConcurrencyCount = 5;
|
||||
}
|
||||
if (config.SpeedTestItem.UdpTestTarget.IsNullOrEmpty())
|
||||
{
|
||||
config.SpeedTestItem.UdpTestTarget = Global.UdpTestTargets.First();
|
||||
}
|
||||
|
||||
config.Mux4RayItem ??= new()
|
||||
{
|
||||
@@ -158,7 +165,7 @@ public static class ConfigHandler
|
||||
config.Fragment4RayItem ??= new()
|
||||
{
|
||||
Packets = "tlshello",
|
||||
Length = "100-200",
|
||||
Length = "50-100",
|
||||
Interval = "10-20"
|
||||
};
|
||||
config.GlobalHotkeys ??= new();
|
||||
@@ -233,9 +240,6 @@ public static class ConfigHandler
|
||||
item.Password = profileItem.Password;
|
||||
|
||||
item.Network = profileItem.Network;
|
||||
item.HeaderType = profileItem.HeaderType;
|
||||
item.RequestHost = profileItem.RequestHost;
|
||||
item.Path = profileItem.Path;
|
||||
|
||||
item.StreamSecurity = profileItem.StreamSecurity;
|
||||
item.Sni = profileItem.Sni;
|
||||
@@ -247,14 +251,13 @@ public static class ConfigHandler
|
||||
item.ShortId = profileItem.ShortId;
|
||||
item.SpiderX = profileItem.SpiderX;
|
||||
item.Mldsa65Verify = profileItem.Mldsa65Verify;
|
||||
item.Extra = profileItem.Extra;
|
||||
item.MuxEnabled = profileItem.MuxEnabled;
|
||||
item.Cert = profileItem.Cert;
|
||||
item.CertSha = profileItem.CertSha;
|
||||
item.EchConfigList = profileItem.EchConfigList;
|
||||
item.EchForceQuery = profileItem.EchForceQuery;
|
||||
item.Finalmask = profileItem.Finalmask;
|
||||
item.ProtoExtra = profileItem.ProtoExtra;
|
||||
item.TransportExtra = profileItem.TransportExtra;
|
||||
}
|
||||
|
||||
var ret = item.ConfigType switch
|
||||
@@ -269,6 +272,7 @@ public static class ConfigHandler
|
||||
EConfigType.TUIC => await AddTuicServer(config, item),
|
||||
EConfigType.WireGuard => await AddWireguardServer(config, item),
|
||||
EConfigType.Anytls => await AddAnytlsServer(config, item),
|
||||
EConfigType.Naive => await AddNaiveServer(config, item),
|
||||
_ => -1,
|
||||
};
|
||||
return ret;
|
||||
@@ -293,9 +297,6 @@ public static class ConfigHandler
|
||||
VmessSecurity = profileItem.GetProtocolExtra().VmessSecurity?.TrimEx()
|
||||
});
|
||||
profileItem.Network = profileItem.Network.TrimEx();
|
||||
profileItem.HeaderType = profileItem.HeaderType.TrimEx();
|
||||
profileItem.RequestHost = profileItem.RequestHost.TrimEx();
|
||||
profileItem.Path = profileItem.Path.TrimEx();
|
||||
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
||||
|
||||
if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity))
|
||||
@@ -703,10 +704,12 @@ public static class ConfigHandler
|
||||
public static async Task<int> AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.ConfigType = EConfigType.Hysteria2;
|
||||
//profileItem.CoreType = ECoreType.sing_box;
|
||||
|
||||
profileItem.Address = profileItem.Address.TrimEx();
|
||||
profileItem.Password = profileItem.Password.TrimEx();
|
||||
profileItem.Fingerprint = string.Empty;
|
||||
profileItem.Alpn = string.Empty;
|
||||
//profileItem.Alpn = "h3";
|
||||
profileItem.Network = string.Empty;
|
||||
|
||||
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||
@@ -746,11 +749,14 @@ public static class ConfigHandler
|
||||
profileItem.Username = profileItem.Username.TrimEx();
|
||||
profileItem.Password = profileItem.Password.TrimEx();
|
||||
profileItem.Network = string.Empty;
|
||||
profileItem.Fingerprint = string.Empty;
|
||||
|
||||
if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType))
|
||||
var congestionControl = profileItem.GetProtocolExtra().CongestionControl;
|
||||
if (!Global.TuicCongestionControls.Contains(congestionControl))
|
||||
{
|
||||
profileItem.HeaderType = Global.TuicCongestionControls.FirstOrDefault()!;
|
||||
congestionControl = Global.TuicCongestionControls.FirstOrDefault()!;
|
||||
}
|
||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with { CongestionControl = congestionControl });
|
||||
|
||||
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||
{
|
||||
@@ -784,12 +790,30 @@ public static class ConfigHandler
|
||||
|
||||
profileItem.Address = profileItem.Address.TrimEx();
|
||||
profileItem.Password = profileItem.Password.TrimEx();
|
||||
var wgReserved = profileItem.GetProtocolExtra().WgReserved?.TrimEx();
|
||||
if (!wgReserved.IsNullOrEmpty()
|
||||
&& !wgReserved.Contains(','))
|
||||
{
|
||||
// Base64 format, convert to standard format
|
||||
try
|
||||
{
|
||||
var bytes = Convert.FromBase64String(wgReserved);
|
||||
var reserved = new byte[3];
|
||||
Array.Copy(bytes, reserved, Math.Min(bytes.Length, 3));
|
||||
|
||||
wgReserved = string.Join(", ", reserved);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// If conversion fails, keep the original value
|
||||
}
|
||||
}
|
||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||
{
|
||||
WgPublicKey = profileItem.GetProtocolExtra().WgPublicKey?.TrimEx(),
|
||||
WgPresharedKey = profileItem.GetProtocolExtra().WgPresharedKey?.TrimEx(),
|
||||
WgInterfaceAddress = profileItem.GetProtocolExtra().WgInterfaceAddress?.TrimEx(),
|
||||
WgReserved = profileItem.GetProtocolExtra().WgReserved?.TrimEx(),
|
||||
WgReserved = wgReserved,
|
||||
WgMtu = profileItem.GetProtocolExtra().WgMtu is null or <= 0 ? Global.TunMtus.First() : profileItem.GetProtocolExtra().WgMtu,
|
||||
});
|
||||
|
||||
@@ -804,7 +828,7 @@ public static class ConfigHandler
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add or edit a Anytls server
|
||||
/// Add or edit an Anytls server
|
||||
/// Validates and processes Anytls-specific settings
|
||||
/// </summary>
|
||||
/// <param name="config">Current configuration</param>
|
||||
@@ -831,6 +855,38 @@ public static class ConfigHandler
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add or edit a Naive server
|
||||
/// Validates and processes Naive-specific settings
|
||||
/// </summary>
|
||||
/// <param name="config">Current configuration</param>
|
||||
/// <param name="profileItem">Naive profile to add</param>
|
||||
/// <param name="toFile">Whether to save to file</param>
|
||||
/// <returns>0 if successful, -1 if failed</returns>
|
||||
public static async Task<int> AddNaiveServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.ConfigType = EConfigType.Naive;
|
||||
profileItem.CoreType = ECoreType.sing_box;
|
||||
|
||||
profileItem.Address = profileItem.Address.TrimEx();
|
||||
profileItem.Username = profileItem.Username.TrimEx();
|
||||
profileItem.Password = profileItem.Password.TrimEx();
|
||||
profileItem.Fingerprint = string.Empty;
|
||||
profileItem.Alpn = string.Empty;
|
||||
profileItem.Network = string.Empty;
|
||||
profileItem.AllowInsecure = "false";
|
||||
if (profileItem.StreamSecurity.IsNullOrEmpty())
|
||||
{
|
||||
profileItem.StreamSecurity = Global.StreamSecurity;
|
||||
}
|
||||
if (profileItem.Password.IsNullOrEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
await AddServerCommon(config, profileItem, toFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort the server list by the specified column
|
||||
/// Updates the sort order in the profile extension data
|
||||
@@ -962,9 +1018,6 @@ public static class ConfigHandler
|
||||
profileItem.Address = profileItem.Address.TrimEx();
|
||||
profileItem.Password = profileItem.Password.TrimEx();
|
||||
profileItem.Network = profileItem.Network.TrimEx();
|
||||
profileItem.HeaderType = profileItem.HeaderType.TrimEx();
|
||||
profileItem.RequestHost = profileItem.RequestHost.TrimEx();
|
||||
profileItem.Path = profileItem.Path.TrimEx();
|
||||
profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
|
||||
|
||||
var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx();
|
||||
@@ -1009,13 +1062,19 @@ public static class ConfigHandler
|
||||
|
||||
foreach (var item in lstProfile)
|
||||
{
|
||||
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
||||
if (item.IsComplex())
|
||||
{
|
||||
lstKeep.Add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
||||
{
|
||||
lstRemove.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstRemove.Add(item);
|
||||
lstKeep.Add(item);
|
||||
}
|
||||
}
|
||||
await RemoveServers(config, lstRemove);
|
||||
@@ -1033,7 +1092,7 @@ public static class ConfigHandler
|
||||
/// <returns>0 if successful</returns>
|
||||
public static async Task<int> AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.ConfigVersion = 3;
|
||||
profileItem.ConfigVersion = 4;
|
||||
|
||||
if (profileItem.StreamSecurity.IsNotEmpty())
|
||||
{
|
||||
@@ -1077,7 +1136,8 @@ public static class ConfigHandler
|
||||
|
||||
if (toFile)
|
||||
{
|
||||
profileItem.SetProtocolExtra();
|
||||
//profileItem.SetProtocolExtra();
|
||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra());
|
||||
await SQLiteHelper.Instance.ReplaceAsync(profileItem);
|
||||
}
|
||||
return 0;
|
||||
@@ -1100,18 +1160,28 @@ public static class ConfigHandler
|
||||
|
||||
var oProtocolExtra = o.GetProtocolExtra();
|
||||
var nProtocolExtra = n.GetProtocolExtra();
|
||||
var oTransport = o.GetTransportExtra();
|
||||
var nTransport = n.GetTransportExtra();
|
||||
|
||||
return o.ConfigType == n.ConfigType
|
||||
&& AreEqual(o.Address, n.Address)
|
||||
&& o.Port == n.Port
|
||||
&& AreEqual(o.Password, n.Password)
|
||||
&& AreEqual(o.Username, n.Username)
|
||||
&& AreEqual(oProtocolExtra.VlessEncryption, nProtocolExtra.VlessEncryption)
|
||||
&& AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod)
|
||||
&& AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity)
|
||||
&& AreEqual(o.Network, n.Network)
|
||||
&& AreEqual(o.HeaderType, n.HeaderType)
|
||||
&& AreEqual(o.RequestHost, n.RequestHost)
|
||||
&& AreEqual(o.Path, n.Path)
|
||||
&& AreEqual(oTransport.RawHeaderType, nTransport.RawHeaderType)
|
||||
&& AreEqual(oTransport.Host, nTransport.Host)
|
||||
&& AreEqual(oTransport.Path, nTransport.Path)
|
||||
&& AreEqual(oTransport.XhttpMode, nTransport.XhttpMode)
|
||||
&& AreEqual(oTransport.XhttpExtra, nTransport.XhttpExtra)
|
||||
&& AreEqual(oTransport.GrpcAuthority, nTransport.GrpcAuthority)
|
||||
&& AreEqual(oTransport.GrpcServiceName, nTransport.GrpcServiceName)
|
||||
&& AreEqual(oTransport.GrpcMode, nTransport.GrpcMode)
|
||||
&& AreEqual(oTransport.KcpHeaderType, nTransport.KcpHeaderType)
|
||||
&& AreEqual(oTransport.KcpSeed, nTransport.KcpSeed)
|
||||
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
|
||||
&& AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow)
|
||||
&& AreEqual(oProtocolExtra.SalamanderPass, nProtocolExtra.SalamanderPass)
|
||||
@@ -1380,19 +1450,34 @@ public static class ConfigHandler
|
||||
/// <returns>A SOCKS profile item or null if not needed</returns>
|
||||
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
|
||||
{
|
||||
if (node.ConfigType != EConfigType.Custom || !(node.PreSocksPort > 0))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ProfileItem? itemSocks = null;
|
||||
var preCoreType = AppManager.Instance.RunningCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||
itemSocks = new ProfileItem()
|
||||
var enableLegacyProtect = config.TunModeItem.EnableLegacyProtect
|
||||
|| Utils.IsNonWindows();
|
||||
if (node.ConfigType != EConfigType.Custom
|
||||
&& coreType != ECoreType.sing_box
|
||||
&& config.TunModeItem.EnableTun
|
||||
&& enableLegacyProtect)
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = node.PreSocksPort.Value,
|
||||
};
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||
};
|
||||
}
|
||||
else if (node.ConfigType == EConfigType.Custom
|
||||
&& node.PreSocksPort is > 0 and <= 65535)
|
||||
{
|
||||
var preCoreType = config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
|
||||
itemSocks = new ProfileItem()
|
||||
{
|
||||
CoreType = preCoreType,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = node.PreSocksPort.Value,
|
||||
};
|
||||
}
|
||||
return itemSocks;
|
||||
}
|
||||
|
||||
@@ -1443,10 +1528,8 @@ public static class ConfigHandler
|
||||
}
|
||||
|
||||
var subFilter = string.Empty;
|
||||
//remove sub items
|
||||
if (isSub && subid.IsNotEmpty())
|
||||
{
|
||||
await RemoveServersViaSubid(config, subid, isSub);
|
||||
subFilter = (await AppManager.Instance.GetSubItem(subid))?.Filter ?? "";
|
||||
}
|
||||
|
||||
@@ -1496,6 +1579,7 @@ public static class ConfigHandler
|
||||
EConfigType.TUIC => await AddTuicServer(config, profileItem, false),
|
||||
EConfigType.WireGuard => await AddWireguardServer(config, profileItem, false),
|
||||
EConfigType.Anytls => await AddAnytlsServer(config, profileItem, false),
|
||||
EConfigType.Naive => await AddNaiveServer(config, profileItem, false),
|
||||
_ => -1,
|
||||
};
|
||||
|
||||
@@ -1548,10 +1632,6 @@ public static class ConfigHandler
|
||||
}
|
||||
if (lstProfiles != null && lstProfiles.Count > 0)
|
||||
{
|
||||
if (isSub && subid.IsNotEmpty())
|
||||
{
|
||||
await RemoveServersViaSubid(config, subid, isSub);
|
||||
}
|
||||
var count = 0;
|
||||
foreach (var it in lstProfiles)
|
||||
{
|
||||
@@ -1571,40 +1651,23 @@ public static class ConfigHandler
|
||||
|
||||
ProfileItem? profileItem = null;
|
||||
//Is sing-box configuration
|
||||
if (profileItem is null)
|
||||
{
|
||||
profileItem = SingboxFmt.ResolveFull(strData, subRemarks);
|
||||
}
|
||||
profileItem ??= SingboxFmt.ResolveFull(strData, subRemarks);
|
||||
//Is v2ray configuration
|
||||
if (profileItem is null)
|
||||
{
|
||||
profileItem = V2rayFmt.ResolveFull(strData, subRemarks);
|
||||
}
|
||||
profileItem ??= V2rayFmt.ResolveFull(strData, subRemarks);
|
||||
//Is Html Page
|
||||
if (profileItem is null && HtmlPageFmt.IsHtmlPage(strData))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//Is Clash configuration
|
||||
if (profileItem is null)
|
||||
{
|
||||
profileItem = ClashFmt.ResolveFull(strData, subRemarks);
|
||||
}
|
||||
profileItem ??= ClashFmt.ResolveFull(strData, subRemarks);
|
||||
//Is hysteria configuration
|
||||
if (profileItem is null)
|
||||
{
|
||||
profileItem = Hysteria2Fmt.ResolveFull2(strData, subRemarks);
|
||||
}
|
||||
profileItem ??= Hysteria2Fmt.ResolveFull2(strData, subRemarks);
|
||||
if (profileItem is null || profileItem.Address.IsNullOrEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isSub && subid.IsNotEmpty())
|
||||
{
|
||||
await RemoveServersViaSubid(config, subid, isSub);
|
||||
}
|
||||
|
||||
profileItem.Subid = subid;
|
||||
profileItem.IsSub = isSub;
|
||||
profileItem.PreSocksPort = preSocksPort;
|
||||
@@ -1634,11 +1697,6 @@ public static class ConfigHandler
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (isSub && subid.IsNotEmpty())
|
||||
{
|
||||
await RemoveServersViaSubid(config, subid, isSub);
|
||||
}
|
||||
|
||||
var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
|
||||
if (lstSsServer?.Count > 0)
|
||||
{
|
||||
@@ -1659,6 +1717,86 @@ public static class ConfigHandler
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static async Task<int> AddBatchServers4Wireguard(Config config, string strData, string subid, bool isSub)
|
||||
{
|
||||
if (strData.IsNullOrEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (!(strData.Contains("[Interface]", StringComparison.OrdinalIgnoreCase)
|
||||
&& strData.Contains("[Peer]", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var lstServer = WireguardFmt.ResolveConfig(strData);
|
||||
if (lstServer?.Count > 0)
|
||||
{
|
||||
var counter = 0;
|
||||
foreach (var item in lstServer)
|
||||
{
|
||||
item.Subid = subid;
|
||||
item.IsSub = isSub;
|
||||
if (await AddWireguardServer(config, item) == 0)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
await SaveConfig(config);
|
||||
return counter;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static async Task<int> AddBatchServers4InnerUri(Config config, string strData, string subid, bool isSub)
|
||||
{
|
||||
if (strData.IsNullOrEmpty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
var lstServer = InnerFmt.Resolve(strData, subid);
|
||||
if (lstServer?.Count > 0)
|
||||
{
|
||||
var counter = 0;
|
||||
List<ProfileItem> lstAdd = [];
|
||||
foreach (var profileItem in lstServer)
|
||||
{
|
||||
profileItem.Subid = subid;
|
||||
profileItem.IsSub = isSub;
|
||||
|
||||
var addStatus = profileItem.ConfigType switch
|
||||
{
|
||||
EConfigType.VMess => await AddVMessServer(config, profileItem, false),
|
||||
EConfigType.Shadowsocks => await AddShadowsocksServer(config, profileItem, false),
|
||||
EConfigType.HTTP => await AddHttpServer(config, profileItem, false),
|
||||
EConfigType.SOCKS => await AddSocksServer(config, profileItem, false),
|
||||
EConfigType.Trojan => await AddTrojanServer(config, profileItem, false),
|
||||
EConfigType.VLESS => await AddVlessServer(config, profileItem, false),
|
||||
EConfigType.Hysteria2 => await AddHysteria2Server(config, profileItem, false),
|
||||
EConfigType.TUIC => await AddTuicServer(config, profileItem, false),
|
||||
EConfigType.WireGuard => await AddWireguardServer(config, profileItem, false),
|
||||
EConfigType.Anytls => await AddAnytlsServer(config, profileItem, false),
|
||||
EConfigType.Naive => await AddNaiveServer(config, profileItem, false),
|
||||
EConfigType.PolicyGroup or EConfigType.ProxyChain => await AddServerCommon(config, profileItem, false),
|
||||
_ => -1,
|
||||
};
|
||||
if (addStatus == 0)
|
||||
{
|
||||
counter++;
|
||||
lstAdd.Add(profileItem);
|
||||
}
|
||||
}
|
||||
if (lstAdd.Count > 0)
|
||||
{
|
||||
await SQLiteHelper.Instance.InsertAllAsync(lstAdd);
|
||||
}
|
||||
await SaveConfig(config);
|
||||
return counter;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Main entry point for adding batch servers from various formats
|
||||
/// Tries different parsing methods to import as many servers as possible
|
||||
@@ -1680,6 +1818,7 @@ public static class ConfigHandler
|
||||
{
|
||||
lstOriSub = await AppManager.Instance.ProfileItems(subid);
|
||||
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
||||
await RemoveServersViaSubid(config, subid, true);
|
||||
}
|
||||
|
||||
var counter = 0;
|
||||
@@ -1701,6 +1840,26 @@ public static class ConfigHandler
|
||||
counter = await AddBatchServers4SsSIP008(config, strData, subid, isSub);
|
||||
}
|
||||
|
||||
//maybe wireguard config
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = await AddBatchServers4Wireguard(config, strData, subid, isSub);
|
||||
}
|
||||
|
||||
//May be standard uri mixed with internal uri
|
||||
var innerUriCount = await AddBatchServers4InnerUri(config, strData, subid, isSub);
|
||||
if (innerUriCount > 0)
|
||||
{
|
||||
if (counter > 0)
|
||||
{
|
||||
counter += innerUriCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
counter = innerUriCount;
|
||||
}
|
||||
}
|
||||
|
||||
//maybe other sub
|
||||
if (counter < 1)
|
||||
{
|
||||
@@ -1881,6 +2040,12 @@ public static class ConfigHandler
|
||||
await SQLiteHelper.Instance.DeleteAsync(item);
|
||||
await RemoveServersViaSubid(config, id, false);
|
||||
|
||||
if (item.Id == config.SubIndexId)
|
||||
{
|
||||
var subs = await AppManager.Instance.SubItems();
|
||||
config.SubIndexId = subs.LastOrDefault()?.Id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ public class BaseFmt
|
||||
{
|
||||
private static readonly string[] _allowInsecureArray = new[] { "insecure", "allowInsecure", "allow_insecure" };
|
||||
|
||||
private static string UrlEncodeSafe(string? value) => Utils.UrlEncode(value ?? string.Empty);
|
||||
|
||||
protected static string GetIpv6(string address)
|
||||
{
|
||||
if (Utils.IsIpv6(address))
|
||||
@@ -21,6 +23,8 @@ public class BaseFmt
|
||||
|
||||
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
|
||||
{
|
||||
var transport = item.GetTransportExtra();
|
||||
|
||||
if (item.StreamSecurity.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("security", item.StreamSecurity);
|
||||
@@ -87,54 +91,69 @@ public class BaseFmt
|
||||
dicQuery.Add("fm", Utils.UrlEncode(finalmask));
|
||||
}
|
||||
|
||||
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp));
|
||||
|
||||
switch (item.Network)
|
||||
var network = item.GetNetwork();
|
||||
if (!Global.Networks.Contains(network))
|
||||
{
|
||||
case nameof(ETransport.tcp):
|
||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||
if (item.RequestHost.IsNotEmpty())
|
||||
network = nameof(ETransport.raw);
|
||||
}
|
||||
|
||||
//dicQuery.Add("type", network);
|
||||
dicQuery.Add("type", network == nameof(ETransport.raw) ? Global.RawNetworkAlias : network);
|
||||
|
||||
switch (network)
|
||||
{
|
||||
case nameof(ETransport.raw):
|
||||
dicQuery.Add("headerType", transport.RawHeaderType.IsNotEmpty() ? transport.RawHeaderType : Global.None);
|
||||
if (transport.Host.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||
}
|
||||
if (transport.Path.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.kcp):
|
||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||
if (item.Path.IsNotEmpty())
|
||||
dicQuery.Add("headerType", transport.KcpHeaderType.IsNotEmpty() ? transport.KcpHeaderType : Global.None);
|
||||
if (transport.KcpSeed.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("seed", Utils.UrlEncode(item.Path));
|
||||
dicQuery.Add("seed", UrlEncodeSafe(transport.KcpSeed));
|
||||
}
|
||||
if (transport.KcpMtu > 0)
|
||||
{
|
||||
dicQuery.Add("mtu", transport.KcpMtu.ToString());
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
case nameof(ETransport.httpupgrade):
|
||||
if (item.RequestHost.IsNotEmpty())
|
||||
if (transport.Host.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||
}
|
||||
if (item.Path.IsNotEmpty())
|
||||
if (transport.Path.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.xhttp):
|
||||
if (item.RequestHost.IsNotEmpty())
|
||||
if (transport.Host.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||
dicQuery.Add("host", UrlEncodeSafe(transport.Host));
|
||||
}
|
||||
if (item.Path.IsNotEmpty())
|
||||
if (transport.Path.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||
dicQuery.Add("path", UrlEncodeSafe(transport.Path));
|
||||
}
|
||||
if (item.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(item.HeaderType))
|
||||
if (transport.XhttpMode.IsNotEmpty() && Global.XhttpMode.Contains(transport.XhttpMode))
|
||||
{
|
||||
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
||||
dicQuery.Add("mode", UrlEncodeSafe(transport.XhttpMode));
|
||||
}
|
||||
if (item.Extra.IsNotEmpty())
|
||||
if (transport.XhttpExtra.IsNotEmpty())
|
||||
{
|
||||
var node = JsonUtils.ParseJson(item.Extra);
|
||||
var node = JsonUtils.ParseJson(transport.XhttpExtra);
|
||||
var extra = node != null
|
||||
? JsonUtils.Serialize(node, new JsonSerializerOptions
|
||||
{
|
||||
@@ -142,38 +161,19 @@ public class BaseFmt
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||
})
|
||||
: item.Extra;
|
||||
dicQuery.Add("extra", Utils.UrlEncode(extra));
|
||||
: transport.XhttpExtra;
|
||||
dicQuery.Add("extra", UrlEncodeSafe(extra));
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.http):
|
||||
case nameof(ETransport.h2):
|
||||
dicQuery["type"] = nameof(ETransport.http);
|
||||
if (item.RequestHost.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("host", Utils.UrlEncode(item.RequestHost));
|
||||
}
|
||||
if (item.Path.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("path", Utils.UrlEncode(item.Path));
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.quic):
|
||||
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None);
|
||||
dicQuery.Add("quicSecurity", Utils.UrlEncode(item.RequestHost));
|
||||
dicQuery.Add("key", Utils.UrlEncode(item.Path));
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
if (item.Path.IsNotEmpty())
|
||||
if (transport.GrpcServiceName.IsNotEmpty())
|
||||
{
|
||||
dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost));
|
||||
dicQuery.Add("serviceName", Utils.UrlEncode(item.Path));
|
||||
if (item.HeaderType is Global.GrpcGunMode or Global.GrpcMultiMode)
|
||||
dicQuery.Add("authority", UrlEncodeSafe(transport.GrpcAuthority));
|
||||
dicQuery.Add("serviceName", UrlEncodeSafe(transport.GrpcServiceName));
|
||||
if (transport.GrpcMode is Global.GrpcGunMode or Global.GrpcMultiMode)
|
||||
{
|
||||
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType));
|
||||
dicQuery.Add("mode", UrlEncodeSafe(transport.GrpcMode));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -216,6 +216,8 @@ public class BaseFmt
|
||||
|
||||
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
|
||||
{
|
||||
var transport = item.GetTransportExtra();
|
||||
|
||||
item.StreamSecurity = GetQueryValue(query, "security");
|
||||
item.Sni = GetQueryValue(query, "sni");
|
||||
item.Alpn = GetQueryDecoded(query, "alpn");
|
||||
@@ -258,36 +260,57 @@ public class BaseFmt
|
||||
item.AllowInsecure = string.Empty;
|
||||
}
|
||||
|
||||
item.Network = GetQueryValue(query, "type", nameof(ETransport.tcp));
|
||||
var net = GetQueryValue(query, "type", nameof(ETransport.raw));
|
||||
if (net == Global.RawNetworkAlias)
|
||||
{
|
||||
net = nameof(ETransport.raw);
|
||||
}
|
||||
if (!Global.Networks.Contains(net))
|
||||
{
|
||||
net = nameof(ETransport.raw);
|
||||
}
|
||||
|
||||
item.Network = net;
|
||||
switch (item.Network)
|
||||
{
|
||||
case nameof(ETransport.tcp):
|
||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
||||
item.RequestHost = GetQueryDecoded(query, "host");
|
||||
case nameof(ETransport.raw):
|
||||
transport = transport with
|
||||
{
|
||||
RawHeaderType = GetQueryValue(query, "headerType", Global.None),
|
||||
Host = GetQueryDecoded(query, "host"),
|
||||
Path = GetQueryDecoded(query, "path"),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.kcp):
|
||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
||||
item.Path = GetQueryDecoded(query, "seed");
|
||||
var kcpSeed = GetQueryDecoded(query, "seed");
|
||||
var kcpMtuStr = GetQueryValue(query, "mtu");
|
||||
var kcpMtu = int.TryParse(kcpMtuStr, out var mtu) ? mtu : 0;
|
||||
transport = transport with
|
||||
{
|
||||
KcpHeaderType = GetQueryValue(query, "headerType", Global.None),
|
||||
KcpSeed = kcpSeed,
|
||||
KcpMtu = kcpMtu > 0 ? mtu : null,
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
case nameof(ETransport.httpupgrade):
|
||||
item.RequestHost = GetQueryDecoded(query, "host");
|
||||
item.Path = GetQueryDecoded(query, "path", "/");
|
||||
transport = transport with
|
||||
{
|
||||
Host = GetQueryDecoded(query, "host"),
|
||||
Path = GetQueryDecoded(query, "path", "/"),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.xhttp):
|
||||
item.RequestHost = GetQueryDecoded(query, "host");
|
||||
item.Path = GetQueryDecoded(query, "path", "/");
|
||||
item.HeaderType = GetQueryDecoded(query, "mode");
|
||||
var extraDecoded = GetQueryDecoded(query, "extra");
|
||||
if (extraDecoded.IsNotEmpty())
|
||||
var xhttpExtra = GetQueryDecoded(query, "extra");
|
||||
if (xhttpExtra.IsNotEmpty())
|
||||
{
|
||||
var node = JsonUtils.ParseJson(extraDecoded);
|
||||
var node = JsonUtils.ParseJson(xhttpExtra);
|
||||
if (node != null)
|
||||
{
|
||||
extraDecoded = JsonUtils.Serialize(node, new JsonSerializerOptions
|
||||
xhttpExtra = JsonUtils.Serialize(node, new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.Never,
|
||||
@@ -295,31 +318,32 @@ public class BaseFmt
|
||||
});
|
||||
}
|
||||
}
|
||||
item.Extra = extraDecoded;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.http):
|
||||
case nameof(ETransport.h2):
|
||||
item.Network = nameof(ETransport.h2);
|
||||
item.RequestHost = GetQueryDecoded(query, "host");
|
||||
item.Path = GetQueryDecoded(query, "path", "/");
|
||||
break;
|
||||
|
||||
case nameof(ETransport.quic):
|
||||
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
|
||||
item.RequestHost = GetQueryValue(query, "quicSecurity", Global.None);
|
||||
item.Path = GetQueryDecoded(query, "key");
|
||||
transport = transport with
|
||||
{
|
||||
Host = GetQueryDecoded(query, "host"),
|
||||
Path = GetQueryDecoded(query, "path", "/"),
|
||||
XhttpMode = GetQueryDecoded(query, "mode"),
|
||||
XhttpExtra = xhttpExtra,
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
item.RequestHost = GetQueryDecoded(query, "authority");
|
||||
item.Path = GetQueryDecoded(query, "serviceName");
|
||||
item.HeaderType = GetQueryDecoded(query, "mode", Global.GrpcGunMode);
|
||||
transport = transport with
|
||||
{
|
||||
GrpcAuthority = GetQueryDecoded(query, "authority"),
|
||||
GrpcServiceName = GetQueryDecoded(query, "serviceName"),
|
||||
GrpcMode = GetQueryDecoded(query, "mode", Global.GrpcGunMode),
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
item.Network = nameof(ETransport.raw);
|
||||
break;
|
||||
}
|
||||
|
||||
item.SetTransportExtra(transport);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ public class FmtHandler
|
||||
EConfigType.TUIC => TuicFmt.ToUri(item),
|
||||
EConfigType.WireGuard => WireguardFmt.ToUri(item),
|
||||
EConfigType.Anytls => AnytlsFmt.ToUri(item),
|
||||
EConfigType.Naive => NaiveFmt.ToUri(item),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -80,6 +81,12 @@ public class FmtHandler
|
||||
{
|
||||
return AnytlsFmt.Resolve(str, out msg);
|
||||
}
|
||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Naive])
|
||||
|| str.StartsWith(Global.NaiveHttpsProtocolShare)
|
||||
|| str.StartsWith(Global.NaiveQuicProtocolShare))
|
||||
{
|
||||
return NaiveFmt.Resolve(str, out msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = ResUI.NonvmessOrssProtocol;
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
namespace ServiceLib.Handler.Fmt;
|
||||
|
||||
public class InnerFmt
|
||||
{
|
||||
private static readonly Lazy<string> SessionSalt = new(() => Utils.GetGuid(false));
|
||||
|
||||
public static List<ProfileItem>? Resolve(string strData, string subid)
|
||||
{
|
||||
var list = new List<ProfileItem>();
|
||||
// Overwrite externally imported indexIds to avoid possible sources of attacks
|
||||
var indexIdMap = new Dictionary<string, string>();
|
||||
using (var reader = new StringReader(strData))
|
||||
{
|
||||
while (reader.ReadLine() is { } line)
|
||||
{
|
||||
if (line.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var trimmedLine = line.Trim();
|
||||
if (!trimmedLine.StartsWith(Global.InnerUriProtocol, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var profileItem = ResolveSingle(trimmedLine);
|
||||
if (profileItem is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (profileItem.ConfigType == EConfigType.Custom)
|
||||
{
|
||||
// Unsupported, also to avoid possible sources of attacks, skip it
|
||||
continue;
|
||||
}
|
||||
// overwrite indexId
|
||||
var newIndexId = Utils.GetGuid(false);
|
||||
if (!profileItem.IndexId.IsNullOrEmpty())
|
||||
{
|
||||
// Ignore duplicated indexId
|
||||
indexIdMap[profileItem.IndexId] = newIndexId;
|
||||
}
|
||||
profileItem.IndexId = newIndexId;
|
||||
list.Add(profileItem);
|
||||
}
|
||||
}
|
||||
// For group-type profile items, also overwrite the ChildItems and ChildSubId
|
||||
var emptyGroupProfileList = new List<ProfileItem>();
|
||||
foreach (var item in list.Where(i => i.ConfigType.IsGroupType()))
|
||||
{
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
// Only allow "self" as a special value for SubChildItems to avoid possible sources of attacks,
|
||||
// which means it will be replaced with the subid, otherwise set it to null
|
||||
//if (!protocolExtra.SubChildItems.IsNullOrEmpty())
|
||||
if (protocolExtra.SubChildItems == "self")
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
SubChildItems = subid
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
SubChildItems = null
|
||||
};
|
||||
}
|
||||
if (Utils.String2List(protocolExtra.ChildItems) is { Count: > 0 } childIndexIds)
|
||||
{
|
||||
var newChildIndexIds = childIndexIds
|
||||
.Select(id => indexIdMap.GetValueOrDefault(id, null))
|
||||
.Where(id => !id.IsNullOrEmpty())
|
||||
.ToList();
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
ChildItems = Utils.List2String(newChildIndexIds)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
ChildItems = null
|
||||
};
|
||||
}
|
||||
item.SetProtocolExtra(protocolExtra);
|
||||
if (protocolExtra.SubChildItems.IsNullOrEmpty()
|
||||
&& protocolExtra.ChildItems.IsNullOrEmpty())
|
||||
{
|
||||
emptyGroupProfileList.Add(item);
|
||||
}
|
||||
}
|
||||
// Remove empty group profile items
|
||||
list.RemoveAll(emptyGroupProfileList.Contains);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static string? ToUri(List<ProfileItem> items)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.ConfigType == EConfigType.Custom)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var itemClone = JsonUtils.DeepCopy(item);
|
||||
if (itemClone is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// overwrite indexId
|
||||
var originalIndexId = itemClone.IndexId;
|
||||
var newIndexId = GetReproducibleExportId(originalIndexId);
|
||||
itemClone.IndexId = newIndexId;
|
||||
if (itemClone.ConfigType.IsGroupType())
|
||||
{
|
||||
var protocolExtra = itemClone.GetProtocolExtra();
|
||||
if (!protocolExtra.SubChildItems.IsNullOrEmpty())
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
SubChildItems = "self"
|
||||
};
|
||||
}
|
||||
if (Utils.String2List(protocolExtra.ChildItems) is { Count: > 0 } childIndexIds)
|
||||
{
|
||||
var newChildIndexIds = childIndexIds
|
||||
.Select(GetReproducibleExportId)
|
||||
.Where(id => !id.IsNullOrEmpty())
|
||||
.ToList();
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
ChildItems = Utils.List2String(newChildIndexIds)
|
||||
};
|
||||
}
|
||||
itemClone.SetProtocolExtra(protocolExtra);
|
||||
}
|
||||
var uri = ToUriSingle(itemClone);
|
||||
if (!uri.IsNullOrEmpty())
|
||||
{
|
||||
sb.AppendLine(uri);
|
||||
}
|
||||
}
|
||||
return sb.Length > 0 ? sb.ToString() : null;
|
||||
}
|
||||
|
||||
private static ProfileItem? ResolveSingle(string str)
|
||||
{
|
||||
// format: v2rayn://vless/{url-safe base64 encoded_string}
|
||||
var parsedUri = Utils.TryUri(str);
|
||||
if (parsedUri is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var segment = parsedUri.AbsolutePath.TrimStart('/');
|
||||
var decodedResult = Utils.Base64Decode(segment);
|
||||
var jsonNode = JsonUtils.ParseJson(decodedResult);
|
||||
if (jsonNode is not JsonObject jsonObj)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// flatten
|
||||
// move jsonObj.ProtoExtraObj to jsonObj.ProtoExtra (string)
|
||||
// move jsonObj.TransportExtraObj to jsonObj.TransportExtra (string)
|
||||
if (jsonObj.TryGetPropertyValue("ProtoExtraObj", out var protoExtraNode)
|
||||
&& protoExtraNode is JsonObject protoExtraObj)
|
||||
{
|
||||
jsonObj["ProtoExtra"] = JsonUtils.Serialize(protoExtraObj, false);
|
||||
jsonObj.Remove("ProtoExtraObj");
|
||||
}
|
||||
if (jsonObj.TryGetPropertyValue("TransportExtraObj", out var transportExtraNode)
|
||||
&& transportExtraNode is JsonObject transportExtraObj)
|
||||
{
|
||||
jsonObj["TransportExtra"] = JsonUtils.Serialize(transportExtraObj, false);
|
||||
jsonObj.Remove("TransportExtraObj");
|
||||
}
|
||||
var profileItem = JsonUtils.Deserialize<ProfileItem>(JsonUtils.Serialize(jsonObj, false));
|
||||
if (profileItem is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (profileItem.ConfigVersion != 4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Check Enum.IsDefined
|
||||
if (!Enum.IsDefined(typeof(EConfigType), profileItem.ConfigType))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (profileItem.CoreType is not (null or ECoreType.Xray or ECoreType.sing_box))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var protocolExtra = profileItem.GetProtocolExtra();
|
||||
var multipleLoad = protocolExtra.MultipleLoad;
|
||||
if (multipleLoad is not null && !Enum.IsDefined(typeof(EMultipleLoad), multipleLoad))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return profileItem;
|
||||
}
|
||||
|
||||
private static string? ToUriSingle(ProfileItem item)
|
||||
{
|
||||
var jsonNode = JsonUtils.ParseJson(JsonUtils.Serialize(item, false));
|
||||
if (jsonNode is not JsonObject jsonObj)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// unflatten
|
||||
// move jsonObj.ProtoExtra (string) to jsonObj.ProtoExtraObj
|
||||
// move jsonObj.TransportExtra (string) to jsonObj.TransportExtraObj
|
||||
if (jsonObj.TryGetPropertyValue("ProtoExtra", out var protoExtraNode)
|
||||
&& protoExtraNode is JsonValue protoExtraValue
|
||||
&& protoExtraValue.TryGetValue<string>(out var protoExtraStr)
|
||||
&& !protoExtraStr.IsNullOrEmpty()
|
||||
&& JsonUtils.ParseJson(protoExtraStr) is JsonObject protoExtraObj)
|
||||
{
|
||||
jsonObj["ProtoExtraObj"] = protoExtraObj;
|
||||
jsonObj.Remove("ProtoExtra");
|
||||
}
|
||||
if (jsonObj.TryGetPropertyValue("TransportExtra", out var transportExtraNode)
|
||||
&& transportExtraNode is JsonValue transportExtraValue
|
||||
&& transportExtraValue.TryGetValue<string>(out var transportExtraStr)
|
||||
&& !transportExtraStr.IsNullOrEmpty()
|
||||
&& JsonUtils.ParseJson(transportExtraStr) is JsonObject transportExtraObj)
|
||||
{
|
||||
jsonObj["TransportExtraObj"] = transportExtraObj;
|
||||
jsonObj.Remove("TransportExtra");
|
||||
}
|
||||
// remove subid and isSub
|
||||
jsonObj.Remove("Subid");
|
||||
jsonObj.Remove("IsSub");
|
||||
// Remove empty properties to reduce the length of the exported string
|
||||
RemoveEmptyJson(jsonObj);
|
||||
var jsonStr = JsonUtils.Serialize(jsonObj, false);
|
||||
var encodedStr = Utils.Base64Encode(jsonStr).Replace('+', '-').Replace('/', '_').Replace("=", "");
|
||||
return $"{Global.InnerUriProtocol}{item.ConfigType.ToString().ToLower()}/{encodedStr}";
|
||||
}
|
||||
|
||||
private static string GetReproducibleExportId(string originalIndexId)
|
||||
{
|
||||
if (originalIndexId.IsNullOrEmpty())
|
||||
{
|
||||
return originalIndexId;
|
||||
}
|
||||
|
||||
var hash = HashCode.Combine(SessionSalt.Value, originalIndexId) & 0x7FFFFFFF;
|
||||
var bytes = BitConverter.GetBytes(hash);
|
||||
return Convert.ToBase64String(bytes).Replace("=", "");
|
||||
}
|
||||
|
||||
private static void RemoveEmptyJson(JsonNode? node)
|
||||
{
|
||||
// ReSharper disable once ConvertIfStatementToSwitchStatement
|
||||
if (node is JsonObject jsonObject)
|
||||
{
|
||||
var propertiesToRemove = new List<string>();
|
||||
|
||||
foreach (var property in jsonObject)
|
||||
{
|
||||
RemoveEmptyJson(property.Value);
|
||||
|
||||
if (IsEmpty(property.Value))
|
||||
{
|
||||
propertiesToRemove.Add(property.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var key in propertiesToRemove)
|
||||
{
|
||||
jsonObject.Remove(key);
|
||||
}
|
||||
}
|
||||
else if (node is JsonArray jsonArray)
|
||||
{
|
||||
for (var i = jsonArray.Count - 1; i >= 0; i--)
|
||||
{
|
||||
RemoveEmptyJson(jsonArray[i]);
|
||||
|
||||
if (IsEmpty(jsonArray[i]))
|
||||
{
|
||||
jsonArray.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsEmpty(JsonNode? node)
|
||||
{
|
||||
return node switch
|
||||
{
|
||||
null => true,
|
||||
JsonValue value when value.TryGetValue<string>(out var str) => string.IsNullOrEmpty(str),
|
||||
JsonObject obj => obj.Count == 0,
|
||||
JsonArray arr => arr.Count == 0,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
namespace ServiceLib.Handler.Fmt;
|
||||
|
||||
public class NaiveFmt : BaseFmt
|
||||
{
|
||||
public static ProfileItem? Resolve(string str, out string msg)
|
||||
{
|
||||
msg = ResUI.ConfigurationFormatIncorrect;
|
||||
|
||||
var parsedUrl = Utils.TryUri(str);
|
||||
if (parsedUrl == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileItem item = new()
|
||||
{
|
||||
ConfigType = EConfigType.Naive,
|
||||
Remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped),
|
||||
Address = parsedUrl.IdnHost,
|
||||
Port = parsedUrl.Port,
|
||||
};
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
if (parsedUrl.Scheme.Contains("quic"))
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
NaiveQuic = true,
|
||||
};
|
||||
}
|
||||
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||
if (rawUserInfo.Contains(':'))
|
||||
{
|
||||
var split = rawUserInfo.Split(':', 2);
|
||||
item.Username = split[0];
|
||||
item.Password = split[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Password = rawUserInfo;
|
||||
}
|
||||
|
||||
var query = Utils.ParseQueryString(parsedUrl.Query);
|
||||
ResolveUriQuery(query, ref item);
|
||||
var insecureConcurrency = int.TryParse(GetQueryValue(query, "insecure-concurrency"), out var ic) ? ic : 0;
|
||||
if (insecureConcurrency > 0)
|
||||
{
|
||||
protocolExtra = protocolExtra with
|
||||
{
|
||||
InsecureConcurrency = insecureConcurrency,
|
||||
};
|
||||
}
|
||||
|
||||
item.SetProtocolExtra(protocolExtra);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static string? ToUri(ProfileItem? item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var remark = string.Empty;
|
||||
if (item.Remarks.IsNotEmpty())
|
||||
{
|
||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||
}
|
||||
var userInfo = item.Username.IsNotEmpty() ? $"{Utils.UrlEncode(item.Username)}:{Utils.UrlEncode(item.Password)}" : Utils.UrlEncode(item.Password);
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
ToUriQuery(item, Global.None, ref dicQuery);
|
||||
var protocolExtra = item.GetProtocolExtra();
|
||||
if (protocolExtra.InsecureConcurrency > 0)
|
||||
{
|
||||
dicQuery.Add("insecure-concurrency", protocolExtra?.InsecureConcurrency.ToString());
|
||||
}
|
||||
|
||||
var query = dicQuery.Count > 0
|
||||
? ("?" + string.Join("&", dicQuery.Select(x => x.Key + "=" + x.Value).ToArray()))
|
||||
: string.Empty;
|
||||
var url = $"{userInfo}@{GetIpv6(item.Address)}:{item.Port}";
|
||||
|
||||
if (protocolExtra.NaiveQuic == true)
|
||||
{
|
||||
return $"{Global.NaiveQuicProtocolShare}{url}{query}{remark}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{Global.NaiveHttpsProtocolShare}{url}{query}{remark}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,31 +42,28 @@ public class ShadowsocksFmt : BaseFmt
|
||||
//url = Utile.Base64Encode(url);
|
||||
//new Sip002
|
||||
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true);
|
||||
var transport = item.GetTransportExtra();
|
||||
|
||||
// plugin
|
||||
var plugin = string.Empty;
|
||||
var pluginArgs = string.Empty;
|
||||
|
||||
if (item.Network == nameof(ETransport.tcp) && item.HeaderType == Global.TcpHeaderHttp)
|
||||
if (item.Network == nameof(ETransport.raw) && transport.RawHeaderType == Global.RawHeaderHttp)
|
||||
{
|
||||
plugin = "obfs-local";
|
||||
pluginArgs = $"obfs=http;obfs-host={item.RequestHost};";
|
||||
pluginArgs = $"obfs=http;obfs-host={transport.Host};";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Network == nameof(ETransport.ws))
|
||||
{
|
||||
pluginArgs += "mode=websocket;";
|
||||
pluginArgs += $"host={item.RequestHost};";
|
||||
pluginArgs += $"host={transport.Host};";
|
||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||
var path = item.Path.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||
var path = (transport.Path ?? string.Empty).Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||
pluginArgs += $"path={path};";
|
||||
}
|
||||
else if (item.Network == nameof(ETransport.quic))
|
||||
{
|
||||
pluginArgs += "mode=quic;";
|
||||
}
|
||||
if (item.StreamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
pluginArgs += "tls;";
|
||||
@@ -213,8 +210,11 @@ public class ShadowsocksFmt : BaseFmt
|
||||
{
|
||||
obfsHost = obfsHost.Replace("obfs-host=", "");
|
||||
item.Network = Global.DefaultNetwork;
|
||||
item.HeaderType = Global.TcpHeaderHttp;
|
||||
item.RequestHost = obfsHost;
|
||||
item.SetTransportExtra(item.GetTransportExtra() with
|
||||
{
|
||||
RawHeaderType = Global.RawHeaderHttp,
|
||||
Host = obfsHost,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Parse v2ray-plugin
|
||||
@@ -231,21 +231,20 @@ public class ShadowsocksFmt : BaseFmt
|
||||
if (modeValue == "websocket")
|
||||
{
|
||||
item.Network = nameof(ETransport.ws);
|
||||
var t = item.GetTransportExtra();
|
||||
if (!host.IsNullOrEmpty())
|
||||
{
|
||||
item.RequestHost = host.Replace("host=", "");
|
||||
item.Sni = item.RequestHost;
|
||||
var wsHost = host.Replace("host=", "");
|
||||
t = t with { Host = wsHost };
|
||||
item.Sni = wsHost;
|
||||
}
|
||||
if (!path.IsNullOrEmpty())
|
||||
{
|
||||
var pathValue = path.Replace("path=", "");
|
||||
pathValue = pathValue.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\");
|
||||
item.Path = pathValue;
|
||||
t = t with { Path = pathValue };
|
||||
}
|
||||
}
|
||||
else if (modeValue == "quic")
|
||||
{
|
||||
item.Network = nameof(ETransport.quic);
|
||||
item.SetTransportExtra(t);
|
||||
}
|
||||
|
||||
if (hasTls)
|
||||
|
||||
@@ -30,7 +30,10 @@ public class TuicFmt : BaseFmt
|
||||
|
||||
var query = Utils.ParseQueryString(url.Query);
|
||||
ResolveUriQuery(query, ref item);
|
||||
item.HeaderType = GetQueryValue(query, "congestion_control");
|
||||
item.SetProtocolExtra(item.GetProtocolExtra() with
|
||||
{
|
||||
CongestionControl = GetQueryValue(query, "congestion_control")
|
||||
});
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -51,7 +54,10 @@ public class TuicFmt : BaseFmt
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
ToUriQueryLite(item, ref dicQuery);
|
||||
|
||||
dicQuery.Add("congestion_control", item.HeaderType);
|
||||
if (!item.GetProtocolExtra().CongestionControl.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("congestion_control", item.GetProtocolExtra().CongestionControl);
|
||||
}
|
||||
|
||||
return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Username ?? ""}:{item.Password}", dicQuery, remark);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class VmessFmt : BaseFmt
|
||||
|
||||
var vmessQRCode = new VmessQRCode
|
||||
{
|
||||
// vmess link keeps shared transport keys; map from new transport model on export.
|
||||
v = 2,
|
||||
ps = item.Remarks.TrimEx(),
|
||||
add = item.Address,
|
||||
@@ -33,10 +34,34 @@ public class VmessFmt : BaseFmt
|
||||
id = item.Password,
|
||||
aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0,
|
||||
scy = item.GetProtocolExtra().VmessSecurity ?? "",
|
||||
net = item.Network,
|
||||
type = item.HeaderType,
|
||||
host = item.RequestHost,
|
||||
path = item.Path,
|
||||
net = item.GetNetwork() == nameof(ETransport.raw) ? Global.RawNetworkAlias : item.Network,
|
||||
type = item.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => item.GetTransportExtra().RawHeaderType,
|
||||
nameof(ETransport.kcp) => item.GetTransportExtra().KcpHeaderType,
|
||||
nameof(ETransport.xhttp) => item.GetTransportExtra().XhttpMode,
|
||||
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcMode,
|
||||
_ => Global.None,
|
||||
},
|
||||
host = item.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => item.GetTransportExtra().Host,
|
||||
nameof(ETransport.ws) => item.GetTransportExtra().Host,
|
||||
nameof(ETransport.httpupgrade) => item.GetTransportExtra().Host,
|
||||
nameof(ETransport.xhttp) => item.GetTransportExtra().Host,
|
||||
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcAuthority,
|
||||
_ => null,
|
||||
},
|
||||
path = item.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => item.GetTransportExtra().Path,
|
||||
nameof(ETransport.kcp) => item.GetTransportExtra().KcpSeed,
|
||||
nameof(ETransport.ws) => item.GetTransportExtra().Path,
|
||||
nameof(ETransport.httpupgrade) => item.GetTransportExtra().Path,
|
||||
nameof(ETransport.xhttp) => item.GetTransportExtra().Path,
|
||||
nameof(ETransport.grpc) => item.GetTransportExtra().GrpcServiceName,
|
||||
_ => null,
|
||||
},
|
||||
tls = item.StreamSecurity,
|
||||
sni = item.Sni,
|
||||
alpn = item.Alpn,
|
||||
@@ -70,7 +95,10 @@ public class VmessFmt : BaseFmt
|
||||
}
|
||||
|
||||
item.Network = Global.DefaultNetwork;
|
||||
item.HeaderType = Global.None;
|
||||
var transport = new TransportExtraItem
|
||||
{
|
||||
RawHeaderType = Global.None,
|
||||
};
|
||||
|
||||
//item.ConfigVersion = vmessQRCode.v;
|
||||
item.Remarks = Utils.ToString(vmessQRCode.ps);
|
||||
@@ -84,15 +112,30 @@ public class VmessFmt : BaseFmt
|
||||
});
|
||||
if (vmessQRCode.net.IsNotEmpty())
|
||||
{
|
||||
item.Network = vmessQRCode.net;
|
||||
item.Network = vmessQRCode.net == Global.RawNetworkAlias ? nameof(ETransport.raw) : vmessQRCode.net;
|
||||
}
|
||||
if (vmessQRCode.type.IsNotEmpty())
|
||||
{
|
||||
item.HeaderType = vmessQRCode.type;
|
||||
transport = item.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => transport with { RawHeaderType = vmessQRCode.type },
|
||||
nameof(ETransport.kcp) => transport with { KcpHeaderType = vmessQRCode.type },
|
||||
nameof(ETransport.xhttp) => transport with { XhttpMode = vmessQRCode.type },
|
||||
nameof(ETransport.grpc) => transport with { GrpcMode = vmessQRCode.type },
|
||||
_ => transport,
|
||||
};
|
||||
}
|
||||
|
||||
item.RequestHost = Utils.ToString(vmessQRCode.host);
|
||||
item.Path = Utils.ToString(vmessQRCode.path);
|
||||
transport = item.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||
nameof(ETransport.kcp) => transport with { KcpSeed = Utils.ToString(vmessQRCode.path) },
|
||||
nameof(ETransport.ws) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||
nameof(ETransport.httpupgrade) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||
nameof(ETransport.xhttp) => transport with { Host = Utils.ToString(vmessQRCode.host), Path = Utils.ToString(vmessQRCode.path) },
|
||||
nameof(ETransport.grpc) => transport with { GrpcAuthority = Utils.ToString(vmessQRCode.host), GrpcServiceName = Utils.ToString(vmessQRCode.path) },
|
||||
_ => transport,
|
||||
};
|
||||
item.SetTransportExtra(transport);
|
||||
item.StreamSecurity = Utils.ToString(vmessQRCode.tls);
|
||||
item.Sni = Utils.ToString(vmessQRCode.sni);
|
||||
item.Alpn = Utils.ToString(vmessQRCode.alpn);
|
||||
@@ -122,7 +165,7 @@ public class VmessFmt : BaseFmt
|
||||
|
||||
item.SetProtocolExtra(new ProtocolExtraItem
|
||||
{
|
||||
VmessSecurity = "auto",
|
||||
VmessSecurity = Global.DefaultSecurity,
|
||||
});
|
||||
|
||||
var query = Utils.ParseQueryString(url.Query);
|
||||
|
||||
@@ -27,9 +27,10 @@ public class WireguardFmt : BaseFmt
|
||||
item.SetProtocolExtra(item.GetProtocolExtra() with
|
||||
{
|
||||
WgPublicKey = GetQueryDecoded(query, "publickey"),
|
||||
WgPresharedKey = GetQueryDecoded(query, "presharedkey"),
|
||||
WgReserved = GetQueryDecoded(query, "reserved"),
|
||||
WgInterfaceAddress = GetQueryDecoded(query, "address"),
|
||||
WgMtu = int.TryParse(GetQueryDecoded(query, "mtu"), out var mtuVal) ? mtuVal : 1280,
|
||||
WgMtu = int.TryParse(GetQueryDecoded(query, "mtu"), out var mtuVal) ? mtuVal : null,
|
||||
});
|
||||
|
||||
return item;
|
||||
@@ -48,20 +49,183 @@ public class WireguardFmt : BaseFmt
|
||||
remark = "#" + Utils.UrlEncode(item.Remarks);
|
||||
}
|
||||
|
||||
var protoExtra = item.GetProtocolExtra();
|
||||
var dicQuery = new Dictionary<string, string>();
|
||||
if (!item.GetProtocolExtra().WgPublicKey.IsNullOrEmpty())
|
||||
if (!protoExtra.WgPublicKey.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("publickey", Utils.UrlEncode(item.GetProtocolExtra().WgPublicKey));
|
||||
dicQuery.Add("publickey", Utils.UrlEncode(protoExtra.WgPublicKey));
|
||||
}
|
||||
if (!item.GetProtocolExtra().WgReserved.IsNullOrEmpty())
|
||||
if (!protoExtra.WgPresharedKey.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("reserved", Utils.UrlEncode(item.GetProtocolExtra().WgReserved));
|
||||
dicQuery.Add("presharedkey", Utils.UrlEncode(protoExtra.WgPresharedKey));
|
||||
}
|
||||
if (!item.GetProtocolExtra().WgInterfaceAddress.IsNullOrEmpty())
|
||||
if (!protoExtra.WgReserved.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("address", Utils.UrlEncode(item.GetProtocolExtra().WgInterfaceAddress));
|
||||
dicQuery.Add("reserved", Utils.UrlEncode(protoExtra.WgReserved));
|
||||
}
|
||||
if (!protoExtra.WgInterfaceAddress.IsNullOrEmpty())
|
||||
{
|
||||
dicQuery.Add("address", Utils.UrlEncode(protoExtra.WgInterfaceAddress));
|
||||
}
|
||||
if (protoExtra.WgMtu > 0)
|
||||
{
|
||||
dicQuery.Add("mtu", protoExtra.WgMtu.ToString());
|
||||
}
|
||||
dicQuery.Add("mtu", Utils.UrlEncode(item.GetProtocolExtra().WgMtu > 0 ? item.GetProtocolExtra().WgMtu.ToString() : "1280"));
|
||||
return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Password, dicQuery, remark);
|
||||
}
|
||||
|
||||
public static List<ProfileItem>? ResolveConfig(string strData)
|
||||
{
|
||||
var interfaceDic = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
var peerDicList = new List<Dictionary<string, string>>();
|
||||
var currentDicRef = interfaceDic;
|
||||
using (var reader = new StringReader(strData))
|
||||
{
|
||||
while (reader.ReadLine() is { } line)
|
||||
{
|
||||
if (line.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var trimmedLine = line.Trim();
|
||||
|
||||
if (trimmedLine.Equals("[Interface]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
currentDicRef = interfaceDic;
|
||||
continue;
|
||||
}
|
||||
if (trimmedLine.Equals("[Peer]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var peerDic = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
peerDicList.Add(peerDic);
|
||||
currentDicRef = peerDic;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trimmedLine.StartsWith('[') || trimmedLine.StartsWith('#') || trimmedLine.StartsWith(';'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var idx = line.IndexOf('=');
|
||||
if (idx <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = line[..idx].Trim();
|
||||
var value = line[(idx + 1)..].Trim();
|
||||
var commentPos = value.IndexOfAny(['#', ';']);
|
||||
if (commentPos >= 0)
|
||||
{
|
||||
value = value[..commentPos].TrimEnd();
|
||||
}
|
||||
|
||||
currentDicRef[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!interfaceDic.TryGetValue("PrivateKey", out var privateKey) || privateKey.IsNullOrEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var wgMtu = interfaceDic.TryGetValue("MTU", out var mtuStr) && int.TryParse(mtuStr, out var mtuVal) ? mtuVal : 0;
|
||||
var wgInterfaceAddress = interfaceDic.TryGetValue("Address", out var interfaceAddress) ? interfaceAddress : string.Empty;
|
||||
|
||||
var index = 0;
|
||||
var resultList = new List<ProfileItem>();
|
||||
|
||||
foreach (var peerDic in peerDicList)
|
||||
{
|
||||
if (!peerDic.TryGetValue("Endpoint", out var endpoint) || endpoint.IsNullOrEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!TryParseEndpoint(endpoint, out var peerAddress, out var peerPort))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var protoExtra = new ProtocolExtraItem
|
||||
{
|
||||
WgPublicKey = (peerDic.TryGetValue("PublicKey", out var publicKey) ? publicKey : string.Empty).NullIfEmpty(),
|
||||
WgPresharedKey = (peerDic.TryGetValue("PresharedKey", out var presharedKey) ? presharedKey : string.Empty).NullIfEmpty(),
|
||||
WgInterfaceAddress = wgInterfaceAddress,
|
||||
WgReserved = (peerDic.TryGetValue("Reserved", out var reserved) ? reserved : string.Empty).NullIfEmpty(),
|
||||
WgMtu = wgMtu > 0 ? wgMtu : null,
|
||||
};
|
||||
|
||||
var item = new ProfileItem
|
||||
{
|
||||
Remarks = $"{nameof(EConfigType.WireGuard)} Peer {index + 1}",
|
||||
ConfigType = EConfigType.WireGuard,
|
||||
Address = peerAddress,
|
||||
Port = peerPort,
|
||||
Password = privateKey,
|
||||
};
|
||||
item.SetProtocolExtra(protoExtra);
|
||||
resultList.Add(item);
|
||||
|
||||
index += 1;
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private static bool TryParseEndpoint(string endpoint, out string address, out int port)
|
||||
{
|
||||
address = string.Empty;
|
||||
port = 2408;
|
||||
|
||||
var trimmedEndpoint = endpoint.Trim();
|
||||
if (trimmedEndpoint.IsNullOrEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trimmedEndpoint[0] == '[')
|
||||
{
|
||||
var closeIndex = trimmedEndpoint.IndexOf(']');
|
||||
if (closeIndex <= 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
address = trimmedEndpoint[1..closeIndex].Trim();
|
||||
var portIndex = closeIndex + 1;
|
||||
if (portIndex < trimmedEndpoint.Length && trimmedEndpoint[portIndex] == ':' &&
|
||||
int.TryParse(trimmedEndpoint[(portIndex + 1)..].Trim(), out var bracketedPort) && bracketedPort is > 0 and <= 65535)
|
||||
{
|
||||
port = bracketedPort;
|
||||
}
|
||||
|
||||
return address.IsNotEmpty();
|
||||
}
|
||||
|
||||
var lastColonIndex = trimmedEndpoint.LastIndexOf(':');
|
||||
if (lastColonIndex <= 0)
|
||||
{
|
||||
address = trimmedEndpoint;
|
||||
return true;
|
||||
}
|
||||
|
||||
address = trimmedEndpoint[..lastColonIndex].Trim();
|
||||
var portText = trimmedEndpoint[(lastColonIndex + 1)..].Trim();
|
||||
if (address.IsNullOrEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (int.TryParse(portText, out var parsedPortValue) && parsedPortValue is > 0 and <= 65535)
|
||||
{
|
||||
port = parsedPortValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
address = trimmedEndpoint;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,12 +305,19 @@ public sealed class AppManager
|
||||
return await SQLiteHelper.Instance.TableAsync<FullConfigTemplateItem>().FirstOrDefaultAsync(it => it.CoreType == eCoreType);
|
||||
}
|
||||
|
||||
public async Task MigrateProfileExtra()
|
||||
{
|
||||
await MigrateProfileExtraGroup();
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
public async Task MigrateProfileExtra()
|
||||
{
|
||||
await MigrateProfileExtraGroupV2ToV3();
|
||||
|
||||
await MigrateProfileExtraV2ToV3();
|
||||
|
||||
await MigrateProfileTransportV3ToV4();
|
||||
}
|
||||
|
||||
private async Task MigrateProfileExtraV2ToV3()
|
||||
{
|
||||
const int pageSize = 100;
|
||||
var offset = 0;
|
||||
|
||||
@@ -326,7 +333,7 @@ public sealed class AppManager
|
||||
break;
|
||||
}
|
||||
|
||||
var batchSuccessCount = await MigrateProfileExtraSub(batch);
|
||||
var batchSuccessCount = await MigrateProfileExtraV2ToV3Sub(batch);
|
||||
|
||||
// Only increment offset by the number of failed items that remain in the result set
|
||||
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
|
||||
@@ -334,10 +341,122 @@ public sealed class AppManager
|
||||
}
|
||||
|
||||
//await ProfileGroupItemManager.Instance.ClearAll();
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
private async Task<int> MigrateProfileExtraSub(List<ProfileItem> batch)
|
||||
private async Task MigrateProfileTransportV3ToV4()
|
||||
{
|
||||
const int pageSize = 100;
|
||||
var offset = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var sql = $"SELECT * FROM ProfileItem WHERE ConfigVersion = 3 LIMIT {pageSize} OFFSET {offset}";
|
||||
var batch = await SQLiteHelper.Instance.QueryAsync<ProfileItem>(sql);
|
||||
if (batch is null || batch.Count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var updateProfileItems = new List<ProfileItem>();
|
||||
foreach (var item in batch)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (item.Network == Global.RawNetworkAlias)
|
||||
{
|
||||
item.Network = nameof(ETransport.raw);
|
||||
}
|
||||
var transport = item.GetTransportExtra();
|
||||
var network = item.GetNetwork();
|
||||
|
||||
switch (network)
|
||||
{
|
||||
case nameof(ETransport.raw):
|
||||
transport = transport with
|
||||
{
|
||||
RawHeaderType = item.HeaderType.NullIfEmpty(),
|
||||
Host = item.RequestHost.NullIfEmpty(),
|
||||
Path = item.Path.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
case nameof(ETransport.httpupgrade):
|
||||
transport = transport with
|
||||
{
|
||||
Host = item.RequestHost.NullIfEmpty(),
|
||||
Path = item.Path.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.xhttp):
|
||||
transport = transport with
|
||||
{
|
||||
Host = item.RequestHost.NullIfEmpty(),
|
||||
Path = item.Path.NullIfEmpty(),
|
||||
XhttpMode = item.HeaderType.NullIfEmpty(),
|
||||
XhttpExtra = item.Extra.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
transport = transport with
|
||||
{
|
||||
GrpcAuthority = item.RequestHost.NullIfEmpty(),
|
||||
GrpcServiceName = item.Path.NullIfEmpty(),
|
||||
GrpcMode = item.HeaderType.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
|
||||
case nameof(ETransport.kcp):
|
||||
transport = transport with
|
||||
{
|
||||
KcpHeaderType = item.HeaderType.NullIfEmpty(),
|
||||
KcpSeed = item.Path.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
item.Network = Global.DefaultNetwork;
|
||||
transport = transport with
|
||||
{
|
||||
RawHeaderType = item.HeaderType.NullIfEmpty(),
|
||||
Host = item.RequestHost.NullIfEmpty(),
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
item.SetTransportExtra(transport);
|
||||
item.ConfigVersion = 4;
|
||||
updateProfileItems.Add(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog($"MigrateProfileTransportV3ToV4 Error: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
if (updateProfileItems.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = await SQLiteHelper.Instance.UpdateAllAsync(updateProfileItems);
|
||||
offset += batch.Count - count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog($"MigrateProfileTransportV3ToV4 update error: {ex}");
|
||||
offset += batch.Count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
offset += batch.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<int> MigrateProfileExtraV2ToV3Sub(List<ProfileItem> batch)
|
||||
{
|
||||
var updateProfileItems = new List<ProfileItem>();
|
||||
|
||||
@@ -380,6 +499,7 @@ public sealed class AppManager
|
||||
break;
|
||||
|
||||
case EConfigType.TUIC:
|
||||
extra = extra with { CongestionControl = item.HeaderType.NullIfEmpty(), };
|
||||
item.Username = item.Id;
|
||||
item.Id = item.Security;
|
||||
item.Password = item.Security;
|
||||
@@ -434,9 +554,8 @@ public sealed class AppManager
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> MigrateProfileExtraGroup()
|
||||
private async Task<bool> MigrateProfileExtraGroupV2ToV3()
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
||||
var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
||||
|
||||
@@ -501,9 +620,10 @@ public sealed class AppManager
|
||||
return true;
|
||||
|
||||
//await ProfileGroupItemManager.Instance.ClearAll();
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
#pragma warning restore CS0618
|
||||
|
||||
#endregion SqliteHelper
|
||||
|
||||
#region Core Type
|
||||
|
||||
@@ -203,7 +203,7 @@ public class CertPemManager
|
||||
/// <summary>
|
||||
/// Get certificate in PEM format from a server with CA pinning validation
|
||||
/// </summary>
|
||||
public async Task<(string?, string?)> GetCertPemAsync(string target, string serverName, int timeout = 4)
|
||||
public async Task<(string?, string?)> GetCertPemAsync(string target, string serverName, int timeout = 4, bool allowInsecure = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -215,12 +215,14 @@ public class CertPemManager
|
||||
using var client = new TcpClient();
|
||||
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
||||
|
||||
await using var ssl = new SslStream(client.GetStream(), false, ValidateServerCertificate);
|
||||
var callback = new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) =>
|
||||
ValidateServerCertificate(sender, certificate, chain, sslPolicyErrors, allowInsecure));
|
||||
await using var ssl = new SslStream(client.GetStream(), false, callback);
|
||||
|
||||
var sslOptions = new SslClientAuthenticationOptions
|
||||
{
|
||||
TargetHost = serverName,
|
||||
RemoteCertificateValidationCallback = ValidateServerCertificate
|
||||
RemoteCertificateValidationCallback = callback
|
||||
};
|
||||
|
||||
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
||||
@@ -249,7 +251,7 @@ public class CertPemManager
|
||||
/// <summary>
|
||||
/// Get certificate chain in PEM format from a server with CA pinning validation
|
||||
/// </summary>
|
||||
public async Task<(List<string>, string?)> GetCertChainPemAsync(string target, string serverName, int timeout = 4)
|
||||
public async Task<(List<string>, string?)> GetCertChainPemAsync(string target, string serverName, int timeout = 4, bool allowInsecure = false)
|
||||
{
|
||||
var pemList = new List<string>();
|
||||
try
|
||||
@@ -262,12 +264,14 @@ public class CertPemManager
|
||||
using var client = new TcpClient();
|
||||
await client.ConnectAsync(domain, port > 0 ? port : 443, cts.Token);
|
||||
|
||||
await using var ssl = new SslStream(client.GetStream(), false, ValidateServerCertificate);
|
||||
var callback = new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) =>
|
||||
ValidateServerCertificate(sender, certificate, chain, sslPolicyErrors, allowInsecure));
|
||||
await using var ssl = new SslStream(client.GetStream(), false, callback);
|
||||
|
||||
var sslOptions = new SslClientAuthenticationOptions
|
||||
{
|
||||
TargetHost = serverName,
|
||||
RemoteCertificateValidationCallback = ValidateServerCertificate
|
||||
RemoteCertificateValidationCallback = callback
|
||||
};
|
||||
|
||||
await ssl.AuthenticateAsClientAsync(sslOptions, cts.Token);
|
||||
@@ -300,16 +304,23 @@ public class CertPemManager
|
||||
/// Validate server certificate with CA pinning
|
||||
/// </summary>
|
||||
private bool ValidateServerCertificate(
|
||||
object sender,
|
||||
object _,
|
||||
X509Certificate? certificate,
|
||||
X509Chain? chain,
|
||||
SslPolicyErrors sslPolicyErrors)
|
||||
SslPolicyErrors sslPolicyErrors,
|
||||
bool allowInsecure)
|
||||
{
|
||||
if (certificate == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// In insecure mode, accept any certificate so self-signed certs can be fetched.
|
||||
if (allowInsecure)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check certificate name mismatch
|
||||
if (sslPolicyErrors.HasFlag(SslPolicyErrors.RemoteCertificateNameMismatch))
|
||||
{
|
||||
|
||||
@@ -68,6 +68,7 @@ public sealed class CoreInfoManager
|
||||
DownloadUrlWinArm64 = urlN + "/download/{0}/v2rayN-windows-arm64.zip",
|
||||
DownloadUrlLinux64 = urlN + "/download/{0}/v2rayN-linux-64.zip",
|
||||
DownloadUrlLinuxArm64 = urlN + "/download/{0}/v2rayN-linux-arm64.zip",
|
||||
DownloadUrlLinuxRiscV64 = urlN + "/download/{0}/v2rayN-linux-riscv64.zip",
|
||||
DownloadUrlOSX64 = urlN + "/download/{0}/v2rayN-macos-64.zip",
|
||||
DownloadUrlOSXArm64 = urlN + "/download/{0}/v2rayN-macos-arm64.zip",
|
||||
},
|
||||
@@ -111,6 +112,7 @@ public sealed class CoreInfoManager
|
||||
DownloadUrlWinArm64 = urlXray + "/download/{0}/Xray-windows-arm64-v8a.zip",
|
||||
DownloadUrlLinux64 = urlXray + "/download/{0}/Xray-linux-64.zip",
|
||||
DownloadUrlLinuxArm64 = urlXray + "/download/{0}/Xray-linux-arm64-v8a.zip",
|
||||
DownloadUrlLinuxRiscV64 = urlXray + "/download/{0}/Xray-linux-riscv64.zip",
|
||||
DownloadUrlOSX64 = urlXray + "/download/{0}/Xray-macos-64.zip",
|
||||
DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip",
|
||||
Match = "Xray",
|
||||
@@ -133,6 +135,7 @@ public sealed class CoreInfoManager
|
||||
DownloadUrlWinArm64 = urlMihomo + "/download/{0}/mihomo-windows-arm64-{0}.zip",
|
||||
DownloadUrlLinux64 = urlMihomo + "/download/{0}/mihomo-linux-amd64-v1-{0}.gz",
|
||||
DownloadUrlLinuxArm64 = urlMihomo + "/download/{0}/mihomo-linux-arm64-{0}.gz",
|
||||
DownloadUrlLinuxRiscV64 = urlMihomo + "/download/{0}/mihomo-linux-riscv64-{0}.gz",
|
||||
DownloadUrlOSX64 = urlMihomo + "/download/{0}/mihomo-darwin-amd64-v1-{0}.gz",
|
||||
DownloadUrlOSXArm64 = urlMihomo + "/download/{0}/mihomo-darwin-arm64-{0}.gz",
|
||||
Match = "Mihomo",
|
||||
@@ -175,6 +178,7 @@ public sealed class CoreInfoManager
|
||||
DownloadUrlWinArm64 = urlSingbox + "/download/{0}/sing-box-{1}-windows-arm64.zip",
|
||||
DownloadUrlLinux64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-amd64.tar.gz",
|
||||
DownloadUrlLinuxArm64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-arm64.tar.gz",
|
||||
DownloadUrlLinuxRiscV64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-riscv64.tar.gz",
|
||||
DownloadUrlOSX64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-amd64.tar.gz",
|
||||
DownloadUrlOSXArm64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-arm64.tar.gz",
|
||||
Match = "sing-box",
|
||||
@@ -265,6 +269,7 @@ public sealed class CoreInfoManager
|
||||
names.Add("mihomo-linux-amd64-v1");
|
||||
names.Add("mihomo-linux-amd64");
|
||||
names.Add("mihomo-linux-arm64");
|
||||
names.Add("mihomo-linux-riscv64");
|
||||
}
|
||||
else if (Utils.IsMacOS())
|
||||
{
|
||||
|
||||
@@ -90,6 +90,9 @@ public class CoreManager
|
||||
|
||||
await CoreStart(mainContext);
|
||||
await CoreStartPreService(preContext);
|
||||
|
||||
AppManager.Instance.RunningCoreType = preContext?.RunCoreType ?? mainContext.RunCoreType;
|
||||
|
||||
if (_processService != null)
|
||||
{
|
||||
await UpdateFunc(true, $"{node.GetSummary()}");
|
||||
@@ -172,7 +175,7 @@ public class CoreManager
|
||||
private async Task CoreStart(CoreConfigContext context)
|
||||
{
|
||||
var node = context.Node;
|
||||
var coreType = AppManager.Instance.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||
|
||||
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
||||
|
||||
@@ -15,6 +15,10 @@ public class CoreBasicItem
|
||||
|
||||
public string DefUserAgent { get; set; }
|
||||
|
||||
public string? SendThrough { get; set; }
|
||||
|
||||
public string? BindInterface { get; set; }
|
||||
|
||||
public bool EnableFragment { get; set; }
|
||||
|
||||
public bool EnableCacheFile4Sbox { get; set; } = true;
|
||||
@@ -47,11 +51,9 @@ public class KcpItem
|
||||
|
||||
public int DownlinkCapacity { get; set; }
|
||||
|
||||
public bool Congestion { get; set; }
|
||||
public int CwndMultiplier { get; set; }
|
||||
|
||||
public int ReadBufferSize { get; set; }
|
||||
|
||||
public int WriteBufferSize { get; set; }
|
||||
public int MaxSendingWindow { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -144,6 +146,8 @@ public class TunModeItem
|
||||
public string Stack { get; set; }
|
||||
public int Mtu { get; set; }
|
||||
public bool EnableIPv6Address { get; set; }
|
||||
public string IcmpRouting { get; set; }
|
||||
public bool EnableLegacyProtect { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -154,6 +158,7 @@ public class SpeedTestItem
|
||||
public string SpeedPingTestUrl { get; set; }
|
||||
public int MixedConcurrencyCount { get; set; }
|
||||
public string IPAPIUrl { get; set; }
|
||||
public string UdpTestTarget { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -193,7 +198,7 @@ public class HysteriaItem
|
||||
{
|
||||
public int UpMbps { get; set; }
|
||||
public int DownMbps { get; set; }
|
||||
public int HopInterval { get; set; } = 30;
|
||||
public int HopInterval { get; set; } = Global.Hysteria2DefaultHopInt;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -16,10 +16,8 @@ public record CoreConfigContext
|
||||
|
||||
// TUN Compatibility
|
||||
public bool IsTunEnabled { get; init; } = false;
|
||||
public HashSet<string> ProtectDomainList { get; init; } = new();
|
||||
// -> tun inbound --(if routing proxy)--> relay outbound
|
||||
// -> proxy core (relay inbound --> proxy outbound --(dialerProxy)--> protect outbound)
|
||||
// -> protect inbound -> direct proxy outbound data -> internet
|
||||
public int TunProtectSsPort { get; init; } = 0;
|
||||
public int ProxyRelaySsPort { get; init; } = 0;
|
||||
public HashSet<string> ProtectDomainList { get; init; } = [];
|
||||
|
||||
public bool IsWindows { get; init; }
|
||||
public bool IsMacOS { get; init; }
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class CoreInfo
|
||||
public string? DownloadUrlWinArm64 { get; set; }
|
||||
public string? DownloadUrlLinux64 { get; set; }
|
||||
public string? DownloadUrlLinuxArm64 { get; set; }
|
||||
public string? DownloadUrlLinuxRiscV64 { get; set; }
|
||||
public string? DownloadUrlOSX64 { get; set; }
|
||||
public string? DownloadUrlOSXArm64 { get; set; }
|
||||
public string? Match { get; set; }
|
||||
|
||||
@@ -4,12 +4,13 @@ namespace ServiceLib.Models;
|
||||
public class ProfileItem
|
||||
{
|
||||
private ProtocolExtraItem? _protocolExtraCache;
|
||||
private TransportExtraItem? _transportExtraCache;
|
||||
|
||||
public ProfileItem()
|
||||
{
|
||||
IndexId = string.Empty;
|
||||
ConfigType = EConfigType.VMess;
|
||||
ConfigVersion = 3;
|
||||
ConfigVersion = 4;
|
||||
Subid = string.Empty;
|
||||
Address = string.Empty;
|
||||
Port = 0;
|
||||
@@ -17,9 +18,6 @@ public class ProfileItem
|
||||
Username = string.Empty;
|
||||
Network = string.Empty;
|
||||
Remarks = string.Empty;
|
||||
HeaderType = string.Empty;
|
||||
RequestHost = string.Empty;
|
||||
Path = string.Empty;
|
||||
StreamSecurity = string.Empty;
|
||||
AllowInsecure = string.Empty;
|
||||
}
|
||||
@@ -126,20 +124,26 @@ public class ProfileItem
|
||||
return true;
|
||||
}
|
||||
|
||||
public ProtocolExtraItem GetProtocolExtra()
|
||||
{
|
||||
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
||||
}
|
||||
|
||||
public void SetProtocolExtra(ProtocolExtraItem extraItem)
|
||||
{
|
||||
_protocolExtraCache = extraItem;
|
||||
ProtoExtra = JsonUtils.Serialize(extraItem, false);
|
||||
}
|
||||
|
||||
public void SetProtocolExtra()
|
||||
public TransportExtraItem GetTransportExtra()
|
||||
{
|
||||
ProtoExtra = JsonUtils.Serialize(_protocolExtraCache, false);
|
||||
return _transportExtraCache ??= JsonUtils.Deserialize<TransportExtraItem>(TransportExtra) ?? new TransportExtraItem();
|
||||
}
|
||||
|
||||
public ProtocolExtraItem GetProtocolExtra()
|
||||
public void SetTransportExtra(TransportExtraItem transportExtra)
|
||||
{
|
||||
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
|
||||
_transportExtraCache = transportExtra;
|
||||
TransportExtra = JsonUtils.Serialize(transportExtra, false);
|
||||
}
|
||||
|
||||
#endregion function
|
||||
@@ -160,9 +164,16 @@ public class ProfileItem
|
||||
public string Password { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Network { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.RawHeaderType/XhttpMode/GrpcMode/KcpHeaderType instead.")]
|
||||
public string HeaderType { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.Host/GrpcAuthority instead.")]
|
||||
public string RequestHost { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.Path/GrpcServiceName/KcpSeed instead.")]
|
||||
public string Path { get; set; }
|
||||
|
||||
public string StreamSecurity { get; set; }
|
||||
public string AllowInsecure { get; set; }
|
||||
public string Sni { get; set; }
|
||||
@@ -172,15 +183,18 @@ public class ProfileItem
|
||||
public string ShortId { get; set; }
|
||||
public string SpiderX { get; set; }
|
||||
public string Mldsa65Verify { get; set; }
|
||||
|
||||
[Obsolete("Use TransportExtra.XhttpExtra instead.")]
|
||||
public string Extra { get; set; }
|
||||
|
||||
public bool? MuxEnabled { get; set; }
|
||||
public string Cert { get; set; }
|
||||
public string CertSha { get; set; }
|
||||
public string EchConfigList { get; set; }
|
||||
public string EchForceQuery { get; set; }
|
||||
public string Finalmask { get; set; }
|
||||
|
||||
public string ProtoExtra { get; set; }
|
||||
public string TransportExtra { get; set; }
|
||||
|
||||
[Obsolete("Use ProtocolExtraItem.Ports instead.")]
|
||||
public string Ports { get; set; }
|
||||
|
||||
@@ -2,6 +2,9 @@ namespace ServiceLib.Models;
|
||||
|
||||
public record ProtocolExtraItem
|
||||
{
|
||||
public bool? Uot { get; init; }
|
||||
public string? CongestionControl { get; init; }
|
||||
|
||||
// vmess
|
||||
public string? AlterId { get; init; }
|
||||
public string? VmessSecurity { get; init; }
|
||||
@@ -29,6 +32,10 @@ public record ProtocolExtraItem
|
||||
public string? Ports { get; init; }
|
||||
public string? HopInterval { get; init; }
|
||||
|
||||
// naiveproxy
|
||||
public int? InsecureConcurrency { get; init; }
|
||||
public bool? NaiveQuic { get; init; }
|
||||
|
||||
// group profile
|
||||
public string? GroupType { get; init; }
|
||||
public string? ChildItems { get; init; }
|
||||
|
||||
@@ -134,10 +134,14 @@ public class Outbound4Sbox : BaseServer4Sbox
|
||||
public int? recv_window_conn { get; set; }
|
||||
public int? recv_window { get; set; }
|
||||
public bool? disable_mtu_discovery { get; set; }
|
||||
public int? insecure_concurrency { get; set; }
|
||||
public bool? udp_over_tcp { get; set; }
|
||||
public string? method { get; set; }
|
||||
public string? username { get; set; }
|
||||
public string? password { get; set; }
|
||||
public string? congestion_control { get; set; }
|
||||
public bool? quic { get; set; }
|
||||
public string? quic_congestion_control { get; set; }
|
||||
public string? version { get; set; }
|
||||
public string? network { get; set; }
|
||||
public string? packet_encoding { get; set; }
|
||||
@@ -169,7 +173,7 @@ public class Peer4Sbox
|
||||
public string? pre_shared_key { get; set; }
|
||||
public List<string> allowed_ips { get; set; }
|
||||
public int? persistent_keepalive_interval { get; set; }
|
||||
public List<int> reserved { get; set; }
|
||||
public List<int>? reserved { get; set; }
|
||||
}
|
||||
|
||||
public class Tls4Sbox
|
||||
@@ -233,6 +237,9 @@ public class Transport4Sbox
|
||||
public class Headers4Sbox
|
||||
{
|
||||
public string? Host { get; set; }
|
||||
|
||||
[JsonPropertyName("User-Agent")]
|
||||
public string UserAgent { get; set; }
|
||||
}
|
||||
|
||||
public class HyObfs4Sbox
|
||||
@@ -255,14 +262,6 @@ public class Server4Sbox : BaseServer4Sbox
|
||||
|
||||
// public List<string>? path { get; set; } // hosts
|
||||
public Dictionary<string, List<string>>? predefined { get; set; }
|
||||
|
||||
// Deprecated in sing-box 1.12.0 , kept for backward compatibility
|
||||
public string? address { get; set; }
|
||||
|
||||
public string? address_resolver { get; set; }
|
||||
public string? address_strategy { get; set; }
|
||||
public string? strategy { get; set; }
|
||||
// Deprecated End
|
||||
}
|
||||
|
||||
public class Experimental4Sbox
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace ServiceLib.Models;
|
||||
|
||||
public record TransportExtraItem
|
||||
{
|
||||
public string? RawHeaderType { get; init; }
|
||||
|
||||
public string? Host { get; init; }
|
||||
public string? Path { get; init; }
|
||||
public string? XhttpMode { get; init; }
|
||||
public string? XhttpExtra { get; init; }
|
||||
|
||||
public string? GrpcAuthority { get; init; }
|
||||
public string? GrpcServiceName { get; init; }
|
||||
public string? GrpcMode { get; init; }
|
||||
|
||||
public string? KcpHeaderType { get; init; }
|
||||
public string? KcpSeed { get; init; }
|
||||
public int? KcpMtu { get; init; }
|
||||
}
|
||||
@@ -47,9 +47,9 @@ public class Inbounds4Ray
|
||||
{
|
||||
public string tag { get; set; }
|
||||
|
||||
public int port { get; set; }
|
||||
public int? port { get; set; }
|
||||
|
||||
public string listen { get; set; }
|
||||
public string? listen { get; set; }
|
||||
|
||||
public string protocol { get; set; }
|
||||
|
||||
@@ -75,6 +75,18 @@ public class Inboundsettings4Ray
|
||||
public bool? allowTransparent { get; set; }
|
||||
|
||||
public List<AccountsItem4Ray>? accounts { get; set; }
|
||||
|
||||
public string? name { get; set; }
|
||||
|
||||
public int? MTU { get; set; }
|
||||
|
||||
public List<string>? gateway { get; set; }
|
||||
|
||||
public List<string>? autoSystemRoutingTable { get; set; }
|
||||
|
||||
public string? autoOutboundsInterface { get; set; }
|
||||
|
||||
// public List<string>? dns { get; set; }
|
||||
}
|
||||
|
||||
public class UsersItem4Ray
|
||||
@@ -105,6 +117,8 @@ public class Outbounds4Ray
|
||||
|
||||
public string protocol { get; set; }
|
||||
|
||||
public string? sendThrough { get; set; }
|
||||
|
||||
public string? targetStrategy { get; set; }
|
||||
|
||||
public Outboundsettings4Ray settings { get; set; }
|
||||
@@ -126,11 +140,10 @@ public class Outboundsettings4Ray
|
||||
|
||||
public int? userLevel { get; set; }
|
||||
|
||||
public FragmentItem4Ray? fragment { get; set; }
|
||||
|
||||
public string? secretKey { get; set; }
|
||||
|
||||
public Object? address { get; set; }
|
||||
public object? address { get; set; }
|
||||
|
||||
public int? port { get; set; }
|
||||
|
||||
public List<WireguardPeer4Ray>? peers { get; set; }
|
||||
@@ -150,6 +163,7 @@ public class WireguardPeer4Ray
|
||||
{
|
||||
public string endpoint { get; set; }
|
||||
public string publicKey { get; set; }
|
||||
public string? preSharedKey { get; set; }
|
||||
}
|
||||
|
||||
public class VnextItem4Ray
|
||||
@@ -179,6 +193,8 @@ public class ServersItem4Ray
|
||||
|
||||
public string flow { get; set; }
|
||||
|
||||
public bool? uot { get; set; }
|
||||
|
||||
public List<SocksUsersItem4Ray> users { get; set; }
|
||||
}
|
||||
|
||||
@@ -315,7 +331,7 @@ public class StreamSettings4Ray
|
||||
|
||||
public TlsSettings4Ray? tlsSettings { get; set; }
|
||||
|
||||
public TcpSettings4Ray? tcpSettings { get; set; }
|
||||
public RawSettings4Ray? rawSettings { get; set; }
|
||||
|
||||
public KcpSettings4Ray? kcpSettings { get; set; }
|
||||
|
||||
@@ -335,7 +351,7 @@ public class StreamSettings4Ray
|
||||
|
||||
public HysteriaSettings4Ray? hysteriaSettings { get; set; }
|
||||
|
||||
public Finalmask4Ray? finalmask { get; set; }
|
||||
public object? finalmask { get; set; }
|
||||
|
||||
public Sockopt4Ray? sockopt { get; set; }
|
||||
}
|
||||
@@ -369,7 +385,7 @@ public class CertificateSettings4Ray
|
||||
public string? usage { get; set; }
|
||||
}
|
||||
|
||||
public class TcpSettings4Ray
|
||||
public class RawSettings4Ray
|
||||
{
|
||||
public Header4Ray header { get; set; }
|
||||
}
|
||||
@@ -393,11 +409,9 @@ public class KcpSettings4Ray
|
||||
|
||||
public int downlinkCapacity { get; set; }
|
||||
|
||||
public bool congestion { get; set; }
|
||||
public int cwndMultiplier { get; set; }
|
||||
|
||||
public int readBufferSize { get; set; }
|
||||
|
||||
public int writeBufferSize { get; set; }
|
||||
public int maxSendingWindow { get; set; }
|
||||
}
|
||||
|
||||
public class WsSettings4Ray
|
||||
@@ -419,6 +433,8 @@ public class HttpupgradeSettings4Ray
|
||||
public string? path { get; set; }
|
||||
|
||||
public string? host { get; set; }
|
||||
|
||||
public Headers4Ray headers { get; set; }
|
||||
}
|
||||
|
||||
public class XhttpSettings4Ray
|
||||
@@ -454,39 +470,62 @@ public class GrpcSettings4Ray
|
||||
public int? health_check_timeout { get; set; }
|
||||
public bool? permit_without_stream { get; set; }
|
||||
public int? initial_windows_size { get; set; }
|
||||
public string? user_agent { get; set; }
|
||||
}
|
||||
|
||||
public class HysteriaSettings4Ray
|
||||
{
|
||||
public int version { get; set; }
|
||||
public string? auth { get; set; }
|
||||
public string? up { get; set; }
|
||||
public string? down { get; set; }
|
||||
public HysteriaUdpHop4Ray? udphop { get; set; }
|
||||
}
|
||||
|
||||
public class HysteriaUdpHop4Ray
|
||||
public class UdpHop4Ray
|
||||
{
|
||||
public string? port { get; set; }
|
||||
public string? ports { get; set; }
|
||||
public string? interval { get; set; }
|
||||
}
|
||||
|
||||
public class Finalmask4Ray
|
||||
{
|
||||
public List<Mask4Ray>? tcp { get; set; }
|
||||
public List<Mask4Ray>? udp { get; set; }
|
||||
public QuicParams4Ray? quicParams { get; set; }
|
||||
}
|
||||
|
||||
public class Mask4Ray
|
||||
{
|
||||
public string type { get; set; }
|
||||
public object? settings { get; set; }
|
||||
public MaskSettings4Ray? settings { get; set; }
|
||||
}
|
||||
|
||||
public class MaskSettings4Ray
|
||||
{
|
||||
public string? password { get; set; }
|
||||
public string? domain { get; set; }
|
||||
|
||||
// fragment
|
||||
public string? packets { get; set; }
|
||||
|
||||
public string? length { get; set; }
|
||||
public string? delay { get; set; }
|
||||
|
||||
// noise
|
||||
public int? reset { get; set; }
|
||||
|
||||
public List<NoiseMask4Ray>? noise { get; set; }
|
||||
}
|
||||
|
||||
public class NoiseMask4Ray
|
||||
{
|
||||
public string? rand { get; set; }
|
||||
public string? delay { get; set; }
|
||||
}
|
||||
|
||||
public class QuicParams4Ray
|
||||
{
|
||||
public string? congestion { get; set; }
|
||||
public string? brutalUp { get; set; }
|
||||
public string? brutalDown { get; set; }
|
||||
public UdpHop4Ray? udpHop { get; set; }
|
||||
}
|
||||
|
||||
public class AccountsItem4Ray
|
||||
@@ -499,6 +538,9 @@ public class AccountsItem4Ray
|
||||
public class Sockopt4Ray
|
||||
{
|
||||
public string? dialerProxy { get; set; }
|
||||
|
||||
[JsonPropertyName("interface")]
|
||||
public string? Interface { get; set; }
|
||||
}
|
||||
|
||||
public class FragmentItem4Ray
|
||||
|
||||
Generated
+222
-69
@@ -106,7 +106,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please check the Configuration settings first. 的本地化字符串。
|
||||
/// 查找类似 Invalid configuration, please check or reselect 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string CheckServerSettings {
|
||||
get {
|
||||
@@ -222,6 +222,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please fill in the correct IPv4 address for SendThrough. 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string FillCorrectSendThroughIPv4 {
|
||||
get {
|
||||
return ResourceManager.GetString("FillCorrectSendThroughIPv4", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please enter the correct port format. 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -691,7 +700,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add Child 的本地化字符串。
|
||||
/// 查找类似 Add Child 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddChildServer {
|
||||
get {
|
||||
@@ -718,7 +727,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [Hysteria2] 的本地化字符串。
|
||||
/// 查找类似 Add [Hysteria2] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddHysteria2Server {
|
||||
get {
|
||||
@@ -727,7 +736,16 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add Policy Group 的本地化字符串。
|
||||
/// 查找类似 Add [NaïveProxy] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddNaiveServer {
|
||||
get {
|
||||
return ResourceManager.GetString("menuAddNaiveServer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add Policy Group 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddPolicyGroupServer {
|
||||
get {
|
||||
@@ -772,7 +790,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [Shadowsocks] 的本地化字符串。
|
||||
/// 查找类似 Add [Shadowsocks] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddShadowsocksServer {
|
||||
get {
|
||||
@@ -781,7 +799,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [SOCKS] 的本地化字符串。
|
||||
/// 查找类似 Add [SOCKS] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddSocksServer {
|
||||
get {
|
||||
@@ -790,7 +808,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [Trojan] 的本地化字符串。
|
||||
/// 查找类似 Add [Trojan] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddTrojanServer {
|
||||
get {
|
||||
@@ -799,7 +817,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [TUIC] 的本地化字符串。
|
||||
/// 查找类似 Add [TUIC] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddTuicServer {
|
||||
get {
|
||||
@@ -808,7 +826,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [VLESS] 的本地化字符串。
|
||||
/// 查找类似 Add [VLESS] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddVlessServer {
|
||||
get {
|
||||
@@ -817,7 +835,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [VMess] 的本地化字符串。
|
||||
/// 查找类似 Add [VMess] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddVmessServer {
|
||||
get {
|
||||
@@ -826,7 +844,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Add [WireGuard] 的本地化字符串。
|
||||
/// 查找类似 Add [WireGuard] 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuAddWireguardServer {
|
||||
get {
|
||||
@@ -1005,6 +1023,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Export v2rayN Internal Share Link to Clipboard 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuExport2InnerUri {
|
||||
get {
|
||||
return ResourceManager.GetString("menuExport2InnerUri", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Export Share Link to Clipboard 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -1842,6 +1869,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Test Configurations UDP Delay 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string menuUdpTestServer {
|
||||
get {
|
||||
return ResourceManager.GetString("menuUdpTestServer", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 {0} Website 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -2562,6 +2598,24 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Allow insecure cert fetch (self-signed) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbAllowInsecureCertFetch {
|
||||
get {
|
||||
return ResourceManager.GetString("TbAllowInsecureCertFetch", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Only for fetching self-signed certificates. This may expose you to MITM risks. 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbAllowInsecureCertFetchTips {
|
||||
get {
|
||||
return ResourceManager.GetString("TbAllowInsecureCertFetchTips", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 ALPN 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -2652,6 +2706,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Camouflage domain 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbCamouflageDomain {
|
||||
get {
|
||||
return ResourceManager.GetString("TbCamouflageDomain", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Cancel 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -2827,7 +2890,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Supports DNS Object; Click to view documentation 的本地化字符串。
|
||||
/// 查找类似 Please fill in DNS Object; Click to view documentation 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbDnsObjectDoc {
|
||||
get {
|
||||
@@ -2889,15 +2952,6 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 EchForceQuery 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbEchForceQuery {
|
||||
get {
|
||||
return ResourceManager.GetString("TbEchForceQuery", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Edit 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3069,6 +3123,24 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Host 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbHost {
|
||||
get {
|
||||
return ResourceManager.GetString("TbHost", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 ICMP routing policy 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbIcmpRoutingPolicy {
|
||||
get {
|
||||
return ResourceManager.GetString("TbIcmpRoutingPolicy", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 UUID(id) 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3105,6 +3177,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Insecure Concurrency 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbInsecureConcurrency {
|
||||
get {
|
||||
return ResourceManager.GetString("TbInsecureConcurrency", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Most Stable 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3123,6 +3204,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Legacy TUN Protect 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbLegacyProtect {
|
||||
get {
|
||||
return ResourceManager.GetString("TbLegacyProtect", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Address (IPv4, IPv6) 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3141,6 +3231,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 MTU 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbMtu {
|
||||
get {
|
||||
return ResourceManager.GetString("TbMtu", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Transport protocol(network) 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3231,6 +3330,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 PreSharedKey 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbPreSharedKey {
|
||||
get {
|
||||
return ResourceManager.GetString("TbPreSharedKey", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Socks port 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3349,16 +3457,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Camouflage domain(host) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbRequestHost {
|
||||
get {
|
||||
return ResourceManager.GetString("TbRequestHost", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Reserved (2,3,4) 的本地化字符串。
|
||||
/// 查找类似 Reserved 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbReserved {
|
||||
get {
|
||||
@@ -3609,6 +3708,24 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Bind Interface 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsBindInterface {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsBindInterface", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsBindInterfaceTip {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsBindInterfaceTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Users in China region can ignore this item 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -3727,7 +3844,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 This parameter is valid only for tcp/http and ws 的本地化字符串。
|
||||
/// 查找类似 This parameter is valid only for raw/http, ws, gRPC and xhttp 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsDefUserAgentTips {
|
||||
get {
|
||||
@@ -4077,15 +4194,6 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Custom DNS (multiple, separated by commas (,)) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsRemoteDNS {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsRemoteDNS", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Route Only 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -4113,6 +4221,24 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Local outbound address (SendThrough) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsSendThrough {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsSendThrough", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 For multi-interface environments, enter the local machine's IPv4 address 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsSendThroughTip {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsSendThroughTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Set Win10 UWP Loopback 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -4266,15 +4392,6 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 MTU 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsTunMtu {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsTunMtu", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Stack 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -4302,6 +4419,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 UDP Test Url 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsUdpTestUrl {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsUdpTestUrl", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Auth user 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -4491,6 +4617,24 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 UDP over TCP 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbUot {
|
||||
get {
|
||||
return ResourceManager.GetString("TbUot", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Username 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbUsername {
|
||||
get {
|
||||
return ResourceManager.GetString("TbUsername", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Validate Regional Domain IPs 的本地化字符串。
|
||||
/// </summary>
|
||||
@@ -4573,7 +4717,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *Default value tcp 的本地化字符串。
|
||||
/// 查找类似 *Default value raw 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TipNetwork {
|
||||
get {
|
||||
@@ -4591,7 +4735,16 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 XHTTP Extra raw JSON, format: { XHTTP Object } 的本地化字符串。
|
||||
/// 查找类似 XHTTP Extra 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportExtra {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportExtra", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Raw JSON, format: { XHTTP Object } 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportExtraTip {
|
||||
get {
|
||||
@@ -4600,47 +4753,47 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *tcp camouflage type 的本地化字符串。
|
||||
/// 查找类似 raw camouflage type 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportHeaderTypeTip1 {
|
||||
public static string TransportHeaderType1 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportHeaderTypeTip1", resourceCulture);
|
||||
return ResourceManager.GetString("TransportHeaderType1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *kcp camouflage type 的本地化字符串。
|
||||
/// 查找类似 kcp camouflage type 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportHeaderTypeTip2 {
|
||||
public static string TransportHeaderType2 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportHeaderTypeTip2", resourceCulture);
|
||||
return ResourceManager.GetString("TransportHeaderType2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *QUIC camouflage type 的本地化字符串。
|
||||
/// 查找类似 QUIC camouflage type 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportHeaderTypeTip3 {
|
||||
public static string TransportHeaderType3 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportHeaderTypeTip3", resourceCulture);
|
||||
return ResourceManager.GetString("TransportHeaderType3", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *grpc mode 的本地化字符串。
|
||||
/// 查找类似 gRPC mode 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportHeaderTypeTip4 {
|
||||
public static string TransportHeaderType4 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportHeaderTypeTip4", resourceCulture);
|
||||
return ResourceManager.GetString("TransportHeaderType4", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *xhttp mode 的本地化字符串。
|
||||
/// 查找类似 xhttp mode 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportHeaderTypeTip5 {
|
||||
public static string TransportHeaderType5 {
|
||||
get {
|
||||
return ResourceManager.GetString("TransportHeaderTypeTip5", resourceCulture);
|
||||
return ResourceManager.GetString("TransportHeaderType5", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4672,7 +4825,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *grpc service name 的本地化字符串。
|
||||
/// 查找类似 gRPC service name 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportPathTip4 {
|
||||
get {
|
||||
@@ -4726,7 +4879,7 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 *grpc Authority 的本地化字符串。
|
||||
/// 查找类似 gRPC Authority 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TransportRequestHostTip5 {
|
||||
get {
|
||||
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*QUIC key/Kcp seed</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*grpc serviceName</value>
|
||||
<value>gRPC serviceName</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*هاست http جدا شده با کاما (،)</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*QUIC securty</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*tcp camouflage type</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>raw camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*kcp camouflage type</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>kcp camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*QUIC camouflage type</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>QUIC camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*حالت grpc</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>حالت grpc</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>نام مستعار (ملاحظات)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>Camouflage domain(host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>روش رمزگذاری (امنیتی)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>TLS</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*مقدار پیش فرض tcp</value>
|
||||
<value>*مقدار پیش فرض raw</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>نوع هسته</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>مجوز احراز هویت</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>سفارشی DNS (multiple, separated by commas (,))</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>تنظیم کردن Win10 UWP Loopback</value>
|
||||
</data>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>این پارامتر فقط برای tcp/http و ws معتبر است</value>
|
||||
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>FontFamily (نیاز به راه اندازی مجدد)</value>
|
||||
@@ -1068,7 +1062,7 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>پشته شبکه</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
@@ -1081,7 +1075,7 @@
|
||||
<value>کلید خصوصی</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Reserved (2,3,4)</value>
|
||||
<value>Reserved</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>آدرس (IPv4, IPv6)</value>
|
||||
@@ -1102,7 +1096,7 @@
|
||||
<value>پایان تست...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
<value>RPC Authority</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>افزودن سرور [HTTP]</value>
|
||||
@@ -1320,11 +1314,11 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*حالت xhttp</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>حالت xhttp</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>جیسون خام XHTTP Extra, فرمت: { XHTTPObject }</value>
|
||||
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>هنگام بستن پنجره در سینی پنهان شوید</value>
|
||||
@@ -1587,9 +1581,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>Full certificate (chain), PEM format</value>
|
||||
</data>
|
||||
@@ -1680,4 +1671,64 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>Add NaïveProxy</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>Insecure Concurrency</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Username</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP routing policy</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>Camouflage domain</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>Allow insecure cert fetch (self-signed)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Test Configurations UDP Delay</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP Test Url</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Local outbound address (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Bind Interface</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*clé de chiffrement QUIC</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*nom de service gRPC</value>
|
||||
<value>nom de service gRPC</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*hôte http, séparés par des virgules (,)</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*méthode de chiffrement QUIC</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*type de camouflage tcp</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>type de camouflage raw</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*type de camouflage kcp</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>type de camouflage kcp</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*type de camouflage QUIC</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>type de camouflage QUIC</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*mode gRPC</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>mode gRPC</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>Alias (remarks)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>Domaine de camouflage (host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>Méthode de chiffrement (security)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>Sécurité couche transport (TLS)</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*tcp par défaut ; un mauvais choix bloque la connexion</value>
|
||||
<value>*raw par défaut ; un mauvais choix bloque la connexion</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Type de Core</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>Mot de passe d’authentification</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>DNS perso (plusieurs configurables, séparés par virgules)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>Lever la restriction de proxy en boucle locale pour les applications Win10 UWP</value>
|
||||
</data>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>Agent utilisateur (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Valable uniquement pour les protocoles tcp/http et ws</value>
|
||||
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Police actuelle (redémarrage requis)</value>
|
||||
@@ -1065,7 +1059,7 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>Pile de protocoles</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
@@ -1078,7 +1072,7 @@
|
||||
<value>PrivateKey</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Reserved (2,3,4)</value>
|
||||
<value>Reserved</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Address (IPv4,IPv6)</value>
|
||||
@@ -1099,7 +1093,7 @@
|
||||
<value>Arrêt du test en cours...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*Autorité gRPC</value>
|
||||
<value>Autorité gRPC</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>Ajouter [HTTP]</value>
|
||||
@@ -1316,12 +1310,12 @@
|
||||
</data>
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>Le mot de passe sera vérifié en ligne de commande. En cas d’échec ou de dysfonctionnement, redémarrez l’application. Il n’est pas stocké et doit être saisi à chaque redémarrage.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*Mode XHTTP</value>
|
||||
</data>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>Mode XHTTP</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>JSON brut XHTTP Extra, format : { XHTTPObject }</value>
|
||||
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>Masquer dans la barre d’état à la fermeture de la fenêtre</value>
|
||||
@@ -1584,9 +1578,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>Certificat complet (chaîne), format PEM</value>
|
||||
</data>
|
||||
@@ -1621,49 +1612,49 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<value>Finalmask</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeWarning" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} warning: {2}</value>
|
||||
<value>Règle de routage {0} nœud sortant {1} avertissement: {2}</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeError" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} error: {2}. Fallback to proxy node only.</value>
|
||||
<value>Règle {0} nœud VPN sortant {1} erreur : {2}. Repli nœud proxy uniquement.</value>
|
||||
</data>
|
||||
<data name="MsgGroupCycleDependency" xml:space="preserve">
|
||||
<value>Group {0} has a cycle dependency on child node {1}. Skipping this node.</value>
|
||||
<value>Le groupe {0} a une dépendance cyclique avec le nœud enfant {1}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildNodeWarning" xml:space="preserve">
|
||||
<value>Group {0} child node {1} warning: {2}</value>
|
||||
<value>Groupe {0} nœud enfant {1} avertissement : {2}</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildNodeError" xml:space="preserve">
|
||||
<value>Group {0} child node {1} error: {2}. Skipping this node.</value>
|
||||
<value>Groupe {0} nœud enfant {1} erreur : {2}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildGroupNodeWarning" xml:space="preserve">
|
||||
<value>Group {0} child group node {1} warning: {2}</value>
|
||||
<value>Groupe {0} nœud enfant groupe {1} avertissement: {2}</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildGroupNodeError" xml:space="preserve">
|
||||
<value>Group {0} child group node {1} error: {2}. Skipping this node.</value>
|
||||
<value>Groupe {0} nœud groupe enfant {1} erreur: {2}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupNoValidChildNode" xml:space="preserve">
|
||||
<value>Group {0} has no valid child node.</value>
|
||||
<value>Groupe {0} n’a aucun nœud enfant valide.</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleEmptyOutboundTag" xml:space="preserve">
|
||||
<value>Routing rule {0} has an empty outbound tag. Fallback to proxy node only.</value>
|
||||
<value>Règle de routage {0} tag sortant vide. Replié sur le nœud proxy uniquement.</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeNotFound" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} not found. Fallback to proxy node only.</value>
|
||||
<value>Règle de routage {0} nœud sortant {1} introuvable. Repli sur le seul nœud proxy.</value>
|
||||
</data>
|
||||
<data name="MsgSubscriptionPrevProfileNotFound" xml:space="preserve">
|
||||
<value>Subscription previous proxy {0} not found. Skipping.</value>
|
||||
<value>Nœud proxy précédent de l’abonnement {0} introuvable. Ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgSubscriptionNextProfileNotFound" xml:space="preserve">
|
||||
<value>Subscription next proxy {0} not found. Skipping.</value>
|
||||
<value>Nœud proxy suivant de l’abonnement {0} introuvable. Ignoré.</value>
|
||||
</data>
|
||||
<data name="menuGenGroupServer" xml:space="preserve">
|
||||
<value>Generate Policy Group</value>
|
||||
<value>Générer groupe de stratégie</value>
|
||||
</data>
|
||||
<data name="menuAllServers" xml:space="preserve">
|
||||
<value>All configurations</value>
|
||||
<value>Toutes configurations</value>
|
||||
</data>
|
||||
<data name="menuGenRegionGroup" xml:space="preserve">
|
||||
<value>Group by Region</value>
|
||||
<value>Grouper par région</value>
|
||||
</data>
|
||||
<data name="menuEditCopy" xml:space="preserve">
|
||||
<value>Copier</value>
|
||||
@@ -1672,9 +1663,69 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<value>Tout sélect</value>
|
||||
</data>
|
||||
<data name="menuEditPaste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
<value>Coller</value>
|
||||
</data>
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>Ajouter [NaïveProxy]</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>Insecure Concurrency</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Nom d’utilisateur</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>Politique de routage ICMP</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Protection TUN héritée</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>Domaine de camouflage</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>Allow insecure cert fetch (self-signed)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Adresse sortante locale (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>Pour environnements multi-interfaces, entrez l'adresse IPv4 de la machine locale</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Lier l'interface</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>Pour les environnements multi-interfaces, entrez le nom de l'interface à lier. Ne fonctionne que sur les systèmes Windows et en mode TUN</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Test Configurations UDP Delay</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP Test Url</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*QUIC kulcs/KCP seed</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*grpc szolgáltatásnév</value>
|
||||
<value>gRPC szolgáltatásnév</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*http host vesszővel elválasztva (,)</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*QUIC biztonság</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*tcp álcázási típus</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>raw álcázási típus</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*kcp álcázási típus</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>kcp álcázási típus</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*QUIC álcázási típus</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>QUIC álcázási típus</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*grpc mód</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>gRPC mód</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>Alias (megjegyzések)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>Álcázási tartomány(host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>Titkosítási módszer (biztonság)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>TLS</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*Alapértelmezett érték tcp</value>
|
||||
<value>*Alapértelmezett érték raw</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Core Típus</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>Hitelesítési jelszó</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>Egyéni DNS (több, vesszővel (,) elválasztva)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>Win10 UWP Loopback beállítása</value>
|
||||
</data>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Ez a paraméter csak tcp/http és ws esetén érvényes</value>
|
||||
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Betűtípus (újraindítást igényel)</value>
|
||||
@@ -1068,7 +1062,7 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>Hálózati verem</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
@@ -1081,7 +1075,7 @@
|
||||
<value>Privát kulcs</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Fenntartott (2,3,4)</value>
|
||||
<value>Fenntartott</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Cím (IPv4, IPv6)</value>
|
||||
@@ -1102,7 +1096,7 @@
|
||||
<value>Teszt megszakítása...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
<value>gRPC Authority</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>HTTP konfiguráció hozzáadása</value>
|
||||
@@ -1320,11 +1314,11 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>A jelszót a parancssoron keresztül ellenőrizzük. Ha egy érvényesítési hiba miatt az alkalmazás hibásan működik, indítsa újra az alkalmazást. A jelszó nem kerül tárolásra, és minden újraindítás után újra meg kell adni.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*xhttp mód</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>xhttp mód</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>XHTTP Extra nyers JSON, formátum: { XHTTP Objektum }</value>
|
||||
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>Ablak bezárásakor a tálcára rejtés</value>
|
||||
@@ -1587,9 +1581,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>Full certificate (chain), PEM format</value>
|
||||
</data>
|
||||
@@ -1680,4 +1671,64 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>[NaïveProxy] konfiguráció hozzáadása</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>Insecure Concurrency</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Username</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP routing policy</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>Álcázási tartomány</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>Allow insecure cert fetch (self-signed)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Test Configurations UDP Delay</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP Test Url</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Local outbound address (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Bind Interface</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -121,7 +121,7 @@
|
||||
<value>Export share link to clipboard successfully</value>
|
||||
</data>
|
||||
<data name="CheckServerSettings" xml:space="preserve">
|
||||
<value>Please check the Configuration settings first.</value>
|
||||
<value>Invalid configuration, please check or reselect</value>
|
||||
</data>
|
||||
<data name="ConfigurationFormatIncorrect" xml:space="preserve">
|
||||
<value>Invalid configuration format.</value>
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*QUIC key/KCP seed</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*grpc service name</value>
|
||||
<value>gRPC service name</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*http host separated by commas (,)</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*QUIC security</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*tcp camouflage type</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>raw camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*kcp camouflage type</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>kcp camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*QUIC camouflage type</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>QUIC camouflage type</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*grpc mode</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>gRPC mode</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -514,19 +514,19 @@
|
||||
<value>Add a custom configuration</value>
|
||||
</data>
|
||||
<data name="menuAddShadowsocksServer" xml:space="preserve">
|
||||
<value>Add [Shadowsocks] </value>
|
||||
<value>Add [Shadowsocks]</value>
|
||||
</data>
|
||||
<data name="menuAddSocksServer" xml:space="preserve">
|
||||
<value>Add [SOCKS] </value>
|
||||
<value>Add [SOCKS]</value>
|
||||
</data>
|
||||
<data name="menuAddTrojanServer" xml:space="preserve">
|
||||
<value>Add [Trojan] </value>
|
||||
<value>Add [Trojan]</value>
|
||||
</data>
|
||||
<data name="menuAddVlessServer" xml:space="preserve">
|
||||
<value>Add [VLESS] </value>
|
||||
<value>Add [VLESS]</value>
|
||||
</data>
|
||||
<data name="menuAddVmessServer" xml:space="preserve">
|
||||
<value>Add [VMess] </value>
|
||||
<value>Add [VMess]</value>
|
||||
</data>
|
||||
<data name="menuSelectAll" xml:space="preserve">
|
||||
<value>Select all</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>Alias (remarks)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>Camouflage domain(host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>Encryption method (security)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>TLS</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*Default value tcp</value>
|
||||
<value>*Default value raw</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Core Type</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>Auth pass</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>Custom DNS (multiple, separated by commas (,))</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>Set Win10 UWP Loopback</value>
|
||||
</data>
|
||||
@@ -865,7 +859,7 @@
|
||||
<value>Rule object Doc</value>
|
||||
</data>
|
||||
<data name="TbDnsObjectDoc" xml:space="preserve">
|
||||
<value>Supports DNS Object; Click to view documentation</value>
|
||||
<value>Please fill in DNS Object; Click to view documentation</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>For group please leave blank here</value>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>This parameter is valid only for tcp/http and ws</value>
|
||||
<value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Font family (requires restart)</value>
|
||||
@@ -1036,7 +1030,7 @@
|
||||
<value>Domain</value>
|
||||
</data>
|
||||
<data name="menuAddHysteria2Server" xml:space="preserve">
|
||||
<value>Add [Hysteria2] </value>
|
||||
<value>Add [Hysteria2]</value>
|
||||
</data>
|
||||
<data name="TbSettingsHysteriaBandwidth" xml:space="preserve">
|
||||
<value>Hysteria Max bandwidth (Up/Down)</value>
|
||||
@@ -1045,7 +1039,7 @@
|
||||
<value>Use System Hosts</value>
|
||||
</data>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>Add [TUIC] </value>
|
||||
<value>Add [TUIC]</value>
|
||||
</data>
|
||||
<data name="TbHeaderType8" xml:space="preserve">
|
||||
<value>Congestion control</value>
|
||||
@@ -1068,20 +1062,20 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>Stack</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>Enable IPv6 Address</value>
|
||||
</data>
|
||||
<data name="menuAddWireguardServer" xml:space="preserve">
|
||||
<value>Add [WireGuard] </value>
|
||||
<value>Add [WireGuard]</value>
|
||||
</data>
|
||||
<data name="TbPrivateKey" xml:space="preserve">
|
||||
<value>Private Key</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Reserved (2,3,4)</value>
|
||||
<value>Reserved</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Address (IPv4, IPv6)</value>
|
||||
@@ -1102,7 +1096,7 @@
|
||||
<value>Test terminating...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
<value>gRPC Authority</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>Add [HTTP]</value>
|
||||
@@ -1320,11 +1314,11 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*xhttp mode</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>xhttp mode</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>XHTTP Extra raw JSON, format: { XHTTP Object }</value>
|
||||
<value>Raw JSON, format: { XHTTP Object }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>Hide to tray when closing the window</value>
|
||||
@@ -1495,13 +1489,13 @@
|
||||
<value>Policy Group Type</value>
|
||||
</data>
|
||||
<data name="menuAddPolicyGroupServer" xml:space="preserve">
|
||||
<value>Add Policy Group </value>
|
||||
<value>Add Policy Group</value>
|
||||
</data>
|
||||
<data name="menuAddProxyChainServer" xml:space="preserve">
|
||||
<value>Add Proxy Chain</value>
|
||||
</data>
|
||||
<data name="menuAddChildServer" xml:space="preserve">
|
||||
<value>Add Child </value>
|
||||
<value>Add Child</value>
|
||||
</data>
|
||||
<data name="menuRemoveChildServer" xml:space="preserve">
|
||||
<value>Remove Child </value>
|
||||
@@ -1587,9 +1581,6 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>Full certificate (chain), PEM format</value>
|
||||
</data>
|
||||
@@ -1680,4 +1671,64 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>Add [NaïveProxy]</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>Insecure Concurrency</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Username</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP routing policy</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>Camouflage domain</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>Allow insecure cert fetch (self-signed)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>Only for fetching self-signed certificates. This may expose you to MITM risks.</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Test Configurations UDP Delay</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP Test Url</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Local outbound address (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Bind Interface</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -142,7 +142,7 @@
|
||||
<value>Не удалось получить конфигурацию по умолчанию</value>
|
||||
</data>
|
||||
<data name="FailedImportedCustomServer" xml:space="preserve">
|
||||
<value>Не удалось импортировать сервер пользовательской конфигурации</value>
|
||||
<value>Не удалось импортировать пользовательскую конфигурацию</value>
|
||||
</data>
|
||||
<data name="FailedReadConfiguration" xml:space="preserve">
|
||||
<value>Не удалось прочитать файл конфигурации</value>
|
||||
@@ -211,13 +211,13 @@
|
||||
<value>Не удалось импортировать подписку</value>
|
||||
</data>
|
||||
<data name="MsgGetSubscriptionSuccessfully" xml:space="preserve">
|
||||
<value>Содержимое подписки успешно импортировано</value>
|
||||
<value>Содержимое подписки успешно получено</value>
|
||||
</data>
|
||||
<data name="MsgNoValidSubscription" xml:space="preserve">
|
||||
<value>Нет установленных подписок</value>
|
||||
</data>
|
||||
<data name="MsgParsingSuccessfully" xml:space="preserve">
|
||||
<value>Парсинг {0} прошел успешно</value>
|
||||
<value>Успешно обработано: {0}</value>
|
||||
</data>
|
||||
<data name="MsgStartGettingSubscriptions" xml:space="preserve">
|
||||
<value>Начинаю получать подписки</value>
|
||||
@@ -244,7 +244,7 @@
|
||||
<value>Успешное обновление ядра! Перезапуск службы...</value>
|
||||
</data>
|
||||
<data name="NonvmessOrssProtocol" xml:space="preserve">
|
||||
<value>Не является протоколом VMess или Shadowsocks</value>
|
||||
<value>Протокол не VMess и не Shadowsocks</value>
|
||||
</data>
|
||||
<data name="NotFoundCore" xml:space="preserve">
|
||||
<value>Файл ядра ({1}) не найден в папке {0}. Скачайте по адресу {2} и поместите его туда</value>
|
||||
@@ -253,7 +253,7 @@
|
||||
<value>Сканирование завершено, не найден корректный QR код</value>
|
||||
</data>
|
||||
<data name="OperationFailed" xml:space="preserve">
|
||||
<value>Операция безуспешна, проверьте и попробуйте ещё раз</value>
|
||||
<value>Операция не удалась, проверьте и повторите попытку</value>
|
||||
</data>
|
||||
<data name="PleaseFillRemarks" xml:space="preserve">
|
||||
<value>Введите примечания</value>
|
||||
@@ -268,7 +268,7 @@
|
||||
<value>Сначала выберите сервер</value>
|
||||
</data>
|
||||
<data name="RemoveDuplicateServerResult" xml:space="preserve">
|
||||
<value>Удаление дублей завершено. Старая: {0}, Новая: {1}</value>
|
||||
<value>Дедупликация конфигураций завершена. Было: {0}, Стало: {1}.</value>
|
||||
</data>
|
||||
<data name="RemoveServer" xml:space="preserve">
|
||||
<value>Вы уверены, что хотите удалить сервер?</value>
|
||||
@@ -283,16 +283,16 @@
|
||||
<value>Конфигурация выполнена успешно {0}</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedCustomServer" xml:space="preserve">
|
||||
<value>Пользовательская конфигурация сервера успешно импортирована</value>
|
||||
<value>Пользовательская конфигурация успешно импортирована</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedServerViaClipboard" xml:space="preserve">
|
||||
<value>{0} серверов импортировано из буфера обмена</value>
|
||||
<value>Из буфера обмена импортировано конфигураций: {0}</value>
|
||||
</data>
|
||||
<data name="SuccessfullyImportedServerViaScan" xml:space="preserve">
|
||||
<value>Сканирование URL-адреса импорта прошло успешно</value>
|
||||
<value>Ссылка общего доступа успешно отсканирована и импортирована</value>
|
||||
</data>
|
||||
<data name="TestMeOutput" xml:space="preserve">
|
||||
<value>Задержка текущего сервера: {0} мс, {1}</value>
|
||||
<value>Задержка: {0} мс, {1}</value>
|
||||
</data>
|
||||
<data name="OperationSuccess" xml:space="preserve">
|
||||
<value>Операция успешна</value>
|
||||
@@ -334,7 +334,7 @@
|
||||
<value>Введите корректный пользовательский DNS</value>
|
||||
</data>
|
||||
<data name="TransportPathTip1" xml:space="preserve">
|
||||
<value>*WebSocket-путь</value>
|
||||
<value>*Путь ws/http upgrade/xhttp</value>
|
||||
</data>
|
||||
<data name="TransportPathTip2" xml:space="preserve">
|
||||
<value>*HTTP2-путь</value>
|
||||
@@ -343,13 +343,13 @@
|
||||
<value>*QUIC-ключ / KCP-seed</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>Имя сервиса *gRPC</value>
|
||||
<value>Имя сервиса gRPC</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*http-хосты, разделённые запятыми (,)</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip2" xml:space="preserve">
|
||||
<value>*WebSocket-хост</value>
|
||||
<value>*Хост ws/http upgrade/xhttp</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip3" xml:space="preserve">
|
||||
<value>*HTTP2-хосты, разделённые запятыми (,)</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>Безопасность *QUIC</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>Тип *TCP-камуфляжа</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>Тип raw-камуфляжа</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>Тип *KCP-камуфляжа</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>Тип KCP-камуфляжа</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>Тип *QUIC-камуфляжа</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>Тип QUIC-камуфляжа</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>Режим *gRPC</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>Режим gRPC</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -382,7 +382,7 @@
|
||||
<value>Глобальная горячая клавиша {0} зарегистрирована успешно</value>
|
||||
</data>
|
||||
<data name="AllGroupServers" xml:space="preserve">
|
||||
<value>Все серверы</value>
|
||||
<value>Все</value>
|
||||
</data>
|
||||
<data name="FillServerAddressCustom" xml:space="preserve">
|
||||
<value>Выберите файл конфигурации сервера для импорта</value>
|
||||
@@ -397,7 +397,7 @@
|
||||
<value>Локальный</value>
|
||||
</data>
|
||||
<data name="MsgServerTitle" xml:space="preserve">
|
||||
<value>Фильтр серверов</value>
|
||||
<value>Фильтр, нажмите Enter для выполнения</value>
|
||||
</data>
|
||||
<data name="menuCheckUpdate" xml:space="preserve">
|
||||
<value>Проверить обновления</value>
|
||||
@@ -409,19 +409,19 @@
|
||||
<value>Выход</value>
|
||||
</data>
|
||||
<data name="menuGlobalHotkeySetting" xml:space="preserve">
|
||||
<value>Глобальная настройка горячих клавиш</value>
|
||||
<value>Настройка глобальных горячих клавиш</value>
|
||||
</data>
|
||||
<data name="menuHelp" xml:space="preserve">
|
||||
<value>Помощь</value>
|
||||
</data>
|
||||
<data name="menuOptionSetting" xml:space="preserve">
|
||||
<value>Настройка параметров</value>
|
||||
<value>Настройки</value>
|
||||
</data>
|
||||
<data name="menuPromotion" xml:space="preserve">
|
||||
<value>Содействие</value>
|
||||
<value>Продвижение</value>
|
||||
</data>
|
||||
<data name="menuReload" xml:space="preserve">
|
||||
<value>Перезагрузка</value>
|
||||
<value>Перезагрузить</value>
|
||||
</data>
|
||||
<data name="menuRoutingSetting" xml:space="preserve">
|
||||
<value>Настройки маршрутизации</value>
|
||||
@@ -436,13 +436,13 @@
|
||||
<value>Обновить текущую подписку без прокси</value>
|
||||
</data>
|
||||
<data name="menuSubGroupUpdateViaProxy" xml:space="preserve">
|
||||
<value>Обновить подписку через прокси</value>
|
||||
<value>Обновить текущую подписку через прокси</value>
|
||||
</data>
|
||||
<data name="menuSubscription" xml:space="preserve">
|
||||
<value>Группа подписки</value>
|
||||
</data>
|
||||
<data name="menuSubSetting" xml:space="preserve">
|
||||
<value>Настройки группы подписки</value>
|
||||
<value>Настройки групп подписки</value>
|
||||
</data>
|
||||
<data name="menuSubUpdate" xml:space="preserve">
|
||||
<value>Обновить подписку без прокси</value>
|
||||
@@ -472,46 +472,46 @@
|
||||
<value>Язык (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="menuAddServerViaClipboard" xml:space="preserve">
|
||||
<value>Импорт массива URL из буфера обмена</value>
|
||||
<value>Импорт ссылок общего доступа из буфера обмена</value>
|
||||
</data>
|
||||
<data name="menuAddServerViaScan" xml:space="preserve">
|
||||
<value>Сканировать QR-код с экрана</value>
|
||||
<value>Сканировать QR-код на экране</value>
|
||||
</data>
|
||||
<data name="menuCopyServer" xml:space="preserve">
|
||||
<value>Клонировать выбранный сервер</value>
|
||||
<value>Клонировать выбранное</value>
|
||||
</data>
|
||||
<data name="menuRemoveDuplicateServer" xml:space="preserve">
|
||||
<value>Удалить дубликаты серверов</value>
|
||||
<value>Удалить дубликаты</value>
|
||||
</data>
|
||||
<data name="menuRemoveServer" xml:space="preserve">
|
||||
<value>Удалить выбранные серверы</value>
|
||||
<value>Удалить выбранное</value>
|
||||
</data>
|
||||
<data name="menuSetDefaultServer" xml:space="preserve">
|
||||
<value>Установить как активный сервер</value>
|
||||
<value>Сделать активным</value>
|
||||
</data>
|
||||
<data name="menuClearServerStatistics" xml:space="preserve">
|
||||
<value>Очистить всю статистику</value>
|
||||
<value>Очистить статистику всех сервисов</value>
|
||||
</data>
|
||||
<data name="menuRealPingServer" xml:space="preserve">
|
||||
<value>Тест на реальную задержку сервера</value>
|
||||
<value>Тест реальной задержки</value>
|
||||
</data>
|
||||
<data name="menuSortServerResult" xml:space="preserve">
|
||||
<value>Сортировать по результату теста</value>
|
||||
<value>Сортировка по результату теста</value>
|
||||
</data>
|
||||
<data name="menuSpeedServer" xml:space="preserve">
|
||||
<value>Тест на скорость загрузки сервера</value>
|
||||
<value>Тест скорости загрузки</value>
|
||||
</data>
|
||||
<data name="menuTcpingServer" xml:space="preserve">
|
||||
<value>Тест задержки с tcping</value>
|
||||
<value>Тест tcping</value>
|
||||
</data>
|
||||
<data name="menuExport2ClientConfig" xml:space="preserve">
|
||||
<value>Экспортировать выбранный сервер для клиента</value>
|
||||
<value>Экспортировать выбранное как полную конфигурацию</value>
|
||||
</data>
|
||||
<data name="menuExport2ShareUrl" xml:space="preserve">
|
||||
<value>Экспорт URL-адресов общего доступа в буфер обмена</value>
|
||||
<value>Копировать ссылку общего доступа в буфер обмена</value>
|
||||
</data>
|
||||
<data name="menuAddCustomServer" xml:space="preserve">
|
||||
<value>Добавить сервер пользовательской конфигурации</value>
|
||||
<value>Добавить пользовательскую конфигурацию</value>
|
||||
</data>
|
||||
<data name="menuAddShadowsocksServer" xml:space="preserve">
|
||||
<value>Добавить сервер [Shadowsocks]</value>
|
||||
@@ -556,13 +556,13 @@
|
||||
<value>Поделиться</value>
|
||||
</data>
|
||||
<data name="LvEnabled" xml:space="preserve">
|
||||
<value>Включены обновления</value>
|
||||
<value>Включить обновление</value>
|
||||
</data>
|
||||
<data name="LvSort" xml:space="preserve">
|
||||
<value>Сортировка</value>
|
||||
</data>
|
||||
<data name="LvUserAgent" xml:space="preserve">
|
||||
<value>Заголовок User-Agent</value>
|
||||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbCancel" xml:space="preserve">
|
||||
<value>Отмена</value>
|
||||
@@ -595,7 +595,7 @@
|
||||
<value>UUID (id)</value>
|
||||
</data>
|
||||
<data name="TbNetwork" xml:space="preserve">
|
||||
<value>Транспортный протокол сети</value>
|
||||
<value>Транспортный протокол (network)</value>
|
||||
</data>
|
||||
<data name="TbPath" xml:space="preserve">
|
||||
<value>Путь</value>
|
||||
@@ -604,13 +604,10 @@
|
||||
<value>Порт</value>
|
||||
</data>
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>Примечание</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>Маскирующий домен (хост)</value>
|
||||
<value>Псевдоним (remarks)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>Метод шифрования</value>
|
||||
<value>Метод шифрования (security)</value>
|
||||
</data>
|
||||
<data name="TbSNI" xml:space="preserve">
|
||||
<value>SNI</value>
|
||||
@@ -619,13 +616,13 @@
|
||||
<value>TLS</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*По-умолчанию TCP</value>
|
||||
<value>*По-умолчанию raw</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Ядро</value>
|
||||
</data>
|
||||
<data name="TbFlow5" xml:space="preserve">
|
||||
<value>Поток</value>
|
||||
<value>Управление потоком (Flow)</value>
|
||||
</data>
|
||||
<data name="TbGUID" xml:space="preserve">
|
||||
<value>Генерировать</value>
|
||||
@@ -634,7 +631,7 @@
|
||||
<value>Пароль</value>
|
||||
</data>
|
||||
<data name="TbId4" xml:space="preserve">
|
||||
<value>Пароль(Необязательно)</value>
|
||||
<value>Пароль (необязательно)</value>
|
||||
</data>
|
||||
<data name="TbId5" xml:space="preserve">
|
||||
<value>UUID(id)</value>
|
||||
@@ -643,10 +640,10 @@
|
||||
<value>Шифрование</value>
|
||||
</data>
|
||||
<data name="TbSecurity4" xml:space="preserve">
|
||||
<value>Пользователь(Необязательно)</value>
|
||||
<value>Пользователь (необязательно)</value>
|
||||
</data>
|
||||
<data name="TbSecurity5" xml:space="preserve">
|
||||
<value>Шифрования</value>
|
||||
<value>Шифрование</value>
|
||||
</data>
|
||||
<data name="TbPreSocksPort" xml:space="preserve">
|
||||
<value>Порт SOCKS</value>
|
||||
@@ -655,7 +652,7 @@
|
||||
<value>* После установки этого значения служба SOCKS будет запущена с использованием Xray/sing-box(TUN) для обеспечения таких функций, как отображение скорости</value>
|
||||
</data>
|
||||
<data name="TbBrowse" xml:space="preserve">
|
||||
<value>Просмотр</value>
|
||||
<value>Обзор</value>
|
||||
</data>
|
||||
<data name="TbEdit" xml:space="preserve">
|
||||
<value>Редактировать</value>
|
||||
@@ -667,7 +664,7 @@
|
||||
<value>Разрешить подключения из локальной сети</value>
|
||||
</data>
|
||||
<data name="TbSettingsAutoHideStartup" xml:space="preserve">
|
||||
<value>Автоскрытие при автозапуске</value>
|
||||
<value>Автоматически скрывать при запуске</value>
|
||||
</data>
|
||||
<data name="TbSettingsAutoUpdateInterval" xml:space="preserve">
|
||||
<value>Интервал автоматического обновления Geo в часах</value>
|
||||
@@ -676,7 +673,7 @@
|
||||
<value>Ядро: базовые настройки</value>
|
||||
</data>
|
||||
<data name="TbCustomDnsRay" xml:space="preserve">
|
||||
<value>V2ray Custom DNS</value>
|
||||
<value>Пользовательский DNS для v2ray</value>
|
||||
</data>
|
||||
<data name="TbSettingsCoreKcp" xml:space="preserve">
|
||||
<value>Ядро: настройки KCP</value>
|
||||
@@ -700,10 +697,10 @@
|
||||
<value>Исключение</value>
|
||||
</data>
|
||||
<data name="TbSettingsExceptionTip" xml:space="preserve">
|
||||
<value>Исключение. Не используйте прокси-сервер для адресов, начинающихся с (,), используйте точку с запятой (;)</value>
|
||||
<value>Исключения: не использовать прокси для адресов, начинающихся с указанных. Разделяйте точкой с запятой (;)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDisplayRealTimeSpeed" xml:space="preserve">
|
||||
<value>Показывать скорость в реальном времени</value>
|
||||
<value>Показывать скорость в реальном времени (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="TbSettingsKeepOlderDedupl" xml:space="preserve">
|
||||
<value>Сохранить старые при удалении дублей</value>
|
||||
@@ -721,10 +718,7 @@
|
||||
<value>Настройки v2rayN</value>
|
||||
</data>
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>Пароль аутентификации</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>Пользовательский DNS (если несколько, то делите запятыми (,))</value>
|
||||
<value>Пароль авторизации</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>Разрешить loopback для приложений UWP (Win10)</value>
|
||||
@@ -736,10 +730,10 @@
|
||||
<value>Смешанный порт</value>
|
||||
</data>
|
||||
<data name="TbSettingsStartBoot" xml:space="preserve">
|
||||
<value>Автозапуск</value>
|
||||
<value>Запускать при старте системы</value>
|
||||
</data>
|
||||
<data name="TbSettingsStatistics" xml:space="preserve">
|
||||
<value>Включить статистику (требуется перезагрузка)</value>
|
||||
<value>Включить статистику трафика (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSubConvert" xml:space="preserve">
|
||||
<value>URL конвертации подписок</value>
|
||||
@@ -748,31 +742,31 @@
|
||||
<value>Настройки системного прокси</value>
|
||||
</data>
|
||||
<data name="TbSettingsTrayMenuServersLimit" xml:space="preserve">
|
||||
<value>Лимит серверов в меню трея</value>
|
||||
<value>Лимит отображения серверов в контекстном меню трея</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpEnabled" xml:space="preserve">
|
||||
<value>Включить UDP</value>
|
||||
</data>
|
||||
<data name="TbSettingsUser" xml:space="preserve">
|
||||
<value>Имя пользователя (логин)</value>
|
||||
<value>Пользователь авторизации</value>
|
||||
</data>
|
||||
<data name="TbClearSystemProxy" xml:space="preserve">
|
||||
<value>Очистить системный прокси</value>
|
||||
</data>
|
||||
<data name="TbDisplayGUI" xml:space="preserve">
|
||||
<value>Показать GUI</value>
|
||||
<value>Показать интерфейс</value>
|
||||
</data>
|
||||
<data name="TbGlobalHotkeySetting" xml:space="preserve">
|
||||
<value>Настройка горячих клавиш</value>
|
||||
<value>Настройка глобальных горячих клавиш</value>
|
||||
</data>
|
||||
<data name="TbGlobalHotkeySettingTip" xml:space="preserve">
|
||||
<value>Установите непосредственно, нажав на клавиатуру, вступит в силу после перезапуска</value>
|
||||
<value>Задайте, нажав нужную комбинацию клавиш; вступит в силу после перезапуска</value>
|
||||
</data>
|
||||
<data name="TbNotChangeSystemProxy" xml:space="preserve">
|
||||
<value>Не изменять системный прокси</value>
|
||||
<value>Не менять системный прокси</value>
|
||||
</data>
|
||||
<data name="TbReset" xml:space="preserve">
|
||||
<value>Обнулить</value>
|
||||
<value>Сбросить</value>
|
||||
</data>
|
||||
<data name="TbSetSystemProxy" xml:space="preserve">
|
||||
<value>Установить системный прокси</value>
|
||||
@@ -781,16 +775,16 @@
|
||||
<value>Режим PAC</value>
|
||||
</data>
|
||||
<data name="menuShareServer" xml:space="preserve">
|
||||
<value>Поделиться сервером</value>
|
||||
<value>Поделиться</value>
|
||||
</data>
|
||||
<data name="menuRouting" xml:space="preserve">
|
||||
<value>Маршрутизация</value>
|
||||
</data>
|
||||
<data name="NotRunAsAdmin" xml:space="preserve">
|
||||
<value>Пользователь</value>
|
||||
<value>Запущено без прав администратора</value>
|
||||
</data>
|
||||
<data name="RunAsAdmin" xml:space="preserve">
|
||||
<value>Администратор</value>
|
||||
<value>Запущено от имени администратора</value>
|
||||
</data>
|
||||
<data name="menuMoveBottom" xml:space="preserve">
|
||||
<value>Спуститься вниз</value>
|
||||
@@ -808,13 +802,13 @@
|
||||
<value>Фильтр, поддерживает regex</value>
|
||||
</data>
|
||||
<data name="menuWebsiteItem" xml:space="preserve">
|
||||
<value>{0} веб-сайт</value>
|
||||
<value>Веб-сайт {0}</value>
|
||||
</data>
|
||||
<data name="menuRoutingAdvancedAdd" xml:space="preserve">
|
||||
<value>Добавить</value>
|
||||
</data>
|
||||
<data name="menuRoutingAdvancedImportRules" xml:space="preserve">
|
||||
<value>Добавить расширенные правила</value>
|
||||
<value>Импортировать правила</value>
|
||||
</data>
|
||||
<data name="menuRoutingAdvancedRemove" xml:space="preserve">
|
||||
<value>Удалить выбранные</value>
|
||||
@@ -859,7 +853,7 @@
|
||||
<value>Детальные настройки правил маршрутизации</value>
|
||||
</data>
|
||||
<data name="TbAutoSort" xml:space="preserve">
|
||||
<value>Домен и IP автоматически сортируются при сохранении</value>
|
||||
<value>Домен, IP и процесс автоматически сортируются при сохранении</value>
|
||||
</data>
|
||||
<data name="TbRuleobjectDoc" xml:space="preserve">
|
||||
<value>Документация RuleObject</value>
|
||||
@@ -868,7 +862,7 @@
|
||||
<value>Поддерживаются DNS-объекты, нажмите для просмотра документации</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>Необязательное поле</value>
|
||||
<value>Для группы оставьте это поле пустым</value>
|
||||
</data>
|
||||
<data name="TipChangeRouting" xml:space="preserve">
|
||||
<value>Настройки маршрутизации изменены</value>
|
||||
@@ -880,7 +874,7 @@
|
||||
<value>Только маршрут</value>
|
||||
</data>
|
||||
<data name="TbSettingsNotProxyLocalAddress" xml:space="preserve">
|
||||
<value>Не используйте прокси-серверы для локальных (интранет) адресов</value>
|
||||
<value>Не использовать прокси для локальных (интранет) адресов</value>
|
||||
</data>
|
||||
<data name="menuMixedTestServer" xml:space="preserve">
|
||||
<value>Тест задержки и скорости всех серверов (Ctrl+E)</value>
|
||||
@@ -895,13 +889,13 @@
|
||||
<value>Не удалось запустить ядро, посмотрите логи</value>
|
||||
</data>
|
||||
<data name="LvFilter" xml:space="preserve">
|
||||
<value>Фильтр примечаний (Regex)</value>
|
||||
<value>Фильтр по примечаниям (регулярные выражения)</value>
|
||||
</data>
|
||||
<data name="TbDisplayLog" xml:space="preserve">
|
||||
<value>Показать логи</value>
|
||||
<value>Отображать журнал</value>
|
||||
</data>
|
||||
<data name="TbEnableTunAs" xml:space="preserve">
|
||||
<value>Режим VPN</value>
|
||||
<value>Включить TUN</value>
|
||||
</data>
|
||||
<data name="TbSettingsNewPort4LAN" xml:space="preserve">
|
||||
<value>Новый порт для локальной сети</value>
|
||||
@@ -910,10 +904,10 @@
|
||||
<value>Настройки режима TUN</value>
|
||||
</data>
|
||||
<data name="menuMoveToGroup" xml:space="preserve">
|
||||
<value>Перейти в группу</value>
|
||||
<value>Переместить в группу</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableDragDropSort" xml:space="preserve">
|
||||
<value>Включить сортировку перетаскиванием сервера (требуется перезагрузка)</value>
|
||||
<value>Включить сортировку перетаскиванием сервера (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="TbAutoRefresh" xml:space="preserve">
|
||||
<value>Автообновление</value>
|
||||
@@ -922,10 +916,10 @@
|
||||
<value>Пропустить тест</value>
|
||||
</data>
|
||||
<data name="menuEditServer" xml:space="preserve">
|
||||
<value>Редактировать сервер</value>
|
||||
<value>Редактировать</value>
|
||||
</data>
|
||||
<data name="TbSettingsDoubleClick2Activate" xml:space="preserve">
|
||||
<value>Двойной клик чтобы сделать сервер активным</value>
|
||||
<value>Двойной клик для активации конфигурации</value>
|
||||
</data>
|
||||
<data name="SpeedtestingCompleted" xml:space="preserve">
|
||||
<value>Тест завершен</value>
|
||||
@@ -937,19 +931,19 @@
|
||||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Параметр действует только для TCP/HTTP и WebSocket (WS)</value>
|
||||
<value>Параметр действует только для raw/http, ws, gRPC и xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Шрифт (требуется перезагрузка)</value>
|
||||
<value>Шрифт (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamilyTip" xml:space="preserve">
|
||||
<value>Скопируйте файл шрифта TTF/TTC в каталог guiFonts и заново откройте окно настроек</value>
|
||||
</data>
|
||||
<data name="TbSettingsSocksPortTip" xml:space="preserve">
|
||||
<value>Pac порт = +3,Xray API порт = +4, mihomo API порт = +5</value>
|
||||
<value>PAC-порт = +3; Xray API порт = +4; mihomo API порт = +5;</value>
|
||||
</data>
|
||||
<data name="TbSettingsStartBootTip" xml:space="preserve">
|
||||
<value>Установите это с правами администратора</value>
|
||||
<value>Установите с правами администратора; после запуска приложение получит права администратора</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontSize" xml:space="preserve">
|
||||
<value>Размер шрифта</value>
|
||||
@@ -964,7 +958,7 @@
|
||||
<value>Переместить вверх/вниз</value>
|
||||
</data>
|
||||
<data name="TbPublicKey" xml:space="preserve">
|
||||
<value>PublicKey</value>
|
||||
<value>Открытый ключ</value>
|
||||
</data>
|
||||
<data name="TbShortId" xml:space="preserve">
|
||||
<value>ShortId</value>
|
||||
@@ -973,22 +967,22 @@
|
||||
<value>SpiderX</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableHWA" xml:space="preserve">
|
||||
<value>Включить аппаратное ускорение (требуется перезагрузка)</value>
|
||||
<value>Включить аппаратное ускорение (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="SpeedtestingWait" xml:space="preserve">
|
||||
<value>Ожидание тестирования…</value>
|
||||
<value>Ожидание…</value>
|
||||
</data>
|
||||
<data name="SpeedtestingPressEscToExit" xml:space="preserve">
|
||||
<value>нажмите ESC для отмены</value>
|
||||
<value>Нажмите ESC для прекращения теста</value>
|
||||
</data>
|
||||
<data name="TipDisplayLog" xml:space="preserve">
|
||||
<value>Отключите при аномальном разрыве соединения</value>
|
||||
<value>Отключите при нестабильном соединении</value>
|
||||
</data>
|
||||
<data name="MsgSkipSubscriptionUpdate" xml:space="preserve">
|
||||
<value>Обновления не включены — подписка пропущена</value>
|
||||
</data>
|
||||
<data name="menuRebootAsAdmin" xml:space="preserve">
|
||||
<value>Перезагрузить как администратор</value>
|
||||
<value>Перезапустить от имени администратора</value>
|
||||
</data>
|
||||
<data name="LvMoreUrl" xml:space="preserve">
|
||||
<value>Дополнительные URL через запятую, конвертация подписки недоступна</value>
|
||||
@@ -1003,7 +997,7 @@
|
||||
<value>Включить запись логов в файл</value>
|
||||
</data>
|
||||
<data name="LvConvertTarget" xml:space="preserve">
|
||||
<value>Преобразовать тип цели</value>
|
||||
<value>Целевой тип конвертации</value>
|
||||
</data>
|
||||
<data name="LvConvertTargetTip" xml:space="preserve">
|
||||
<value>Если преобразование не требуется, оставьте поле пустым</value>
|
||||
@@ -1012,7 +1006,7 @@
|
||||
<value>Настройки DNS</value>
|
||||
</data>
|
||||
<data name="TbCustomDnsSingbox" xml:space="preserve">
|
||||
<value>sing-box Custom DNS</value>
|
||||
<value>Пользовательский DNS для sing-box</value>
|
||||
</data>
|
||||
<data name="TbDnsSingboxObjectDoc" xml:space="preserve">
|
||||
<value>Заполните структуру DNS, нажмите, чтобы открыть документ</value>
|
||||
@@ -1042,13 +1036,13 @@
|
||||
<value>Максимальная пропускная способность Hysteria (загрузка/отдача)</value>
|
||||
</data>
|
||||
<data name="TbSettingsUseSystemHosts" xml:space="preserve">
|
||||
<value>Использовать системные узлы</value>
|
||||
<value>Использовать системный файл hosts</value>
|
||||
</data>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>Добавить сервер [TUIC]</value>
|
||||
</data>
|
||||
<data name="TbHeaderType8" xml:space="preserve">
|
||||
<value>Контроль перегрузок</value>
|
||||
<value>Управление перегрузками</value>
|
||||
</data>
|
||||
<data name="LvPrevProfile" xml:space="preserve">
|
||||
<value>Примечания к предыдущему прокси</value>
|
||||
@@ -1068,7 +1062,7 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>Сетевой стек</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
@@ -1081,10 +1075,10 @@
|
||||
<value>Приватный ключ</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Зарезервировано (2, 3, 4)</value>
|
||||
<value>Зарезервировано</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Адрес (Ipv4,Ipv6)</value>
|
||||
<value>Адрес (IPv4, IPv6)</value>
|
||||
</data>
|
||||
<data name="TbPath7" xml:space="preserve">
|
||||
<value>Пароль obfs</value>
|
||||
@@ -1099,10 +1093,10 @@
|
||||
<value>URL для быстрой проверки реальной задержки</value>
|
||||
</data>
|
||||
<data name="SpeedtestingStop" xml:space="preserve">
|
||||
<value>Отмена тестирования...</value>
|
||||
<value>Завершение тестирования...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>* gRPC Authority (HTTP/2 псевдозаголовок :authority)</value>
|
||||
<value>gRPC Authority (HTTP/2 псевдозаголовок :authority)</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>Добавить сервер [HTTP]</value>
|
||||
@@ -1117,7 +1111,7 @@
|
||||
<value>Пользовательский набор правил для sing-box</value>
|
||||
</data>
|
||||
<data name="NeedRebootTips" xml:space="preserve">
|
||||
<value>Операция успешна. Перезапустите приложение</value>
|
||||
<value>Операция успешна. Закройте приложение, нажав «Выход» в меню трея, и запустите его заново</value>
|
||||
</data>
|
||||
<data name="menuOpenTheFileLocation" xml:space="preserve">
|
||||
<value>Открыть место хранения</value>
|
||||
@@ -1138,10 +1132,10 @@
|
||||
<value>Скорость загрузки</value>
|
||||
</data>
|
||||
<data name="TbSortingDownTraffic" xml:space="preserve">
|
||||
<value>Скачанный трафик</value>
|
||||
<value>Загруженный трафик</value>
|
||||
</data>
|
||||
<data name="TbSortingHost" xml:space="preserve">
|
||||
<value>Узел</value>
|
||||
<value>Хост</value>
|
||||
</data>
|
||||
<data name="TbSortingName" xml:space="preserve">
|
||||
<value>Имя</value>
|
||||
@@ -1204,7 +1198,7 @@
|
||||
<value>Стратегия домена по умолчанию для исходящих</value>
|
||||
</data>
|
||||
<data name="TbSettingsMainGirdOrientation" xml:space="preserve">
|
||||
<value>Основная ориентация макета (требуется перезагрузка)</value>
|
||||
<value>Основная ориентация макета (требуется перезапуск)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDomainDNSAddress" xml:space="preserve">
|
||||
<value>Исходящий DNS адрес</value>
|
||||
@@ -1216,13 +1210,13 @@
|
||||
<value>Экспорт ссылок в формате Base64 в буфер обмена</value>
|
||||
</data>
|
||||
<data name="menuExport2ClientConfigClipboard" xml:space="preserve">
|
||||
<value>Экспортировать выбранный сервер для полной конфигурации в буфер обмена</value>
|
||||
<value>Экспортировать полную конфигурацию в буфер обмена</value>
|
||||
</data>
|
||||
<data name="menuShowOrHideMainWindow" xml:space="preserve">
|
||||
<value>Показать или скрыть главное окно</value>
|
||||
</data>
|
||||
<data name="TbPreSocksPort4Sub" xml:space="preserve">
|
||||
<value>Пользовательская конфигурация порта SOCKS</value>
|
||||
<value>Порт SOCKS для пользовательской конфигурации</value>
|
||||
</data>
|
||||
<data name="menuBackupAndRestore" xml:space="preserve">
|
||||
<value>Резервное копирование и восстановление</value>
|
||||
@@ -1276,13 +1270,13 @@
|
||||
<value>Источник файлов наборов правил sing-box (необязательно)</value>
|
||||
</data>
|
||||
<data name="UpgradeAppNotExistTip" xml:space="preserve">
|
||||
<value>Программы для обновления не существует</value>
|
||||
<value>Приложение для обновления не найдено</value>
|
||||
</data>
|
||||
<data name="TbSettingsRoutingRulesSource" xml:space="preserve">
|
||||
<value>Источник правил маршрутизации</value>
|
||||
<value>Источник правил маршрутизации (необязательно)</value>
|
||||
</data>
|
||||
<data name="menuRegionalPresets" xml:space="preserve">
|
||||
<value>Региональные пресеты</value>
|
||||
<value>Настройка региональных пресетов</value>
|
||||
</data>
|
||||
<data name="menuRegionalPresetsDefault" xml:space="preserve">
|
||||
<value>По умолчанию (Китай)</value>
|
||||
@@ -1300,13 +1294,13 @@
|
||||
<value>Сканировать QR-код с изображения</value>
|
||||
</data>
|
||||
<data name="InvalidUrlTip" xml:space="preserve">
|
||||
<value>Неверный адрес (Url)</value>
|
||||
<value>Неверный адрес (URL)</value>
|
||||
</data>
|
||||
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||
<value>Не используйте небезопасный адрес подписки по протоколу HTTP</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
|
||||
<value>Установите шрифт в систему и перезапустите настройки</value>
|
||||
<value>Установите шрифт в систему, выберите или введите имя шрифта, перезапустите настройки</value>
|
||||
</data>
|
||||
<data name="menuExitTips" xml:space="preserve">
|
||||
<value>Вы уверены, что хотите выйти?</value>
|
||||
@@ -1320,20 +1314,20 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>Пароль sudo будет проверен в терминале. Если из-за ошибки проверки приложение начнёт работать некорректно, перезапустите его. Пароль не сохраняется — его нужно вводить после каждого перезапуска.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*XHTTP-режим</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>XHTTP-режим</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>Дополнительный „сырой“ JSON для XHTTP, формат: { XHTTP Object }</value>
|
||||
<value>Сырой JSON, формат: { XHTTP Object }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>Скрыть в трее при закрытии окна</value>
|
||||
<value>Сворачивать в трей при закрытии окна</value>
|
||||
</data>
|
||||
<data name="TbSettingsMixedConcurrencyCount" xml:space="preserve">
|
||||
<value>Количество одновременно выполняемых тестов при многоэтапном тестировании</value>
|
||||
</data>
|
||||
<data name="TbSettingsExceptionTip2" xml:space="preserve">
|
||||
<value>Исключение. Не используйте прокси-сервер для адресов с запятой (,)</value>
|
||||
<value>Исключения: не использовать прокси для указанных адресов. Разделяйте запятой (,)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDestOverride" xml:space="preserve">
|
||||
<value>Тип сниффинга</value>
|
||||
@@ -1342,10 +1336,10 @@
|
||||
<value>Включить второй смешанный порт</value>
|
||||
</data>
|
||||
<data name="TbRoutingInboundTagTips" xml:space="preserve">
|
||||
<value>socks: локальный порт, socks2: второй локальный порт, socks3: LAN порт</value>
|
||||
<value>socks: локальный порт, socks2: второй локальный порт, socks3: LAN-порт</value>
|
||||
</data>
|
||||
<data name="TbSettingsTheme" xml:space="preserve">
|
||||
<value>Темы</value>
|
||||
<value>Тема</value>
|
||||
</data>
|
||||
<data name="menuCopyProxyCmdToClipboard" xml:space="preserve">
|
||||
<value>Копировать команду прокси в буфер обмена</value>
|
||||
@@ -1384,7 +1378,7 @@
|
||||
<value>Mldsa65Verify</value>
|
||||
</data>
|
||||
<data name="menuAddAnytlsServer" xml:space="preserve">
|
||||
<value>Добавить сервер [Anytls]</value>
|
||||
<value>Добавить сервер [AnyTLS]</value>
|
||||
</data>
|
||||
<data name="TbRemoteDNS" xml:space="preserve">
|
||||
<value>Удалённый DNS</value>
|
||||
@@ -1587,9 +1581,6 @@
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>Полный сертификат (цепочка) в формате PEM</value>
|
||||
</data>
|
||||
@@ -1675,9 +1666,69 @@
|
||||
<value>Выбрать все</value>
|
||||
</data>
|
||||
<data name="menuEditPaste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
<value>Вставить</value>
|
||||
</data>
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
<value>Форматировать</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP поверх TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>Добавить сервер [NaïveProxy]</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>Небезопасная конкурентность (Insecure Concurrency)</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Имя пользователя</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>Политика маршрутизации ICMP</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Устаревшая защита TUN (Legacy Protect)</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>Камуфляжный домен</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Хост</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>Дополнительные параметры XHTTP (Extra)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>Разрешить небезопасную загрузку сертификата (самоподписанного)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>Только для загрузки самоподписанных сертификатов. Это может подвергнуть вас риску атаки «человек посередине» (MITM).</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>Тест UDP-задержки конфигураций</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>URL для UDP-теста</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Локальный исходящий адрес (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>Для среды с несколькими сетевыми интерфейсами укажите IPv4-адрес локального компьютера</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Укажите корректный IPv4-адрес для SendThrough.</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>Привязать интерфейс</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>Для среды с несколькими сетевыми интерфейсами укажите имя интерфейса для привязки. Работает только в Windows и режиме TUN</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -121,7 +121,7 @@
|
||||
<value>导出分享链接至剪贴板成功</value>
|
||||
</data>
|
||||
<data name="CheckServerSettings" xml:space="preserve">
|
||||
<value>请先检查设置</value>
|
||||
<value>配置项无效,请检查或重新选择</value>
|
||||
</data>
|
||||
<data name="ConfigurationFormatIncorrect" xml:space="preserve">
|
||||
<value>配置格式不正确</value>
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*QUIC 加密密钥</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*grpc serviceName</value>
|
||||
<value>gRPC serviceName</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*http host 中间逗号 (,) 分隔</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*QUIC 加密方式</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*tcp 伪装类型</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>raw 伪装类型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*kcp 伪装类型</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>kcp 伪装类型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*QUIC 伪装类型</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>QUIC 伪装类型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*grpc 模式</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>gRPC 模式</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -517,16 +517,16 @@
|
||||
<value>添加 [Shadowsocks]</value>
|
||||
</data>
|
||||
<data name="menuAddSocksServer" xml:space="preserve">
|
||||
<value>添加 [SOCKS] </value>
|
||||
<value>添加 [SOCKS]</value>
|
||||
</data>
|
||||
<data name="menuAddTrojanServer" xml:space="preserve">
|
||||
<value>添加 [Trojan] </value>
|
||||
<value>添加 [Trojan]</value>
|
||||
</data>
|
||||
<data name="menuAddVlessServer" xml:space="preserve">
|
||||
<value>添加 [VLESS] </value>
|
||||
<value>添加 [VLESS]</value>
|
||||
</data>
|
||||
<data name="menuAddVmessServer" xml:space="preserve">
|
||||
<value>添加 [VMess] </value>
|
||||
<value>添加 [VMess]</value>
|
||||
</data>
|
||||
<data name="menuSelectAll" xml:space="preserve">
|
||||
<value>全选</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>别名 (remarks)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>伪装域名 (host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>加密方式 (security)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>传输层安全 (TLS)</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*默认 tcp,选错会无法连接</value>
|
||||
<value>*默认 raw,选错会无法连接</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Core 类型</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>认证密码</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>自定义 DNS (可多个,用逗号 (,) 分隔)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>解除 Win10 UWP 应用回环代理限制</value>
|
||||
</data>
|
||||
@@ -865,7 +859,7 @@
|
||||
<value>规则详细说明文档</value>
|
||||
</data>
|
||||
<data name="TbDnsObjectDoc" xml:space="preserve">
|
||||
<value>支持填写 DnsObject,JSON 格式,点击查看文档</value>
|
||||
<value>请填写 DnsObject,JSON 格式,点击查看文档</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>普通分组此处请留空</value>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>用户代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>仅对 tcp/http、ws 协议生效</value>
|
||||
<value>仅对 raw/http、ws、gRPC、xhttp 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>当前字体 (需重启)</value>
|
||||
@@ -1033,7 +1027,7 @@
|
||||
<value>Domain</value>
|
||||
</data>
|
||||
<data name="menuAddHysteria2Server" xml:space="preserve">
|
||||
<value>添加 [Hysteria2] </value>
|
||||
<value>添加 [Hysteria2]</value>
|
||||
</data>
|
||||
<data name="TbSettingsHysteriaBandwidth" xml:space="preserve">
|
||||
<value>Hysteria 最大带宽 (Up/Dw)</value>
|
||||
@@ -1042,7 +1036,7 @@
|
||||
<value>使用系统 hosts</value>
|
||||
</data>
|
||||
<data name="menuAddTuicServer" xml:space="preserve">
|
||||
<value>添加 [TUIC] </value>
|
||||
<value>添加 [TUIC]</value>
|
||||
</data>
|
||||
<data name="TbHeaderType8" xml:space="preserve">
|
||||
<value>拥塞控制算法</value>
|
||||
@@ -1065,20 +1059,20 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>协议栈</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
<value>启用 IPv6</value>
|
||||
</data>
|
||||
<data name="menuAddWireguardServer" xml:space="preserve">
|
||||
<value>添加 [WireGuard] </value>
|
||||
<value>添加 [WireGuard]</value>
|
||||
</data>
|
||||
<data name="TbPrivateKey" xml:space="preserve">
|
||||
<value>PrivateKey</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Reserved (2,3,4)</value>
|
||||
<value>Reserved</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Address (IPv4,IPv6)</value>
|
||||
@@ -1099,10 +1093,10 @@
|
||||
<value>测试终止中...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
<value>gRPC Authority</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>添加 [HTTP] </value>
|
||||
<value>添加 [HTTP]</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableFragment" xml:space="preserve">
|
||||
<value>启用分片 (Fragment)</value>
|
||||
@@ -1317,11 +1311,11 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>密码将调用命令行校验,如果因为校验错误导致无法正常运行时,请重启本应用。 密码不会存储,每次重启后都需要再次输入。</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*XHTTP 模式</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>XHTTP 模式</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>XHTTP Extra 原始 JSON,格式: { XHTTPObject }</value>
|
||||
<value>原始 JSON,格式: { XHTTPObject }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>关闭窗口时隐藏至托盘</value>
|
||||
@@ -1381,7 +1375,7 @@
|
||||
<value>Mldsa65Verify</value>
|
||||
</data>
|
||||
<data name="menuAddAnytlsServer" xml:space="preserve">
|
||||
<value>添加 [Anytls] </value>
|
||||
<value>添加 [Anytls]</value>
|
||||
</data>
|
||||
<data name="TbRemoteDNS" xml:space="preserve">
|
||||
<value>远程 DNS</value>
|
||||
@@ -1584,9 +1578,6 @@
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>完整证书(链),PEM 格式</value>
|
||||
</data>
|
||||
@@ -1677,4 +1668,64 @@
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>格式化</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>添加 [NaïveProxy]</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>不安全并发</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>用户名</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP 路由策略</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>旧版 TUN 保护</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>伪装域名</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>允许不安全获取证书(自签名)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>仅用于抓取自签证书,存在中间人风险。</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>测试 UDP 延迟 (多选)</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP 测试地址</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>本地出站地址 (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>用于多网口环境,请填写本机 IPv4 地址</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>请填写正确的 SendThrough IPv4 地址。</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>绑定网口</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>用于多网口环境,填写要绑定的网口名称,仅生效于 Windows 系统或 TUN 模式</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>导出 v2rayN 内部分享链接至剪贴板 (多选)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -121,7 +121,7 @@
|
||||
<value>匯出分享連結至剪貼簿成功</value>
|
||||
</data>
|
||||
<data name="CheckServerSettings" xml:space="preserve">
|
||||
<value>請先檢查設定</value>
|
||||
<value>配置項目無效,請檢查或重新選擇</value>
|
||||
</data>
|
||||
<data name="ConfigurationFormatIncorrect" xml:space="preserve">
|
||||
<value>設定格式不正確</value>
|
||||
@@ -343,7 +343,7 @@
|
||||
<value>*QUIC 加密金鑰</value>
|
||||
</data>
|
||||
<data name="TransportPathTip4" xml:space="preserve">
|
||||
<value>*grpc serviceName</value>
|
||||
<value>gRPC serviceName</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip1" xml:space="preserve">
|
||||
<value>*http host 中間逗號 (,) 分隔</value>
|
||||
@@ -357,17 +357,17 @@
|
||||
<data name="TransportRequestHostTip4" xml:space="preserve">
|
||||
<value>*QUIC 加密方式</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip1" xml:space="preserve">
|
||||
<value>*TCP 偽裝類型</value>
|
||||
<data name="TransportHeaderType1" xml:space="preserve">
|
||||
<value>raw 偽裝類型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip2" xml:space="preserve">
|
||||
<value>*KCP 偽裝類型</value>
|
||||
<data name="TransportHeaderType2" xml:space="preserve">
|
||||
<value>KCP 偽裝類型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip3" xml:space="preserve">
|
||||
<value>*QUIC 偽裝類型</value>
|
||||
<data name="TransportHeaderType3" xml:space="preserve">
|
||||
<value>QUIC 偽裝類型</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip4" xml:space="preserve">
|
||||
<value>*GRPC 模式</value>
|
||||
<data name="TransportHeaderType4" xml:space="preserve">
|
||||
<value>gRPC 模式</value>
|
||||
</data>
|
||||
<data name="LvTLS" xml:space="preserve">
|
||||
<value>TLS</value>
|
||||
@@ -606,9 +606,6 @@
|
||||
<data name="TbRemarks" xml:space="preserve">
|
||||
<value>別名 (remarks)</value>
|
||||
</data>
|
||||
<data name="TbRequestHost" xml:space="preserve">
|
||||
<value>偽裝域名 (host)</value>
|
||||
</data>
|
||||
<data name="TbSecurity" xml:space="preserve">
|
||||
<value>加密方式 (security)</value>
|
||||
</data>
|
||||
@@ -619,7 +616,7 @@
|
||||
<value>傳輸層安全性 (TLS)</value>
|
||||
</data>
|
||||
<data name="TipNetwork" xml:space="preserve">
|
||||
<value>*預設 TCP,選錯會無法連線</value>
|
||||
<value>*預設 raw,選錯會無法連線</value>
|
||||
</data>
|
||||
<data name="TbCoreType" xml:space="preserve">
|
||||
<value>Core 類型</value>
|
||||
@@ -723,9 +720,6 @@
|
||||
<data name="TbSettingsPass" xml:space="preserve">
|
||||
<value>認證密碼</value>
|
||||
</data>
|
||||
<data name="TbSettingsRemoteDNS" xml:space="preserve">
|
||||
<value>自訂 DNS (可多個,用逗號 (,) 分隔)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSetUWP" xml:space="preserve">
|
||||
<value>解除 Win10 UWP 應用回環代理限制</value>
|
||||
</data>
|
||||
@@ -865,7 +859,7 @@
|
||||
<value>規則詳細說明檔案</value>
|
||||
</data>
|
||||
<data name="TbDnsObjectDoc" xml:space="preserve">
|
||||
<value>支援填寫 DnsObject,JSON 格式,點擊查看說明</value>
|
||||
<value>請填寫 DnsObject,JSON 格式,點擊查看說明</value>
|
||||
</data>
|
||||
<data name="SubUrlTips" xml:space="preserve">
|
||||
<value>普通分組此處請留空</value>
|
||||
@@ -937,7 +931,7 @@
|
||||
<value>使用者代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>僅對 TCP/HTTP、WS 協定生效</value>
|
||||
<value>僅對 raw/HTTP、WS、gRPC、XHTTP 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>目前字型 (需重啟)</value>
|
||||
@@ -1065,7 +1059,7 @@
|
||||
<data name="TbSettingsTunStack" xml:space="preserve">
|
||||
<value>協定堆疊</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunMtu" xml:space="preserve">
|
||||
<data name="TbMtu" xml:space="preserve">
|
||||
<value>MTU</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableIPv6Address" xml:space="preserve">
|
||||
@@ -1078,7 +1072,7 @@
|
||||
<value>PrivateKey</value>
|
||||
</data>
|
||||
<data name="TbReserved" xml:space="preserve">
|
||||
<value>Reserved (2,3,4)</value>
|
||||
<value>Reserved</value>
|
||||
</data>
|
||||
<data name="TbLocalAddress" xml:space="preserve">
|
||||
<value>Address (Ipv4,Ipv6)</value>
|
||||
@@ -1099,7 +1093,7 @@
|
||||
<value>測試終止中...</value>
|
||||
</data>
|
||||
<data name="TransportRequestHostTip5" xml:space="preserve">
|
||||
<value>*grpc Authority</value>
|
||||
<value>gRPC Authority</value>
|
||||
</data>
|
||||
<data name="menuAddHttpServer" xml:space="preserve">
|
||||
<value>新增 [HTTP] 節點</value>
|
||||
@@ -1317,11 +1311,11 @@
|
||||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>密碼將調用命令行校驗,如果因為校驗錯誤導致無法正常運行時,請重啟本應用。密碼不會存儲,每次重啟後都需要再次輸入。</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*xhttp 模式</value>
|
||||
<data name="TransportHeaderType5" xml:space="preserve">
|
||||
<value>xhttp 模式</value>
|
||||
</data>
|
||||
<data name="TransportExtraTip" xml:space="preserve">
|
||||
<value>XHTTP Extra 原始 JSON,格式: { XHTTPObject }</value>
|
||||
<value>原始 JSON,格式: { XHTTPObject }</value>
|
||||
</data>
|
||||
<data name="TbSettingsHide2TrayWhenClose" xml:space="preserve">
|
||||
<value>關閉視窗時隱藏至托盤</value>
|
||||
@@ -1584,9 +1578,6 @@
|
||||
<data name="TbEchConfigList" xml:space="preserve">
|
||||
<value>EchConfigList</value>
|
||||
</data>
|
||||
<data name="TbEchForceQuery" xml:space="preserve">
|
||||
<value>EchForceQuery</value>
|
||||
</data>
|
||||
<data name="TbFullCertTips" xml:space="preserve">
|
||||
<value>完整憑證(鏈),PEM 格式</value>
|
||||
</data>
|
||||
@@ -1672,9 +1663,69 @@
|
||||
<value>全選</value>
|
||||
</data>
|
||||
<data name="menuEditPaste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
<value>貼上</value>
|
||||
</data>
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
<value>格式化</value>
|
||||
</data>
|
||||
<data name="TbUot" xml:space="preserve">
|
||||
<value>UDP over TCP</value>
|
||||
</data>
|
||||
<data name="menuAddNaiveServer" xml:space="preserve">
|
||||
<value>新增 [NaïveProxy] 節點</value>
|
||||
</data>
|
||||
<data name="TbInsecureConcurrency" xml:space="preserve">
|
||||
<value>不安全的並行處理</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>使用者名稱</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP 路由策略</value>
|
||||
</data>
|
||||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>舊版 TUN 保護</value>
|
||||
</data>
|
||||
<data name="TbCamouflageDomain" xml:space="preserve">
|
||||
<value>偽裝域名</value>
|
||||
</data>
|
||||
<data name="TbHost" xml:space="preserve">
|
||||
<value>Host</value>
|
||||
</data>
|
||||
<data name="TransportExtra" xml:space="preserve">
|
||||
<value>XHTTP Extra</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetch" xml:space="preserve">
|
||||
<value>允許不安全獲取證書(自簽名)</value>
|
||||
</data>
|
||||
<data name="TbAllowInsecureCertFetchTips" xml:space="preserve">
|
||||
<value>僅用於抓取自簽證書,存在中間人風險。</value>
|
||||
</data>
|
||||
<data name="menuUdpTestServer" xml:space="preserve">
|
||||
<value>測試 UDP 延遲(多選)</value>
|
||||
</data>
|
||||
<data name="TbSettingsUdpTestUrl" xml:space="preserve">
|
||||
<value>UDP 測試網址</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>本機出站位址 (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>適用於多網路介面環境,請填寫本機 IPv4 位址</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>請填寫正確的 SendThrough IPv4 位址。</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterface" xml:space="preserve">
|
||||
<value>綁定網路介面</value>
|
||||
</data>
|
||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||
<value>適用於多網路介面環境,請填寫要綁定的介面名稱;Windows 系統有效,其他系統僅在 TUN 模式下生效</value>
|
||||
</data>
|
||||
<data name="TbPreSharedKey" xml:space="preserve">
|
||||
<value>PreSharedKey</value>
|
||||
</data>
|
||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||
<value>匯出 v2rayN 內部分享連結至剪貼簿(多選)</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"tag": "tun",
|
||||
"protocol": "tun",
|
||||
"settings": {
|
||||
"name": "xray_tun",
|
||||
"MTU": 9000,
|
||||
"gateway": [
|
||||
"172.18.0.1/30",
|
||||
"fdfe:dcba:9876::1/126"
|
||||
],
|
||||
"autoSystemRoutingTable": [
|
||||
"0.0.0.0/0",
|
||||
"::/0"
|
||||
],
|
||||
"autoOutboundsInterface": "auto"
|
||||
},
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": [
|
||||
"http",
|
||||
"tls"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"network": "udp",
|
||||
"port": "135,137-139,5353",
|
||||
"outboundTag": "block"
|
||||
},
|
||||
{
|
||||
"ip": [
|
||||
"224.0.0.0/3",
|
||||
"ff00::/8"
|
||||
],
|
||||
"outboundTag": "block"
|
||||
}
|
||||
]
|
||||
@@ -1,5 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
trim() {
|
||||
local -n ref=$1
|
||||
ref="${ref#"${ref%%[![:space:]]*}"}"
|
||||
ref="${ref%"${ref##*[![:space:]]}"}"
|
||||
}
|
||||
|
||||
build_gsettings_array() {
|
||||
[[ -z "$1" ]] && echo "[]" && return
|
||||
local host joined hosts=()
|
||||
IFS=',' read -ra parts <<< "$1"
|
||||
for host in "${parts[@]}"; do
|
||||
trim host
|
||||
[[ -n "$host" ]] && hosts+=("$host")
|
||||
done
|
||||
[[ ${#hosts[@]} -eq 0 ]] && echo "[]" && return
|
||||
printf -v joined "'%s'," "${hosts[@]}"
|
||||
echo "[${joined%,}]"
|
||||
}
|
||||
|
||||
# Function to set proxy for GNOME
|
||||
set_gnome_proxy() {
|
||||
local MODE=$1
|
||||
@@ -21,7 +40,7 @@ set_gnome_proxy() {
|
||||
done
|
||||
|
||||
# Set ignored hosts
|
||||
gsettings set org.gnome.system.proxy ignore-hosts "['$IGNORE_HOSTS']"
|
||||
gsettings set org.gnome.system.proxy ignore-hosts "$(build_gsettings_array "$IGNORE_HOSTS")"
|
||||
|
||||
echo "GNOME: Manual proxy settings applied."
|
||||
echo "Proxy IP: $PROXY_IP"
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
<EmbeddedResource Include="Sample\SampleHttpResponse" />
|
||||
<EmbeddedResource Include="Sample\SampleInbound" />
|
||||
<EmbeddedResource Include="Sample\SampleOutbound" />
|
||||
<EmbeddedResource Include="Sample\SampleTunInbound" />
|
||||
<EmbeddedResource Include="Sample\SampleTunRules" />
|
||||
<EmbeddedResource Include="Sample\SingboxSampleClientConfig" />
|
||||
<EmbeddedResource Include="Sample\SingboxSampleOutbound" />
|
||||
<EmbeddedResource Include="Sample\tun_singbox_dns" />
|
||||
@@ -82,4 +84,8 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ServiceLib.UdpTest\ServiceLib.UdpTest.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -57,55 +57,13 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
||||
|
||||
ConvertGeo2Ruleset();
|
||||
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
|
||||
ret.Data = ApplyFullConfigTemplate();
|
||||
if (context.TunProtectSsPort is > 0 and <= 65535)
|
||||
{
|
||||
var ssInbound = new
|
||||
{
|
||||
type = "shadowsocks",
|
||||
tag = "tun-protect-ss",
|
||||
listen = Global.Loopback,
|
||||
listen_port = context.TunProtectSsPort,
|
||||
method = "none",
|
||||
password = "none",
|
||||
};
|
||||
var directRule = new Rule4Sbox()
|
||||
{
|
||||
inbound = new List<string> { ssInbound.tag },
|
||||
outbound = Global.DirectTag,
|
||||
};
|
||||
var singboxConfigNode = JsonUtils.ParseJson(ret.Data.ToString())!.AsObject();
|
||||
var inboundsNode = singboxConfigNode["inbounds"]!.AsArray();
|
||||
inboundsNode.Add(JsonUtils.SerializeToNode(ssInbound, new JsonSerializerOptions
|
||||
{
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||
}));
|
||||
var routeNode = singboxConfigNode["route"]?.AsObject();
|
||||
var rulesNode = routeNode?["rules"]?.AsArray();
|
||||
var protectRuleNode = JsonUtils.SerializeToNode(directRule,
|
||||
new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull });
|
||||
if (rulesNode != null)
|
||||
{
|
||||
rulesNode.Insert(0, protectRuleNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
var newRulesNode = new JsonArray() { protectRuleNode };
|
||||
if (routeNode is null)
|
||||
{
|
||||
var newRouteNode = new JsonObject() { ["rules"] = newRulesNode };
|
||||
singboxConfigNode["route"] = newRouteNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
routeNode["rules"] = newRulesNode;
|
||||
}
|
||||
}
|
||||
ret.Data = JsonUtils.Serialize(singboxConfigNode);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -213,6 +171,8 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
||||
_coreConfig.route.rules.Add(rule);
|
||||
}
|
||||
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
return ret;
|
||||
@@ -271,6 +231,8 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
||||
listen_port = port,
|
||||
type = EInboundProtocol.mixed.ToString(),
|
||||
});
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
|
||||
@@ -58,4 +58,56 @@ public partial class CoreConfigSingboxService
|
||||
|
||||
return JsonUtils.Serialize(fullConfigTemplateNode);
|
||||
}
|
||||
|
||||
private void ApplyOutboundBindInterface()
|
||||
{
|
||||
var bindInterface = _config.CoreBasicItem.BindInterface?.TrimEx();
|
||||
if (bindInterface.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!(context.IsTunEnabled || context.IsWindows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||
{
|
||||
outbound.bind_interface = ShouldBindNet(outbound) ? bindInterface : null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyOutboundSendThrough()
|
||||
{
|
||||
var sendThrough = _config.CoreBasicItem.SendThrough?.TrimEx();
|
||||
if (sendThrough.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||
{
|
||||
outbound.inet4_bind_address = ShouldBindNet(outbound) ? sendThrough : null;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldBindNet(Outbound4Sbox outbound)
|
||||
{
|
||||
if (outbound.type is "direct" or "block" or "dns" or "selector" or "urltest")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!outbound.detour.IsNullOrEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var outboundAddress = outbound.server ?? string.Empty;
|
||||
|
||||
if (outboundAddress.Equals("localhost", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !IPAddress.TryParse(outboundAddress, out var address) || !IPAddress.IsLoopback(address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ public partial class CoreConfigSingboxService
|
||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet) ?? [];
|
||||
var expectedIPCidr = new List<string>();
|
||||
var expectedIPsRegions = new List<string>();
|
||||
var regionNames = new HashSet<string>();
|
||||
var regionName = string.Empty;
|
||||
|
||||
if (!string.IsNullOrEmpty(simpleDnsItem?.DirectExpectedIPs))
|
||||
{
|
||||
@@ -310,16 +310,16 @@ public partial class CoreConfigSingboxService
|
||||
|
||||
foreach (var ip in ipItems)
|
||||
{
|
||||
if (ip.StartsWith("geoip:", StringComparison.OrdinalIgnoreCase))
|
||||
if (ip.StartsWith(Global.GeoIPPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var region = ip["geoip:".Length..];
|
||||
if (!string.IsNullOrEmpty(region))
|
||||
var region = ip[Global.GeoIPPrefix.Length..];
|
||||
if (string.IsNullOrEmpty(region))
|
||||
{
|
||||
expectedIPsRegions.Add(region);
|
||||
regionNames.Add(region);
|
||||
regionNames.Add($"geolocation-{region}");
|
||||
regionNames.Add($"tld-{region}");
|
||||
continue;
|
||||
}
|
||||
|
||||
expectedIPsRegions.Add(region);
|
||||
regionName = region;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -352,19 +352,25 @@ public partial class CoreConfigSingboxService
|
||||
rule.server = Global.SingboxDirectDNSTag;
|
||||
rule.strategy = Utils.DomainStrategy4Sbox(simpleDnsItem.Strategy4Freedom);
|
||||
|
||||
if (expectedIPsRegions.Count > 0 && rule.geosite?.Count > 0)
|
||||
if (expectedIPsRegions.Count > 0 && rule.geosite?.Count > 0 && !regionName.IsNullOrEmpty())
|
||||
{
|
||||
var geositeSet = new HashSet<string>(rule.geosite);
|
||||
if (regionNames.Intersect(geositeSet).Any())
|
||||
var regionGeosite = rule.geosite.Where(g => g.EndsWith($"-{regionName}", StringComparison.OrdinalIgnoreCase)
|
||||
|| g.EndsWith($"@{regionName}", StringComparison.OrdinalIgnoreCase)
|
||||
|| g == regionName).ToList();
|
||||
if (regionGeosite.Count > 0)
|
||||
{
|
||||
rule.geosite.RemoveAll(regionGeosite.Contains);
|
||||
var rule4ExpectedIPs = JsonUtils.DeepCopy(rule);
|
||||
rule4ExpectedIPs.geosite = regionGeosite;
|
||||
if (expectedIPsRegions.Count > 0)
|
||||
{
|
||||
rule.geoip = expectedIPsRegions;
|
||||
rule4ExpectedIPs.geoip = expectedIPsRegions;
|
||||
}
|
||||
if (expectedIPCidr.Count > 0)
|
||||
{
|
||||
rule.ip_cidr = expectedIPCidr;
|
||||
rule4ExpectedIPs.ip_cidr = expectedIPCidr;
|
||||
}
|
||||
_coreConfig.dns.rules.Add(rule4ExpectedIPs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,15 +435,7 @@ public partial class CoreConfigSingboxService
|
||||
return;
|
||||
}
|
||||
_coreConfig.dns = dns4Sbox;
|
||||
if (dns4Sbox.servers?.Count > 0 &&
|
||||
dns4Sbox.servers.First().address.IsNullOrEmpty())
|
||||
{
|
||||
GenDnsProtectCustom();
|
||||
}
|
||||
else
|
||||
{
|
||||
GenDnsProtectCustomLegacy();
|
||||
}
|
||||
GenDnsProtectCustom();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -479,23 +477,6 @@ public partial class CoreConfigSingboxService
|
||||
_coreConfig.dns = dns4Sbox;
|
||||
}
|
||||
|
||||
private void GenDnsProtectCustomLegacy()
|
||||
{
|
||||
GenDnsProtectCustom();
|
||||
|
||||
_coreConfig.dns?.servers?.RemoveAll(s => s.tag == Global.SingboxLocalDNSTag);
|
||||
var dnsItem = context.RawDnsItem;
|
||||
var localDnsServer = new Server4Sbox()
|
||||
{
|
||||
address = string.IsNullOrEmpty(dnsItem?.DomainDNSAddress)
|
||||
? Global.DomainPureIPDNSAddress.FirstOrDefault()
|
||||
: dnsItem?.DomainDNSAddress,
|
||||
tag = Global.SingboxLocalDNSTag,
|
||||
detour = Global.DirectTag,
|
||||
};
|
||||
_coreConfig.dns?.servers?.Add(localDnsServer);
|
||||
}
|
||||
|
||||
private Rule4Sbox? BuildProtectDomainRule()
|
||||
{
|
||||
if (context.ProtectDomainList.Count == 0)
|
||||
|
||||
@@ -8,10 +8,10 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
var listen = "0.0.0.0";
|
||||
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
var isUsingLocalMixedPort = _node.Address == Global.Loopback && _node.Port == listenPort;
|
||||
_coreConfig.inbounds = [];
|
||||
|
||||
if (!context.IsTunEnabled
|
||||
|| (context.IsTunEnabled && _node.Port != listenPort))
|
||||
if (!context.IsTunEnabled || !isUsingLocalMixedPort)
|
||||
{
|
||||
var inbound = new Inbound4Sbox()
|
||||
{
|
||||
@@ -62,7 +62,7 @@ public partial class CoreConfigSingboxService
|
||||
}
|
||||
|
||||
var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(EmbedUtils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { };
|
||||
tunInbound.interface_name = Utils.IsMacOS() ? $"utun{new Random().Next(99)}" : "singbox_tun";
|
||||
tunInbound.interface_name = context.IsMacOS ? $"utun{new Random().Next(99)}" : "singbox_tun";
|
||||
tunInbound.mtu = _config.TunModeItem.Mtu;
|
||||
tunInbound.auto_route = _config.TunModeItem.AutoRoute;
|
||||
tunInbound.strict_route = _config.TunModeItem.StrictRoute;
|
||||
|
||||
@@ -22,7 +22,7 @@ public partial class CoreConfigSingboxService
|
||||
}
|
||||
if (withSelector)
|
||||
{
|
||||
var proxyTags = proxyOutboundList.Where(n => n.tag.StartsWith(Global.ProxyTag)).Select(n => n.tag).ToList();
|
||||
var proxyTags = proxyOutboundList.Where(n => n.tag.StartsWith(baseTagName)).Select(n => n.tag).ToList();
|
||||
if (proxyTags.Count > 1)
|
||||
{
|
||||
proxyOutboundList.InsertRange(0, BuildSelectorOutbounds(proxyTags, baseTagName));
|
||||
@@ -84,6 +84,8 @@ public partial class CoreConfigSingboxService
|
||||
try
|
||||
{
|
||||
var protocolExtra = _node.GetProtocolExtra();
|
||||
var transportExtra = _node.GetTransportExtra();
|
||||
var network = _node.GetNetwork();
|
||||
outbound.server = _node.Address;
|
||||
outbound.server_port = _node.Port;
|
||||
outbound.type = Global.ProtocolTypes[_node.ConfigType];
|
||||
@@ -112,28 +114,25 @@ public partial class CoreConfigSingboxService
|
||||
outbound.method = AppManager.Instance.GetShadowsocksSecurities(_node).Contains(protocolExtra.SsMethod)
|
||||
? protocolExtra.SsMethod : Global.None;
|
||||
outbound.password = _node.Password;
|
||||
outbound.udp_over_tcp = protocolExtra.Uot == true ? true : null;
|
||||
|
||||
if (_node.Network == nameof(ETransport.tcp) && _node.HeaderType == Global.TcpHeaderHttp)
|
||||
if (network == nameof(ETransport.raw) && transportExtra.RawHeaderType == Global.RawHeaderHttp)
|
||||
{
|
||||
outbound.plugin = "obfs-local";
|
||||
outbound.plugin_opts = $"obfs=http;obfs-host={_node.RequestHost};";
|
||||
outbound.plugin_opts = $"obfs=http;obfs-host={transportExtra.Host};";
|
||||
}
|
||||
else
|
||||
{
|
||||
var pluginArgs = string.Empty;
|
||||
if (_node.Network == nameof(ETransport.ws))
|
||||
if (network == nameof(ETransport.ws))
|
||||
{
|
||||
pluginArgs += "mode=websocket;";
|
||||
pluginArgs += $"host={_node.RequestHost};";
|
||||
pluginArgs += $"host={transportExtra.Host};";
|
||||
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
|
||||
// Equal signs and commas [and backslashes] must be escaped with a backslash.
|
||||
var path = _node.Path.Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||
var path = (transportExtra.Path ?? string.Empty).Replace("\\", "\\\\").Replace("=", "\\=").Replace(",", "\\,");
|
||||
pluginArgs += $"path={path};";
|
||||
}
|
||||
else if (_node.Network == nameof(ETransport.quic))
|
||||
{
|
||||
pluginArgs += "mode=quic;";
|
||||
}
|
||||
if (_node.StreamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
pluginArgs += "tls;";
|
||||
@@ -223,13 +222,14 @@ public partial class CoreConfigSingboxService
|
||||
password = protocolExtra.SalamanderPass.TrimEx(),
|
||||
};
|
||||
}
|
||||
|
||||
outbound.up_mbps = protocolExtra?.UpMbps is { } su and >= 0
|
||||
int? upMbps = protocolExtra?.UpMbps is { } su and >= 0
|
||||
? su
|
||||
: _config.HysteriaItem.UpMbps;
|
||||
outbound.down_mbps = protocolExtra?.DownMbps is { } sd and >= 0
|
||||
int? downMbps = protocolExtra?.DownMbps is { } sd and >= 0
|
||||
? sd
|
||||
: _config.HysteriaItem.DownMbps;
|
||||
outbound.up_mbps = upMbps > 0 ? upMbps : null;
|
||||
outbound.down_mbps = downMbps > 0 ? downMbps : null;
|
||||
var ports = protocolExtra?.Ports?.IsNullOrEmpty() == false ? protocolExtra.Ports : null;
|
||||
if ((!ports.IsNullOrEmpty()) && (ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
|
||||
{
|
||||
@@ -269,7 +269,7 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
outbound.uuid = _node.Username;
|
||||
outbound.password = _node.Password;
|
||||
outbound.congestion_control = _node.HeaderType;
|
||||
outbound.congestion_control = protocolExtra.CongestionControl;
|
||||
break;
|
||||
}
|
||||
case EConfigType.Anytls:
|
||||
@@ -277,6 +277,22 @@ public partial class CoreConfigSingboxService
|
||||
outbound.password = _node.Password;
|
||||
break;
|
||||
}
|
||||
case EConfigType.Naive:
|
||||
{
|
||||
outbound.username = _node.Username;
|
||||
outbound.password = _node.Password;
|
||||
if (protocolExtra.NaiveQuic == true)
|
||||
{
|
||||
outbound.quic = true;
|
||||
outbound.quic_congestion_control = protocolExtra.CongestionControl.NullIfEmpty();
|
||||
}
|
||||
if (protocolExtra.InsecureConcurrency > 0)
|
||||
{
|
||||
outbound.insecure_concurrency = protocolExtra.InsecureConcurrency;
|
||||
}
|
||||
outbound.udp_over_tcp = protocolExtra.Uot == true ? true : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FillOutboundTls(outbound);
|
||||
@@ -293,7 +309,7 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
var protocolExtra = _node.GetProtocolExtra();
|
||||
|
||||
endpoint.address = Utils.String2List(protocolExtra.WgInterfaceAddress);
|
||||
endpoint.address = Utils.String2List(protocolExtra.WgInterfaceAddress)?.Select(s => s.Trim()).ToList() ?? ["172.16.0.2/32"];
|
||||
endpoint.type = Global.ProtocolTypes[_node.ConfigType];
|
||||
|
||||
switch (_node.ConfigType)
|
||||
@@ -302,13 +318,12 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
var peer = new Peer4Sbox
|
||||
{
|
||||
public_key = protocolExtra.WgPublicKey,
|
||||
public_key = protocolExtra.WgPublicKey ?? string.Empty,
|
||||
pre_shared_key = protocolExtra.WgPresharedKey,
|
||||
reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
|
||||
reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(s => s.Trim()).Select(int.Parse).ToList(),
|
||||
address = _node.Address,
|
||||
port = _node.Port,
|
||||
// TODO default ["0.0.0.0/0", "::/0"]
|
||||
allowed_ips = new() { "0.0.0.0/0", "::/0" },
|
||||
allowed_ips = ["0.0.0.0/0", "::/0"],
|
||||
};
|
||||
endpoint.private_key = _node.Password;
|
||||
endpoint.mtu = protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu : Global.TunMtus.First();
|
||||
@@ -363,9 +378,18 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
serverName = _node.Sni;
|
||||
}
|
||||
else if (_node.RequestHost.IsNotEmpty())
|
||||
else
|
||||
{
|
||||
serverName = Utils.String2List(_node.RequestHost)?.First();
|
||||
var host = _node.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => _node.GetTransportExtra().Host,
|
||||
nameof(ETransport.ws) => _node.GetTransportExtra().Host,
|
||||
nameof(ETransport.httpupgrade) => _node.GetTransportExtra().Host,
|
||||
nameof(ETransport.xhttp) => _node.GetTransportExtra().Host,
|
||||
nameof(ETransport.grpc) => _node.GetTransportExtra().GrpcAuthority,
|
||||
_ => null,
|
||||
};
|
||||
serverName = Utils.String2List(host)?.First();
|
||||
}
|
||||
var tls = new Tls4Sbox()
|
||||
{
|
||||
@@ -420,27 +444,31 @@ public partial class CoreConfigSingboxService
|
||||
try
|
||||
{
|
||||
var transport = new Transport4Sbox();
|
||||
var transportExtra = _node.GetTransportExtra();
|
||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||
var useragentValue = Global.RawHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||
|
||||
switch (_node.GetNetwork())
|
||||
{
|
||||
case nameof(ETransport.h2):
|
||||
transport.type = nameof(ETransport.http);
|
||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
break;
|
||||
|
||||
case nameof(ETransport.tcp): //http
|
||||
if (_node.HeaderType == Global.TcpHeaderHttp)
|
||||
case nameof(ETransport.raw): //http
|
||||
if (transportExtra.RawHeaderType == Global.RawHeaderHttp)
|
||||
{
|
||||
transport.type = nameof(ETransport.http);
|
||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
transport.host = transportExtra.Host.IsNullOrEmpty()
|
||||
? null
|
||||
: Utils.String2List(transportExtra.Host);
|
||||
transport.path = transportExtra.Path.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
transport.type = nameof(ETransport.ws);
|
||||
var wsPath = _node.Path;
|
||||
var wsPath = transportExtra.Path;
|
||||
|
||||
// Parse eh and ed parameters from path using regex
|
||||
if (!wsPath.IsNullOrEmpty())
|
||||
@@ -469,29 +497,35 @@ public partial class CoreConfigSingboxService
|
||||
}
|
||||
|
||||
transport.path = wsPath.NullIfEmpty();
|
||||
if (_node.RequestHost.IsNotEmpty())
|
||||
if (transportExtra.Host.IsNotEmpty())
|
||||
{
|
||||
transport.headers = new()
|
||||
{
|
||||
Host = _node.RequestHost
|
||||
Host = transportExtra.Host
|
||||
};
|
||||
}
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.httpupgrade):
|
||||
transport.type = nameof(ETransport.httpupgrade);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
transport.host = _node.RequestHost.NullIfEmpty();
|
||||
transport.path = transportExtra.Path.NullIfEmpty();
|
||||
transport.host = transportExtra.Host.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case nameof(ETransport.quic):
|
||||
transport.type = nameof(ETransport.quic);
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
transport.type = nameof(ETransport.grpc);
|
||||
transport.service_name = _node.Path;
|
||||
transport.service_name = transportExtra.GrpcServiceName;
|
||||
transport.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s");
|
||||
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s");
|
||||
transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;
|
||||
@@ -554,7 +588,12 @@ public partial class CoreConfigSingboxService
|
||||
for (var i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
var node = nodes[i];
|
||||
var currentTag = $"{baseTagName}-{i + 1}";
|
||||
var currentTag = $"{baseTagName}-{i + 1}-{node.Remarks}";
|
||||
|
||||
if (nodes.Count == 1)
|
||||
{
|
||||
currentTag = baseTagName;
|
||||
}
|
||||
|
||||
if (node.ConfigType.IsGroupType())
|
||||
{
|
||||
@@ -585,8 +624,8 @@ public partial class CoreConfigSingboxService
|
||||
for (var i = 0; i < nodesReverse.Count; i++)
|
||||
{
|
||||
var node = nodesReverse[i];
|
||||
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}";
|
||||
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}" : null;
|
||||
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}-{node.Remarks}";
|
||||
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}-{nodesReverse[i + 1].Remarks}" : null;
|
||||
if (node.ConfigType.IsGroupType())
|
||||
{
|
||||
var childProfiles = new CoreConfigSingboxService(context with { Node = node, }).BuildGroupProxyOutbounds(currentTag);
|
||||
@@ -727,13 +766,12 @@ public partial class CoreConfigSingboxService
|
||||
}, null);
|
||||
}
|
||||
var idx = echConfig.IndexOf('+');
|
||||
// NOTE: query_server_name, since sing-box 1.13.0
|
||||
//var queryServerName = idx > 0 ? echConfig[..idx] : null;
|
||||
var queryServerName = idx > 0 ? echConfig[..idx] : null;
|
||||
var echDnsServer = idx > 0 ? echConfig[(idx + 1)..] : echConfig;
|
||||
return (new Ech4Sbox()
|
||||
{
|
||||
enabled = true,
|
||||
query_server_name = null,
|
||||
query_server_name = queryServerName,
|
||||
}, ParseDnsAddress(echDnsServer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public partial class CoreConfigSingboxService
|
||||
strategy = directDnsStrategy
|
||||
};
|
||||
|
||||
if (_config.TunModeItem.EnableTun)
|
||||
if (context.IsTunEnabled)
|
||||
{
|
||||
_coreConfig.route.auto_detect_interface = true;
|
||||
|
||||
@@ -47,6 +47,36 @@ public partial class CoreConfigSingboxService
|
||||
outbound = Global.DirectTag,
|
||||
process_name = lstDirectExe
|
||||
});
|
||||
|
||||
// ICMP Routing
|
||||
var icmpRouting = _config.TunModeItem.IcmpRouting ?? "";
|
||||
if (!Global.TunIcmpRoutingPolicies.Contains(icmpRouting))
|
||||
{
|
||||
icmpRouting = Global.TunIcmpRoutingPolicies.First();
|
||||
}
|
||||
if (icmpRouting == "direct")
|
||||
{
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
network = ["icmp"],
|
||||
outbound = Global.DirectTag,
|
||||
});
|
||||
}
|
||||
else if (icmpRouting != "rule")
|
||||
{
|
||||
var rejectMethod = icmpRouting switch
|
||||
{
|
||||
"unreachable" => "default",
|
||||
"drop" => "drop",
|
||||
_ => "reply",
|
||||
};
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
network = ["icmp"],
|
||||
action = "reject",
|
||||
method = rejectMethod,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (_config.Inbound.First().SniffingEnabled)
|
||||
@@ -66,7 +96,6 @@ public partial class CoreConfigSingboxService
|
||||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
port = [53],
|
||||
network = ["udp"],
|
||||
action = "hijack-dns"
|
||||
});
|
||||
}
|
||||
@@ -300,11 +329,52 @@ public partial class CoreConfigSingboxService
|
||||
if (item.Ip?.Count > 0)
|
||||
{
|
||||
var countIp = 0;
|
||||
foreach (var it in item.Ip)
|
||||
var negativeIpList = item.Ip.Where(it => it.StartsWith('!')).ToList();
|
||||
if (negativeIpList.Count > 0)
|
||||
{
|
||||
if (ParseV2Address(it, rule2))
|
||||
var positiveIpList = item.Ip.Except(negativeIpList).ToList();
|
||||
var positiveRule = rule2;
|
||||
positiveRule = JsonUtils.DeepCopy(rule2);
|
||||
positiveRule.outbound = null;
|
||||
positiveRule.action = null;
|
||||
foreach (var it in positiveIpList)
|
||||
{
|
||||
countIp++;
|
||||
if (ParseV2Address(it, positiveRule))
|
||||
{
|
||||
countIp++;
|
||||
}
|
||||
}
|
||||
var negativeRule = new Rule4Sbox();
|
||||
foreach (var it in negativeIpList)
|
||||
{
|
||||
// Remove first '!' and trim spaces
|
||||
var ip = it[1..].Trim();
|
||||
if (ParseV2Address(ip, negativeRule))
|
||||
{
|
||||
countIp++;
|
||||
}
|
||||
}
|
||||
negativeRule.invert = true;
|
||||
rule2 = new Rule4Sbox()
|
||||
{
|
||||
outbound = rule2.outbound,
|
||||
action = rule2.action,
|
||||
type = "logical",
|
||||
mode = "or",
|
||||
rules = [
|
||||
positiveRule,
|
||||
negativeRule
|
||||
]
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var it in item.Ip)
|
||||
{
|
||||
if (ParseV2Address(it, rule2))
|
||||
{
|
||||
countIp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (countIp > 0)
|
||||
@@ -377,10 +447,10 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (domain.StartsWith("geosite:"))
|
||||
else if (domain.StartsWith(Global.GeoSitePrefix))
|
||||
{
|
||||
rule.geosite ??= [];
|
||||
rule.geosite?.Add(domain.Substring(8));
|
||||
rule.geosite?.Add(domain[Global.GeoSitePrefix.Length..]);
|
||||
}
|
||||
else if (domain.StartsWith("regexp:"))
|
||||
{
|
||||
@@ -421,28 +491,18 @@ public partial class CoreConfigSingboxService
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (address.Equals("geoip:private"))
|
||||
else if (address.Equals($"{Global.GeoIPPrefix}private"))
|
||||
{
|
||||
rule.ip_is_private = true;
|
||||
}
|
||||
else if (address.StartsWith("geoip:"))
|
||||
else if (address.StartsWith(Global.GeoIPPrefix))
|
||||
{
|
||||
rule.geoip ??= new();
|
||||
rule.geoip?.Add(address.Substring(6));
|
||||
}
|
||||
else if (address.Equals("geoip:!private"))
|
||||
{
|
||||
rule.ip_is_private = false;
|
||||
}
|
||||
else if (address.StartsWith("geoip:!"))
|
||||
{
|
||||
rule.geoip ??= new();
|
||||
rule.geoip?.Add(address.Substring(6));
|
||||
rule.invert = true;
|
||||
rule.geoip ??= [];
|
||||
rule.geoip?.Add(address[Global.GeoIPPrefix.Length..]);
|
||||
}
|
||||
else
|
||||
{
|
||||
rule.ip_cidr ??= new();
|
||||
rule.ip_cidr ??= [];
|
||||
rule.ip_cidr?.Add(address);
|
||||
}
|
||||
return true;
|
||||
@@ -464,7 +524,7 @@ public partial class CoreConfigSingboxService
|
||||
return Global.ProxyTag;
|
||||
}
|
||||
|
||||
var tag = $"{node.IndexId}-{Global.ProxyTag}";
|
||||
var tag = $"{node.IndexId}-{Global.ProxyTag}-{node.Remarks}";
|
||||
if (_coreConfig.outbounds.Any(o => o.tag.StartsWith(tag))
|
||||
|| (_coreConfig.endpoints != null && _coreConfig.endpoints.Any(e => e.tag.StartsWith(tag))))
|
||||
{
|
||||
|
||||
@@ -15,10 +15,6 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
var ret = new RetResult();
|
||||
try
|
||||
{
|
||||
if (context.IsTunEnabled && context.TunProtectSsPort > 0 && context.ProxyRelaySsPort > 0)
|
||||
{
|
||||
return GenerateClientProxyRelayConfig();
|
||||
}
|
||||
if (_node == null
|
||||
|| !_node.IsValid())
|
||||
{
|
||||
@@ -60,6 +56,13 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
|
||||
GenStatistic();
|
||||
|
||||
if (_config.CoreBasicItem.EnableFragment)
|
||||
{
|
||||
ApplyOutboundFragment();
|
||||
}
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
var finalRule = BuildFinalRule();
|
||||
if (!string.IsNullOrEmpty(finalRule?.balancerTag))
|
||||
{
|
||||
@@ -159,6 +162,11 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
listen = Global.Loopback,
|
||||
port = port,
|
||||
protocol = EInboundProtocol.mixed.ToString(),
|
||||
settings = new Inboundsettings4Ray()
|
||||
{
|
||||
udp = true,
|
||||
auth = "noauth"
|
||||
},
|
||||
};
|
||||
inbound.tag = inbound.protocol + inbound.port.ToString();
|
||||
_coreConfig.inbounds.Add(inbound);
|
||||
@@ -192,6 +200,12 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
_coreConfig.routing.rules.Add(rule);
|
||||
}
|
||||
|
||||
if (_config.CoreBasicItem.EnableFragment)
|
||||
{
|
||||
ApplyOutboundFragment();
|
||||
}
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
@@ -249,10 +263,22 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
listen = Global.Loopback,
|
||||
port = port,
|
||||
protocol = EInboundProtocol.mixed.ToString(),
|
||||
settings = new Inboundsettings4Ray()
|
||||
{
|
||||
udp = true,
|
||||
auth = "noauth"
|
||||
},
|
||||
});
|
||||
|
||||
_coreConfig.routing.rules.Add(BuildFinalRule());
|
||||
|
||||
if (_config.CoreBasicItem.EnableFragment)
|
||||
{
|
||||
ApplyOutboundFragment();
|
||||
}
|
||||
ApplyOutboundBindInterface();
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
@@ -266,114 +292,5 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
}
|
||||
}
|
||||
|
||||
public RetResult GenerateClientProxyRelayConfig()
|
||||
{
|
||||
var ret = new RetResult();
|
||||
try
|
||||
{
|
||||
if (_node == null
|
||||
|| !_node.IsValid())
|
||||
{
|
||||
ret.Msg = ResUI.CheckServerSettings;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (_node.GetNetwork() is nameof(ETransport.quic))
|
||||
{
|
||||
ret.Msg = ResUI.Incorrectconfiguration + $" - {_node.GetNetwork()}";
|
||||
return ret;
|
||||
}
|
||||
|
||||
var result = EmbedUtils.GetEmbedText(Global.V2raySampleClient);
|
||||
if (result.IsNullOrEmpty())
|
||||
{
|
||||
ret.Msg = ResUI.FailedGetDefaultConfiguration;
|
||||
return ret;
|
||||
}
|
||||
|
||||
_coreConfig = JsonUtils.Deserialize<V2rayConfig>(result);
|
||||
if (_coreConfig == null)
|
||||
{
|
||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return ret;
|
||||
}
|
||||
|
||||
GenLog();
|
||||
_coreConfig.outbounds.Clear();
|
||||
GenOutbounds();
|
||||
GenStatistic();
|
||||
|
||||
var protectNode = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.Xray,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
Address = Global.Loopback,
|
||||
Port = context.TunProtectSsPort,
|
||||
Password = Global.None,
|
||||
};
|
||||
protectNode.SetProtocolExtra(protectNode.GetProtocolExtra() with
|
||||
{
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
|
||||
foreach (var outbound in _coreConfig.outbounds
|
||||
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||
{
|
||||
outbound.streamSettings ??= new();
|
||||
outbound.streamSettings.sockopt ??= new();
|
||||
outbound.streamSettings.sockopt.dialerProxy = "tun-protect-ss";
|
||||
}
|
||||
// ech protected
|
||||
foreach (var outbound in _coreConfig.outbounds
|
||||
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
||||
{
|
||||
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
||||
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-protect-ss";
|
||||
}
|
||||
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
||||
{
|
||||
Node = protectNode,
|
||||
}).BuildProxyOutbound("tun-protect-ss"));
|
||||
|
||||
_coreConfig.routing.rules ??= [];
|
||||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
||||
_coreConfig.routing.rules.Add(new()
|
||||
{
|
||||
inboundTag = ["proxy-relay-ss"],
|
||||
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
||||
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix : null,
|
||||
type = "field"
|
||||
});
|
||||
|
||||
//_coreConfig.inbounds.Clear();
|
||||
|
||||
var configNode = JsonUtils.ParseJson(JsonUtils.Serialize(_coreConfig))!;
|
||||
configNode["inbounds"]!.AsArray().Add(new
|
||||
{
|
||||
listen = Global.Loopback,
|
||||
port = context.ProxyRelaySsPort,
|
||||
protocol = "shadowsocks",
|
||||
settings = new
|
||||
{
|
||||
network = "tcp,udp",
|
||||
method = Global.None,
|
||||
password = Global.None,
|
||||
},
|
||||
tag = "proxy-relay-ss",
|
||||
});
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(configNode);
|
||||
return ret;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
ret.Msg = ResUI.FailedGenDefaultConfiguration;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion public gen function
|
||||
}
|
||||
|
||||
@@ -5,12 +5,18 @@ public partial class CoreConfigV2rayService
|
||||
private string ApplyFullConfigTemplate()
|
||||
{
|
||||
var fullConfigTemplate = context.FullConfigTemplate;
|
||||
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
||||
if (fullConfigTemplate is not { Enabled: true })
|
||||
{
|
||||
return JsonUtils.Serialize(_coreConfig);
|
||||
}
|
||||
|
||||
var fullConfigTemplateNode = JsonNode.Parse(fullConfigTemplate.Config);
|
||||
var fullConfigTemplateItem = context.IsTunEnabled ? fullConfigTemplate.TunConfig : fullConfigTemplate.Config;
|
||||
if (fullConfigTemplateItem.IsNullOrEmpty())
|
||||
{
|
||||
return JsonUtils.Serialize(_coreConfig);
|
||||
}
|
||||
|
||||
var fullConfigTemplateNode = JsonNode.Parse(fullConfigTemplateItem);
|
||||
if (fullConfigTemplateNode == null)
|
||||
{
|
||||
return JsonUtils.Serialize(_coreConfig);
|
||||
@@ -109,9 +115,7 @@ public partial class CoreConfigV2rayService
|
||||
?? string.Empty;
|
||||
if (!Utils.IsPrivateNetwork(outboundAddress))
|
||||
{
|
||||
outbound.streamSettings ??= new StreamSettings4Ray();
|
||||
outbound.streamSettings.sockopt ??= new Sockopt4Ray();
|
||||
outbound.streamSettings.sockopt.dialerProxy = fullConfigTemplate.ProxyDetour;
|
||||
FillDialerProxy(outbound, fullConfigTemplate.ProxyDetour);
|
||||
}
|
||||
}
|
||||
customOutboundsNode.Add(JsonUtils.DeepCopy(outbound));
|
||||
@@ -129,4 +133,80 @@ public partial class CoreConfigV2rayService
|
||||
|
||||
return JsonUtils.Serialize(fullConfigTemplateNode);
|
||||
}
|
||||
|
||||
private void ApplyOutboundBindInterface()
|
||||
{
|
||||
var bindInterface = _config.CoreBasicItem.BindInterface?.TrimEx();
|
||||
if (bindInterface.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!(context.IsTunEnabled || context.IsWindows))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||
{
|
||||
if (!ShouldBindNet(outbound))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
outbound.streamSettings ??= new();
|
||||
outbound.streamSettings.sockopt ??= new();
|
||||
outbound.streamSettings.sockopt.Interface = bindInterface;
|
||||
// xhttp download bind interface
|
||||
if (outbound?.streamSettings?.xhttpSettings?.extra is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
|
||||
if (xhttpExtra is not JsonObject xhttpExtraObject
|
||||
|| xhttpExtraObject["downloadSettings"] is not JsonObject downloadSettings)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
|
||||
sockopt["interface"] = bindInterface;
|
||||
downloadSettings["sockopt"] = sockopt;
|
||||
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyOutboundSendThrough()
|
||||
{
|
||||
var sendThrough = _config.CoreBasicItem.SendThrough?.TrimEx();
|
||||
if (sendThrough.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var outbound in _coreConfig.outbounds ?? [])
|
||||
{
|
||||
outbound.sendThrough = ShouldBindNet(outbound) ? sendThrough : null;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ShouldBindNet(Outbounds4Ray outbound)
|
||||
{
|
||||
if (outbound.protocol is "freedom" or "blackhole" or "dns" or "loopback")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (outbound.streamSettings?.sockopt?.dialerProxy.IsNullOrEmpty() == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var outboundAddress = outbound.settings?.servers?.FirstOrDefault()?.address
|
||||
?? outbound.settings?.vnext?.FirstOrDefault()?.address
|
||||
?? outbound.settings?.address?.ToString()
|
||||
?? string.Empty;
|
||||
|
||||
if (outboundAddress.Equals("localhost", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !IPAddress.TryParse(outboundAddress, out var address) || !IPAddress.IsLoopback(address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public partial class CoreConfigV2rayService
|
||||
var proxyGeositeList = new List<string>();
|
||||
var expectedDomainList = new List<string>();
|
||||
var expectedIPs = new List<string>();
|
||||
var regionNames = new HashSet<string>();
|
||||
var regionName = string.Empty;
|
||||
|
||||
var bootstrapDNSAddress = ParseDnsAddresses(simpleDNSItem?.BootstrapDNS, Global.DomainPureIPDNSAddress.First());
|
||||
var dnsServerDomains = new List<string>();
|
||||
@@ -160,18 +160,14 @@ public partial class CoreConfigV2rayService
|
||||
.Where(s => !string.IsNullOrEmpty(s))
|
||||
.ToList();
|
||||
|
||||
foreach (var ip in expectedIPs)
|
||||
foreach (var region in from ip in expectedIPs
|
||||
where ip.StartsWith(Global.GeoIPPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
select ip[Global.GeoIPPrefix.Length..]
|
||||
into region
|
||||
where !string.IsNullOrEmpty(region)
|
||||
select region)
|
||||
{
|
||||
if (ip.StartsWith("geoip:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var region = ip["geoip:".Length..];
|
||||
if (!string.IsNullOrEmpty(region))
|
||||
{
|
||||
regionNames.Add($"geosite:{region}");
|
||||
regionNames.Add($"geosite:geolocation-{region}");
|
||||
regionNames.Add($"geosite:tld-{region}");
|
||||
}
|
||||
}
|
||||
regionName = region;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,9 +197,14 @@ public partial class CoreConfigV2rayService
|
||||
|
||||
if (item.OutboundTag == Global.DirectTag)
|
||||
{
|
||||
if (normalizedDomain.StartsWith("geosite:") || normalizedDomain.StartsWith("ext:"))
|
||||
if (normalizedDomain.StartsWith(Global.GeoSitePrefix) || normalizedDomain.StartsWith("ext:"))
|
||||
{
|
||||
(regionNames.Contains(normalizedDomain) ? expectedDomainList : directGeositeList).Add(normalizedDomain);
|
||||
var isExpectedDomain = !regionName.IsNullOrEmpty()
|
||||
&& (normalizedDomain.EndsWith($"-{regionName}")
|
||||
|| normalizedDomain.EndsWith($"@{regionName}")
|
||||
|| normalizedDomain == Global.GeoSitePrefix + regionName);
|
||||
var targetList = isExpectedDomain ? expectedDomainList : directGeositeList;
|
||||
targetList.Add(normalizedDomain);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -212,7 +213,7 @@ public partial class CoreConfigV2rayService
|
||||
}
|
||||
else if (item.OutboundTag != Global.BlockTag)
|
||||
{
|
||||
if (normalizedDomain.StartsWith("geosite:") || normalizedDomain.StartsWith("ext:"))
|
||||
if (normalizedDomain.StartsWith(Global.GeoSitePrefix) || normalizedDomain.StartsWith("ext:"))
|
||||
{
|
||||
proxyGeositeList.Add(normalizedDomain);
|
||||
}
|
||||
@@ -370,11 +371,11 @@ public partial class CoreConfigV2rayService
|
||||
try
|
||||
{
|
||||
var item = context.RawDnsItem;
|
||||
var normalDNS = item?.NormalDNS;
|
||||
var customDNS = context.IsTunEnabled ? item?.TunDNS : item?.NormalDNS;
|
||||
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
||||
if (normalDNS.IsNullOrEmpty())
|
||||
if (customDNS.IsNullOrEmpty())
|
||||
{
|
||||
normalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||
customDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||
}
|
||||
|
||||
//Outbound Freedom domainStrategy
|
||||
@@ -389,11 +390,11 @@ public partial class CoreConfigV2rayService
|
||||
}
|
||||
}
|
||||
|
||||
var obj = JsonUtils.ParseJson(normalDNS);
|
||||
var obj = JsonUtils.ParseJson(customDNS);
|
||||
if (obj is null)
|
||||
{
|
||||
List<string> servers = [];
|
||||
var arrDNS = normalDNS.Split(',');
|
||||
var arrDNS = customDNS.Split(',');
|
||||
foreach (var str in arrDNS)
|
||||
{
|
||||
servers.Add(str);
|
||||
|
||||
@@ -7,36 +7,66 @@ public partial class CoreConfigV2rayService
|
||||
try
|
||||
{
|
||||
var listen = "0.0.0.0";
|
||||
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||
_coreConfig.inbounds = [];
|
||||
|
||||
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
|
||||
_coreConfig.inbounds.Add(inbound);
|
||||
var isUsingLocalMixedPort = _node.Address == Global.Loopback && _node.Port == listenPort;
|
||||
|
||||
if (_config.Inbound.First().SecondLocalPortEnabled)
|
||||
if (!context.IsTunEnabled || !isUsingLocalMixedPort)
|
||||
{
|
||||
var inbound2 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks2, true);
|
||||
_coreConfig.inbounds.Add(inbound2);
|
||||
}
|
||||
_coreConfig.inbounds.Add(inbound);
|
||||
|
||||
if (_config.Inbound.First().AllowLANConn)
|
||||
{
|
||||
if (_config.Inbound.First().NewPort4LAN)
|
||||
if (_config.Inbound.First().SecondLocalPortEnabled)
|
||||
{
|
||||
var inbound3 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks3, true);
|
||||
inbound3.listen = listen;
|
||||
_coreConfig.inbounds.Add(inbound3);
|
||||
var inbound2 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks2, true);
|
||||
_coreConfig.inbounds.Add(inbound2);
|
||||
}
|
||||
|
||||
//auth
|
||||
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
||||
if (_config.Inbound.First().AllowLANConn)
|
||||
{
|
||||
if (_config.Inbound.First().NewPort4LAN)
|
||||
{
|
||||
inbound3.settings.auth = "password";
|
||||
inbound3.settings.accounts = new List<AccountsItem4Ray> { new() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass } };
|
||||
var inbound3 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks3, true);
|
||||
inbound3.listen = listen;
|
||||
_coreConfig.inbounds.Add(inbound3);
|
||||
|
||||
//auth
|
||||
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty())
|
||||
{
|
||||
inbound3.settings.auth = "password";
|
||||
inbound3.settings.accounts = new List<AccountsItem4Ray>
|
||||
{
|
||||
new() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass }
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inbound.listen = listen;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
if (context.IsTunEnabled)
|
||||
{
|
||||
if (_config.TunModeItem.Mtu <= 0)
|
||||
{
|
||||
inbound.listen = listen;
|
||||
_config.TunModeItem.Mtu = Global.TunMtus.First();
|
||||
}
|
||||
var tunInbound = JsonUtils.Deserialize<Inbounds4Ray>(EmbedUtils.GetEmbedText(Global.V2raySampleTunInbound)) ?? new Inbounds4Ray { };
|
||||
tunInbound.settings.name = context.IsMacOS ? $"utun{new Random().Next(99)}" : "xray_tun";
|
||||
tunInbound.settings.MTU = _config.TunModeItem.Mtu;
|
||||
if (_config.TunModeItem.EnableIPv6Address == false)
|
||||
{
|
||||
tunInbound.settings.gateway = ["172.18.0.1/30"];
|
||||
}
|
||||
var bindInterface = _config.CoreBasicItem.BindInterface?.TrimEx();
|
||||
if (!bindInterface.IsNullOrEmpty())
|
||||
{
|
||||
tunInbound.settings.autoOutboundsInterface = bindInterface;
|
||||
}
|
||||
tunInbound.sniffing = inbound.sniffing;
|
||||
_coreConfig.inbounds.Add(tunInbound);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -12,6 +12,10 @@ public partial class CoreConfigV2rayService
|
||||
GenObservatory(multipleLoad);
|
||||
GenBalancer(multipleLoad);
|
||||
}
|
||||
if (context.IsTunEnabled)
|
||||
{
|
||||
_coreConfig.outbounds.Add(BuildDnsOutbound());
|
||||
}
|
||||
}
|
||||
|
||||
private List<Outbounds4Ray> BuildAllProxyOutbounds(string baseTagName = Global.ProxyTag)
|
||||
@@ -25,38 +29,6 @@ public partial class CoreConfigV2rayService
|
||||
{
|
||||
proxyOutboundList.Add(BuildProxyOutbound(baseTagName));
|
||||
}
|
||||
|
||||
if (_config.CoreBasicItem.EnableFragment)
|
||||
{
|
||||
var fragmentOutbound = new Outbounds4Ray
|
||||
{
|
||||
protocol = "freedom",
|
||||
tag = $"frag-{baseTagName}",
|
||||
settings = new()
|
||||
{
|
||||
fragment = new()
|
||||
{
|
||||
packets = _config.Fragment4RayItem?.Packets,
|
||||
length = _config.Fragment4RayItem?.Length,
|
||||
interval = _config.Fragment4RayItem?.Interval
|
||||
}
|
||||
}
|
||||
};
|
||||
var actOutboundWithTlsList =
|
||||
proxyOutboundList.Where(n => n.streamSettings?.security.IsNullOrEmpty() == false
|
||||
&& (n.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true)).ToList();
|
||||
if (actOutboundWithTlsList.Count > 0)
|
||||
{
|
||||
proxyOutboundList.Add(fragmentOutbound);
|
||||
}
|
||||
foreach (var outbound in actOutboundWithTlsList)
|
||||
{
|
||||
outbound.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = fragmentOutbound.tag
|
||||
};
|
||||
}
|
||||
}
|
||||
return proxyOutboundList;
|
||||
}
|
||||
|
||||
@@ -153,6 +125,7 @@ public partial class CoreConfigV2rayService
|
||||
serversItem.password = _node.Password;
|
||||
serversItem.method = AppManager.Instance.GetShadowsocksSecurities(_node).Contains(protocolExtra.SsMethod)
|
||||
? protocolExtra.SsMethod : "none";
|
||||
serversItem.uot = protocolExtra.Uot == true ? true : null;
|
||||
|
||||
serversItem.ota = false;
|
||||
serversItem.level = 1;
|
||||
@@ -227,12 +200,13 @@ public partial class CoreConfigV2rayService
|
||||
usersItem.email = Global.UserEMail;
|
||||
usersItem.encryption = protocolExtra.VlessEncryption;
|
||||
|
||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
||||
if (protocolExtra.Flow.IsNullOrEmpty())
|
||||
{
|
||||
usersItem.flow = protocolExtra.Flow;
|
||||
FillOutboundMux(outbound, muxEnabled, muxEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
usersItem.flow = protocolExtra.Flow;
|
||||
FillOutboundMux(outbound, false, muxEnabled);
|
||||
}
|
||||
outbound.settings.servers = null;
|
||||
@@ -284,13 +258,14 @@ public partial class CoreConfigV2rayService
|
||||
var peer = new WireguardPeer4Ray
|
||||
{
|
||||
publicKey = protocolExtra.WgPublicKey ?? "",
|
||||
endpoint = address + ":" + _node.Port.ToString()
|
||||
endpoint = address + ":" + _node.Port.ToString(),
|
||||
preSharedKey = protocolExtra.WgPresharedKey,
|
||||
};
|
||||
var setting = new Outboundsettings4Ray
|
||||
{
|
||||
address = Utils.String2List(protocolExtra.WgInterfaceAddress),
|
||||
address = Utils.String2List(protocolExtra.WgInterfaceAddress)?.Select(s => s.Trim()).ToList() ?? ["172.16.0.2/32"],
|
||||
secretKey = _node.Password,
|
||||
reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
|
||||
reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(s => s.Trim()).Select(int.Parse).ToList(),
|
||||
mtu = protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu : Global.TunMtus.First(),
|
||||
peers = [peer]
|
||||
};
|
||||
@@ -350,15 +325,54 @@ public partial class CoreConfigV2rayService
|
||||
network = "hysteria";
|
||||
}
|
||||
streamSettings.network = network;
|
||||
var host = _node.RequestHost.TrimEx();
|
||||
var path = _node.Path.TrimEx();
|
||||
var sni = _node.Sni.TrimEx();
|
||||
var useragent = "";
|
||||
if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty())
|
||||
var transport = _node.GetTransportExtra();
|
||||
var host = string.Empty;
|
||||
var path = string.Empty;
|
||||
var kcpSeed = string.Empty;
|
||||
var kcpMtu = 0;
|
||||
var headerType = string.Empty;
|
||||
var xhttpExtra = string.Empty;
|
||||
switch (network)
|
||||
{
|
||||
useragent = Global.UserAgentTexts.GetValueOrDefault(_config.CoreBasicItem.DefUserAgent, _config.CoreBasicItem.DefUserAgent);
|
||||
case nameof(ETransport.raw):
|
||||
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||
headerType = transport.RawHeaderType?.TrimEx() ?? string.Empty;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.kcp):
|
||||
kcpSeed = transport.KcpSeed?.TrimEx() ?? string.Empty;
|
||||
headerType = transport.KcpHeaderType?.TrimEx() ?? string.Empty;
|
||||
kcpMtu = transport.KcpMtu > 0 ? transport.KcpMtu!.Value : _config.KcpItem.Mtu;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.httpupgrade):
|
||||
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.xhttp):
|
||||
host = transport.Host?.TrimEx() ?? string.Empty;
|
||||
path = transport.Path?.TrimEx() ?? string.Empty;
|
||||
headerType = transport.XhttpMode?.TrimEx() ?? string.Empty;
|
||||
xhttpExtra = transport.XhttpExtra?.TrimEx() ?? string.Empty;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
host = transport.GrpcAuthority?.TrimEx() ?? string.Empty;
|
||||
path = transport.GrpcServiceName?.TrimEx() ?? string.Empty;
|
||||
headerType = transport.GrpcMode?.TrimEx() ?? string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
var sni = _node.Sni.TrimEx();
|
||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||
|
||||
//if tls
|
||||
if (_node.StreamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
@@ -370,7 +384,6 @@ public partial class CoreConfigV2rayService
|
||||
alpn = _node.GetAlpn(),
|
||||
fingerprint = _node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : _node.Fingerprint,
|
||||
echConfigList = _node.EchConfigList.NullIfEmpty(),
|
||||
echForceQuery = _node.EchForceQuery.NullIfEmpty()
|
||||
};
|
||||
if (sni.IsNotEmpty())
|
||||
{
|
||||
@@ -380,6 +393,11 @@ public partial class CoreConfigV2rayService
|
||||
{
|
||||
tlsSettings.serverName = Utils.String2List(host)?.First();
|
||||
}
|
||||
if (!tlsSettings.echConfigList.IsNullOrEmpty())
|
||||
{
|
||||
// For legacy xray compatibility, remove this in the future
|
||||
tlsSettings.echForceQuery = "full";
|
||||
}
|
||||
var certs = CertPemManager.ParsePemChain(_node.Cert);
|
||||
if (certs.Count > 0)
|
||||
{
|
||||
@@ -430,45 +448,45 @@ public partial class CoreConfigV2rayService
|
||||
case nameof(ETransport.kcp):
|
||||
KcpSettings4Ray kcpSettings = new()
|
||||
{
|
||||
mtu = _config.KcpItem.Mtu,
|
||||
mtu = kcpMtu,
|
||||
tti = _config.KcpItem.Tti
|
||||
};
|
||||
|
||||
kcpSettings.uplinkCapacity = _config.KcpItem.UplinkCapacity;
|
||||
kcpSettings.downlinkCapacity = _config.KcpItem.DownlinkCapacity;
|
||||
|
||||
kcpSettings.congestion = _config.KcpItem.Congestion;
|
||||
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
|
||||
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
|
||||
streamSettings.finalmask ??= new();
|
||||
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header))
|
||||
kcpSettings.cwndMultiplier = _config.KcpItem.CwndMultiplier;
|
||||
kcpSettings.maxSendingWindow = _config.KcpItem.MaxSendingWindow;
|
||||
var kcpFinalmask = new Finalmask4Ray();
|
||||
if (Global.KcpHeaderMaskMap.TryGetValue(headerType, out var header))
|
||||
{
|
||||
streamSettings.finalmask.udp =
|
||||
kcpFinalmask.udp =
|
||||
[
|
||||
new Mask4Ray
|
||||
{
|
||||
type = header,
|
||||
settings = _node.HeaderType == "dns" && !host.IsNullOrEmpty() ? new MaskSettings4Ray { domain = host } : null
|
||||
settings = null
|
||||
}
|
||||
];
|
||||
}
|
||||
streamSettings.finalmask.udp ??= [];
|
||||
if (path.IsNullOrEmpty())
|
||||
kcpFinalmask.udp ??= [];
|
||||
if (kcpSeed.IsNullOrEmpty())
|
||||
{
|
||||
streamSettings.finalmask.udp.Add(new Mask4Ray
|
||||
kcpFinalmask.udp.Add(new Mask4Ray
|
||||
{
|
||||
type = "mkcp-original"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
streamSettings.finalmask.udp.Add(new Mask4Ray
|
||||
kcpFinalmask.udp.Add(new Mask4Ray
|
||||
{
|
||||
type = "mkcp-aes128gcm",
|
||||
settings = new MaskSettings4Ray { password = path }
|
||||
settings = new MaskSettings4Ray { password = kcpSeed }
|
||||
});
|
||||
}
|
||||
streamSettings.kcpSettings = kcpSettings;
|
||||
streamSettings.finalmask = kcpFinalmask;
|
||||
break;
|
||||
//ws
|
||||
case nameof(ETransport.ws):
|
||||
@@ -494,13 +512,17 @@ public partial class CoreConfigV2rayService
|
||||
case nameof(ETransport.httpupgrade):
|
||||
HttpupgradeSettings4Ray httpupgradeSettings = new();
|
||||
|
||||
if (host.IsNotEmpty())
|
||||
{
|
||||
httpupgradeSettings.host = host;
|
||||
}
|
||||
if (path.IsNotEmpty())
|
||||
{
|
||||
httpupgradeSettings.path = path;
|
||||
}
|
||||
if (host.IsNotEmpty())
|
||||
if (useragent.IsNotEmpty())
|
||||
{
|
||||
httpupgradeSettings.host = host;
|
||||
httpupgradeSettings.headers.UserAgent = useragent;
|
||||
}
|
||||
streamSettings.httpupgradeSettings = httpupgradeSettings;
|
||||
|
||||
@@ -518,67 +540,31 @@ public partial class CoreConfigV2rayService
|
||||
{
|
||||
xhttpSettings.host = host;
|
||||
}
|
||||
if (_node.HeaderType.IsNotEmpty() && Global.XhttpMode.Contains(_node.HeaderType))
|
||||
if (headerType.IsNotEmpty() && Global.XhttpMode.Contains(headerType))
|
||||
{
|
||||
xhttpSettings.mode = _node.HeaderType;
|
||||
xhttpSettings.mode = headerType;
|
||||
}
|
||||
if (_node.Extra.IsNotEmpty())
|
||||
if (xhttpExtra.IsNotEmpty())
|
||||
{
|
||||
xhttpSettings.extra = JsonUtils.ParseJson(_node.Extra);
|
||||
xhttpSettings.extra = JsonUtils.ParseJson(xhttpExtra);
|
||||
}
|
||||
|
||||
streamSettings.xhttpSettings = xhttpSettings;
|
||||
FillOutboundMux(outbound);
|
||||
|
||||
break;
|
||||
//h2
|
||||
case nameof(ETransport.h2):
|
||||
HttpSettings4Ray httpSettings = new();
|
||||
|
||||
if (host.IsNotEmpty())
|
||||
{
|
||||
httpSettings.host = Utils.String2List(host);
|
||||
}
|
||||
httpSettings.path = path;
|
||||
|
||||
streamSettings.httpSettings = httpSettings;
|
||||
|
||||
break;
|
||||
//quic
|
||||
case nameof(ETransport.quic):
|
||||
QuicSettings4Ray quicsettings = new()
|
||||
{
|
||||
security = host,
|
||||
key = path,
|
||||
header = new Header4Ray
|
||||
{
|
||||
type = _node.HeaderType
|
||||
}
|
||||
};
|
||||
streamSettings.quicSettings = quicsettings;
|
||||
if (_node.StreamSecurity == Global.StreamSecurity)
|
||||
{
|
||||
if (sni.IsNotEmpty())
|
||||
{
|
||||
streamSettings.tlsSettings.serverName = sni;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamSettings.tlsSettings.serverName = _node.Address;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
GrpcSettings4Ray grpcSettings = new()
|
||||
{
|
||||
authority = host.NullIfEmpty(),
|
||||
serviceName = path,
|
||||
multiMode = _node.HeaderType == Global.GrpcMultiMode,
|
||||
multiMode = headerType == Global.GrpcMultiMode,
|
||||
idle_timeout = _config.GrpcItem.IdleTimeout,
|
||||
health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
|
||||
permit_without_stream = _config.GrpcItem.PermitWithoutStream,
|
||||
initial_windows_size = _config.GrpcItem.InitialWindowsSize,
|
||||
user_agent = useragent.NullIfEmpty(),
|
||||
};
|
||||
streamSettings.grpcSettings = grpcSettings;
|
||||
break;
|
||||
@@ -591,62 +577,73 @@ public partial class CoreConfigV2rayService
|
||||
: _config.HysteriaItem.UpMbps;
|
||||
int? downMbps = protocolExtra?.DownMbps is { } sd and >= 0
|
||||
? sd
|
||||
: _config.HysteriaItem.UpMbps;
|
||||
: _config.HysteriaItem.DownMbps;
|
||||
var hopInterval = !protocolExtra.HopInterval.IsNullOrEmpty()
|
||||
? protocolExtra.HopInterval
|
||||
: (_config.HysteriaItem.HopInterval >= 5
|
||||
? _config.HysteriaItem.HopInterval
|
||||
: Global.Hysteria2DefaultHopInt).ToString();
|
||||
HysteriaUdpHop4Ray? udpHop = null;
|
||||
var hy2Finalmask = new Finalmask4Ray();
|
||||
var quicParams = new QuicParams4Ray();
|
||||
if (!ports.IsNullOrEmpty() &&
|
||||
(ports.Contains(':') || ports.Contains('-') || ports.Contains(',')))
|
||||
{
|
||||
udpHop = new HysteriaUdpHop4Ray
|
||||
var udpHop = new UdpHop4Ray
|
||||
{
|
||||
port = ports.Replace(':', '-'),
|
||||
ports = ports.Replace(':', '-'),
|
||||
interval = hopInterval,
|
||||
};
|
||||
quicParams.udpHop = udpHop;
|
||||
}
|
||||
if (upMbps > 0 || downMbps > 0)
|
||||
{
|
||||
quicParams.congestion = "brutal";
|
||||
quicParams.brutalUp = upMbps > 0 ? $"{upMbps}mbps" : null;
|
||||
quicParams.brutalDown = downMbps > 0 ? $"{downMbps}mbps" : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
quicParams.congestion = "bbr";
|
||||
}
|
||||
hy2Finalmask.quicParams = quicParams;
|
||||
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
|
||||
{
|
||||
hy2Finalmask.udp =
|
||||
[
|
||||
new Mask4Ray
|
||||
{
|
||||
type = "salamander",
|
||||
settings = new MaskSettings4Ray { password = protocolExtra.SalamanderPass.TrimEx(), }
|
||||
}
|
||||
];
|
||||
}
|
||||
streamSettings.hysteriaSettings = new()
|
||||
{
|
||||
version = 2,
|
||||
auth = _node.Password,
|
||||
up = upMbps > 0 ? $"{upMbps}mbps" : null,
|
||||
down = downMbps > 0 ? $"{downMbps}mbps" : null,
|
||||
udphop = udpHop,
|
||||
};
|
||||
if (!protocolExtra.SalamanderPass.IsNullOrEmpty())
|
||||
{
|
||||
streamSettings.finalmask ??= new();
|
||||
streamSettings.finalmask.udp =
|
||||
[
|
||||
new Mask4Ray
|
||||
{
|
||||
type = "salamander",
|
||||
settings = new MaskSettings4Ray { password = protocolExtra.SalamanderPass.TrimEx(), }
|
||||
}
|
||||
];
|
||||
}
|
||||
streamSettings.finalmask = hy2Finalmask;
|
||||
break;
|
||||
|
||||
default:
|
||||
//tcp
|
||||
if (_node.HeaderType == Global.TcpHeaderHttp)
|
||||
// raw
|
||||
if (headerType == Global.RawHeaderHttp)
|
||||
{
|
||||
TcpSettings4Ray tcpSettings = new()
|
||||
RawSettings4Ray rawSettings = new()
|
||||
{
|
||||
header = new Header4Ray
|
||||
{
|
||||
type = _node.HeaderType
|
||||
type = headerType
|
||||
}
|
||||
};
|
||||
|
||||
//request Host
|
||||
var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
|
||||
var useragentValue = Global.RawHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||
var arrHost = host.Split(',');
|
||||
var host2 = string.Join(",".AppendQuotes(), arrHost);
|
||||
request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
|
||||
request = request.Replace("$requestUserAgent$", $"{useragent.AppendQuotes()}");
|
||||
request = request.Replace("$requestUserAgent$", $"{useragentValue.AppendQuotes()}");
|
||||
//Path
|
||||
var pathHttp = @"/";
|
||||
if (path.IsNotEmpty())
|
||||
@@ -655,16 +652,16 @@ public partial class CoreConfigV2rayService
|
||||
pathHttp = string.Join(",".AppendQuotes(), arrPath);
|
||||
}
|
||||
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}");
|
||||
tcpSettings.header.request = JsonUtils.Deserialize<object>(request);
|
||||
rawSettings.header.request = JsonUtils.Deserialize<object>(request);
|
||||
|
||||
streamSettings.tcpSettings = tcpSettings;
|
||||
streamSettings.rawSettings = rawSettings;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_node.Finalmask.IsNullOrEmpty())
|
||||
{
|
||||
streamSettings.finalmask = JsonUtils.Deserialize<Finalmask4Ray>(_node.Finalmask);
|
||||
streamSettings.finalmask = JsonUtils.ParseJson(_node.Finalmask);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -687,7 +684,12 @@ public partial class CoreConfigV2rayService
|
||||
for (var i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
var node = nodes[i];
|
||||
var currentTag = $"{baseTagName}-{i + 1}";
|
||||
var currentTag = $"{baseTagName}-{i + 1}-{node.Remarks}";
|
||||
|
||||
if (nodes.Count == 1)
|
||||
{
|
||||
currentTag = baseTagName;
|
||||
}
|
||||
|
||||
if (node.ConfigType.IsGroupType())
|
||||
{
|
||||
@@ -718,8 +720,8 @@ public partial class CoreConfigV2rayService
|
||||
for (var i = 0; i < nodesReverse.Count; i++)
|
||||
{
|
||||
var node = nodesReverse[i];
|
||||
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}";
|
||||
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}" : null;
|
||||
var currentTag = i == 0 ? baseTagName : $"chain-{baseTagName}-{i}-{node.Remarks}";
|
||||
var dialerProxyTag = i != nodesReverse.Count - 1 ? $"chain-{baseTagName}-{i + 1}-{nodesReverse[i + 1].Remarks}" : null;
|
||||
if (node.ConfigType.IsGroupType())
|
||||
{
|
||||
var childProfiles = new CoreConfigV2rayService(context with { Node = node, }).BuildGroupProxyOutbounds(currentTag);
|
||||
@@ -729,10 +731,7 @@ public partial class CoreConfigV2rayService
|
||||
childProfiles.Where(n => n?.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true);
|
||||
foreach (var chainEndNode in chainEndNodes)
|
||||
{
|
||||
chainEndNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = dialerProxyTag
|
||||
};
|
||||
FillDialerProxy(chainEndNode, dialerProxyTag);
|
||||
}
|
||||
}
|
||||
if (i != 0)
|
||||
@@ -740,12 +739,10 @@ public partial class CoreConfigV2rayService
|
||||
var chainStartNodes = childProfiles.Where(n => n.tag.StartsWith(currentTag)).ToList();
|
||||
if (chainStartNodes.Count == 1)
|
||||
{
|
||||
var firstChainTag = chainStartNodes.First().tag;
|
||||
foreach (var existedChainEndNode in resultOutbounds.Where(n => n.streamSettings?.sockopt?.dialerProxy == currentTag))
|
||||
{
|
||||
existedChainEndNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = chainStartNodes.First().tag
|
||||
};
|
||||
FillDialerProxy(existedChainEndNode, firstChainTag);
|
||||
}
|
||||
}
|
||||
else if (chainStartNodes.Count > 1)
|
||||
@@ -768,12 +765,8 @@ public partial class CoreConfigV2rayService
|
||||
var nextTag = k + 1 < existedChainNodesClone.Count
|
||||
? existedChainNodesClone[k + 1].tag
|
||||
: chainStartNode.tag;
|
||||
existedChainNode.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = (previousDialerProxyTag == currentTag)
|
||||
? chainStartNode.tag
|
||||
: nextTag
|
||||
};
|
||||
FillDialerProxy(existedChainNode,
|
||||
previousDialerProxyTag == currentTag ? chainStartNode.tag : nextTag);
|
||||
resultOutbounds.Add(existedChainNode);
|
||||
}
|
||||
j++;
|
||||
@@ -789,14 +782,102 @@ public partial class CoreConfigV2rayService
|
||||
|
||||
if (!dialerProxyTag.IsNullOrEmpty())
|
||||
{
|
||||
outbound.streamSettings.sockopt = new()
|
||||
{
|
||||
dialerProxy = dialerProxyTag
|
||||
};
|
||||
FillDialerProxy(outbound, dialerProxyTag);
|
||||
}
|
||||
|
||||
resultOutbounds.Add(outbound);
|
||||
}
|
||||
return resultOutbounds;
|
||||
}
|
||||
|
||||
private static void FillDialerProxy(Outbounds4Ray outbound, string dialerProxyTag)
|
||||
{
|
||||
outbound.streamSettings ??= new();
|
||||
outbound.streamSettings.sockopt ??= new();
|
||||
outbound.streamSettings.sockopt.dialerProxy = dialerProxyTag;
|
||||
|
||||
// xhttp download dialer proxy
|
||||
if (outbound?.streamSettings?.xhttpSettings?.extra is not null)
|
||||
{
|
||||
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
|
||||
if (xhttpExtra is JsonObject xhttpExtraObject
|
||||
&& xhttpExtraObject["downloadSettings"] is JsonObject downloadSettings)
|
||||
{
|
||||
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
|
||||
sockopt["dialerProxy"] = dialerProxyTag;
|
||||
downloadSettings["sockopt"] = sockopt;
|
||||
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Outbounds4Ray BuildDnsOutbound()
|
||||
{
|
||||
var outbound = new Outbounds4Ray { tag = Global.DnsOutboundTag, protocol = "dns", };
|
||||
return outbound;
|
||||
}
|
||||
|
||||
private void ApplyOutboundFragment()
|
||||
{
|
||||
var actOutboundWithTlsList =
|
||||
_coreConfig.outbounds.Where(n => n.streamSettings?.security.IsNullOrEmpty() == false
|
||||
&& (n.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||
.ToList();
|
||||
|
||||
var configPackets = _config.Fragment4RayItem?.Packets ?? "tlshello";
|
||||
var configLength = _config.Fragment4RayItem?.Length ?? "50-100";
|
||||
var configDelay = _config.Fragment4RayItem?.Interval ?? "10-20";
|
||||
|
||||
var fragmentMask = new Mask4Ray
|
||||
{
|
||||
type = "fragment",
|
||||
settings = new MaskSettings4Ray
|
||||
{
|
||||
packets = configPackets,
|
||||
length = configLength,
|
||||
delay = configDelay,
|
||||
}
|
||||
};
|
||||
var noiseMask = new Mask4Ray
|
||||
{
|
||||
type = "noise",
|
||||
settings = new MaskSettings4Ray
|
||||
{
|
||||
length = "10-20",
|
||||
delay = "10-16",
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var outbound in actOutboundWithTlsList)
|
||||
{
|
||||
//var packets = configPackets;
|
||||
//if (outbound.streamSettings.security == Global.StreamSecurityReality
|
||||
// && packets == "tlshello")
|
||||
//{
|
||||
// packets = "1-3";
|
||||
//}
|
||||
//else if (outbound.streamSettings.security == Global.StreamSecurity
|
||||
// && packets != "tlshello")
|
||||
//{
|
||||
// packets = "tlshello";
|
||||
//}
|
||||
var finalMaskJsonObj = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings?.finalmask)) as JsonObject ?? new JsonObject();
|
||||
// tcp fragment
|
||||
var tcpFinalmaskList = finalMaskJsonObj["tcp"] as JsonArray ?? [];
|
||||
if (tcpFinalmaskList.Count == 0)
|
||||
{
|
||||
tcpFinalmaskList.Add(JsonUtils.SerializeToNode(fragmentMask));
|
||||
finalMaskJsonObj["tcp"] = tcpFinalmaskList;
|
||||
}
|
||||
// udp noise
|
||||
var udpFinalmaskList = finalMaskJsonObj["udp"] as JsonArray ?? [];
|
||||
if (udpFinalmaskList.Count == 0)
|
||||
{
|
||||
udpFinalmaskList.Add(JsonUtils.SerializeToNode(noiseMask));
|
||||
finalMaskJsonObj["udp"] = udpFinalmaskList;
|
||||
}
|
||||
// write back
|
||||
outbound.streamSettings.finalmask = finalMaskJsonObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,31 @@ public partial class CoreConfigV2rayService
|
||||
{
|
||||
try
|
||||
{
|
||||
if (context.IsTunEnabled)
|
||||
{
|
||||
var tunRules = JsonUtils.Deserialize<List<RulesItem4Ray>>(EmbedUtils.GetEmbedText(Global.V2raySampleTunRules));
|
||||
if (tunRules != null)
|
||||
{
|
||||
_coreConfig.routing.rules.AddRange(tunRules);
|
||||
}
|
||||
var (lstDnsExe, lstDirectExe) = BuildRoutingDirectExe();
|
||||
_coreConfig.routing.rules.Add(new()
|
||||
{
|
||||
port = "53",
|
||||
process = lstDnsExe,
|
||||
outboundTag = Global.DnsOutboundTag,
|
||||
});
|
||||
_coreConfig.routing.rules.Add(new()
|
||||
{
|
||||
process = lstDirectExe,
|
||||
outboundTag = Global.DirectTag,
|
||||
});
|
||||
_coreConfig.routing.rules.Add(new()
|
||||
{
|
||||
port = "53",
|
||||
outboundTag = Global.DnsOutboundTag,
|
||||
});
|
||||
}
|
||||
if (_coreConfig.routing?.rules != null)
|
||||
{
|
||||
_coreConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
|
||||
@@ -164,7 +189,7 @@ public partial class CoreConfigV2rayService
|
||||
return Global.ProxyTag;
|
||||
}
|
||||
|
||||
var tag = $"{node.IndexId}-{Global.ProxyTag}";
|
||||
var tag = $"{node.IndexId}-{Global.ProxyTag}-{node.Remarks}";
|
||||
if (_coreConfig.outbounds.Any(p => p.tag.StartsWith(tag)))
|
||||
{
|
||||
return tag;
|
||||
@@ -205,4 +230,37 @@ public partial class CoreConfigV2rayService
|
||||
}
|
||||
return finalRule;
|
||||
}
|
||||
|
||||
private static (List<string> lstDnsExe, List<string> lstDirectExe) BuildRoutingDirectExe()
|
||||
{
|
||||
var dnsExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
var directExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var coreInfoResult = CoreInfoManager.Instance.GetCoreInfo();
|
||||
|
||||
foreach (var coreConfig in coreInfoResult)
|
||||
{
|
||||
if (coreConfig.CoreType == ECoreType.v2rayN)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var baseExeName in coreConfig.CoreExes)
|
||||
{
|
||||
if (coreConfig.CoreType != ECoreType.Xray)
|
||||
{
|
||||
dnsExeSet.Add(Utils.GetExeName(baseExeName));
|
||||
}
|
||||
directExeSet.Add(Utils.GetExeName(baseExeName));
|
||||
}
|
||||
}
|
||||
|
||||
directExeSet.Add("xray/");
|
||||
directExeSet.Add("self/");
|
||||
|
||||
var lstDnsExe = new List<string>(dnsExeSet);
|
||||
var lstDirectExe = new List<string>(directExeSet);
|
||||
|
||||
return (lstDnsExe, lstDirectExe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using ServiceLib.UdpTest;
|
||||
|
||||
namespace ServiceLib.Services;
|
||||
|
||||
public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateFunc)
|
||||
@@ -49,6 +51,10 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||
await RunRealPingBatchAsync(lstSelected, exitLoopKey);
|
||||
break;
|
||||
|
||||
case ESpeedActionType.UdpTest:
|
||||
await RunUdpTestBatchAsync(lstSelected, exitLoopKey);
|
||||
break;
|
||||
|
||||
case ESpeedActionType.Speedtest:
|
||||
await RunMixedTestAsync(lstSelected, 1, true, exitLoopKey);
|
||||
break;
|
||||
@@ -101,6 +107,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||
{
|
||||
case ESpeedActionType.Tcping:
|
||||
case ESpeedActionType.Realping:
|
||||
case ESpeedActionType.UdpTest:
|
||||
await UpdateFunc(it.IndexId, ResUI.Speedtesting, "");
|
||||
ProfileExManager.Instance.SetTestDelay(it.IndexId, 0);
|
||||
break;
|
||||
@@ -238,6 +245,86 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task RunUdpTestBatchAsync(List<ServerTestItem> lstSelected, string exitLoopKey, int pageSize = 0)
|
||||
{
|
||||
if (pageSize <= 0)
|
||||
{
|
||||
pageSize = lstSelected.Count < Global.SpeedTestPageSize ? lstSelected.Count : Global.SpeedTestPageSize;
|
||||
}
|
||||
var lstTest = GetTestBatchItem(lstSelected, pageSize);
|
||||
|
||||
List<ServerTestItem> lstFailed = new();
|
||||
foreach (var lst in lstTest)
|
||||
{
|
||||
var ret = await RunUdpTestAsync(lst, exitLoopKey);
|
||||
if (ret == false)
|
||||
{
|
||||
lstFailed.AddRange(lst);
|
||||
}
|
||||
await Task.Delay(100);
|
||||
}
|
||||
|
||||
//Retest the failed part
|
||||
if (lstFailed.Count > 0)
|
||||
{
|
||||
if (ShouldStopTest(exitLoopKey))
|
||||
{
|
||||
await UpdateFunc("", ResUI.SpeedtestingSkip);
|
||||
return;
|
||||
}
|
||||
|
||||
await UpdateFunc("", string.Format(ResUI.SpeedtestingTestFailedPart, lstFailed.Count));
|
||||
|
||||
await RunUdpTestAsync(lstFailed, exitLoopKey);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> RunUdpTestAsync(List<ServerTestItem> selecteds, string exitLoopKey)
|
||||
{
|
||||
ProcessService processService = null;
|
||||
try
|
||||
{
|
||||
processService = await CoreManager.Instance.LoadCoreConfigSpeedtest(selecteds);
|
||||
if (processService is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
await Task.Delay(1000);
|
||||
|
||||
List<Task> tasks = new();
|
||||
foreach (var it in selecteds)
|
||||
{
|
||||
if (!it.AllowTest)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ShouldStopTest(exitLoopKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
tasks.Add(Task.Run(async () =>
|
||||
{
|
||||
await DoUdpTest(it);
|
||||
}));
|
||||
}
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (processService != null)
|
||||
{
|
||||
await processService?.StopAsync();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task RunMixedTestAsync(List<ServerTestItem> selecteds, int concurrencyCount, bool blSpeedTest, string exitLoopKey)
|
||||
{
|
||||
using var concurrencySemaphore = new SemaphoreSlim(concurrencyCount);
|
||||
@@ -330,6 +417,24 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<int> DoUdpTest(ServerTestItem it)
|
||||
{
|
||||
var udpService = UdpTestService.CreateFromTarget(_config?.SpeedTestItem.UdpTestTarget, out var udpTestUrl);
|
||||
var responseTime = -1;
|
||||
try
|
||||
{
|
||||
responseTime = (int)(await udpService.SendUdpRequestAsync(udpTestUrl, it.Port, TimeSpan.FromSeconds(5))).TotalMilliseconds;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
||||
await UpdateFunc(it.IndexId, responseTime.ToString());
|
||||
return responseTime;
|
||||
}
|
||||
|
||||
private async Task<int> GetTcpingTime(string url, int port)
|
||||
{
|
||||
var responseTime = -1;
|
||||
|
||||
@@ -301,7 +301,12 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||
}
|
||||
else if (Utils.IsLinux())
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
var arch = RuntimeInformation.ProcessArchitecture;
|
||||
if (arch.ToString().Equals("RiscV64", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return coreInfo?.DownloadUrlLinuxRiscV64;
|
||||
}
|
||||
return arch switch
|
||||
{
|
||||
Architecture.Arm64 => coreInfo?.DownloadUrlLinuxArm64,
|
||||
Architecture.X64 => coreInfo?.DownloadUrlLinux64,
|
||||
@@ -370,8 +375,8 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||
foreach (var item in rules ?? [])
|
||||
{
|
||||
AddPrefixedItems(item.Ip, "geoip:", geoipFiles);
|
||||
AddPrefixedItems(item.Domain, "geosite:", geoSiteFiles);
|
||||
AddPrefixedItems(item.Ip, Global.GeoIPPrefix, geoipFiles);
|
||||
AddPrefixedItems(item.Domain, Global.GeoSitePrefix, geoSiteFiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ public class AddServerViewModel : MyReactiveObject
|
||||
[Reactive]
|
||||
public string CertSha { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool AllowInsecureCertFetch { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string SalamanderPass { get; set; }
|
||||
|
||||
@@ -50,8 +53,9 @@ public class AddServerViewModel : MyReactiveObject
|
||||
[Reactive]
|
||||
public string WgPublicKey { get; set; }
|
||||
|
||||
//[Reactive]
|
||||
//public string WgPresharedKey { get; set; }
|
||||
[Reactive]
|
||||
public string WgPresharedKey { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string WgInterfaceAddress { get; set; }
|
||||
|
||||
@@ -61,6 +65,163 @@ public class AddServerViewModel : MyReactiveObject
|
||||
[Reactive]
|
||||
public int WgMtu { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool Uot { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string CongestionControl { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public int? InsecureConcurrency { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool NaiveQuic { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string RawHeaderType { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string Host { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string Path { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string XhttpMode { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string XhttpExtra { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string GrpcAuthority { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string GrpcServiceName { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string GrpcMode { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string KcpHeaderType { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string KcpSeed { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public int? KcpMtu { get; set; }
|
||||
|
||||
public string TransportHeaderType
|
||||
{
|
||||
get => SelectedSource.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => RawHeaderType,
|
||||
nameof(ETransport.kcp) => KcpHeaderType,
|
||||
nameof(ETransport.xhttp) => XhttpMode,
|
||||
nameof(ETransport.grpc) => GrpcMode,
|
||||
_ => string.Empty,
|
||||
};
|
||||
set
|
||||
{
|
||||
switch (SelectedSource.GetNetwork())
|
||||
{
|
||||
case nameof(ETransport.raw):
|
||||
RawHeaderType = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.kcp):
|
||||
KcpHeaderType = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.xhttp):
|
||||
XhttpMode = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
GrpcMode = value;
|
||||
break;
|
||||
}
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string TransportHost
|
||||
{
|
||||
get => SelectedSource.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => Host,
|
||||
nameof(ETransport.ws) => Host,
|
||||
nameof(ETransport.httpupgrade) => Host,
|
||||
nameof(ETransport.xhttp) => Host,
|
||||
nameof(ETransport.grpc) => GrpcAuthority,
|
||||
_ => string.Empty,
|
||||
};
|
||||
set
|
||||
{
|
||||
switch (SelectedSource.GetNetwork())
|
||||
{
|
||||
case nameof(ETransport.raw):
|
||||
case nameof(ETransport.ws):
|
||||
case nameof(ETransport.httpupgrade):
|
||||
case nameof(ETransport.xhttp):
|
||||
Host = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
GrpcAuthority = value;
|
||||
break;
|
||||
}
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string TransportPath
|
||||
{
|
||||
get => SelectedSource.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.kcp) => KcpSeed,
|
||||
nameof(ETransport.ws) => Path,
|
||||
nameof(ETransport.httpupgrade) => Path,
|
||||
nameof(ETransport.xhttp) => Path,
|
||||
nameof(ETransport.grpc) => GrpcServiceName,
|
||||
_ => string.Empty,
|
||||
};
|
||||
set
|
||||
{
|
||||
switch (SelectedSource.GetNetwork())
|
||||
{
|
||||
case nameof(ETransport.kcp):
|
||||
KcpSeed = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.ws):
|
||||
case nameof(ETransport.httpupgrade):
|
||||
case nameof(ETransport.xhttp):
|
||||
Path = value;
|
||||
break;
|
||||
|
||||
case nameof(ETransport.grpc):
|
||||
GrpcServiceName = value;
|
||||
break;
|
||||
}
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string TransportExtraText
|
||||
{
|
||||
get => SelectedSource.GetNetwork() == nameof(ETransport.xhttp)
|
||||
? XhttpExtra
|
||||
: string.Empty;
|
||||
set
|
||||
{
|
||||
if (SelectedSource.GetNetwork() == nameof(ETransport.xhttp))
|
||||
{
|
||||
XhttpExtra = value;
|
||||
}
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> FetchCertCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
@@ -89,14 +250,21 @@ public class AddServerViewModel : MyReactiveObject
|
||||
this.WhenAnyValue(x => x.CertSha)
|
||||
.Subscribe(_ => UpdateCertTip());
|
||||
|
||||
this.WhenAnyValue(x => x.SelectedSource.Network)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
this.RaisePropertyChanged(nameof(TransportHeaderType));
|
||||
this.RaisePropertyChanged(nameof(TransportHost));
|
||||
this.RaisePropertyChanged(nameof(TransportPath));
|
||||
this.RaisePropertyChanged(nameof(TransportExtraText));
|
||||
});
|
||||
|
||||
this.WhenAnyValue(x => x.Cert)
|
||||
.Subscribe(_ => UpdateCertSha());
|
||||
|
||||
if (profileItem.IndexId.IsNullOrEmpty())
|
||||
{
|
||||
profileItem.Network = Global.DefaultNetwork;
|
||||
profileItem.HeaderType = Global.None;
|
||||
profileItem.RequestHost = "";
|
||||
profileItem.StreamSecurity = "";
|
||||
SelectedSource = profileItem;
|
||||
}
|
||||
@@ -108,21 +276,39 @@ public class AddServerViewModel : MyReactiveObject
|
||||
Cert = SelectedSource?.Cert?.ToString() ?? string.Empty;
|
||||
CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty;
|
||||
|
||||
var protocolExtra = SelectedSource?.GetProtocolExtra();
|
||||
Ports = protocolExtra?.Ports ?? string.Empty;
|
||||
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
||||
Flow = protocolExtra?.Flow ?? string.Empty;
|
||||
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
||||
UpMbps = protocolExtra?.UpMbps;
|
||||
DownMbps = protocolExtra?.DownMbps;
|
||||
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
|
||||
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||
SsMethod = protocolExtra?.SsMethod ?? string.Empty;
|
||||
WgPublicKey = protocolExtra?.WgPublicKey ?? string.Empty;
|
||||
WgInterfaceAddress = protocolExtra?.WgInterfaceAddress ?? string.Empty;
|
||||
WgReserved = protocolExtra?.WgReserved ?? string.Empty;
|
||||
WgMtu = protocolExtra?.WgMtu ?? 1280;
|
||||
var protocolExtra = SelectedSource?.GetProtocolExtra() ?? new();
|
||||
var transport = SelectedSource?.GetTransportExtra() ?? new();
|
||||
Ports = protocolExtra.Ports ?? string.Empty;
|
||||
AlterId = int.TryParse(protocolExtra.AlterId, out var result) ? result : 0;
|
||||
Flow = protocolExtra.Flow ?? string.Empty;
|
||||
SalamanderPass = protocolExtra.SalamanderPass ?? string.Empty;
|
||||
UpMbps = protocolExtra.UpMbps;
|
||||
DownMbps = protocolExtra.DownMbps;
|
||||
HopInterval = protocolExtra.HopInterval ?? string.Empty;
|
||||
VmessSecurity = protocolExtra.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||
VlessEncryption = protocolExtra.VlessEncryption?.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||
SsMethod = protocolExtra.SsMethod ?? string.Empty;
|
||||
WgPublicKey = protocolExtra.WgPublicKey ?? string.Empty;
|
||||
WgPresharedKey = protocolExtra.WgPresharedKey ?? string.Empty;
|
||||
WgInterfaceAddress = protocolExtra.WgInterfaceAddress ?? string.Empty;
|
||||
WgReserved = protocolExtra.WgReserved ?? string.Empty;
|
||||
WgMtu = protocolExtra.WgMtu ?? 1280;
|
||||
Uot = protocolExtra.Uot ?? false;
|
||||
CongestionControl = protocolExtra.CongestionControl ?? string.Empty;
|
||||
InsecureConcurrency = protocolExtra.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
|
||||
NaiveQuic = protocolExtra.NaiveQuic ?? false;
|
||||
|
||||
RawHeaderType = transport.RawHeaderType ?? Global.None;
|
||||
Host = transport.Host ?? string.Empty;
|
||||
Path = transport.Path ?? string.Empty;
|
||||
XhttpMode = transport.XhttpMode ?? Global.DefaultXhttpMode;
|
||||
XhttpExtra = transport.XhttpExtra ?? string.Empty;
|
||||
GrpcAuthority = transport.GrpcAuthority ?? string.Empty;
|
||||
GrpcServiceName = transport.GrpcServiceName ?? string.Empty;
|
||||
GrpcMode = transport.GrpcMode.IsNullOrEmpty() ? Global.GrpcGunMode : transport.GrpcMode;
|
||||
KcpHeaderType = transport.KcpHeaderType.IsNullOrEmpty() ? Global.None : transport.KcpHeaderType;
|
||||
KcpSeed = transport.KcpSeed ?? string.Empty;
|
||||
KcpMtu = transport.KcpMtu;
|
||||
}
|
||||
|
||||
private async Task SaveServerAsync()
|
||||
@@ -169,6 +355,26 @@ public class AddServerViewModel : MyReactiveObject
|
||||
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
||||
SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert;
|
||||
SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha;
|
||||
if (!Global.Networks.Contains(SelectedSource.Network))
|
||||
{
|
||||
SelectedSource.Network = Global.DefaultNetwork;
|
||||
}
|
||||
|
||||
var transport = new TransportExtraItem
|
||||
{
|
||||
RawHeaderType = RawHeaderType.NullIfEmpty(),
|
||||
Host = Host.NullIfEmpty(),
|
||||
Path = Path.NullIfEmpty(),
|
||||
XhttpMode = XhttpMode.NullIfEmpty(),
|
||||
XhttpExtra = XhttpExtra.NullIfEmpty(),
|
||||
GrpcAuthority = GrpcAuthority.NullIfEmpty(),
|
||||
GrpcServiceName = GrpcServiceName.NullIfEmpty(),
|
||||
GrpcMode = GrpcMode.NullIfEmpty(),
|
||||
KcpHeaderType = KcpHeaderType.NullIfEmpty(),
|
||||
KcpSeed = KcpSeed.NullIfEmpty(),
|
||||
KcpMtu = KcpMtu > 0 ? KcpMtu : null,
|
||||
};
|
||||
|
||||
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
|
||||
{
|
||||
Ports = Ports.NullIfEmpty(),
|
||||
@@ -182,10 +388,16 @@ public class AddServerViewModel : MyReactiveObject
|
||||
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
||||
SsMethod = SsMethod.NullIfEmpty(),
|
||||
WgPublicKey = WgPublicKey.NullIfEmpty(),
|
||||
WgPresharedKey = WgPresharedKey.NullIfEmpty(),
|
||||
WgInterfaceAddress = WgInterfaceAddress.NullIfEmpty(),
|
||||
WgReserved = WgReserved.NullIfEmpty(),
|
||||
WgMtu = WgMtu >= 576 ? WgMtu : null,
|
||||
Uot = Uot ? true : null,
|
||||
CongestionControl = CongestionControl.NullIfEmpty(),
|
||||
InsecureConcurrency = InsecureConcurrency > 0 ? InsecureConcurrency : null,
|
||||
NaiveQuic = NaiveQuic ? true : null,
|
||||
});
|
||||
SelectedSource.SetTransportExtra(transport);
|
||||
|
||||
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||
{
|
||||
@@ -241,7 +453,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||
var serverName = SelectedSource.Sni;
|
||||
if (serverName.IsNullOrEmpty())
|
||||
{
|
||||
serverName = SelectedSource.RequestHost;
|
||||
serverName = GetCurrentTransportHost();
|
||||
}
|
||||
if (serverName.IsNullOrEmpty())
|
||||
{
|
||||
@@ -252,7 +464,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||
domain += $":{SelectedSource.Port}";
|
||||
}
|
||||
|
||||
(Cert, var certError) = await CertPemManager.Instance.GetCertPemAsync(domain, serverName);
|
||||
(Cert, var certError) = await CertPemManager.Instance.GetCertPemAsync(domain, serverName, allowInsecure: AllowInsecureCertFetch);
|
||||
UpdateCertTip(certError);
|
||||
}
|
||||
|
||||
@@ -266,7 +478,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||
var serverName = SelectedSource.Sni;
|
||||
if (serverName.IsNullOrEmpty())
|
||||
{
|
||||
serverName = SelectedSource.RequestHost;
|
||||
serverName = GetCurrentTransportHost();
|
||||
}
|
||||
if (serverName.IsNullOrEmpty())
|
||||
{
|
||||
@@ -277,8 +489,21 @@ public class AddServerViewModel : MyReactiveObject
|
||||
domain += $":{SelectedSource.Port}";
|
||||
}
|
||||
|
||||
var (certs, certError) = await CertPemManager.Instance.GetCertChainPemAsync(domain, serverName);
|
||||
var (certs, certError) = await CertPemManager.Instance.GetCertChainPemAsync(domain, serverName, allowInsecure: AllowInsecureCertFetch);
|
||||
Cert = CertPemManager.ConcatenatePemChain(certs);
|
||||
UpdateCertTip(certError);
|
||||
}
|
||||
|
||||
private string GetCurrentTransportHost()
|
||||
{
|
||||
return SelectedSource.GetNetwork() switch
|
||||
{
|
||||
nameof(ETransport.raw) => Host,
|
||||
nameof(ETransport.ws) => Host,
|
||||
nameof(ETransport.httpupgrade) => Host,
|
||||
nameof(ETransport.xhttp) => Host,
|
||||
nameof(ETransport.grpc) => GrpcAuthority,
|
||||
_ => string.Empty,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
[Reactive] public string DomainStrategy4FreedomCompatible { get; set; }
|
||||
[Reactive] public string DomainDNSAddressCompatible { get; set; }
|
||||
[Reactive] public string NormalDNSCompatible { get; set; }
|
||||
[Reactive] public string TunDNSCompatible { get; set; }
|
||||
|
||||
[Reactive] public string DomainStrategy4Freedom2Compatible { get; set; }
|
||||
[Reactive] public string DomainDNSAddress2Compatible { get; set; }
|
||||
@@ -43,6 +44,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
ImportDefConfig4V2rayCompatibleCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
NormalDNSCompatible = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||
TunDNSCompatible = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName);
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
|
||||
@@ -84,6 +86,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
|
||||
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
|
||||
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
|
||||
TunDNSCompatible = item1?.TunDNS ?? string.Empty;
|
||||
|
||||
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
SBCustomDNSEnableCompatible = item2.Enabled;
|
||||
@@ -124,10 +127,27 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TunDNSCompatible.IsNotEmpty())
|
||||
{
|
||||
var obj = JsonUtils.ParseJson(TunDNSCompatible);
|
||||
if (obj != null && obj["servers"] != null)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TunDNSCompatible.Contains('{') || TunDNSCompatible.Contains('}'))
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NormalDNS2Compatible.IsNotEmpty())
|
||||
{
|
||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
||||
if (obj2 == null)
|
||||
if (obj2 == null
|
||||
|| obj2.servers.Count == 0
|
||||
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
@@ -136,7 +156,9 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
if (TunDNS2Compatible.IsNotEmpty())
|
||||
{
|
||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
||||
if (obj2 == null)
|
||||
if (obj2 == null
|
||||
|| obj2.servers.Count == 0
|
||||
|| obj2.servers.Any(s => s.type.IsNullOrEmpty()))
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
@@ -149,14 +171,15 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||
item1.DomainDNSAddress = DomainDNSAddressCompatible;
|
||||
item1.UseSystemHosts = UseSystemHostsCompatible;
|
||||
item1.NormalDNS = NormalDNSCompatible;
|
||||
item1.TunDNS = TunDNSCompatible;
|
||||
await ConfigHandler.SaveDNSItems(_config, item1);
|
||||
|
||||
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
item2.Enabled = SBCustomDNSEnableCompatible;
|
||||
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
||||
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
||||
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(NormalDNS2Compatible));
|
||||
item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(TunDNS2Compatible));
|
||||
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible));
|
||||
item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible));
|
||||
await ConfigHandler.SaveDNSItems(_config, item2);
|
||||
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
|
||||
@@ -13,6 +13,9 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||
[Reactive]
|
||||
public string FullConfigTemplate4Ray { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string FullTunConfigTemplate4Ray { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string FullConfigTemplate4Singbox { get; set; }
|
||||
|
||||
@@ -50,10 +53,15 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||
private async Task Init()
|
||||
{
|
||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||
EnableFullConfigTemplate4Ray = item?.Enabled ?? false;
|
||||
FullConfigTemplate4Ray = item?.Config ?? string.Empty;
|
||||
AddProxyOnly4Ray = item?.AddProxyOnly ?? false;
|
||||
ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty;
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EnableFullConfigTemplate4Ray = item.Enabled;
|
||||
FullConfigTemplate4Ray = item.Config ?? string.Empty;
|
||||
FullTunConfigTemplate4Ray = item.TunConfig ?? string.Empty;
|
||||
AddProxyOnly4Ray = item.AddProxyOnly ?? false;
|
||||
ProxyDetour4Ray = item.ProxyDetour ?? string.Empty;
|
||||
|
||||
var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
|
||||
@@ -82,10 +90,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||
private async Task<bool> SaveXrayConfigAsync()
|
||||
{
|
||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||
if (item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
item.Enabled = EnableFullConfigTemplate4Ray;
|
||||
item.Config = null;
|
||||
|
||||
item.Config = FullConfigTemplate4Ray;
|
||||
item.TunConfig = FullTunConfigTemplate4Ray;
|
||||
|
||||
item.AddProxyOnly = AddProxyOnly4Ray;
|
||||
item.ProxyDetour = ProxyDetour4Ray;
|
||||
@@ -97,10 +108,11 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||
private async Task<bool> SaveSingboxConfigAsync()
|
||||
{
|
||||
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||
if (item == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
item.Enabled = EnableFullConfigTemplate4Singbox;
|
||||
item.Config = null;
|
||||
item.TunConfig = null;
|
||||
|
||||
item.Config = FullConfigTemplate4Singbox;
|
||||
item.TunConfig = FullTunConfigTemplate4Singbox;
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||
public ReactiveCommand<Unit, Unit> AddTuicServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddWireguardServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddAnytlsServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddNaiveServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddCustomServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddPolicyGroupServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddProxyChainServerCmd { get; }
|
||||
@@ -117,6 +118,10 @@ public class MainWindowViewModel : MyReactiveObject
|
||||
{
|
||||
await AddServerAsync(EConfigType.Anytls);
|
||||
});
|
||||
AddNaiveServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await AddServerAsync(EConfigType.Naive);
|
||||
});
|
||||
AddCustomServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await AddServerAsync(EConfigType.Custom);
|
||||
@@ -554,7 +559,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
await LoadCore(allResult.ResolvedMainContext, allResult.PreSocksResult?.Context);
|
||||
await LoadCore(allResult.MainResult.Context, allResult.PreSocksResult?.Context);
|
||||
await SysProxyHandler.UpdateSysProxy(_config, false);
|
||||
await Task.Delay(1000);
|
||||
});
|
||||
|
||||
@@ -20,6 +20,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
[Reactive] public bool defAllowInsecure { get; set; }
|
||||
[Reactive] public string defFingerprint { get; set; }
|
||||
[Reactive] public string defUserAgent { get; set; }
|
||||
[Reactive] public string sendThrough { get; set; }
|
||||
[Reactive] public string bindInterface { get; set; }
|
||||
[Reactive] public string mux4SboxProtocol { get; set; }
|
||||
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
||||
[Reactive] public int? hyUpMbps { get; set; }
|
||||
@@ -58,6 +60,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
[Reactive] public int SpeedTestTimeout { get; set; }
|
||||
[Reactive] public string SpeedTestUrl { get; set; }
|
||||
[Reactive] public string SpeedPingTestUrl { get; set; }
|
||||
[Reactive] public string UdpTestTarget { get; set; }
|
||||
[Reactive] public int MixedConcurrencyCount { get; set; }
|
||||
[Reactive] public bool EnableHWA { get; set; }
|
||||
[Reactive] public string SubConvertUrl { get; set; }
|
||||
@@ -95,6 +98,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
[Reactive] public string TunStack { get; set; }
|
||||
[Reactive] public int TunMtu { get; set; }
|
||||
[Reactive] public bool TunEnableIPv6Address { get; set; }
|
||||
[Reactive] public string TunIcmpRouting { get; set; }
|
||||
[Reactive] public bool TunEnableLegacyProtect { get; set; }
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
@@ -152,6 +157,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure;
|
||||
defFingerprint = _config.CoreBasicItem.DefFingerprint;
|
||||
defUserAgent = _config.CoreBasicItem.DefUserAgent;
|
||||
sendThrough = _config.CoreBasicItem.SendThrough ?? string.Empty;
|
||||
bindInterface = _config.CoreBasicItem.BindInterface ?? string.Empty;
|
||||
mux4SboxProtocol = _config.Mux4SboxItem.Protocol;
|
||||
enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox;
|
||||
hyUpMbps = _config.HysteriaItem.UpMbps;
|
||||
@@ -191,6 +198,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
SpeedTestUrl = _config.SpeedTestItem.SpeedTestUrl;
|
||||
MixedConcurrencyCount = _config.SpeedTestItem.MixedConcurrencyCount;
|
||||
SpeedPingTestUrl = _config.SpeedTestItem.SpeedPingTestUrl;
|
||||
UdpTestTarget = _config.SpeedTestItem.UdpTestTarget;
|
||||
EnableHWA = _config.GuiItem.EnableHWA;
|
||||
SubConvertUrl = _config.ConstItem.SubConvertUrl;
|
||||
MainGirdOrientation = (int)_config.UiItem.MainGirdOrientation;
|
||||
@@ -218,6 +226,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
TunStack = _config.TunModeItem.Stack;
|
||||
TunMtu = _config.TunModeItem.Mtu;
|
||||
TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address;
|
||||
TunIcmpRouting = _config.TunModeItem.IcmpRouting;
|
||||
TunEnableLegacyProtect = _config.TunModeItem.EnableLegacyProtect;
|
||||
|
||||
#endregion Tun mode
|
||||
|
||||
@@ -293,6 +303,12 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
||||
return;
|
||||
}
|
||||
var sendThroughValue = sendThrough.TrimEx();
|
||||
if (sendThroughValue.IsNotEmpty() && !Utils.IsIpv4(sendThroughValue))
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectSendThroughIPv4);
|
||||
return;
|
||||
}
|
||||
var needReboot = EnableStatistics != _config.GuiItem.EnableStatistics
|
||||
|| DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed
|
||||
|| EnableDragDropSort != _config.UiItem.EnableDragDropSort
|
||||
@@ -332,6 +348,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
_config.CoreBasicItem.DefAllowInsecure = defAllowInsecure;
|
||||
_config.CoreBasicItem.DefFingerprint = defFingerprint;
|
||||
_config.CoreBasicItem.DefUserAgent = defUserAgent;
|
||||
_config.CoreBasicItem.SendThrough = sendThrough.TrimEx();
|
||||
_config.CoreBasicItem.BindInterface = bindInterface.TrimEx();
|
||||
_config.Mux4SboxItem.Protocol = mux4SboxProtocol;
|
||||
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
|
||||
_config.HysteriaItem.UpMbps = hyUpMbps ?? 0;
|
||||
@@ -355,6 +373,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
_config.SpeedTestItem.MixedConcurrencyCount = MixedConcurrencyCount;
|
||||
_config.SpeedTestItem.SpeedTestUrl = SpeedTestUrl;
|
||||
_config.SpeedTestItem.SpeedPingTestUrl = SpeedPingTestUrl;
|
||||
_config.SpeedTestItem.UdpTestTarget = UdpTestTarget;
|
||||
_config.GuiItem.EnableHWA = EnableHWA;
|
||||
_config.ConstItem.SubConvertUrl = SubConvertUrl;
|
||||
_config.UiItem.MainGirdOrientation = (EGirdOrientation)MainGirdOrientation;
|
||||
@@ -376,6 +395,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
_config.TunModeItem.Stack = TunStack;
|
||||
_config.TunModeItem.Mtu = TunMtu;
|
||||
_config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address;
|
||||
_config.TunModeItem.IcmpRouting = TunIcmpRouting;
|
||||
_config.TunModeItem.EnableLegacyProtect = TunEnableLegacyProtect;
|
||||
|
||||
//coreType
|
||||
await SaveCoreType();
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
|
||||
}
|
||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||
: null) ?? SubItems.LastOrDefault();
|
||||
: null) ?? SubItems.FirstOrDefault();
|
||||
}
|
||||
|
||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||
|
||||
@@ -60,6 +60,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
|
||||
public ReactiveCommand<Unit, Unit> TcpingServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RealPingServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> UdpTestServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SpeedServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SortServerResultCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RemoveInvalidServerResultCmd { get; }
|
||||
@@ -71,6 +72,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
public ReactiveCommand<Unit, Unit> Export2ClientConfigClipboardCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> Export2ShareUrlBase64Cmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> Export2InnerUriCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AddSubCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> EditSubCmd { get; }
|
||||
@@ -178,6 +180,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
{
|
||||
await ServerSpeedtest(ESpeedActionType.Realping);
|
||||
}, canEditRemove);
|
||||
UdpTestServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await ServerSpeedtest(ESpeedActionType.UdpTest);
|
||||
}, canEditRemove);
|
||||
SpeedServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await ServerSpeedtest(ESpeedActionType.Speedtest);
|
||||
@@ -207,6 +213,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
{
|
||||
await Export2ShareUrlAsync(true);
|
||||
}, canEditRemove);
|
||||
Export2InnerUriCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await Export2InnerUrlAsync();
|
||||
}, canEditRemove);
|
||||
|
||||
//Subscription
|
||||
AddSubCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
@@ -393,7 +403,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
}
|
||||
SelectedSub = (_config.SubIndexId.IsNotEmpty()
|
||||
? SubItems.FirstOrDefault(t => t.Id == _config.SubIndexId)
|
||||
: null) ?? SubItems.LastOrDefault();
|
||||
: null) ?? SubItems.FirstOrDefault();
|
||||
}
|
||||
|
||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||
@@ -709,18 +719,22 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
|
||||
public async Task ServerSpeedtest(ESpeedActionType actionType)
|
||||
{
|
||||
if (actionType == ESpeedActionType.Mixedtest)
|
||||
List<ProfileItem>? lstSelected;
|
||||
if (actionType is ESpeedActionType.Mixedtest or ESpeedActionType.FastRealping)
|
||||
{
|
||||
SelectedProfiles = ProfileItems;
|
||||
if (actionType == ESpeedActionType.FastRealping)
|
||||
{
|
||||
actionType = ESpeedActionType.Realping;
|
||||
}
|
||||
|
||||
lstSelected = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(ProfileItems?.OrderBy(t => t.Sort)));
|
||||
}
|
||||
else if (actionType == ESpeedActionType.FastRealping)
|
||||
else
|
||||
{
|
||||
SelectedProfiles = ProfileItems;
|
||||
actionType = ESpeedActionType.Realping;
|
||||
lstSelected = await GetProfileItems(false);
|
||||
}
|
||||
|
||||
var lstSelected = await GetProfileItems(false);
|
||||
if (lstSelected == null)
|
||||
if (lstSelected is null || lstSelected.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -831,6 +845,32 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Export2InnerUrlAsync()
|
||||
{
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var result = string.Empty;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
result = InnerFmt.ToUri(lstSelected);
|
||||
});
|
||||
|
||||
if (!result.IsNullOrEmpty())
|
||||
{
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, result);
|
||||
NoticeManager.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||
}
|
||||
else
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Add Servers
|
||||
|
||||
#region Subscription
|
||||
|
||||
@@ -22,7 +22,6 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||
public ReactiveCommand<Unit, Unit> RoutingAdvancedSetDefaultCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RoutingAdvancedImportRulesCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||
public bool IsModified { get; set; }
|
||||
|
||||
#endregion Reactive
|
||||
@@ -53,12 +52,19 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||
await RoutingAdvancedImportRules();
|
||||
});
|
||||
|
||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await SaveRoutingAsync();
|
||||
});
|
||||
|
||||
_ = Init();
|
||||
|
||||
// Auto-save DomainStrategy when changed
|
||||
this.WhenAnyValue(
|
||||
x => x.DomainStrategy,
|
||||
x => x.DomainStrategy4Singbox)
|
||||
.Skip(1)
|
||||
.DistinctUntilChanged()
|
||||
.Subscribe(x =>
|
||||
{
|
||||
IsModified = true;
|
||||
_ = SaveSettingsAsync();
|
||||
});
|
||||
}
|
||||
|
||||
private async Task Init()
|
||||
@@ -96,20 +102,14 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveRoutingAsync()
|
||||
/// <summary>
|
||||
/// Save DomainStrategy settings
|
||||
/// </summary>
|
||||
public async Task SaveSettingsAsync()
|
||||
{
|
||||
_config.RoutingBasicItem.DomainStrategy = DomainStrategy;
|
||||
_config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox;
|
||||
|
||||
if (await ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
|
||||
#endregion Refresh Save
|
||||
|
||||
@@ -490,6 +490,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
AppEvents.ReloadRequested.Publish();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace v2rayN.Desktop.Common;
|
||||
|
||||
public enum ButtonResult
|
||||
{
|
||||
None = 0,
|
||||
Yes = 1,
|
||||
No = 2
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace v2rayN.Desktop.Common;
|
||||
|
||||
public partial class QRCodeAvaloniaUtils
|
||||
{
|
||||
public static byte[]? CaptureScreen()
|
||||
{
|
||||
if (!Utils.IsWindows())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return CaptureScreenWindows();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("CaptureScreen", ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[]? CaptureScreenWindows()
|
||||
{
|
||||
var hdcScreen = IntPtr.Zero;
|
||||
var hdcMemory = IntPtr.Zero;
|
||||
var hBitmap = IntPtr.Zero;
|
||||
|
||||
try
|
||||
{
|
||||
var workArea = new RECT();
|
||||
SystemParametersInfo(SPI_GETWORKAREA, 0, ref workArea, 0);
|
||||
|
||||
var left = workArea.Left;
|
||||
var top = workArea.Top;
|
||||
var width = workArea.Right - workArea.Left;
|
||||
var height = workArea.Bottom - workArea.Top;
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
{
|
||||
left = 0;
|
||||
top = 0;
|
||||
width = GetSystemMetrics(0);
|
||||
height = GetSystemMetrics(1);
|
||||
}
|
||||
|
||||
hdcScreen = GetDC(IntPtr.Zero);
|
||||
if (hdcScreen == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
hdcMemory = CreateCompatibleDC(hdcScreen);
|
||||
hBitmap = CreateCompatibleBitmap(hdcScreen, width, height);
|
||||
|
||||
if (hBitmap == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
SelectObject(hdcMemory, hBitmap);
|
||||
|
||||
const int SRCCOPY = 0x00CC0020;
|
||||
BitBlt(hdcMemory, 0, 0, width, height, hdcScreen, left, top, SRCCOPY);
|
||||
|
||||
var bmi = new BITMAPINFO
|
||||
{
|
||||
biSize = Marshal.SizeOf(typeof(BITMAPINFO)),
|
||||
biWidth = width,
|
||||
biHeight = -height,
|
||||
biPlanes = 1,
|
||||
biBitCount = 32,
|
||||
biCompression = 0
|
||||
};
|
||||
|
||||
var imageSize = width * height * 4;
|
||||
var imageData = new byte[imageSize];
|
||||
|
||||
var scanLines = GetDIBits(hdcScreen, hBitmap, 0, (uint)height, imageData, ref bmi, 0);
|
||||
|
||||
if (scanLines == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var bitmap = new SKBitmap(width, height, SKColorType.Bgra8888, SKAlphaType.Premul);
|
||||
Marshal.Copy(imageData, 0, bitmap.GetPixels(), imageSize);
|
||||
|
||||
using var image = SKImage.FromBitmap(bitmap);
|
||||
using var encoded = image.Encode(SKEncodedImageFormat.Png, 100);
|
||||
return encoded.ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("CaptureScreenWindows", ex);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hBitmap != IntPtr.Zero)
|
||||
{
|
||||
DeleteObject(hBitmap);
|
||||
}
|
||||
|
||||
if (hdcMemory != IntPtr.Zero)
|
||||
{
|
||||
DeleteDC(hdcMemory);
|
||||
}
|
||||
|
||||
if (hdcScreen != IntPtr.Zero)
|
||||
{
|
||||
ReleaseDC(IntPtr.Zero, hdcScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Win32 API
|
||||
|
||||
[LibraryImport("user32.dll")]
|
||||
private static partial IntPtr GetDC(IntPtr hwnd);
|
||||
|
||||
[LibraryImport("user32.dll")]
|
||||
private static partial int ReleaseDC(IntPtr hwnd, IntPtr hdc);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
private static partial IntPtr CreateCompatibleDC(IntPtr hdc);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
private static partial IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
private static partial IntPtr SelectObject(IntPtr hdc, IntPtr hObject);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
|
||||
IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool DeleteObject(IntPtr hObject);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool DeleteDC(IntPtr hdc);
|
||||
|
||||
[LibraryImport("gdi32.dll")]
|
||||
private static partial int GetDIBits(IntPtr hdc, IntPtr hbmp, uint uStartScan, uint cScanLines,
|
||||
byte[] lpvBits, ref BITMAPINFO lpbmi, uint uUsage);
|
||||
|
||||
[LibraryImport("user32.dll")]
|
||||
private static partial int GetSystemMetrics(int nIndex);
|
||||
|
||||
[LibraryImport("user32.dll", EntryPoint = "SystemParametersInfoW", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool SystemParametersInfo(int uiAction, int uiParam, ref RECT pvParam, int fWinIni);
|
||||
|
||||
private const int SPI_GETWORKAREA = 0x0030;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
public int Left;
|
||||
public int Top;
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct BITMAPINFO
|
||||
{
|
||||
public int biSize;
|
||||
public int biWidth;
|
||||
public int biHeight;
|
||||
public short biPlanes;
|
||||
public short biBitCount;
|
||||
public int biCompression;
|
||||
public int biSizeImage;
|
||||
public int biXPelsPerMeter;
|
||||
public int biYPelsPerMeter;
|
||||
public int biClrUsed;
|
||||
public int biClrImportant;
|
||||
}
|
||||
|
||||
#endregion Win32 API
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user