Compare commits

...

21 commits

Author SHA1 Message Date
DHR60
9f0ef36cc0
Refactor Transport (#9004)
Some checks are pending
release Linux / build (push) Waiting to run
release Linux / release-zip (push) Blocked by required conditions
release Linux / build and release deb x64 & arm64 (push) Waiting to run
release Linux / build and release rpm x64 & arm64 (push) Waiting to run
release Linux / build and release rpm riscv64 (push) Waiting to run
release macOS / build (push) Waiting to run
release macOS / release-zip (push) Blocked by required conditions
release macOS / package and release macOS dmg (push) Blocked by required conditions
release Windows desktop (Avalonia UI) / build (push) Waiting to run
release Windows desktop (Avalonia UI) / release-zip (push) Blocked by required conditions
release Windows / build (push) Waiting to run
release Windows / release-zip (push) Blocked by required conditions
* Refactor transport

* Rename tcp to raw

* Fix

* Fix

Fix raw http ui

Fill xhttp default mode

Fix share uri

Remove RawHost

Fix singbox tcp http path

Fix vmess share uri

* Tidy Resx

* Fix

* Rename TransportExtra to TransportExtraItem

---------

Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
2026-04-16 20:21:10 +08:00
DHR60
494b35c1f7
Add xray tun support (#9063)
* Add xray tun support

* Revert mtu list
2026-04-16 19:17:44 +08:00
2dust
177ad7db3d up 7.20.4 2026-04-16 13:39:52 +08:00
JieXu
3bda022574
Add RiscV64 RPM build && Update (#9114)
Some checks are pending
release Linux / build (push) Waiting to run
release Linux / release-zip (push) Blocked by required conditions
release Linux / build and release deb x64 & arm64 (push) Waiting to run
release Linux / build and release rpm x64 & arm64 (push) Waiting to run
release Linux / build and release rpm riscv64 (push) Waiting to run
release macOS / build (push) Waiting to run
release macOS / release-zip (push) Blocked by required conditions
release macOS / package and release macOS dmg (push) Blocked by required conditions
release Windows desktop (Avalonia UI) / build (push) Waiting to run
release Windows desktop (Avalonia UI) / release-zip (push) Blocked by required conditions
release Windows / build (push) Waiting to run
release Windows / release-zip (push) Blocked by required conditions
* Create package-rhel-riscv.sh

* Update build-linux.yml

* Update UpdateService.cs

* Update CoreInfo.cs

* Add RiscV64 download URLs for various platforms

* Update build-linux.yml

* Update ResUI.fr.resx

* Update ResUI.fr.resx

* Update ResUI.fr.resx

* Update proxy_set_linux_sh

---------

Co-authored-by: xujie86 <167618598+xujie86@users.noreply.github.com>
2026-04-15 20:50:27 +08:00
DHR60
2ea9c5a2ff
Fix mux (#9117)
Some checks are pending
release Linux / build (push) Waiting to run
release Linux / release-zip (push) Blocked by required conditions
release Linux / build and release deb (push) Waiting to run
release Linux / build and release rpm (push) Waiting to run
release macOS / build (push) Waiting to run
release macOS / release-zip (push) Blocked by required conditions
release macOS / package and release macOS dmg (push) Blocked by required conditions
release Windows desktop (Avalonia UI) / build (push) Waiting to run
release Windows desktop (Avalonia UI) / release-zip (push) Blocked by required conditions
release Windows / build (push) Waiting to run
release Windows / release-zip (push) Blocked by required conditions
2026-04-15 19:06:26 +08:00
DHR60
3cb2869920
Fix (#9110) 2026-04-15 19:06:03 +08:00
Bonjour LI
43dcb90632
CI Workflow fix: rpm/deb runs-on (#9106)
Some checks failed
release Linux / build (push) Has been cancelled
release Linux / build and release deb (push) Has been cancelled
release Linux / build and release rpm (push) Has been cancelled
release macOS / build (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (push) Has been cancelled
release Windows / build (push) Has been cancelled
release Linux / release-zip (push) Has been cancelled
release macOS / release-zip (push) Has been cancelled
release macOS / package and release macOS dmg (push) Has been cancelled
release Windows desktop (Avalonia UI) / release-zip (push) Has been cancelled
release Windows / release-zip (push) Has been cancelled
2026-04-14 14:29:52 +08:00
Bonjour LI
e56fca05fc
Refactor and Optimize CI Workflow (#9083)
Some checks are pending
release Linux / build (push) Waiting to run
release Linux / release-zip (push) Blocked by required conditions
release Linux / build and release deb (push) Waiting to run
release Linux / build and release rpm (push) Waiting to run
release macOS / build (push) Waiting to run
release macOS / release-zip (push) Blocked by required conditions
release macOS / package and release macOS dmg (push) Blocked by required conditions
release Windows desktop (Avalonia UI) / build (push) Waiting to run
release Windows desktop (Avalonia UI) / release-zip (push) Blocked by required conditions
release Windows / build (push) Waiting to run
release Windows / release-zip (push) Blocked by required conditions
* Refactor and Optimize CI Workflow

* Refactor and Optimize CI Workflow (Added input option value annotations for clarity.)
2026-04-14 09:41:07 +08:00
DHR60
495b5db4f1
Adjust DNS priority order (#9091)
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / deb (push) Blocked by required conditions
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
2026-04-13 10:59:37 +08:00
DHR60
dea143b20d
Add sing-box ua (#9087)
* Add sing-box ua

* Add curl and fix
2026-04-13 10:58:40 +08:00
2dust
0db611b7a9 up 7.20.3
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / deb (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
2026-04-12 10:00:43 +08:00
2dust
c3d67d186a Update xunit.runner and fix socks port names 2026-04-12 10:00:14 +08:00
DHR60
6b07ca63a0
Add sing-box send-through (#9081)
* Add sing-box send-through

* Perf resx
2026-04-12 09:25:17 +08:00
renwofei423
6c8f22ab86
feat(send-through): 支持配置本地出站地址 (#8946)
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / deb (push) Blocked by required conditions
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
* feat(send-through): 支持配置本地出站地址

为 Xray 增加 SendThrough 配置项,允许指定本机 IPv4 作为出站源地址。

- 在核心设置页新增 SendThrough 输入框及中英文提示文案
- 保存配置时校验并持久化本机 IPv4 地址
- 生成 Xray 配置时为所有 outbound 写入 sendThrough 字段

影响说明:
- 仅对 Xray 生效,留空时不设置该字段

* fix(send-through): limit sendThrough to remote egress outbounds
2026-04-11 21:02:43 +08:00
DHR60
49f65579aa
Replace protect-ss with protect-socks (#9052) 2026-04-11 19:45:23 +08:00
dependabot[bot]
a69e407bda
Bump actions/upload-artifact from 7.0.0 to 7.0.1 (#9073)
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 7.0.0 to 7.0.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v7.0.0...v7.0.1)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-11 19:42:39 +08:00
taskmgr818
96e5c11fc7
Replace 100MB Cloudflare speedtest URL with 99MB (#9076) 2026-04-11 19:39:25 +08:00
2dust
53041906b3 Use LibraryImport for native APIs
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
release Linux / deb (push) Has been cancelled
release Linux / rpm (push) Has been cancelled
2026-04-06 20:16:30 +08:00
2dust
f2d929f40e Update GlobalHotKeys 2026-04-06 20:00:48 +08:00
2dust
1160d8c154 Add Windows screen QR scan support for avalonia 2026-04-06 15:34:25 +08:00
2dust
75f2cbaef9 Code clean
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / deb (push) Blocked by required conditions
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
2026-04-05 17:18:28 +08:00
75 changed files with 3612 additions and 1430 deletions

View file

@ -13,7 +13,7 @@ jobs:
steps: steps:
- name: Trigger build windows - name: Trigger build windows
if: github.event.inputs.release_tag != '' if: inputs.release_tag != ''
run: | run: |
curl -X POST \ curl -X POST \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
@ -22,12 +22,12 @@ jobs:
-d "{ -d "{
\"ref\": \"master\", \"ref\": \"master\",
\"inputs\": { \"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\" \"release_tag\": \"${{ inputs.release_tag }}\"
} }
}" }"
- name: Trigger build linux - name: Trigger build linux
if: github.event.inputs.release_tag != '' if: inputs.release_tag != ''
run: | run: |
curl -X POST \ curl -X POST \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
@ -36,12 +36,12 @@ jobs:
-d "{ -d "{
\"ref\": \"master\", \"ref\": \"master\",
\"inputs\": { \"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\" \"release_tag\": \"${{ inputs.release_tag }}\"
} }
}" }"
- name: Trigger build osx - name: Trigger build osx
if: github.event.inputs.release_tag != '' if: inputs.release_tag != ''
run: | run: |
curl -X POST \ curl -X POST \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
@ -50,12 +50,12 @@ jobs:
-d "{ -d "{
\"ref\": \"master\", \"ref\": \"master\",
\"inputs\": { \"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\" \"release_tag\": \"${{ inputs.release_tag }}\"
} }
}" }"
- name: Trigger build windows desktop - name: Trigger build windows desktop
if: github.event.inputs.release_tag != '' if: inputs.release_tag != ''
run: | run: |
curl -X POST \ curl -X POST \
-H "Accept: application/vnd.github.v3+json" \ -H "Accept: application/vnd.github.v3+json" \
@ -64,6 +64,6 @@ jobs:
-d "{ -d "{
\"ref\": \"master\", \"ref\": \"master\",
\"inputs\": { \"inputs\": {
\"release_tag\": \"${{ github.event.inputs.release_tag }}\" \"release_tag\": \"${{ inputs.release_tag }}\"
} }
}" }"

View file

@ -13,73 +13,29 @@ on:
permissions: permissions:
contents: write contents: write
env:
OutputArch: "linux-64"
OutputArchArm: "linux-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/linux-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/linux-arm64"
jobs: jobs:
build: build:
strategy: uses: ./.github/workflows/build.yml
matrix: with:
configuration: [Release] target: linux
runs-on: ubuntu-24.04
steps: release-zip:
- name: Checkout if: inputs.release_tag != ''
uses: actions/checkout@v6.0.2 needs: build
with: uses: ./.github/workflows/package-zip.yml
submodules: 'recursive' with:
fetch-depth: '0' target: linux
release_tag: ${{ inputs.release_tag }}
- 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
deb: deb:
needs: build name: build and release deb x64 & arm64
if: | 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/')) (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
container: container: debian:13
image: debian:13
env: 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: steps:
- name: Prepare tools (Debian) - name: Prepare tools (Debian)
@ -115,12 +71,6 @@ jobs:
echo "==== Dist tree ====" echo "==== Dist tree ===="
ls -R "$GITHUB_WORKSPACE/dist/deb" || true 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 - name: Upload DEBs to release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
@ -130,15 +80,14 @@ jobs:
prerelease: true prerelease: true
rpm: rpm:
needs: build name: build and release rpm x64 & arm64
if: | 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/')) (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
container: container: registry.access.redhat.com/ubi10/ubi
image: registry.access.redhat.com/ubi10/ubi
env: 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: steps:
- name: Prepare tools (Red Hat) - name: Prepare tools (Red Hat)
@ -207,12 +156,6 @@ jobs:
submodules: 'recursive' submodules: 'recursive'
fetch-depth: '0' 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 - name: Ensure script permissions
run: chmod 755 package-rhel.sh run: chmod 755 package-rhel.sh
@ -228,12 +171,6 @@ jobs:
echo "==== Dist tree ====" echo "==== Dist tree ===="
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true 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 - name: Upload RPMs to release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
@ -241,3 +178,76 @@ jobs:
tag: ${{ env.RELEASE_TAG }} tag: ${{ env.RELEASE_TAG }}
file_glob: true file_glob: true
prerelease: 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: ghcr.io/xujiegb/fedora-riscv:43-latest
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 curl jq wget file \
ca-certificates desktop-file-utils xdg-utils python3 gcc make glibc-devel kernel-headers libatomic libstdc++
- 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

View file

@ -10,78 +10,62 @@ on:
branches: branches:
- master - master
env: permissions:
OutputArch: "macos-64" contents: write
OutputArchArm: "macos-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/macos-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/macos-arm64"
jobs: jobs:
build: 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: strategy:
matrix: matrix:
configuration: [Release] arch: [ x64, arm64 ]
runs-on: macos-latest runs-on: macos-latest
env:
Arch: |-
${{
case(
matrix.arch == 'x64', '64',
matrix.arch
)
}}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6.0.2 uses: actions/checkout@v6.0.2
- name: Restore build artifacts
uses: actions/download-artifact@v8
with: with:
submodules: 'recursive' name: ${{ matrix.arch }}
fetch-depth: '0' path: v2rayN-macos-${{ env.Arch }}
- name: Setup - name: Setup create-dmg
uses: actions/setup-dotnet@v5.2.0 run: brew install create-dmg
with:
dotnet-version: '8.0.x'
- name: Build - name: Ensure script permissions
run: | run: chmod 755 package-osx.sh
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 - name: Package dmg
uses: actions/upload-artifact@v7.0.0 run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
with:
name: v2rayN-macos
path: |
${{ github.workspace }}/v2rayN/Release/macos*
# 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: Upload dmg to release - name: Upload dmg to release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
if: github.event.inputs.release_tag != ''
with: with:
file: ${{ github.workspace }}/v2rayN*.dmg 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 file_glob: true
prerelease: true prerelease: true

View file

@ -10,62 +10,19 @@ on:
branches: branches:
- master - master
env: permissions:
OutputArch: "windows-64" contents: write
OutputArchArm: "windows-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
jobs: jobs:
build: build:
strategy: uses: ./.github/workflows/build.yml
matrix: with:
configuration: [Release] target: windows
runs-on: ubuntu-latest release-zip:
if: inputs.release_tag != ''
steps: needs: build
- name: Checkout uses: ./.github/workflows/package-zip.yml
uses: actions/checkout@v6.0.2 with:
with: target: windows-desktop
submodules: 'recursive' release_tag: ${{ inputs.release_tag }}
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

View file

@ -10,57 +10,20 @@ on:
branches: branches:
- master - master
env: permissions:
OutputArch: "windows-64" contents: write
OutputArchArm: "windows-arm64"
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
jobs: jobs:
build: build:
strategy: uses: ./.github/workflows/build.yml
matrix: with:
configuration: [Release] target: windows
project: ./v2rayN/v2rayN.csproj
runs-on: ubuntu-latest release-zip:
if: inputs.release_tag != ''
steps: needs: build
- name: Checkout uses: ./.github/workflows/package-zip.yml
uses: actions/checkout@v6.0.2 with:
target: windows
- name: Setup release_tag: ${{ inputs.release_tag }}
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

71
.github/workflows/build.yml vendored Normal file
View file

@ -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 }}

64
.github/workflows/package-zip.yml vendored Normal file
View file

@ -0,0 +1,64 @@
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: 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

View file

@ -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

703
package-rhel-riscv.sh Normal file
View file

@ -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.1}"
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.49.1 amalgamation
sqlite_year="2025"
sqlite_ver="3490100"
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 "=============================================="

View file

@ -1,7 +1,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>7.20.2</Version> <Version>7.20.4</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View file

@ -12,10 +12,11 @@
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" /> <PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
<PackageVersion Include="CliWrap" Version="3.10.1" /> <PackageVersion Include="CliWrap" Version="3.10.1" />
<PackageVersion Include="Downloader" Version="5.1.0" /> <PackageVersion Include="Downloader" Version="5.1.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" /> <PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" /> <PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
<PackageVersion Include="MessageBox.Avalonia" Version="3.3.1.1" /> <PackageVersion Include="MessageBox.Avalonia" Version="3.3.1.1" />
<PackageVersion Include="QRCoder" Version="1.7.0" /> <PackageVersion Include="QRCoder" Version="1.8.0" />
<PackageVersion Include="ReactiveUI" Version="23.2.1" /> <PackageVersion Include="ReactiveUI" Version="23.2.1" />
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" /> <PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageVersion Include="ReactiveUI.WPF" Version="23.2.1" /> <PackageVersion Include="ReactiveUI.WPF" Version="23.2.1" />
@ -26,6 +27,8 @@
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" /> <PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
<PackageVersion Include="TaskScheduler" Version="2.12.2" /> <PackageVersion Include="TaskScheduler" Version="2.12.2" />
<PackageVersion Include="WebDav.Client" Version="2.9.0" /> <PackageVersion Include="WebDav.Client" Version="2.9.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" /> <PackageVersion Include="YamlDotNet" Version="16.3.0" />
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" /> <PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
</ItemGroup> </ItemGroup>

View file

@ -0,0 +1,222 @@
using System.Text.Json.Nodes;
using ServiceLib;
using ServiceLib.Enums;
using ServiceLib.Models;
using ServiceLib.Services.CoreConfig;
using Xunit;
namespace ServiceLib.Tests;
public class CoreConfigV2rayServiceTests
{
private const string SendThrough = "198.51.100.10";
[Fact]
public void GenerateClientConfigContent_OnlyAppliesSendThroughToRemoteProxyOutbounds()
{
var node = CreateProxyNode("proxy-1", "198.51.100.1", 443);
var service = new CoreConfigV2rayService(CreateContext(node));
var result = service.GenerateClientConfigContent();
Assert.True(result.Success);
var outbounds = GetOutbounds(result.Data?.ToString());
var proxyOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.ProxyTag);
var directOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.DirectTag);
var blockOutbound = outbounds.Single(outbound => outbound["tag"]!.GetValue<string>() == Global.BlockTag);
Assert.Equal(SendThrough, proxyOutbound["sendThrough"]?.GetValue<string>());
Assert.Null(directOutbound["sendThrough"]);
Assert.Null(blockOutbound["sendThrough"]);
}
[Fact]
public void GenerateClientConfigContent_OnlyAppliesSendThroughToChainExitOutbounds()
{
var exitNode = CreateProxyNode("exit", "198.51.100.2", 443);
var entryNode = CreateProxyNode("entry", "198.51.100.3", 443);
var chainNode = CreateChainNode("chain", exitNode, entryNode);
var service = new CoreConfigV2rayService(CreateContext(
chainNode,
allProxiesMap: new Dictionary<string, ProfileItem>
{
[exitNode.IndexId] = exitNode,
[entryNode.IndexId] = entryNode,
}));
var result = service.GenerateClientConfigContent();
Assert.True(result.Success);
var outbounds = GetOutbounds(result.Data?.ToString())
.Where(outbound => outbound["protocol"]?.GetValue<string>() is not ("freedom" or "blackhole" or "dns"))
.ToList();
var sendThroughOutbounds = outbounds
.Where(outbound => outbound["sendThrough"]?.GetValue<string>() == SendThrough)
.ToList();
var chainedOutbounds = outbounds
.Where(outbound => outbound["streamSettings"]?["sockopt"]?["dialerProxy"] is not null)
.ToList();
Assert.Single(sendThroughOutbounds);
Assert.All(chainedOutbounds, outbound => Assert.Null(outbound["sendThrough"]));
}
[Fact]
public void GenerateClientConfigContent_DoesNotApplySendThroughToTunRelayLoopbackOutbound()
{
var node = CreateProxyNode("proxy-1", "198.51.100.4", 443);
var config = CreateConfig();
config.TunModeItem.EnableLegacyProtect = false;
var service = new CoreConfigV2rayService(CreateContext(
node,
config,
isTunEnabled: true));
var result = service.GenerateClientConfigContent();
Assert.True(result.Success);
var outbounds = GetOutbounds(result.Data?.ToString());
Assert.DoesNotContain(outbounds, outbound => outbound["sendThrough"]?.GetValue<string>() == SendThrough);
}
private static CoreConfigContext CreateContext(
ProfileItem node,
Config? config = null,
Dictionary<string, ProfileItem>? allProxiesMap = null,
bool isTunEnabled = false)
{
return new CoreConfigContext
{
Node = node,
RunCoreType = ECoreType.Xray,
AppConfig = config ?? CreateConfig(),
AllProxiesMap = allProxiesMap ?? new(),
SimpleDnsItem = new SimpleDNSItem(),
IsTunEnabled = isTunEnabled,
};
}
private static Config CreateConfig()
{
return new Config
{
IndexId = string.Empty,
SubIndexId = string.Empty,
CoreBasicItem = new()
{
LogEnabled = false,
Loglevel = "warning",
MuxEnabled = false,
DefAllowInsecure = false,
DefFingerprint = Global.Fingerprints.First(),
DefUserAgent = string.Empty,
SendThrough = SendThrough,
EnableFragment = false,
EnableCacheFile4Sbox = true,
},
TunModeItem = new()
{
EnableTun = false,
AutoRoute = true,
StrictRoute = true,
Stack = string.Empty,
Mtu = 9000,
EnableIPv6Address = false,
IcmpRouting = Global.TunIcmpRoutingPolicies.First(),
EnableLegacyProtect = false,
},
KcpItem = new(),
GrpcItem = new(),
RoutingBasicItem = new()
{
DomainStrategy = Global.DomainStrategies.First(),
DomainStrategy4Singbox = Global.DomainStrategies4Sbox.First(),
RoutingIndexId = string.Empty,
},
GuiItem = new(),
MsgUIItem = new(),
UiItem = new()
{
CurrentLanguage = "en",
CurrentFontFamily = string.Empty,
MainColumnItem = [],
WindowSizeItem = [],
},
ConstItem = new(),
SpeedTestItem = new(),
Mux4RayItem = new()
{
Concurrency = 8,
XudpConcurrency = 8,
XudpProxyUDP443 = "reject",
},
Mux4SboxItem = new()
{
Protocol = string.Empty,
},
HysteriaItem = new(),
ClashUIItem = new()
{
ConnectionsColumnItem = [],
},
SystemProxyItem = new(),
WebDavItem = new(),
CheckUpdateItem = new(),
Fragment4RayItem = null,
Inbound = [new InItem
{
Protocol = EInboundProtocol.socks.ToString(),
LocalPort = 10808,
UdpEnabled = true,
SniffingEnabled = true,
RouteOnly = false,
}],
GlobalHotkeys = [],
CoreTypeItem = [],
SimpleDNSItem = new(),
};
}
private static ProfileItem CreateProxyNode(string indexId, string address, int port)
{
return new ProfileItem
{
IndexId = indexId,
Remarks = indexId,
ConfigType = EConfigType.SOCKS,
CoreType = ECoreType.Xray,
Address = address,
Port = port,
};
}
private static ProfileItem CreateChainNode(string indexId, params ProfileItem[] nodes)
{
var chainNode = new ProfileItem
{
IndexId = indexId,
Remarks = indexId,
ConfigType = EConfigType.ProxyChain,
CoreType = ECoreType.Xray,
};
chainNode.SetProtocolExtra(new ProtocolExtraItem
{
ChildItems = string.Join(',', nodes.Select(node => node.IndexId)),
});
return chainNode;
}
private static List<JsonObject> GetOutbounds(string? json)
{
var root = JsonNode.Parse(json ?? throw new InvalidOperationException("Config JSON is missing"))?.AsObject()
?? throw new InvalidOperationException("Failed to parse config JSON");
return root["outbounds"]?.AsArray().Select(node => node!.AsObject()).ToList()
?? throw new InvalidOperationException("Config JSON does not contain outbounds");
}
}

View file

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServiceLib\ServiceLib.csproj" />
</ItemGroup>
</Project>

View file

@ -522,6 +522,23 @@ public class Utils
return false; 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) public static bool IsIpAddress(string? ip)
{ {
if (ip.IsNullOrEmpty()) if (ip.IsNullOrEmpty())

View file

@ -53,19 +53,23 @@ internal static class WindowsUtils
public static async Task RemoveTunDevice() public static async Task RemoveTunDevice()
{ {
try var tunNameList = new List<string> { "singbox_tun", "xray_tun" };
foreach (var tunName in tunNameList)
{ {
var sum = MD5.HashData(Encoding.UTF8.GetBytes("wintunsingbox_tun")); try
var guid = new Guid(sum); {
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe"; var sum = MD5.HashData(Encoding.UTF8.GetBytes($"wintun{tunName}"));
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """; var guid = new Guid(sum);
var pnpUtilPath = @"C:\Windows\System32\pnputil.exe";
var arg = $$""" /remove-device "SWD\Wintun\{{{guid}}}" """;
// Try to remove the device // Try to remove the device
_ = await Utils.GetCliWrapOutput(pnpUtilPath, arg); _ = await Utils.GetCliWrapOutput(pnpUtilPath, arg);
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(_tag, ex); Logging.SaveLog(_tag, ex);
}
} }
} }
} }

View file

@ -2,7 +2,7 @@ namespace ServiceLib.Enums;
public enum ETransport public enum ETransport
{ {
tcp, raw,
kcp, kcp,
ws, ws,
httpupgrade, httpupgrade,

View file

@ -24,6 +24,8 @@ public class Global
public const string V2raySampleHttpResponseFileName = NamespaceSample + "SampleHttpResponse"; public const string V2raySampleHttpResponseFileName = NamespaceSample + "SampleHttpResponse";
public const string V2raySampleInbound = NamespaceSample + "SampleInbound"; public const string V2raySampleInbound = NamespaceSample + "SampleInbound";
public const string V2raySampleOutbound = NamespaceSample + "SampleOutbound"; 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 SingboxSampleOutbound = NamespaceSample + "SingboxSampleOutbound";
public const string CustomRoutingFileName = NamespaceSample + "custom_routing_"; public const string CustomRoutingFileName = NamespaceSample + "custom_routing_";
public const string TunSingboxDNSFileName = NamespaceSample + "tun_singbox_dns"; 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 SingboxFakeIPFilterFileName = NamespaceSample + "singbox_fakeip_filter";
public const string DefaultSecurity = "auto"; public const string DefaultSecurity = "auto";
public const string DefaultNetwork = "tcp"; public const string DefaultNetwork = "raw";
public const string TcpHeaderHttp = "http"; public const string RawHeaderHttp = "http";
public const string None = "none"; public const string None = "none";
public const string RawNetworkAlias = "tcp";
public const string DefaultXhttpMode = "auto";
public const string ProxyTag = "proxy"; public const string ProxyTag = "proxy";
public const string DirectTag = "direct"; public const string DirectTag = "direct";
public const string BlockTag = "block"; public const string BlockTag = "block";
public const string DnsOutboundTag = "dns";
public const string DnsTag = "dns-module"; public const string DnsTag = "dns-module";
public const string DirectDnsTag = "direct-dns"; public const string DirectDnsTag = "direct-dns";
public const string BalancerTagSuffix = "-round"; public const string BalancerTagSuffix = "-round";
@ -143,7 +148,7 @@ public class Global
@"https://cachefly.cachefly.net/50mb.test", @"https://cachefly.cachefly.net/50mb.test",
@"https://speed.cloudflare.com/__down?bytes=10000000", @"https://speed.cloudflare.com/__down?bytes=10000000",
@"https://speed.cloudflare.com/__down?bytes=50000000", @"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 = public static readonly List<string> SpeedPingTestUrls =
@ -182,14 +187,15 @@ public class Global
@"https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/main/v2rayN/" @"https://raw.githubusercontent.com/Chocolate4U/Iran-v2ray-rules/main/v2rayN/"
]; ];
public static readonly Dictionary<string, string> TcpHttpUserAgentTexts = 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" }, {"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" }, {"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" }, {"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" }, {"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",""} {"golang","Go-http-client/1.1"},
{"curl","curl/7.68.0"},
}; };
public const string Hysteria2ProtocolShare = "hy2://"; public const string Hysteria2ProtocolShare = "hy2://";
@ -292,14 +298,12 @@ public class Global
public static readonly List<string> Networks = public static readonly List<string> Networks =
[ [
"tcp", "raw",
"kcp",
"ws",
"httpupgrade",
"xhttp", "xhttp",
"h2", "kcp",
"quic", "grpc",
"grpc" "ws",
"httpupgrade"
]; ];
public static readonly List<string> KcpHeaderTypes = public static readonly List<string> KcpHeaderTypes =
@ -393,7 +397,8 @@ public class Global
"chrome", "chrome",
"firefox", "firefox",
"edge", "edge",
"golang" "curl",
"golang",
]; ];
public static readonly List<string> XhttpMode = public static readonly List<string> XhttpMode =
@ -424,11 +429,12 @@ public class Global
public static readonly List<string> DomainDirectDNSAddress = 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", "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" "localhost"
]; ];
@ -440,7 +446,7 @@ public class Global
"https://dns.cloudflare.com/dns-query", "https://dns.cloudflare.com/dns-query",
"https://doh.dns.sb/dns-query", "https://doh.dns.sb/dns-query",
"https://doh.opendns.com/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", "8.8.8.8",
"1.1.1.1", "1.1.1.1",
"185.222.222.222", "185.222.222.222",
@ -450,8 +456,8 @@ public class Global
public static readonly List<string> DomainPureIPDNSAddress = public static readonly List<string> DomainPureIPDNSAddress =
[ [
"223.5.5.5",
"119.29.29.29", "119.29.29.29",
"223.5.5.5",
"localhost" "localhost"
]; ];

View file

@ -1,5 +1,3 @@
using System.ComponentModel.DataAnnotations;
namespace ServiceLib.Handler.Builder; namespace ServiceLib.Handler.Builder;
public record CoreConfigContextBuilderResult(CoreConfigContext Context, NodeValidatorResult ValidatorResult) public record CoreConfigContextBuilderResult(CoreConfigContext Context, NodeValidatorResult ValidatorResult)
@ -25,19 +23,6 @@ public record CoreConfigContextBuilderAllResult(
public NodeValidatorResult CombinedValidatorResult => new( public NodeValidatorResult CombinedValidatorResult => new(
[.. MainResult.ValidatorResult.Errors, .. PreSocksResult?.ValidatorResult.Errors ?? []], [.. MainResult.ValidatorResult.Errors, .. PreSocksResult?.ValidatorResult.Errors ?? []],
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]); [.. 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 public class CoreConfigContextBuilder
@ -60,8 +45,6 @@ public class CoreConfigContextBuilder
IsTunEnabled = config.TunModeItem.EnableTun, IsTunEnabled = config.TunModeItem.EnableTun,
SimpleDnsItem = config.SimpleDNSItem, SimpleDnsItem = config.SimpleDNSItem,
ProtectDomainList = [], ProtectDomainList = [],
TunProtectSsPort = 0,
ProxyRelaySsPort = 0,
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType), RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
RoutingItem = await ConfigHandler.GetDefaultRouting(config), RoutingItem = await ConfigHandler.GetDefaultRouting(config),
}; };
@ -124,7 +107,20 @@ public class CoreConfigContextBuilder
} }
var preResult = await BuildPreSocksIfNeeded(mainResult.Context); 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> /// <summary>
@ -150,37 +146,7 @@ public class CoreConfigContextBuilder
}; };
} }
if (!nodeContext.IsTunEnabled return null;
|| 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,
}
};
} }
/// <summary> /// <summary>
@ -347,8 +313,9 @@ public class CoreConfigContextBuilder
} }
// xhttp downloadSettings address protect // xhttp downloadSettings address protect
if (!string.IsNullOrEmpty(node.Extra) var xhttpExtra = node.GetTransportExtra().XhttpExtra;
&& JsonUtils.ParseJson(node.Extra) is JsonObject extra if (!string.IsNullOrEmpty(xhttpExtra)
&& JsonUtils.ParseJson(xhttpExtra) is JsonObject extra
&& extra.TryGetPropertyValue("downloadSettings", out var dsNode) && extra.TryGetPropertyValue("downloadSettings", out var dsNode)
&& dsNode is JsonObject downloadSettings && dsNode is JsonObject downloadSettings
&& downloadSettings.TryGetPropertyValue("address", out var dAddrNode) && downloadSettings.TryGetPropertyValue("address", out var dAddrNode)

View file

@ -20,7 +20,7 @@ public class NodeValidator
[EConfigType.VMess, EConfigType.VLESS, EConfigType.Trojan, EConfigType.Shadowsocks]; [EConfigType.VMess, EConfigType.VLESS, EConfigType.Trojan, EConfigType.Shadowsocks];
private static readonly HashSet<string> SingboxShadowsocksAllowedTransports = 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) public static NodeValidatorResult Validate(ProfileItem item, ECoreType coreType)
{ {
@ -141,9 +141,10 @@ public class NodeValidator
v.Assert(!item.PublicKey.IsNullOrEmpty(), string.Format(ResUI.MsgInvalidProperty, "PublicKey")); 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 not JsonObject) if (JsonUtils.ParseJson(transport.XhttpExtra) is not JsonObject)
{ {
v.Error(string.Format(ResUI.MsgInvalidProperty, "XHTTP Extra")); v.Error(string.Format(ResUI.MsgInvalidProperty, "XHTTP Extra"));
} }
@ -167,7 +168,7 @@ public class NodeValidator
} }
// sing-box does not support non-tcp transports for protocols other than vmess/trojan/vless/shadowsocks // 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, return string.Format(ResUI.MsgCoreNotSupportProtocolTransport,
nameof(ECoreType.sing_box), configType.ToString(), net); nameof(ECoreType.sing_box), configType.ToString(), net);

View file

@ -41,6 +41,7 @@ public static class ConfigHandler
Loglevel = "warning", Loglevel = "warning",
MuxEnabled = false, MuxEnabled = false,
}; };
config.CoreBasicItem.SendThrough = config.CoreBasicItem.SendThrough?.TrimEx();
if (config.Inbound == null) if (config.Inbound == null)
{ {
@ -235,9 +236,6 @@ public static class ConfigHandler
item.Password = profileItem.Password; item.Password = profileItem.Password;
item.Network = profileItem.Network; item.Network = profileItem.Network;
item.HeaderType = profileItem.HeaderType;
item.RequestHost = profileItem.RequestHost;
item.Path = profileItem.Path;
item.StreamSecurity = profileItem.StreamSecurity; item.StreamSecurity = profileItem.StreamSecurity;
item.Sni = profileItem.Sni; item.Sni = profileItem.Sni;
@ -249,7 +247,6 @@ public static class ConfigHandler
item.ShortId = profileItem.ShortId; item.ShortId = profileItem.ShortId;
item.SpiderX = profileItem.SpiderX; item.SpiderX = profileItem.SpiderX;
item.Mldsa65Verify = profileItem.Mldsa65Verify; item.Mldsa65Verify = profileItem.Mldsa65Verify;
item.Extra = profileItem.Extra;
item.MuxEnabled = profileItem.MuxEnabled; item.MuxEnabled = profileItem.MuxEnabled;
item.Cert = profileItem.Cert; item.Cert = profileItem.Cert;
item.CertSha = profileItem.CertSha; item.CertSha = profileItem.CertSha;
@ -257,6 +254,7 @@ public static class ConfigHandler
item.EchForceQuery = profileItem.EchForceQuery; item.EchForceQuery = profileItem.EchForceQuery;
item.Finalmask = profileItem.Finalmask; item.Finalmask = profileItem.Finalmask;
item.ProtoExtra = profileItem.ProtoExtra; item.ProtoExtra = profileItem.ProtoExtra;
item.TransportExtra = profileItem.TransportExtra;
} }
var ret = item.ConfigType switch var ret = item.ConfigType switch
@ -296,9 +294,6 @@ public static class ConfigHandler
VmessSecurity = profileItem.GetProtocolExtra().VmessSecurity?.TrimEx() VmessSecurity = profileItem.GetProtocolExtra().VmessSecurity?.TrimEx()
}); });
profileItem.Network = profileItem.Network.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(); profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity)) if (!Global.VmessSecurities.Contains(profileItem.GetProtocolExtra().VmessSecurity))
@ -750,10 +745,12 @@ public static class ConfigHandler
profileItem.Password = profileItem.Password.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Network = string.Empty; profileItem.Network = 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()) if (profileItem.StreamSecurity.IsNullOrEmpty())
{ {
@ -995,9 +992,6 @@ public static class ConfigHandler
profileItem.Address = profileItem.Address.TrimEx(); profileItem.Address = profileItem.Address.TrimEx();
profileItem.Password = profileItem.Password.TrimEx(); profileItem.Password = profileItem.Password.TrimEx();
profileItem.Network = profileItem.Network.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(); profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx();
var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx(); var vlessEncryption = profileItem.GetProtocolExtra().VlessEncryption?.TrimEx();
@ -1066,7 +1060,7 @@ public static class ConfigHandler
/// <returns>0 if successful</returns> /// <returns>0 if successful</returns>
public static async Task<int> AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true) public static async Task<int> AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
{ {
profileItem.ConfigVersion = 3; profileItem.ConfigVersion = 4;
if (profileItem.StreamSecurity.IsNotEmpty()) if (profileItem.StreamSecurity.IsNotEmpty())
{ {
@ -1134,6 +1128,8 @@ public static class ConfigHandler
var oProtocolExtra = o.GetProtocolExtra(); var oProtocolExtra = o.GetProtocolExtra();
var nProtocolExtra = n.GetProtocolExtra(); var nProtocolExtra = n.GetProtocolExtra();
var oTransport = o.GetTransportExtra();
var nTransport = n.GetTransportExtra();
return o.ConfigType == n.ConfigType return o.ConfigType == n.ConfigType
&& AreEqual(o.Address, n.Address) && AreEqual(o.Address, n.Address)
@ -1144,9 +1140,16 @@ public static class ConfigHandler
&& AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod) && AreEqual(oProtocolExtra.SsMethod, nProtocolExtra.SsMethod)
&& AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity) && AreEqual(oProtocolExtra.VmessSecurity, nProtocolExtra.VmessSecurity)
&& AreEqual(o.Network, n.Network) && AreEqual(o.Network, n.Network)
&& AreEqual(o.HeaderType, n.HeaderType) && AreEqual(oTransport.RawHeaderType, nTransport.RawHeaderType)
&& AreEqual(o.RequestHost, n.RequestHost) && AreEqual(oTransport.Host, nTransport.Host)
&& AreEqual(o.Path, n.Path) && 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) && (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
&& AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow) && AreEqual(oProtocolExtra.Flow, nProtocolExtra.Flow)
&& AreEqual(oProtocolExtra.SalamanderPass, nProtocolExtra.SalamanderPass) && AreEqual(oProtocolExtra.SalamanderPass, nProtocolExtra.SalamanderPass)
@ -1416,10 +1419,12 @@ public static class ConfigHandler
public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType) public static ProfileItem? GetPreSocksItem(Config config, ProfileItem node, ECoreType coreType)
{ {
ProfileItem? itemSocks = null; ProfileItem? itemSocks = null;
var enableLegacyProtect = config.TunModeItem.EnableLegacyProtect
|| Utils.IsNonWindows();
if (node.ConfigType != EConfigType.Custom if (node.ConfigType != EConfigType.Custom
&& coreType != ECoreType.sing_box && coreType != ECoreType.sing_box
&& config.TunModeItem.EnableTun && config.TunModeItem.EnableTun
&& config.TunModeItem.EnableLegacyProtect) && enableLegacyProtect)
{ {
itemSocks = new ProfileItem() itemSocks = new ProfileItem()
{ {

View file

@ -5,6 +5,7 @@ namespace ServiceLib.Handler.Fmt;
public class BaseFmt public class BaseFmt
{ {
private static readonly string[] _allowInsecureArray = new[] { "insecure", "allowInsecure", "allow_insecure" }; 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) protected static string GetIpv6(string address)
{ {
@ -21,6 +22,8 @@ public class BaseFmt
protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery) protected static int ToUriQuery(ProfileItem item, string? securityDef, ref Dictionary<string, string> dicQuery)
{ {
var transport = item.GetTransportExtra();
if (item.StreamSecurity.IsNotEmpty()) if (item.StreamSecurity.IsNotEmpty())
{ {
dicQuery.Add("security", item.StreamSecurity); dicQuery.Add("security", item.StreamSecurity);
@ -87,54 +90,65 @@ public class BaseFmt
dicQuery.Add("fm", Utils.UrlEncode(finalmask)); dicQuery.Add("fm", Utils.UrlEncode(finalmask));
} }
dicQuery.Add("type", item.Network.IsNotEmpty() ? item.Network : nameof(ETransport.tcp)); var network = item.GetNetwork();
if (!Global.Networks.Contains(network))
switch (item.Network)
{ {
case nameof(ETransport.tcp): network = nameof(ETransport.raw);
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None); }
if (item.RequestHost.IsNotEmpty())
//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; break;
case nameof(ETransport.kcp): case nameof(ETransport.kcp):
dicQuery.Add("headerType", item.HeaderType.IsNotEmpty() ? item.HeaderType : Global.None); dicQuery.Add("headerType", transport.KcpHeaderType.IsNotEmpty() ? transport.KcpHeaderType : Global.None);
if (item.Path.IsNotEmpty()) if (transport.KcpSeed.IsNotEmpty())
{ {
dicQuery.Add("seed", Utils.UrlEncode(item.Path)); dicQuery.Add("seed", UrlEncodeSafe(transport.KcpSeed));
} }
break; break;
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): 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; break;
case nameof(ETransport.xhttp): 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 var extra = node != null
? JsonUtils.Serialize(node, new JsonSerializerOptions ? JsonUtils.Serialize(node, new JsonSerializerOptions
{ {
@ -142,38 +156,19 @@ public class BaseFmt
DefaultIgnoreCondition = JsonIgnoreCondition.Never, DefaultIgnoreCondition = JsonIgnoreCondition.Never,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}) })
: item.Extra; : transport.XhttpExtra;
dicQuery.Add("extra", Utils.UrlEncode(extra)); dicQuery.Add("extra", UrlEncodeSafe(extra));
} }
break; 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): case nameof(ETransport.grpc):
if (item.Path.IsNotEmpty()) if (transport.GrpcServiceName.IsNotEmpty())
{ {
dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost)); dicQuery.Add("authority", UrlEncodeSafe(transport.GrpcAuthority));
dicQuery.Add("serviceName", Utils.UrlEncode(item.Path)); dicQuery.Add("serviceName", UrlEncodeSafe(transport.GrpcServiceName));
if (item.HeaderType is Global.GrpcGunMode or Global.GrpcMultiMode) if (transport.GrpcMode is Global.GrpcGunMode or Global.GrpcMultiMode)
{ {
dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType)); dicQuery.Add("mode", UrlEncodeSafe(transport.GrpcMode));
} }
} }
break; break;
@ -216,6 +211,8 @@ public class BaseFmt
protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item) protected static int ResolveUriQuery(NameValueCollection query, ref ProfileItem item)
{ {
var transport = item.GetTransportExtra();
item.StreamSecurity = GetQueryValue(query, "security"); item.StreamSecurity = GetQueryValue(query, "security");
item.Sni = GetQueryValue(query, "sni"); item.Sni = GetQueryValue(query, "sni");
item.Alpn = GetQueryDecoded(query, "alpn"); item.Alpn = GetQueryDecoded(query, "alpn");
@ -258,36 +255,54 @@ public class BaseFmt
item.AllowInsecure = string.Empty; 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) switch (item.Network)
{ {
case nameof(ETransport.tcp): case nameof(ETransport.raw):
item.HeaderType = GetQueryValue(query, "headerType", Global.None); transport = transport with
item.RequestHost = GetQueryDecoded(query, "host"); {
RawHeaderType = GetQueryValue(query, "headerType", Global.None),
Host = GetQueryDecoded(query, "host"),
Path = GetQueryDecoded(query, "path"),
};
break; break;
case nameof(ETransport.kcp): case nameof(ETransport.kcp):
item.HeaderType = GetQueryValue(query, "headerType", Global.None); var kcpSeed = GetQueryDecoded(query, "seed");
item.Path = GetQueryDecoded(query, "seed"); transport = transport with
{
KcpHeaderType = GetQueryValue(query, "headerType", Global.None),
KcpSeed = kcpSeed,
};
break; break;
case nameof(ETransport.ws): case nameof(ETransport.ws):
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
item.RequestHost = GetQueryDecoded(query, "host"); transport = transport with
item.Path = GetQueryDecoded(query, "path", "/"); {
Host = GetQueryDecoded(query, "host"),
Path = GetQueryDecoded(query, "path", "/"),
};
break; break;
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
item.RequestHost = GetQueryDecoded(query, "host"); var xhttpExtra = GetQueryDecoded(query, "extra");
item.Path = GetQueryDecoded(query, "path", "/"); if (xhttpExtra.IsNotEmpty())
item.HeaderType = GetQueryDecoded(query, "mode");
var extraDecoded = GetQueryDecoded(query, "extra");
if (extraDecoded.IsNotEmpty())
{ {
var node = JsonUtils.ParseJson(extraDecoded); var node = JsonUtils.ParseJson(xhttpExtra);
if (node != null) if (node != null)
{ {
extraDecoded = JsonUtils.Serialize(node, new JsonSerializerOptions xhttpExtra = JsonUtils.Serialize(node, new JsonSerializerOptions
{ {
WriteIndented = true, WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.Never, DefaultIgnoreCondition = JsonIgnoreCondition.Never,
@ -295,31 +310,32 @@ public class BaseFmt
}); });
} }
} }
item.Extra = extraDecoded;
break;
case nameof(ETransport.http): transport = transport with
case nameof(ETransport.h2): {
item.Network = nameof(ETransport.h2); Host = GetQueryDecoded(query, "host"),
item.RequestHost = GetQueryDecoded(query, "host"); Path = GetQueryDecoded(query, "path", "/"),
item.Path = GetQueryDecoded(query, "path", "/"); XhttpMode = GetQueryDecoded(query, "mode"),
break; XhttpExtra = xhttpExtra,
};
case nameof(ETransport.quic):
item.HeaderType = GetQueryValue(query, "headerType", Global.None);
item.RequestHost = GetQueryValue(query, "quicSecurity", Global.None);
item.Path = GetQueryDecoded(query, "key");
break; break;
case nameof(ETransport.grpc): case nameof(ETransport.grpc):
item.RequestHost = GetQueryDecoded(query, "authority"); transport = transport with
item.Path = GetQueryDecoded(query, "serviceName"); {
item.HeaderType = GetQueryDecoded(query, "mode", Global.GrpcGunMode); GrpcAuthority = GetQueryDecoded(query, "authority"),
GrpcServiceName = GetQueryDecoded(query, "serviceName"),
GrpcMode = GetQueryDecoded(query, "mode", Global.GrpcGunMode),
};
break; break;
default: default:
item.Network = nameof(ETransport.raw);
break; break;
} }
item.SetTransportExtra(transport);
return 0; return 0;
} }

View file

@ -42,31 +42,28 @@ public class ShadowsocksFmt : BaseFmt
//url = Utile.Base64Encode(url); //url = Utile.Base64Encode(url);
//new Sip002 //new Sip002
var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true); var pw = Utils.Base64Encode($"{item.GetProtocolExtra().SsMethod}:{item.Password}", true);
var transport = item.GetTransportExtra();
// plugin // plugin
var plugin = string.Empty; var plugin = string.Empty;
var pluginArgs = 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"; plugin = "obfs-local";
pluginArgs = $"obfs=http;obfs-host={item.RequestHost};"; pluginArgs = $"obfs=http;obfs-host={transport.Host};";
} }
else else
{ {
if (item.Network == nameof(ETransport.ws)) if (item.Network == nameof(ETransport.ws))
{ {
pluginArgs += "mode=websocket;"; pluginArgs += "mode=websocket;";
pluginArgs += $"host={item.RequestHost};"; pluginArgs += $"host={transport.Host};";
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172 // https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
// Equal signs and commas [and backslashes] must be escaped with a backslash. // 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};"; pluginArgs += $"path={path};";
} }
else if (item.Network == nameof(ETransport.quic))
{
pluginArgs += "mode=quic;";
}
if (item.StreamSecurity == Global.StreamSecurity) if (item.StreamSecurity == Global.StreamSecurity)
{ {
pluginArgs += "tls;"; pluginArgs += "tls;";
@ -213,8 +210,11 @@ public class ShadowsocksFmt : BaseFmt
{ {
obfsHost = obfsHost.Replace("obfs-host=", ""); obfsHost = obfsHost.Replace("obfs-host=", "");
item.Network = Global.DefaultNetwork; item.Network = Global.DefaultNetwork;
item.HeaderType = Global.TcpHeaderHttp; item.SetTransportExtra(item.GetTransportExtra() with
item.RequestHost = obfsHost; {
RawHeaderType = Global.RawHeaderHttp,
Host = obfsHost,
});
} }
} }
// Parse v2ray-plugin // Parse v2ray-plugin
@ -231,21 +231,20 @@ public class ShadowsocksFmt : BaseFmt
if (modeValue == "websocket") if (modeValue == "websocket")
{ {
item.Network = nameof(ETransport.ws); item.Network = nameof(ETransport.ws);
var t = item.GetTransportExtra();
if (!host.IsNullOrEmpty()) if (!host.IsNullOrEmpty())
{ {
item.RequestHost = host.Replace("host=", ""); var wsHost = host.Replace("host=", "");
item.Sni = item.RequestHost; t = t with { Host = wsHost };
item.Sni = wsHost;
} }
if (!path.IsNullOrEmpty()) if (!path.IsNullOrEmpty())
{ {
var pathValue = path.Replace("path=", ""); var pathValue = path.Replace("path=", "");
pathValue = pathValue.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\"); pathValue = pathValue.Replace("\\=", "=").Replace("\\,", ",").Replace("\\\\", "\\");
item.Path = pathValue; t = t with { Path = pathValue };
} }
} item.SetTransportExtra(t);
else if (modeValue == "quic")
{
item.Network = nameof(ETransport.quic);
} }
if (hasTls) if (hasTls)

View file

@ -26,6 +26,7 @@ public class VmessFmt : BaseFmt
var vmessQRCode = new VmessQRCode var vmessQRCode = new VmessQRCode
{ {
// vmess link keeps shared transport keys; map from new transport model on export.
v = 2, v = 2,
ps = item.Remarks.TrimEx(), ps = item.Remarks.TrimEx(),
add = item.Address, add = item.Address,
@ -33,10 +34,34 @@ public class VmessFmt : BaseFmt
id = item.Password, id = item.Password,
aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0, aid = int.TryParse(item.GetProtocolExtra()?.AlterId, out var result) ? result : 0,
scy = item.GetProtocolExtra().VmessSecurity ?? "", scy = item.GetProtocolExtra().VmessSecurity ?? "",
net = item.Network, net = item.GetNetwork() == nameof(ETransport.raw) ? Global.RawNetworkAlias : item.Network,
type = item.HeaderType, type = item.GetNetwork() switch
host = item.RequestHost, {
path = item.Path, 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, tls = item.StreamSecurity,
sni = item.Sni, sni = item.Sni,
alpn = item.Alpn, alpn = item.Alpn,
@ -70,7 +95,10 @@ public class VmessFmt : BaseFmt
} }
item.Network = Global.DefaultNetwork; item.Network = Global.DefaultNetwork;
item.HeaderType = Global.None; var transport = new TransportExtraItem
{
RawHeaderType = Global.None,
};
//item.ConfigVersion = vmessQRCode.v; //item.ConfigVersion = vmessQRCode.v;
item.Remarks = Utils.ToString(vmessQRCode.ps); item.Remarks = Utils.ToString(vmessQRCode.ps);
@ -84,15 +112,30 @@ public class VmessFmt : BaseFmt
}); });
if (vmessQRCode.net.IsNotEmpty()) if (vmessQRCode.net.IsNotEmpty())
{ {
item.Network = vmessQRCode.net; item.Network = vmessQRCode.net == Global.RawNetworkAlias ? nameof(ETransport.raw) : vmessQRCode.net;
} }
if (vmessQRCode.type.IsNotEmpty()) 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,
};
} }
transport = item.GetNetwork() switch
item.RequestHost = Utils.ToString(vmessQRCode.host); {
item.Path = Utils.ToString(vmessQRCode.path); 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.StreamSecurity = Utils.ToString(vmessQRCode.tls);
item.Sni = Utils.ToString(vmessQRCode.sni); item.Sni = Utils.ToString(vmessQRCode.sni);
item.Alpn = Utils.ToString(vmessQRCode.alpn); item.Alpn = Utils.ToString(vmessQRCode.alpn);
@ -122,7 +165,7 @@ public class VmessFmt : BaseFmt
item.SetProtocolExtra(new ProtocolExtraItem item.SetProtocolExtra(new ProtocolExtraItem
{ {
VmessSecurity = "auto", VmessSecurity = Global.DefaultSecurity,
}); });
var query = Utils.ParseQueryString(url.Query); var query = Utils.ParseQueryString(url.Query);

View file

@ -306,10 +306,18 @@ public sealed class AppManager
} }
#pragma warning disable CS0618 #pragma warning disable CS0618
public async Task MigrateProfileExtra() public async Task MigrateProfileExtra()
{ {
await MigrateProfileExtraGroup(); await MigrateProfileExtraGroupV2ToV3();
await MigrateProfileExtraV2ToV3();
await MigrateProfileTransportV3ToV4();
}
private async Task MigrateProfileExtraV2ToV3()
{
const int pageSize = 100; const int pageSize = 100;
var offset = 0; var offset = 0;
@ -325,7 +333,7 @@ public sealed class AppManager
break; 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 // 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 // Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
@ -335,7 +343,120 @@ public sealed class AppManager
//await ProfileGroupItemManager.Instance.ClearAll(); //await ProfileGroupItemManager.Instance.ClearAll();
} }
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>(); var updateProfileItems = new List<ProfileItem>();
@ -433,7 +554,7 @@ public sealed class AppManager
} }
} }
private async Task<bool> MigrateProfileExtraGroup() private async Task<bool> MigrateProfileExtraGroupV2ToV3()
{ {
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync(); 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!)); var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
@ -500,6 +621,7 @@ public sealed class AppManager
//await ProfileGroupItemManager.Instance.ClearAll(); //await ProfileGroupItemManager.Instance.ClearAll();
} }
#pragma warning restore CS0618 #pragma warning restore CS0618
#endregion SqliteHelper #endregion SqliteHelper

View file

@ -68,6 +68,7 @@ public sealed class CoreInfoManager
DownloadUrlWinArm64 = urlN + "/download/{0}/v2rayN-windows-arm64.zip", DownloadUrlWinArm64 = urlN + "/download/{0}/v2rayN-windows-arm64.zip",
DownloadUrlLinux64 = urlN + "/download/{0}/v2rayN-linux-64.zip", DownloadUrlLinux64 = urlN + "/download/{0}/v2rayN-linux-64.zip",
DownloadUrlLinuxArm64 = urlN + "/download/{0}/v2rayN-linux-arm64.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", DownloadUrlOSX64 = urlN + "/download/{0}/v2rayN-macos-64.zip",
DownloadUrlOSXArm64 = urlN + "/download/{0}/v2rayN-macos-arm64.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", DownloadUrlWinArm64 = urlXray + "/download/{0}/Xray-windows-arm64-v8a.zip",
DownloadUrlLinux64 = urlXray + "/download/{0}/Xray-linux-64.zip", DownloadUrlLinux64 = urlXray + "/download/{0}/Xray-linux-64.zip",
DownloadUrlLinuxArm64 = urlXray + "/download/{0}/Xray-linux-arm64-v8a.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", DownloadUrlOSX64 = urlXray + "/download/{0}/Xray-macos-64.zip",
DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip", DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip",
Match = "Xray", Match = "Xray",
@ -133,6 +135,7 @@ public sealed class CoreInfoManager
DownloadUrlWinArm64 = urlMihomo + "/download/{0}/mihomo-windows-arm64-{0}.zip", DownloadUrlWinArm64 = urlMihomo + "/download/{0}/mihomo-windows-arm64-{0}.zip",
DownloadUrlLinux64 = urlMihomo + "/download/{0}/mihomo-linux-amd64-v1-{0}.gz", DownloadUrlLinux64 = urlMihomo + "/download/{0}/mihomo-linux-amd64-v1-{0}.gz",
DownloadUrlLinuxArm64 = urlMihomo + "/download/{0}/mihomo-linux-arm64-{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", DownloadUrlOSX64 = urlMihomo + "/download/{0}/mihomo-darwin-amd64-v1-{0}.gz",
DownloadUrlOSXArm64 = urlMihomo + "/download/{0}/mihomo-darwin-arm64-{0}.gz", DownloadUrlOSXArm64 = urlMihomo + "/download/{0}/mihomo-darwin-arm64-{0}.gz",
Match = "Mihomo", Match = "Mihomo",
@ -175,6 +178,7 @@ public sealed class CoreInfoManager
DownloadUrlWinArm64 = urlSingbox + "/download/{0}/sing-box-{1}-windows-arm64.zip", DownloadUrlWinArm64 = urlSingbox + "/download/{0}/sing-box-{1}-windows-arm64.zip",
DownloadUrlLinux64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-amd64.tar.gz", DownloadUrlLinux64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-amd64.tar.gz",
DownloadUrlLinuxArm64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-arm64.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", DownloadUrlOSX64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-amd64.tar.gz",
DownloadUrlOSXArm64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-arm64.tar.gz", DownloadUrlOSXArm64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-arm64.tar.gz",
Match = "sing-box", Match = "sing-box",
@ -265,6 +269,7 @@ public sealed class CoreInfoManager
names.Add("mihomo-linux-amd64-v1"); names.Add("mihomo-linux-amd64-v1");
names.Add("mihomo-linux-amd64"); names.Add("mihomo-linux-amd64");
names.Add("mihomo-linux-arm64"); names.Add("mihomo-linux-arm64");
names.Add("mihomo-linux-riscv64");
} }
else if (Utils.IsMacOS()) else if (Utils.IsMacOS())
{ {

View file

@ -15,6 +15,8 @@ public class CoreBasicItem
public string DefUserAgent { get; set; } public string DefUserAgent { get; set; }
public string? SendThrough { get; set; }
public bool EnableFragment { get; set; } public bool EnableFragment { get; set; }
public bool EnableCacheFile4Sbox { get; set; } = true; public bool EnableCacheFile4Sbox { get; set; } = true;

View file

@ -16,10 +16,5 @@ public record CoreConfigContext
// TUN Compatibility // TUN Compatibility
public bool IsTunEnabled { get; init; } = false; public bool IsTunEnabled { get; init; } = false;
public HashSet<string> ProtectDomainList { get; init; } = new(); public HashSet<string> ProtectDomainList { get; init; } = [];
// -> 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;
} }

View file

@ -12,6 +12,7 @@ public class CoreInfo
public string? DownloadUrlWinArm64 { get; set; } public string? DownloadUrlWinArm64 { get; set; }
public string? DownloadUrlLinux64 { get; set; } public string? DownloadUrlLinux64 { get; set; }
public string? DownloadUrlLinuxArm64 { get; set; } public string? DownloadUrlLinuxArm64 { get; set; }
public string? DownloadUrlLinuxRiscV64 { get; set; }
public string? DownloadUrlOSX64 { get; set; } public string? DownloadUrlOSX64 { get; set; }
public string? DownloadUrlOSXArm64 { get; set; } public string? DownloadUrlOSXArm64 { get; set; }
public string? Match { get; set; } public string? Match { get; set; }

View file

@ -4,12 +4,13 @@ namespace ServiceLib.Models;
public class ProfileItem public class ProfileItem
{ {
private ProtocolExtraItem? _protocolExtraCache; private ProtocolExtraItem? _protocolExtraCache;
private TransportExtraItem? _transportExtraCache;
public ProfileItem() public ProfileItem()
{ {
IndexId = string.Empty; IndexId = string.Empty;
ConfigType = EConfigType.VMess; ConfigType = EConfigType.VMess;
ConfigVersion = 3; ConfigVersion = 4;
Subid = string.Empty; Subid = string.Empty;
Address = string.Empty; Address = string.Empty;
Port = 0; Port = 0;
@ -17,9 +18,6 @@ public class ProfileItem
Username = string.Empty; Username = string.Empty;
Network = string.Empty; Network = string.Empty;
Remarks = string.Empty; Remarks = string.Empty;
HeaderType = string.Empty;
RequestHost = string.Empty;
Path = string.Empty;
StreamSecurity = string.Empty; StreamSecurity = string.Empty;
AllowInsecure = string.Empty; AllowInsecure = string.Empty;
} }
@ -126,20 +124,26 @@ public class ProfileItem
return true; return true;
} }
public ProtocolExtraItem GetProtocolExtra()
{
return _protocolExtraCache ??= JsonUtils.Deserialize<ProtocolExtraItem>(ProtoExtra) ?? new ProtocolExtraItem();
}
public void SetProtocolExtra(ProtocolExtraItem extraItem) public void SetProtocolExtra(ProtocolExtraItem extraItem)
{ {
_protocolExtraCache = extraItem; _protocolExtraCache = extraItem;
ProtoExtra = JsonUtils.Serialize(extraItem, false); 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 #endregion function
@ -160,9 +164,16 @@ public class ProfileItem
public string Password { get; set; } public string Password { get; set; }
public string Username { get; set; } public string Username { get; set; }
public string Network { get; set; } public string Network { get; set; }
[Obsolete("Use TransportExtra.RawHeaderType/XhttpMode/GrpcMode/KcpHeaderType instead.")]
public string HeaderType { get; set; } public string HeaderType { get; set; }
[Obsolete("Use TransportExtra.Host/GrpcAuthority instead.")]
public string RequestHost { get; set; } public string RequestHost { get; set; }
[Obsolete("Use TransportExtra.Path/GrpcServiceName/KcpSeed instead.")]
public string Path { get; set; } public string Path { get; set; }
public string StreamSecurity { get; set; } public string StreamSecurity { get; set; }
public string AllowInsecure { get; set; } public string AllowInsecure { get; set; }
public string Sni { get; set; } public string Sni { get; set; }
@ -172,7 +183,10 @@ public class ProfileItem
public string ShortId { get; set; } public string ShortId { get; set; }
public string SpiderX { get; set; } public string SpiderX { get; set; }
public string Mldsa65Verify { get; set; } public string Mldsa65Verify { get; set; }
[Obsolete("Use TransportExtra.XhttpExtra instead.")]
public string Extra { get; set; } public string Extra { get; set; }
public bool? MuxEnabled { get; set; } public bool? MuxEnabled { get; set; }
public string Cert { get; set; } public string Cert { get; set; }
public string CertSha { get; set; } public string CertSha { get; set; }
@ -181,6 +195,7 @@ public class ProfileItem
public string Finalmask { get; set; } public string Finalmask { get; set; }
public string ProtoExtra { get; set; } public string ProtoExtra { get; set; }
public string TransportExtra { get; set; }
[Obsolete("Use ProtocolExtraItem.Ports instead.")] [Obsolete("Use ProtocolExtraItem.Ports instead.")]
public string Ports { get; set; } public string Ports { get; set; }

View file

@ -237,6 +237,8 @@ public class Transport4Sbox
public class Headers4Sbox public class Headers4Sbox
{ {
public string? Host { get; set; } public string? Host { get; set; }
[JsonPropertyName("User-Agent")]
public string UserAgent { get; set; }
} }
public class HyObfs4Sbox public class HyObfs4Sbox

View file

@ -0,0 +1,18 @@
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; }
}

View file

@ -47,9 +47,9 @@ public class Inbounds4Ray
{ {
public string tag { get; set; } 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; } public string protocol { get; set; }
@ -75,6 +75,18 @@ public class Inboundsettings4Ray
public bool? allowTransparent { get; set; } public bool? allowTransparent { get; set; }
public List<AccountsItem4Ray>? accounts { 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 public class UsersItem4Ray
@ -105,6 +117,8 @@ public class Outbounds4Ray
public string protocol { get; set; } public string protocol { get; set; }
public string? sendThrough { get; set; }
public string? targetStrategy { get; set; } public string? targetStrategy { get; set; }
public Outboundsettings4Ray settings { get; set; } public Outboundsettings4Ray settings { get; set; }
@ -317,7 +331,7 @@ public class StreamSettings4Ray
public TlsSettings4Ray? tlsSettings { get; set; } public TlsSettings4Ray? tlsSettings { get; set; }
public TcpSettings4Ray? tcpSettings { get; set; } public RawSettings4Ray? rawSettings { get; set; }
public KcpSettings4Ray? kcpSettings { get; set; } public KcpSettings4Ray? kcpSettings { get; set; }
@ -371,7 +385,7 @@ public class CertificateSettings4Ray
public string? usage { get; set; } public string? usage { get; set; }
} }
public class TcpSettings4Ray public class RawSettings4Ray
{ {
public Header4Ray header { get; set; } public Header4Ray header { get; set; }
} }
@ -509,6 +523,8 @@ public class AccountsItem4Ray
public class Sockopt4Ray public class Sockopt4Ray
{ {
public string? dialerProxy { get; set; } public string? dialerProxy { get; set; }
[JsonPropertyName("interface")]
public string? Interface { get; set; }
} }
public class FragmentItem4Ray public class FragmentItem4Ray

View file

@ -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> /// <summary>
/// 查找类似 Please enter the correct port format. 的本地化字符串。 /// 查找类似 Please enter the correct port format. 的本地化字符串。
/// </summary> /// </summary>
@ -2661,6 +2670,15 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 Camouflage domain 的本地化字符串。
/// </summary>
public static string TbCamouflageDomain {
get {
return ResourceManager.GetString("TbCamouflageDomain", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Cancel 的本地化字符串。 /// 查找类似 Cancel 的本地化字符串。
/// </summary> /// </summary>
@ -3078,6 +3096,15 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 Host 的本地化字符串。
/// </summary>
public static string TbHost {
get {
return ResourceManager.GetString("TbHost", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 ICMP routing policy 的本地化字符串。 /// 查找类似 ICMP routing policy 的本地化字符串。
/// </summary> /// </summary>
@ -3384,15 +3411,6 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 Camouflage domain(host) 的本地化字符串。
/// </summary>
public static string TbRequestHost {
get {
return ResourceManager.GetString("TbRequestHost", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Reserved (2,3,4) 的本地化字符串。 /// 查找类似 Reserved (2,3,4) 的本地化字符串。
/// </summary> /// </summary>
@ -3763,7 +3781,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 This parameter is valid only for tcp/http and ws 的本地化字符串。 /// 查找类似 This parameter is valid only for raw/http, ws, gRPC and xhttp 的本地化字符串。
/// </summary> /// </summary>
public static string TbSettingsDefUserAgentTips { public static string TbSettingsDefUserAgentTips {
get { get {
@ -4149,6 +4167,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&apos;s IPv4 address 的本地化字符串。
/// </summary>
public static string TbSettingsSendThroughTip {
get {
return ResourceManager.GetString("TbSettingsSendThroughTip", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Set Win10 UWP Loopback 的本地化字符串。 /// 查找类似 Set Win10 UWP Loopback 的本地化字符串。
/// </summary> /// </summary>
@ -4627,7 +4663,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *Default value tcp 的本地化字符串。 /// 查找类似 *Default value raw 的本地化字符串。
/// </summary> /// </summary>
public static string TipNetwork { public static string TipNetwork {
get { get {
@ -4654,47 +4690,47 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *tcp camouflage type 的本地化字符串。 /// 查找类似 raw camouflage type 的本地化字符串。
/// </summary> /// </summary>
public static string TransportHeaderTypeTip1 { public static string TransportHeaderType1 {
get { get {
return ResourceManager.GetString("TransportHeaderTypeTip1", resourceCulture); return ResourceManager.GetString("TransportHeaderType1", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// 查找类似 *kcp camouflage type 的本地化字符串。 /// 查找类似 kcp camouflage type 的本地化字符串。
/// </summary> /// </summary>
public static string TransportHeaderTypeTip2 { public static string TransportHeaderType2 {
get { get {
return ResourceManager.GetString("TransportHeaderTypeTip2", resourceCulture); return ResourceManager.GetString("TransportHeaderType2", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// 查找类似 *QUIC camouflage type 的本地化字符串。 /// 查找类似 QUIC camouflage type 的本地化字符串。
/// </summary> /// </summary>
public static string TransportHeaderTypeTip3 { public static string TransportHeaderType3 {
get { get {
return ResourceManager.GetString("TransportHeaderTypeTip3", resourceCulture); return ResourceManager.GetString("TransportHeaderType3", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// 查找类似 *grpc mode 的本地化字符串。 /// 查找类似 gRPC mode 的本地化字符串。
/// </summary> /// </summary>
public static string TransportHeaderTypeTip4 { public static string TransportHeaderType4 {
get { get {
return ResourceManager.GetString("TransportHeaderTypeTip4", resourceCulture); return ResourceManager.GetString("TransportHeaderType4", resourceCulture);
} }
} }
/// <summary> /// <summary>
/// 查找类似 *xhttp mode 的本地化字符串。 /// 查找类似 xhttp mode 的本地化字符串。
/// </summary> /// </summary>
public static string TransportHeaderTypeTip5 { public static string TransportHeaderType5 {
get { get {
return ResourceManager.GetString("TransportHeaderTypeTip5", resourceCulture); return ResourceManager.GetString("TransportHeaderType5", resourceCulture);
} }
} }
@ -4726,7 +4762,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *grpc service name 的本地化字符串。 /// 查找类似 gRPC service name 的本地化字符串。
/// </summary> /// </summary>
public static string TransportPathTip4 { public static string TransportPathTip4 {
get { get {
@ -4780,7 +4816,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 *grpc Authority 的本地化字符串。 /// 查找类似 gRPC Authority 的本地化字符串。
/// </summary> /// </summary>
public static string TransportRequestHostTip5 { public static string TransportRequestHostTip5 {
get { get {

View file

@ -343,7 +343,7 @@
<value>*QUIC key/Kcp seed</value> <value>*QUIC key/Kcp seed</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*grpc serviceName</value> <value>gRPC serviceName</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*هاست http جدا شده با کاما (،)</value> <value>*هاست http جدا شده با کاما (،)</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*QUIC securty</value> <value>*QUIC securty</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*tcp camouflage type</value> <value>raw camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*kcp camouflage type</value> <value>kcp camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*QUIC camouflage type</value> <value>QUIC camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*حالت grpc</value> <value>حالت grpc</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>نام مستعار (ملاحظات)</value> <value>نام مستعار (ملاحظات)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>Camouflage domain(host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>روش رمزگذاری (امنیتی)</value> <value>روش رمزگذاری (امنیتی)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>TLS</value> <value>TLS</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*مقدار پیش فرض tcp</value> <value>*مقدار پیش فرض raw</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>نوع هسته</value> <value>نوع هسته</value>
@ -937,7 +934,7 @@
<value>User-Agent</value> <value>User-Agent</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <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>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>FontFamily (نیاز به راه اندازی مجدد)</value> <value>FontFamily (نیاز به راه اندازی مجدد)</value>
@ -1102,7 +1099,7 @@
<value>پایان تست...</value> <value>پایان تست...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value> <value>RPC Authority</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>افزودن سرور [HTTP]</value> <value>افزودن سرور [HTTP]</value>
@ -1320,8 +1317,8 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <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> <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>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TransportHeaderType5" xml:space="preserve">
<value>*حالت xhttp</value> <value>حالت xhttp</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>جیسون خام XHTTP Extra, فرمت: { XHTTPObject }</value> <value>جیسون خام XHTTP Extra, فرمت: { XHTTPObject }</value>
@ -1698,4 +1695,13 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Legacy TUN Protect</value> <value>Legacy TUN Protect</value>
</data> </data>
<data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
</data>
<data name="TbCamouflageDomain" xml:space="preserve">
<value>Camouflage domain</value>
</data>
<data name="TbHost" xml:space="preserve">
<value>Host</value>
</data>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*clé de chiffrement QUIC</value> <value>*clé de chiffrement QUIC</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*nom de service gRPC</value> <value>nom de service gRPC</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*hôte http, séparés par des virgules (,)</value> <value>*hôte http, séparés par des virgules (,)</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*méthode de chiffrement QUIC</value> <value>*méthode de chiffrement QUIC</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*type de camouflage tcp</value> <value>type de camouflage raw</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*type de camouflage kcp</value> <value>type de camouflage kcp</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*type de camouflage QUIC</value> <value>type de camouflage QUIC</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*mode gRPC</value> <value>mode gRPC</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>Alias (remarks)</value> <value>Alias (remarks)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>Domaine de camouflage (host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>Méthode de chiffrement (security)</value> <value>Méthode de chiffrement (security)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>Sécurité couche transport (TLS)</value> <value>Sécurité couche transport (TLS)</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <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>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Type de Core</value> <value>Type de Core</value>
@ -937,7 +934,7 @@
<value>Agent utilisateur (User-Agent)</value> <value>Agent utilisateur (User-Agent)</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <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>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>Police actuelle (redémarrage requis)</value> <value>Police actuelle (redémarrage requis)</value>
@ -1099,7 +1096,7 @@
<value>Arrêt du test en cours...</value> <value>Arrêt du test en cours...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*Autorité gRPC</value> <value>Autorité gRPC</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>Ajouter [HTTP]</value> <value>Ajouter [HTTP]</value>
@ -1316,9 +1313,18 @@
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <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 lapplication. Il nest pas stocké et doit être saisi à chaque redémarrage.</value> <value>Le mot de passe sera vérifié en ligne de commande. En cas déchec ou de dysfonctionnement, redémarrez lapplication. Il nest pas stocké et doit être saisi à chaque redémarrage.</value>
</data>
<data name="TbSettingsSendThrough" xml:space="preserve">
<value>Adresse sortante locale (SendThrough)</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>*Mode XHTTP</value> <value>Pour environnement multi-interfaces, veuillez saisir ladresse IPv4 de la machine locale.</value>
</data>
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
<value>Veuillez saisir ladresse IPv4 correcte de SendThrough.</value>
</data>
<data name="TransportHeaderType5" xml:space="preserve">
<value>Mode XHTTP</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>JSON brut XHTTP Extra, format : { XHTTPObject }</value> <value>JSON brut XHTTP Extra, format : { XHTTPObject }</value>
@ -1621,49 +1627,49 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<value>Finalmask</value> <value>Finalmask</value>
</data> </data>
<data name="MsgRoutingRuleOutboundNodeWarning" xml:space="preserve"> <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>
<data name="MsgRoutingRuleOutboundNodeError" xml:space="preserve"> <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>
<data name="MsgGroupCycleDependency" xml:space="preserve"> <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>
<data name="MsgGroupChildNodeWarning" xml:space="preserve"> <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>
<data name="MsgGroupChildNodeError" xml:space="preserve"> <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>
<data name="MsgGroupChildGroupNodeWarning" xml:space="preserve"> <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>
<data name="MsgGroupChildGroupNodeError" xml:space="preserve"> <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>
<data name="MsgGroupNoValidChildNode" xml:space="preserve"> <data name="MsgGroupNoValidChildNode" xml:space="preserve">
<value>Group {0} has no valid child node.</value> <value>Groupe {0} na aucun nœud enfant valide.</value>
</data> </data>
<data name="MsgRoutingRuleEmptyOutboundTag" xml:space="preserve"> <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>
<data name="MsgRoutingRuleOutboundNodeNotFound" xml:space="preserve"> <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>
<data name="MsgSubscriptionPrevProfileNotFound" xml:space="preserve"> <data name="MsgSubscriptionPrevProfileNotFound" xml:space="preserve">
<value>Subscription previous proxy {0} not found. Skipping.</value> <value>Nœud proxy précédent de labonnement {0} introuvable. Ignoré.</value>
</data> </data>
<data name="MsgSubscriptionNextProfileNotFound" xml:space="preserve"> <data name="MsgSubscriptionNextProfileNotFound" xml:space="preserve">
<value>Subscription next proxy {0} not found. Skipping.</value> <value>Nœud proxy suivant de labonnement {0} introuvable. Ignoré.</value>
</data> </data>
<data name="menuGenGroupServer" xml:space="preserve"> <data name="menuGenGroupServer" xml:space="preserve">
<value>Generate Policy Group</value> <value>Générer groupe de stratégie</value>
</data> </data>
<data name="menuAllServers" xml:space="preserve"> <data name="menuAllServers" xml:space="preserve">
<value>All configurations</value> <value>Toutes configurations</value>
</data> </data>
<data name="menuGenRegionGroup" xml:space="preserve"> <data name="menuGenRegionGroup" xml:space="preserve">
<value>Group by Region</value> <value>Grouper par région</value>
</data> </data>
<data name="menuEditCopy" xml:space="preserve"> <data name="menuEditCopy" xml:space="preserve">
<value>Copier</value> <value>Copier</value>
@ -1672,7 +1678,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<value>Tout sélect</value> <value>Tout sélect</value>
</data> </data>
<data name="menuEditPaste" xml:space="preserve"> <data name="menuEditPaste" xml:space="preserve">
<value>Paste</value> <value>Coller</value>
</data> </data>
<data name="menuEditFormat" xml:space="preserve"> <data name="menuEditFormat" xml:space="preserve">
<value>Format</value> <value>Format</value>
@ -1687,12 +1693,21 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<value>Insecure Concurrency</value> <value>Insecure Concurrency</value>
</data> </data>
<data name="TbUsername" xml:space="preserve"> <data name="TbUsername" xml:space="preserve">
<value>Username</value> <value>Nom dutilisateur</value>
</data> </data>
<data name="TbIcmpRoutingPolicy" xml:space="preserve"> <data name="TbIcmpRoutingPolicy" xml:space="preserve">
<value>ICMP routing policy</value> <value>Politique de routage ICMP</value>
</data> </data>
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Legacy TUN Protect</value> <value>Protection TUN héritée</value>
</data>
<data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>Pour environnements multi-interfaces, entrez ladresse IPv4 de la machine locale.</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>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*QUIC kulcs/KCP seed</value> <value>*QUIC kulcs/KCP seed</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*grpc szolgáltatásnév</value> <value>gRPC szolgáltatásnév</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*http host vesszővel elválasztva (,)</value> <value>*http host vesszővel elválasztva (,)</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*QUIC biztonság</value> <value>*QUIC biztonság</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*tcp álcázási típus</value> <value>raw álcázási típus</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*kcp álcázási típus</value> <value>kcp álcázási típus</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*QUIC álcázási típus</value> <value>QUIC álcázási típus</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*grpc mód</value> <value>gRPC mód</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>Alias (megjegyzések)</value> <value>Alias (megjegyzések)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>Álcázási tartomány(host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>Titkosítási módszer (biztonság)</value> <value>Titkosítási módszer (biztonság)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>TLS</value> <value>TLS</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*Alapértelmezett érték tcp</value> <value>*Alapértelmezett érték raw</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Core Típus</value> <value>Core Típus</value>
@ -937,7 +934,7 @@
<value>User-Agent</value> <value>User-Agent</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <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>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>Betűtípus (újraindítást igényel)</value> <value>Betűtípus (újraindítást igényel)</value>
@ -1102,7 +1099,7 @@
<value>Teszt megszakítása...</value> <value>Teszt megszakítása...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value> <value>gRPC Authority</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>HTTP konfiguráció hozzáadása</value> <value>HTTP konfiguráció hozzáadása</value>
@ -1320,8 +1317,8 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <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> <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>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TransportHeaderType5" xml:space="preserve">
<value>*xhttp mód</value> <value>xhttp mód</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>XHTTP Extra nyers JSON, formátum: { XHTTP Objektum }</value> <value>XHTTP Extra nyers JSON, formátum: { XHTTP Objektum }</value>
@ -1698,4 +1695,13 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Legacy TUN Protect</value> <value>Legacy TUN Protect</value>
</data> </data>
<data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>For multi-interface environments, enter the local machine's IPv4 address</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>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*QUIC key/KCP seed</value> <value>*QUIC key/KCP seed</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*grpc service name</value> <value>gRPC service name</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*http host separated by commas (,)</value> <value>*http host separated by commas (,)</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*QUIC security</value> <value>*QUIC security</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*tcp camouflage type</value> <value>raw camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*kcp camouflage type</value> <value>kcp camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*QUIC camouflage type</value> <value>QUIC camouflage type</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*grpc mode</value> <value>gRPC mode</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>Alias (remarks)</value> <value>Alias (remarks)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>Camouflage domain(host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>Encryption method (security)</value> <value>Encryption method (security)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>TLS</value> <value>TLS</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*Default value tcp</value> <value>*Default value raw</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Core Type</value> <value>Core Type</value>
@ -937,7 +934,7 @@
<value>User-Agent</value> <value>User-Agent</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <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>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>Font family (requires restart)</value> <value>Font family (requires restart)</value>
@ -1102,7 +1099,7 @@
<value>Test terminating...</value> <value>Test terminating...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value> <value>gRPC Authority</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>Add [HTTP]</value> <value>Add [HTTP]</value>
@ -1320,8 +1317,17 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <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> <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>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TbSettingsSendThrough" xml:space="preserve">
<value>*xhttp mode</value> <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="TransportHeaderType5" xml:space="preserve">
<value>xhttp mode</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>XHTTP Extra raw JSON, format: { XHTTP Object }</value> <value>XHTTP Extra raw JSON, format: { XHTTP Object }</value>
@ -1698,4 +1704,10 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Legacy TUN Protect</value> <value>Legacy TUN Protect</value>
</data> </data>
<data name="TbCamouflageDomain" xml:space="preserve">
<value>Camouflage domain</value>
</data>
<data name="TbHost" xml:space="preserve">
<value>Host</value>
</data>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*QUIC-ключ / KCP-seed</value> <value>*QUIC-ключ / KCP-seed</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>Имя сервиса *gRPC</value> <value>Имя сервиса gRPC</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*http-хосты, разделённые запятыми (,)</value> <value>*http-хосты, разделённые запятыми (,)</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>Безопасность *QUIC</value> <value>Безопасность *QUIC</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>Тип *TCP-камуфляжа</value> <value>Тип raw-камуфляжа</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>Тип *KCP-камуфляжа</value> <value>Тип KCP-камуфляжа</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>Тип *QUIC-камуфляжа</value> <value>Тип QUIC-камуфляжа</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>Режим *gRPC</value> <value>Режим gRPC</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>Псевдоним (remarks)</value> <value>Псевдоним (remarks)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>Камуфляжный домен (host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>Метод шифрования (security)</value> <value>Метод шифрования (security)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>TLS</value> <value>TLS</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*По умолчанию TCP</value> <value>*По-умолчанию raw</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Ядро</value> <value>Ядро</value>
@ -937,7 +934,7 @@
<value>User-Agent</value> <value>User-Agent</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <data name="TbSettingsDefUserAgentTips" xml:space="preserve">
<value>Параметр действует только для TCP/HTTP и WebSocket (WS)</value> <value>This parameter is valid only for raw/http, ws, gRPC and xhttp</value>
</data> </data>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>Шрифт (требуется перезапуск)</value> <value>Шрифт (требуется перезапуск)</value>
@ -1102,7 +1099,7 @@
<value>Завершение тестирования...</value> <value>Завершение тестирования...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>* gRPC Authority (HTTP/2 псевдозаголовок :authority)</value> <value>gRPC Authority (HTTP/2 псевдозаголовок :authority)</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>Добавить сервер [HTTP]</value> <value>Добавить сервер [HTTP]</value>
@ -1320,8 +1317,8 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>Пароль sudo будет проверен в терминале. Если из-за ошибки проверки приложение начнёт работать некорректно, перезапустите его. Пароль не сохраняется — его нужно вводить после каждого перезапуска.</value> <value>Пароль sudo будет проверен в терминале. Если из-за ошибки проверки приложение начнёт работать некорректно, перезапустите его. Пароль не сохраняется — его нужно вводить после каждого перезапуска.</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TransportHeaderType5" xml:space="preserve">
<value>*XHTTP-режим</value> <value>XHTTP-режим</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>Дополнительный сырой JSON для XHTTP, формат: { XHTTP Object }</value> <value>Дополнительный сырой JSON для XHTTP, формат: { XHTTP Object }</value>
@ -1698,4 +1695,13 @@
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Устаревшая защита TUN (Legacy Protect)</value> <value>Устаревшая защита TUN (Legacy Protect)</value>
</data> </data>
<data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
</data>
<data name="TbCamouflageDomain" xml:space="preserve">
<value>Камуфляжный домен</value>
</data>
<data name="TbHost" xml:space="preserve">
<value>Host</value>
</data>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*QUIC 加密密钥</value> <value>*QUIC 加密密钥</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*grpc serviceName</value> <value>gRPC serviceName</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*http host 中间逗号 (,) 分隔</value> <value>*http host 中间逗号 (,) 分隔</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*QUIC 加密方式</value> <value>*QUIC 加密方式</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*tcp 伪装类型</value> <value>raw 伪装类型</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*kcp 伪装类型</value> <value>kcp 伪装类型</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*QUIC 伪装类型</value> <value>QUIC 伪装类型</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*grpc 模式</value> <value>gRPC 模式</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>别名 (remarks)</value> <value>别名 (remarks)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>伪装域名 (host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>加密方式 (security)</value> <value>加密方式 (security)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>传输层安全 (TLS)</value> <value>传输层安全 (TLS)</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*默认 tcp,选错会无法连接</value> <value>*默认 raw,选错会无法连接</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Core 类型</value> <value>Core 类型</value>
@ -937,7 +934,7 @@
<value>用户代理 (User-Agent)</value> <value>用户代理 (User-Agent)</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <data name="TbSettingsDefUserAgentTips" xml:space="preserve">
<value>仅对 tcp/http、ws 协议生效</value> <value>仅对 raw/http、ws、gRPC、xhttp 生效</value>
</data> </data>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>当前字体 (需重启)</value> <value>当前字体 (需重启)</value>
@ -1099,7 +1096,7 @@
<value>测试终止中...</value> <value>测试终止中...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value> <value>gRPC Authority</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>添加 [HTTP]</value> <value>添加 [HTTP]</value>
@ -1317,8 +1314,17 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>密码将调用命令行校验,如果因为校验错误导致无法正常运行时,请重启本应用。 密码不会存储,每次重启后都需要再次输入。</value> <value>密码将调用命令行校验,如果因为校验错误导致无法正常运行时,请重启本应用。 密码不会存储,每次重启后都需要再次输入。</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TbSettingsSendThrough" xml:space="preserve">
<value>*XHTTP 模式</value> <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="TransportHeaderType5" xml:space="preserve">
<value>XHTTP 模式</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>XHTTP Extra 原始 JSON格式 { XHTTPObject }</value> <value>XHTTP Extra 原始 JSON格式 { XHTTPObject }</value>
@ -1695,4 +1701,10 @@
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>旧版 TUN 保护</value> <value>旧版 TUN 保护</value>
</data> </data>
<data name="TbCamouflageDomain" xml:space="preserve">
<value>伪装域名</value>
</data>
<data name="TbHost" xml:space="preserve">
<value>Host</value>
</data>
</root> </root>

View file

@ -343,7 +343,7 @@
<value>*QUIC 加密金鑰</value> <value>*QUIC 加密金鑰</value>
</data> </data>
<data name="TransportPathTip4" xml:space="preserve"> <data name="TransportPathTip4" xml:space="preserve">
<value>*grpc serviceName</value> <value>gRPC serviceName</value>
</data> </data>
<data name="TransportRequestHostTip1" xml:space="preserve"> <data name="TransportRequestHostTip1" xml:space="preserve">
<value>*http host 中間逗號 (,) 分隔</value> <value>*http host 中間逗號 (,) 分隔</value>
@ -357,17 +357,17 @@
<data name="TransportRequestHostTip4" xml:space="preserve"> <data name="TransportRequestHostTip4" xml:space="preserve">
<value>*QUIC 加密方式</value> <value>*QUIC 加密方式</value>
</data> </data>
<data name="TransportHeaderTypeTip1" xml:space="preserve"> <data name="TransportHeaderType1" xml:space="preserve">
<value>*TCP 偽裝類型</value> <value>raw 偽裝類型</value>
</data> </data>
<data name="TransportHeaderTypeTip2" xml:space="preserve"> <data name="TransportHeaderType2" xml:space="preserve">
<value>*KCP 偽裝類型</value> <value>KCP 偽裝類型</value>
</data> </data>
<data name="TransportHeaderTypeTip3" xml:space="preserve"> <data name="TransportHeaderType3" xml:space="preserve">
<value>*QUIC 偽裝類型</value> <value>QUIC 偽裝類型</value>
</data> </data>
<data name="TransportHeaderTypeTip4" xml:space="preserve"> <data name="TransportHeaderType4" xml:space="preserve">
<value>*GRPC 模式</value> <value>gRPC 模式</value>
</data> </data>
<data name="LvTLS" xml:space="preserve"> <data name="LvTLS" xml:space="preserve">
<value>TLS</value> <value>TLS</value>
@ -606,9 +606,6 @@
<data name="TbRemarks" xml:space="preserve"> <data name="TbRemarks" xml:space="preserve">
<value>別名 (remarks)</value> <value>別名 (remarks)</value>
</data> </data>
<data name="TbRequestHost" xml:space="preserve">
<value>偽裝域名 (host)</value>
</data>
<data name="TbSecurity" xml:space="preserve"> <data name="TbSecurity" xml:space="preserve">
<value>加密方式 (security)</value> <value>加密方式 (security)</value>
</data> </data>
@ -619,7 +616,7 @@
<value>傳輸層安全性 (TLS)</value> <value>傳輸層安全性 (TLS)</value>
</data> </data>
<data name="TipNetwork" xml:space="preserve"> <data name="TipNetwork" xml:space="preserve">
<value>*預設 TCP,選錯會無法連線</value> <value>*預設 raw,選錯會無法連線</value>
</data> </data>
<data name="TbCoreType" xml:space="preserve"> <data name="TbCoreType" xml:space="preserve">
<value>Core 類型</value> <value>Core 類型</value>
@ -937,7 +934,7 @@
<value>使用者代理 (User-Agent)</value> <value>使用者代理 (User-Agent)</value>
</data> </data>
<data name="TbSettingsDefUserAgentTips" xml:space="preserve"> <data name="TbSettingsDefUserAgentTips" xml:space="preserve">
<value>僅對 TCP/HTTP、WS 協定生效</value> <value>僅對 raw/HTTP、WS、gRPC、XHTTP 生效</value>
</data> </data>
<data name="TbSettingsCurrentFontFamily" xml:space="preserve"> <data name="TbSettingsCurrentFontFamily" xml:space="preserve">
<value>目前字型 (需重啟)</value> <value>目前字型 (需重啟)</value>
@ -1099,7 +1096,7 @@
<value>測試終止中...</value> <value>測試終止中...</value>
</data> </data>
<data name="TransportRequestHostTip5" xml:space="preserve"> <data name="TransportRequestHostTip5" xml:space="preserve">
<value>*grpc Authority</value> <value>gRPC Authority</value>
</data> </data>
<data name="menuAddHttpServer" xml:space="preserve"> <data name="menuAddHttpServer" xml:space="preserve">
<value>新增 [HTTP] 節點</value> <value>新增 [HTTP] 節點</value>
@ -1317,8 +1314,8 @@
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>密碼將調用命令行校驗,如果因為校驗錯誤導致無法正常運行時,請重啟本應用。密碼不會存儲,每次重啟後都需要再次輸入。</value> <value>密碼將調用命令行校驗,如果因為校驗錯誤導致無法正常運行時,請重啟本應用。密碼不會存儲,每次重啟後都需要再次輸入。</value>
</data> </data>
<data name="TransportHeaderTypeTip5" xml:space="preserve"> <data name="TransportHeaderType5" xml:space="preserve">
<value>*xhttp 模式</value> <value>xhttp 模式</value>
</data> </data>
<data name="TransportExtraTip" xml:space="preserve"> <data name="TransportExtraTip" xml:space="preserve">
<value>XHTTP Extra 原始 JSON格式 { XHTTPObject }</value> <value>XHTTP Extra 原始 JSON格式 { XHTTPObject }</value>
@ -1695,4 +1692,13 @@
<data name="TbLegacyProtect" xml:space="preserve"> <data name="TbLegacyProtect" xml:space="preserve">
<value>Legacy TUN Protect</value> <value>Legacy TUN Protect</value>
</data> </data>
<data name="TbSettingsSendThroughTip" xml:space="preserve">
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
</data>
<data name="TbCamouflageDomain" xml:space="preserve">
<value>偽裝域名</value>
</data>
<data name="TbHost" xml:space="preserve">
<value>Host</value>
</data>
</root> </root>

View file

@ -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"
]
}
}

View file

@ -0,0 +1,14 @@
[
{
"network": "udp",
"port": "135,137-139,5353",
"outboundTag": "block"
},
{
"ip": [
"224.0.0.0/3",
"ff00::/8"
],
"outboundTag": "block"
}
]

View file

@ -1,5 +1,24 @@
#!/bin/bash #!/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 # Function to set proxy for GNOME
set_gnome_proxy() { set_gnome_proxy() {
local MODE=$1 local MODE=$1
@ -21,7 +40,7 @@ set_gnome_proxy() {
done done
# Set ignored hosts # 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 "GNOME: Manual proxy settings applied."
echo "Proxy IP: $PROXY_IP" echo "Proxy IP: $PROXY_IP"

View file

@ -38,6 +38,8 @@
<EmbeddedResource Include="Sample\SampleHttpResponse" /> <EmbeddedResource Include="Sample\SampleHttpResponse" />
<EmbeddedResource Include="Sample\SampleInbound" /> <EmbeddedResource Include="Sample\SampleInbound" />
<EmbeddedResource Include="Sample\SampleOutbound" /> <EmbeddedResource Include="Sample\SampleOutbound" />
<EmbeddedResource Include="Sample\SampleTunInbound" />
<EmbeddedResource Include="Sample\SampleTunRules" />
<EmbeddedResource Include="Sample\SingboxSampleClientConfig" /> <EmbeddedResource Include="Sample\SingboxSampleClientConfig" />
<EmbeddedResource Include="Sample\SingboxSampleOutbound" /> <EmbeddedResource Include="Sample\SingboxSampleOutbound" />
<EmbeddedResource Include="Sample\tun_singbox_dns" /> <EmbeddedResource Include="Sample\tun_singbox_dns" />

View file

@ -57,56 +57,12 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
ConvertGeo2Ruleset(); ConvertGeo2Ruleset();
ApplyOutboundSendThrough();
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, ""); ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
ret.Success = true; ret.Success = true;
ret.Data = ApplyFullConfigTemplate(); ret.Data = ApplyFullConfigTemplate();
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
&& 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; return ret;
} }
catch (Exception ex) catch (Exception ex)
@ -214,6 +170,7 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
_coreConfig.route.rules.Add(rule); _coreConfig.route.rules.Add(rule);
} }
ApplyOutboundSendThrough();
ret.Success = true; ret.Success = true;
ret.Data = JsonUtils.Serialize(_coreConfig); ret.Data = JsonUtils.Serialize(_coreConfig);
return ret; return ret;
@ -272,6 +229,7 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
listen_port = port, listen_port = port,
type = EInboundProtocol.mixed.ToString(), type = EInboundProtocol.mixed.ToString(),
}); });
ApplyOutboundSendThrough();
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, ""); ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
ret.Success = true; ret.Success = true;

View file

@ -58,4 +58,40 @@ public partial class CoreConfigSingboxService
return JsonUtils.Serialize(fullConfigTemplateNode); return JsonUtils.Serialize(fullConfigTemplateNode);
} }
private void ApplyOutboundSendThrough()
{
var sendThrough = _config.CoreBasicItem.SendThrough?.TrimEx();
foreach (var outbound in _coreConfig.outbounds ?? [])
{
outbound.inet4_bind_address = ShouldApplySendThrough(outbound, sendThrough) ? sendThrough : null;
}
}
private static bool ShouldApplySendThrough(Outbound4Sbox outbound, string? sendThrough)
{
if (sendThrough.IsNullOrEmpty())
{
return false;
}
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);
}
} }

View file

@ -11,7 +11,7 @@ public partial class CoreConfigSingboxService
_coreConfig.inbounds = []; _coreConfig.inbounds = [];
if (!context.IsTunEnabled if (!context.IsTunEnabled
|| (context.IsTunEnabled && _node.Port != listenPort)) || (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
{ {
var inbound = new Inbound4Sbox() var inbound = new Inbound4Sbox()
{ {

View file

@ -84,6 +84,8 @@ public partial class CoreConfigSingboxService
try try
{ {
var protocolExtra = _node.GetProtocolExtra(); var protocolExtra = _node.GetProtocolExtra();
var transportExtra = _node.GetTransportExtra();
var network = _node.GetNetwork();
outbound.server = _node.Address; outbound.server = _node.Address;
outbound.server_port = _node.Port; outbound.server_port = _node.Port;
outbound.type = Global.ProtocolTypes[_node.ConfigType]; outbound.type = Global.ProtocolTypes[_node.ConfigType];
@ -114,27 +116,23 @@ public partial class CoreConfigSingboxService
outbound.password = _node.Password; outbound.password = _node.Password;
outbound.udp_over_tcp = protocolExtra.Uot == true ? true : null; 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 = "obfs-local";
outbound.plugin_opts = $"obfs=http;obfs-host={_node.RequestHost};"; outbound.plugin_opts = $"obfs=http;obfs-host={transportExtra.Host};";
} }
else else
{ {
var pluginArgs = string.Empty; var pluginArgs = string.Empty;
if (_node.Network == nameof(ETransport.ws)) if (network == nameof(ETransport.ws))
{ {
pluginArgs += "mode=websocket;"; pluginArgs += "mode=websocket;";
pluginArgs += $"host={_node.RequestHost};"; pluginArgs += $"host={transportExtra.Host};";
// https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172 // https://github.com/shadowsocks/v2ray-plugin/blob/e9af1cdd2549d528deb20a4ab8d61c5fbe51f306/args.go#L172
// Equal signs and commas [and backslashes] must be escaped with a backslash. // 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};"; pluginArgs += $"path={path};";
} }
else if (_node.Network == nameof(ETransport.quic))
{
pluginArgs += "mode=quic;";
}
if (_node.StreamSecurity == Global.StreamSecurity) if (_node.StreamSecurity == Global.StreamSecurity)
{ {
pluginArgs += "tls;"; pluginArgs += "tls;";
@ -345,14 +343,6 @@ public partial class CoreConfigSingboxService
{ {
try try
{ {
// The synthetic TUN relay outbound talks to the local Xray shadowsocks relay.
// Xray cannot terminate sing-box h2mux, so muxing here turns local relay traffic
// into sp.mux.sing-box.arpa pseudo-destinations and breaks DNS over TUN.
if (IsTunRelayProxyOutbound())
{
return;
}
var muxEnabled = _node.MuxEnabled ?? _config.CoreBasicItem.MuxEnabled; var muxEnabled = _node.MuxEnabled ?? _config.CoreBasicItem.MuxEnabled;
if (muxEnabled && _config.Mux4SboxItem.Protocol.IsNotEmpty()) if (muxEnabled && _config.Mux4SboxItem.Protocol.IsNotEmpty())
{ {
@ -372,21 +362,6 @@ public partial class CoreConfigSingboxService
} }
} }
private bool IsTunRelayProxyOutbound()
{
if (!context.IsTunEnabled
|| _node.ConfigType != EConfigType.Shadowsocks
|| _node.Address != Global.Loopback
|| _node.Port != context.ProxyRelaySsPort
|| _node.Password != Global.None)
{
return false;
}
var protocolExtra = _node.GetProtocolExtra();
return protocolExtra.SsMethod == Global.None;
}
private void FillOutboundTls(Outbound4Sbox outbound) private void FillOutboundTls(Outbound4Sbox outbound)
{ {
try try
@ -404,9 +379,18 @@ public partial class CoreConfigSingboxService
{ {
serverName = _node.Sni; 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() var tls = new Tls4Sbox()
{ {
@ -461,27 +445,31 @@ public partial class CoreConfigSingboxService
try try
{ {
var transport = new Transport4Sbox(); 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()) switch (_node.GetNetwork())
{ {
case nameof(ETransport.h2): case nameof(ETransport.raw): //http
transport.type = nameof(ETransport.http); if (transportExtra.RawHeaderType == Global.RawHeaderHttp)
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)
{ {
transport.type = nameof(ETransport.http); transport.type = nameof(ETransport.http);
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost); transport.host = transportExtra.Host.IsNullOrEmpty()
transport.path = _node.Path.NullIfEmpty(); ? null
: Utils.String2List(transportExtra.Host);
transport.path = transportExtra.Path.NullIfEmpty();
if (!useragentValue.IsNullOrEmpty())
{
transport.headers ??= new();
transport.headers.UserAgent = useragentValue;
}
} }
break; break;
case nameof(ETransport.ws): case nameof(ETransport.ws):
transport.type = 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 // Parse eh and ed parameters from path using regex
if (!wsPath.IsNullOrEmpty()) if (!wsPath.IsNullOrEmpty())
@ -510,29 +498,35 @@ public partial class CoreConfigSingboxService
} }
transport.path = wsPath.NullIfEmpty(); transport.path = wsPath.NullIfEmpty();
if (_node.RequestHost.IsNotEmpty()) if (transportExtra.Host.IsNotEmpty())
{ {
transport.headers = new() transport.headers = new()
{ {
Host = _node.RequestHost Host = transportExtra.Host
}; };
} }
if (!useragentValue.IsNullOrEmpty())
{
transport.headers ??= new();
transport.headers.UserAgent = useragentValue;
}
break; break;
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
transport.type = nameof(ETransport.httpupgrade); transport.type = nameof(ETransport.httpupgrade);
transport.path = _node.Path.NullIfEmpty(); transport.path = transportExtra.Path.NullIfEmpty();
transport.host = _node.RequestHost.NullIfEmpty(); transport.host = transportExtra.Host.NullIfEmpty();
if (!useragentValue.IsNullOrEmpty())
{
transport.headers ??= new();
transport.headers.UserAgent = useragentValue;
}
break; break;
case nameof(ETransport.quic):
transport.type = nameof(ETransport.quic);
break;
case nameof(ETransport.grpc): case nameof(ETransport.grpc):
transport.type = 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.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s");
transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s"); transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s");
transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream; transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;

View file

@ -24,7 +24,7 @@ public partial class CoreConfigSingboxService
strategy = directDnsStrategy strategy = directDnsStrategy
}; };
if (_config.TunModeItem.EnableTun) if (context.IsTunEnabled)
{ {
_coreConfig.route.auto_detect_interface = true; _coreConfig.route.auto_detect_interface = true;
@ -96,7 +96,6 @@ public partial class CoreConfigSingboxService
_coreConfig.route.rules.Add(new() _coreConfig.route.rules.Add(new()
{ {
port = [53], port = [53],
network = ["udp"],
action = "hijack-dns" action = "hijack-dns"
}); });
} }

View file

@ -15,13 +15,6 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
var ret = new RetResult(); var ret = new RetResult();
try try
{ {
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
&& context.IsTunEnabled
&& context.TunProtectSsPort is > 0 and <= 65535
&& context.ProxyRelaySsPort is > 0 and <= 65535)
{
return GenerateClientProxyRelayConfig();
}
if (_node == null if (_node == null
|| !_node.IsValid()) || !_node.IsValid())
{ {
@ -62,6 +55,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
GenDns(); GenDns();
GenStatistic(); GenStatistic();
ApplyOutboundSendThrough();
var finalRule = BuildFinalRule(); var finalRule = BuildFinalRule();
if (!string.IsNullOrEmpty(finalRule?.balancerTag)) if (!string.IsNullOrEmpty(finalRule?.balancerTag))
@ -195,6 +189,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
_coreConfig.routing.rules.Add(rule); _coreConfig.routing.rules.Add(rule);
} }
ApplyOutboundSendThrough();
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary()); //ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
ret.Success = true; ret.Success = true;
ret.Data = JsonUtils.Serialize(_coreConfig); ret.Data = JsonUtils.Serialize(_coreConfig);
@ -255,6 +250,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
}); });
_coreConfig.routing.rules.Add(BuildFinalRule()); _coreConfig.routing.rules.Add(BuildFinalRule());
ApplyOutboundSendThrough();
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, ""); ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
ret.Success = true; ret.Success = true;
@ -269,140 +265,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,
});
const string protectTag = "tun-protect-ss";
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 = protectTag;
}
// 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 = protectTag;
}
// xhttp download protected
foreach (var outbound in _coreConfig.outbounds
.Where(o => o.streamSettings?.xhttpSettings?.extra is not null))
{
var xhttpExtra = JsonUtils.ParseJson(JsonUtils.Serialize(outbound.streamSettings.xhttpSettings!.extra));
if (xhttpExtra is not JsonObject xhttpExtraObject
|| xhttpExtraObject["downloadSettings"] is not JsonObject downloadSettings)
{
continue;
}
// dialerProxy
var sockopt = downloadSettings["sockopt"] as JsonObject ?? new JsonObject();
sockopt["dialerProxy"] = protectTag;
downloadSettings["sockopt"] = sockopt;
// ech protected
if (downloadSettings["tlsSettings"] is JsonObject tlsSettings
&& tlsSettings["echConfigList"] is not null)
{
tlsSettings["echSockopt"] = new JsonObject
{
["dialerProxy"] = protectTag
};
}
outbound.streamSettings.xhttpSettings.extra = xhttpExtraObject;
}
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
{
Node = protectNode,
}).BuildProxyOutbound(protectTag));
_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 #endregion public gen function
} }

View file

@ -127,4 +127,43 @@ public partial class CoreConfigV2rayService
return JsonUtils.Serialize(fullConfigTemplateNode); return JsonUtils.Serialize(fullConfigTemplateNode);
} }
private void ApplyOutboundSendThrough()
{
var sendThrough = _config.CoreBasicItem.SendThrough?.TrimEx();
foreach (var outbound in _coreConfig.outbounds ?? [])
{
outbound.sendThrough = ShouldApplySendThrough(outbound, sendThrough) ? sendThrough : null;
}
}
private static bool ShouldApplySendThrough(Outbounds4Ray outbound, string? sendThrough)
{
if (sendThrough.IsNullOrEmpty())
{
return false;
}
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);
}
} }

View file

@ -7,36 +7,61 @@ public partial class CoreConfigV2rayService
try try
{ {
var listen = "0.0.0.0"; var listen = "0.0.0.0";
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
_coreConfig.inbounds = []; _coreConfig.inbounds = [];
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true); var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
_coreConfig.inbounds.Add(inbound);
if (_config.Inbound.First().SecondLocalPortEnabled) if (!context.IsTunEnabled
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
{ {
var inbound2 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks2, true); _coreConfig.inbounds.Add(inbound);
_coreConfig.inbounds.Add(inbound2);
}
if (_config.Inbound.First().AllowLANConn) if (_config.Inbound.First().SecondLocalPortEnabled)
{
if (_config.Inbound.First().NewPort4LAN)
{ {
var inbound3 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks3, true); var inbound2 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks2, true);
inbound3.listen = listen; _coreConfig.inbounds.Add(inbound2);
_coreConfig.inbounds.Add(inbound3); }
//auth if (_config.Inbound.First().AllowLANConn)
if (_config.Inbound.First().User.IsNotEmpty() && _config.Inbound.First().Pass.IsNotEmpty()) {
if (_config.Inbound.First().NewPort4LAN)
{ {
inbound3.settings.auth = "password"; var inbound3 = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks3, true);
inbound3.settings.accounts = new List<AccountsItem4Ray> { new() { user = _config.Inbound.First().User, pass = _config.Inbound.First().Pass } }; 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 = Utils.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"];
}
tunInbound.sniffing = inbound.sniffing;
_coreConfig.inbounds.Add(tunInbound);
} }
} }
catch (Exception ex) catch (Exception ex)

View file

@ -12,6 +12,10 @@ public partial class CoreConfigV2rayService
GenObservatory(multipleLoad); GenObservatory(multipleLoad);
GenBalancer(multipleLoad); GenBalancer(multipleLoad);
} }
if (context.IsTunEnabled)
{
_coreConfig.outbounds.Add(BuildDnsOutbound());
}
} }
private List<Outbounds4Ray> BuildAllProxyOutbounds(string baseTagName = Global.ProxyTag) private List<Outbounds4Ray> BuildAllProxyOutbounds(string baseTagName = Global.ProxyTag)
@ -225,12 +229,13 @@ public partial class CoreConfigV2rayService
usersItem.email = Global.UserEMail; usersItem.email = Global.UserEMail;
usersItem.encryption = protocolExtra.VlessEncryption; usersItem.encryption = protocolExtra.VlessEncryption;
if (!protocolExtra.Flow.IsNullOrEmpty()) if (protocolExtra.Flow.IsNullOrEmpty())
{ {
usersItem.flow = protocolExtra.Flow; FillOutboundMux(outbound, muxEnabled, muxEnabled);
} }
else else
{ {
usersItem.flow = protocolExtra.Flow;
FillOutboundMux(outbound, false, muxEnabled); FillOutboundMux(outbound, false, muxEnabled);
} }
outbound.settings.servers = null; outbound.settings.servers = null;
@ -348,8 +353,49 @@ public partial class CoreConfigV2rayService
network = "hysteria"; network = "hysteria";
} }
streamSettings.network = network; streamSettings.network = network;
var host = _node.RequestHost.TrimEx(); var transport = _node.GetTransportExtra();
var path = _node.Path.TrimEx(); var host = string.Empty;
var path = string.Empty;
var kcpSeed = string.Empty;
var headerType = string.Empty;
var xhttpExtra = string.Empty;
switch (network)
{
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;
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 sni = _node.Sni.TrimEx();
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty; var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
@ -435,19 +481,19 @@ public partial class CoreConfigV2rayService
kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize; kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize; kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
var kcpFinalmask = new Finalmask4Ray(); var kcpFinalmask = new Finalmask4Ray();
if (Global.KcpHeaderMaskMap.TryGetValue(_node.HeaderType, out var header)) if (Global.KcpHeaderMaskMap.TryGetValue(headerType, out var header))
{ {
kcpFinalmask.udp = kcpFinalmask.udp =
[ [
new Mask4Ray new Mask4Ray
{ {
type = header, type = header,
settings = _node.HeaderType == "dns" && !host.IsNullOrEmpty() ? new MaskSettings4Ray { domain = host } : null settings = null
} }
]; ];
} }
kcpFinalmask.udp ??= []; kcpFinalmask.udp ??= [];
if (path.IsNullOrEmpty()) if (kcpSeed.IsNullOrEmpty())
{ {
kcpFinalmask.udp.Add(new Mask4Ray kcpFinalmask.udp.Add(new Mask4Ray
{ {
@ -459,7 +505,7 @@ public partial class CoreConfigV2rayService
kcpFinalmask.udp.Add(new Mask4Ray kcpFinalmask.udp.Add(new Mask4Ray
{ {
type = "mkcp-aes128gcm", type = "mkcp-aes128gcm",
settings = new MaskSettings4Ray { password = path } settings = new MaskSettings4Ray { password = kcpSeed }
}); });
} }
streamSettings.kcpSettings = kcpSettings; streamSettings.kcpSettings = kcpSettings;
@ -517,63 +563,25 @@ public partial class CoreConfigV2rayService
{ {
xhttpSettings.host = host; 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; streamSettings.xhttpSettings = xhttpSettings;
FillOutboundMux(outbound); FillOutboundMux(outbound);
break; 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): case nameof(ETransport.grpc):
GrpcSettings4Ray grpcSettings = new() GrpcSettings4Ray grpcSettings = new()
{ {
authority = host.NullIfEmpty(), authority = host.NullIfEmpty(),
serviceName = path, serviceName = path,
multiMode = _node.HeaderType == Global.GrpcMultiMode, multiMode = headerType == Global.GrpcMultiMode,
idle_timeout = _config.GrpcItem.IdleTimeout, idle_timeout = _config.GrpcItem.IdleTimeout,
health_check_timeout = _config.GrpcItem.HealthCheckTimeout, health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
permit_without_stream = _config.GrpcItem.PermitWithoutStream, permit_without_stream = _config.GrpcItem.PermitWithoutStream,
@ -640,20 +648,20 @@ public partial class CoreConfigV2rayService
break; break;
default: default:
//tcp // raw
if (_node.HeaderType == Global.TcpHeaderHttp) if (headerType == Global.RawHeaderHttp)
{ {
TcpSettings4Ray tcpSettings = new() RawSettings4Ray rawSettings = new()
{ {
header = new Header4Ray header = new Header4Ray
{ {
type = _node.HeaderType type = headerType
} }
}; };
//request Host //request Host
var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName); var request = EmbedUtils.GetEmbedText(Global.V2raySampleHttpRequestFileName);
var useragentValue = Global.TcpHttpUserAgentTexts.GetValueOrDefault(useragent, useragent); var useragentValue = Global.RawHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
var arrHost = host.Split(','); var arrHost = host.Split(',');
var host2 = string.Join(",".AppendQuotes(), arrHost); var host2 = string.Join(",".AppendQuotes(), arrHost);
request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}"); request = request.Replace("$requestHost$", $"{host2.AppendQuotes()}");
@ -666,9 +674,9 @@ public partial class CoreConfigV2rayService
pathHttp = string.Join(",".AppendQuotes(), arrPath); pathHttp = string.Join(",".AppendQuotes(), arrPath);
} }
request = request.Replace("$requestPath$", $"{pathHttp.AppendQuotes()}"); 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; break;
} }
@ -824,4 +832,10 @@ public partial class CoreConfigV2rayService
} }
} }
} }
private static Outbounds4Ray BuildDnsOutbound()
{
var outbound = new Outbounds4Ray { tag = Global.DnsOutboundTag, protocol = "dns", };
return outbound;
}
} }

View file

@ -6,6 +6,31 @@ public partial class CoreConfigV2rayService
{ {
try 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) if (_coreConfig.routing?.rules != null)
{ {
_coreConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy; _coreConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
@ -205,4 +230,37 @@ public partial class CoreConfigV2rayService
} }
return finalRule; 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);
}
} }

View file

@ -299,15 +299,22 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
return url; return url;
} }
else if (Utils.IsLinux()) 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.Arm64 => coreInfo?.DownloadUrlLinuxArm64,
Architecture.X64 => coreInfo?.DownloadUrlLinux64, Architecture.X64 => coreInfo?.DownloadUrlLinux64,
_ => null, _ => null,
}; };
} }
else if (Utils.IsMacOS()) else if (Utils.IsMacOS())
{ {
return RuntimeInformation.ProcessArchitecture switch return RuntimeInformation.ProcessArchitecture switch

View file

@ -73,6 +73,163 @@ public class AddServerViewModel : MyReactiveObject
[Reactive] [Reactive]
public bool NaiveQuic { get; set; } 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; }
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):
Host = value;
break;
case nameof(ETransport.ws):
Host = value;
break;
case nameof(ETransport.httpupgrade):
Host = value;
break;
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):
Path = value;
break;
case nameof(ETransport.httpupgrade):
Path = value;
break;
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> FetchCertCmd { get; }
public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; } public ReactiveCommand<Unit, Unit> FetchCertChainCmd { get; }
public ReactiveCommand<Unit, Unit> SaveCmd { get; } public ReactiveCommand<Unit, Unit> SaveCmd { get; }
@ -101,14 +258,21 @@ public class AddServerViewModel : MyReactiveObject
this.WhenAnyValue(x => x.CertSha) this.WhenAnyValue(x => x.CertSha)
.Subscribe(_ => UpdateCertTip()); .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) this.WhenAnyValue(x => x.Cert)
.Subscribe(_ => UpdateCertSha()); .Subscribe(_ => UpdateCertSha());
if (profileItem.IndexId.IsNullOrEmpty()) if (profileItem.IndexId.IsNullOrEmpty())
{ {
profileItem.Network = Global.DefaultNetwork; profileItem.Network = Global.DefaultNetwork;
profileItem.HeaderType = Global.None;
profileItem.RequestHost = "";
profileItem.StreamSecurity = ""; profileItem.StreamSecurity = "";
SelectedSource = profileItem; SelectedSource = profileItem;
} }
@ -121,6 +285,7 @@ public class AddServerViewModel : MyReactiveObject
CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty; CertSha = SelectedSource?.CertSha?.ToString() ?? string.Empty;
var protocolExtra = SelectedSource?.GetProtocolExtra(); var protocolExtra = SelectedSource?.GetProtocolExtra();
var transport = SelectedSource?.GetTransportExtra();
Ports = protocolExtra?.Ports ?? string.Empty; Ports = protocolExtra?.Ports ?? string.Empty;
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0; AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
Flow = protocolExtra?.Flow ?? string.Empty; Flow = protocolExtra?.Flow ?? string.Empty;
@ -139,6 +304,17 @@ public class AddServerViewModel : MyReactiveObject
CongestionControl = protocolExtra?.CongestionControl ?? string.Empty; CongestionControl = protocolExtra?.CongestionControl ?? string.Empty;
InsecureConcurrency = protocolExtra?.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null; InsecureConcurrency = protocolExtra?.InsecureConcurrency > 0 ? protocolExtra.InsecureConcurrency : null;
NaiveQuic = protocolExtra?.NaiveQuic ?? false; 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;
} }
private async Task SaveServerAsync() private async Task SaveServerAsync()
@ -185,6 +361,25 @@ public class AddServerViewModel : MyReactiveObject
SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert; SelectedSource.Cert = Cert.IsNullOrEmpty() ? string.Empty : Cert;
SelectedSource.CertSha = CertSha.IsNullOrEmpty() ? string.Empty : CertSha; 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(),
};
SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with SelectedSource.SetProtocolExtra(SelectedSource.GetProtocolExtra() with
{ {
Ports = Ports.NullIfEmpty(), Ports = Ports.NullIfEmpty(),
@ -206,6 +401,7 @@ public class AddServerViewModel : MyReactiveObject
InsecureConcurrency = InsecureConcurrency > 0 ? InsecureConcurrency : null, InsecureConcurrency = InsecureConcurrency > 0 ? InsecureConcurrency : null,
NaiveQuic = NaiveQuic ? true : null, NaiveQuic = NaiveQuic ? true : null,
}); });
SelectedSource.SetTransportExtra(transport);
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0) if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
{ {
@ -261,7 +457,7 @@ public class AddServerViewModel : MyReactiveObject
var serverName = SelectedSource.Sni; var serverName = SelectedSource.Sni;
if (serverName.IsNullOrEmpty()) if (serverName.IsNullOrEmpty())
{ {
serverName = SelectedSource.RequestHost; serverName = GetCurrentTransportHost();
} }
if (serverName.IsNullOrEmpty()) if (serverName.IsNullOrEmpty())
{ {
@ -286,7 +482,7 @@ public class AddServerViewModel : MyReactiveObject
var serverName = SelectedSource.Sni; var serverName = SelectedSource.Sni;
if (serverName.IsNullOrEmpty()) if (serverName.IsNullOrEmpty())
{ {
serverName = SelectedSource.RequestHost; serverName = GetCurrentTransportHost();
} }
if (serverName.IsNullOrEmpty()) if (serverName.IsNullOrEmpty())
{ {
@ -301,4 +497,17 @@ public class AddServerViewModel : MyReactiveObject
Cert = CertPemManager.ConcatenatePemChain(certs); Cert = CertPemManager.ConcatenatePemChain(certs);
UpdateCertTip(certError); 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,
};
}
} }

View file

@ -559,7 +559,7 @@ public class MainWindowViewModel : MyReactiveObject
await Task.Run(async () => 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 SysProxyHandler.UpdateSysProxy(_config, false);
await Task.Delay(1000); await Task.Delay(1000);
}); });

View file

@ -20,6 +20,7 @@ public class OptionSettingViewModel : MyReactiveObject
[Reactive] public bool defAllowInsecure { get; set; } [Reactive] public bool defAllowInsecure { get; set; }
[Reactive] public string defFingerprint { get; set; } [Reactive] public string defFingerprint { get; set; }
[Reactive] public string defUserAgent { get; set; } [Reactive] public string defUserAgent { get; set; }
[Reactive] public string sendThrough { get; set; }
[Reactive] public string mux4SboxProtocol { get; set; } [Reactive] public string mux4SboxProtocol { get; set; }
[Reactive] public bool enableCacheFile4Sbox { get; set; } [Reactive] public bool enableCacheFile4Sbox { get; set; }
[Reactive] public int? hyUpMbps { get; set; } [Reactive] public int? hyUpMbps { get; set; }
@ -154,6 +155,7 @@ public class OptionSettingViewModel : MyReactiveObject
defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure; defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure;
defFingerprint = _config.CoreBasicItem.DefFingerprint; defFingerprint = _config.CoreBasicItem.DefFingerprint;
defUserAgent = _config.CoreBasicItem.DefUserAgent; defUserAgent = _config.CoreBasicItem.DefUserAgent;
sendThrough = _config.CoreBasicItem.SendThrough;
mux4SboxProtocol = _config.Mux4SboxItem.Protocol; mux4SboxProtocol = _config.Mux4SboxItem.Protocol;
enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox; enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox;
hyUpMbps = _config.HysteriaItem.UpMbps; hyUpMbps = _config.HysteriaItem.UpMbps;
@ -297,6 +299,12 @@ public class OptionSettingViewModel : MyReactiveObject
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort); NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
return; return;
} }
var sendThroughValue = sendThrough?.TrimEx();
if (sendThroughValue.IsNotEmpty() && !Utils.IsIpv4(sendThroughValue))
{
NoticeManager.Instance.Enqueue(ResUI.FillCorrectSendThroughIPv4);
return;
}
var needReboot = EnableStatistics != _config.GuiItem.EnableStatistics var needReboot = EnableStatistics != _config.GuiItem.EnableStatistics
|| DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed || DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed
|| EnableDragDropSort != _config.UiItem.EnableDragDropSort || EnableDragDropSort != _config.UiItem.EnableDragDropSort
@ -336,6 +344,7 @@ public class OptionSettingViewModel : MyReactiveObject
_config.CoreBasicItem.DefAllowInsecure = defAllowInsecure; _config.CoreBasicItem.DefAllowInsecure = defAllowInsecure;
_config.CoreBasicItem.DefFingerprint = defFingerprint; _config.CoreBasicItem.DefFingerprint = defFingerprint;
_config.CoreBasicItem.DefUserAgent = defUserAgent; _config.CoreBasicItem.DefUserAgent = defUserAgent;
_config.CoreBasicItem.SendThrough = sendThrough?.TrimEx();
_config.Mux4SboxItem.Protocol = mux4SboxProtocol; _config.Mux4SboxItem.Protocol = mux4SboxProtocol;
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox; _config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
_config.HysteriaItem.UpMbps = hyUpMbps ?? 0; _config.HysteriaItem.UpMbps = hyUpMbps ?? 0;

View file

@ -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
}

View file

@ -690,128 +690,279 @@
<Grid <Grid
x:Name="gridTransport" x:Name="gridTransport"
Grid.Row="4" Grid.Row="4"
ColumnDefinitions="300,Auto,Auto" RowDefinitions="Auto,Auto,Auto">
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
Grid.ColumnSpan="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
Text="{x:Static resx:ResUI.GbTransport}" /> Text="{x:Static resx:ResUI.GbTransport}" />
<TextBlock <Grid Grid.Row="1" ColumnDefinitions="300,Auto,Auto">
Grid.Row="1" <TextBlock
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbNetwork}" /> Text="{x:Static resx:ResUI.TbNetwork}" />
<ComboBox
x:Name="cmbNetwork"
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TipNetwork}" />
<TextBlock
x:Name="labHeaderType"
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHeaderType}" />
<StackPanel
Grid.Row="2"
Grid.Column="1"
VerticalAlignment="Center"
Orientation="Horizontal">
<ComboBox <ComboBox
x:Name="cmbHeaderType" x:Name="cmbNetwork"
Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource Margin4}" /> Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TipNetwork}" />
</Grid>
<Button <Grid Grid.Row="2">
x:Name="btnExtra" <Grid
Margin="{StaticResource MarginLr8}" x:Name="gridTransportRaw"
Classes="IconButton"> IsVisible="False"
<Button.Content> RowDefinitions="Auto,Auto">
<PathIcon Data="{StaticResource SemiIconMore}"> <Grid Grid.Row="0" ColumnDefinitions="300,Auto">
<PathIcon.RenderTransform> <TextBlock
<RotateTransform Angle="90" /> Grid.Row="0"
</PathIcon.RenderTransform> Grid.Column="0"
</PathIcon> Margin="{StaticResource Margin4}"
</Button.Content> VerticalAlignment="Center"
<Button.Flyout> Text="{x:Static resx:ResUI.TransportHeaderType1}" />
<Flyout> <ComboBox
<StackPanel> x:Name="cmbHeaderTypeRaw"
<TextBlock Grid.Row="0"
Margin="{StaticResource Margin4}" Grid.Column="1"
VerticalAlignment="Center" Width="200"
Text="{x:Static resx:ResUI.TransportExtraTip}" /> Margin="{StaticResource Margin4}" />
<views:JsonEditor </Grid>
x:Name="txtExtra"
Width="400"
MinHeight="100"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>
<TextBlock
x:Name="tipHeaderType"
Grid.Row="2"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHeaderType}" />
<TextBlock <Grid
Grid.Row="3" x:Name="gridTransportRawHttp"
Grid.Column="0" Grid.Row="1"
Margin="{StaticResource Margin4}" ColumnDefinitions="300,Auto"
VerticalAlignment="Center" IsVisible="False"
Text="{x:Static resx:ResUI.TbRequestHost}" /> RowDefinitions="Auto,Auto">
<TextBox <TextBlock
x:Name="txtRequestHost" Grid.Row="0"
Grid.Row="3" Grid.Column="0"
Grid.Column="1" Margin="{StaticResource Margin4}"
Width="400" VerticalAlignment="Center"
Margin="{StaticResource Margin4}" /> Text="{x:Static resx:ResUI.TbCamouflageDomain}" />
<TextBlock <TextBox
x:Name="tipRequestHost" x:Name="txtRequestHostRaw"
Grid.Row="3" Grid.Row="0"
Grid.Column="2" Grid.Column="1"
Margin="{StaticResource Margin4}" Width="400"
VerticalAlignment="Center" Margin="{StaticResource Margin4}" />
Text="{x:Static resx:ResUI.TbRequestHost}" /> <TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathRaw"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
</Grid>
</Grid>
<TextBlock <Grid
Grid.Row="4" x:Name="gridTransportXhttp"
Grid.Column="0" ColumnDefinitions="300,Auto"
Margin="{StaticResource Margin4}" IsVisible="False"
VerticalAlignment="Center" RowDefinitions="Auto,Auto,Auto,Auto">
Text="{x:Static resx:ResUI.TbPath}" /> <TextBlock
<TextBox Grid.Row="0"
x:Name="txtPath" Grid.Column="0"
Grid.Row="4" Margin="{StaticResource Margin4}"
Grid.Column="1" VerticalAlignment="Center"
Width="400" Text="{x:Static resx:ResUI.TransportHeaderType5}" />
Margin="{StaticResource Margin4}" /> <ComboBox
<TextBlock x:Name="cmbHeaderTypeXhttp"
x:Name="tipPath" Grid.Row="0"
Grid.Row="4" Grid.Column="1"
Grid.Column="2" Width="200"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}" />
VerticalAlignment="Center" <TextBlock
Text="{x:Static resx:ResUI.TbPath}" /> Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostXhttp"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathXhttp"
Grid.Row="2"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Top"
Text="{x:Static resx:ResUI.TransportExtraTip}"
TextWrapping="Wrap" />
<views:JsonEditor
x:Name="txtExtraXhttp"
Grid.Row="3"
Grid.Column="1"
Width="400"
MinHeight="100"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
</Grid>
<Grid
x:Name="gridTransportKcp"
ColumnDefinitions="300,Auto"
IsVisible="False"
RowDefinitions="Auto,Auto">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TransportHeaderType2}" />
<ComboBox
x:Name="cmbHeaderTypeKcp"
Grid.Row="0"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="Seed" />
<TextBox
x:Name="txtKcpSeed"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
</Grid>
<Grid
x:Name="gridTransportGrpc"
ColumnDefinitions="300,Auto"
IsVisible="False"
RowDefinitions="Auto,Auto,Auto">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TransportHeaderType4}" />
<ComboBox
x:Name="cmbHeaderTypeGrpc"
Grid.Row="0"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TransportRequestHostTip5}" />
<TextBox
x:Name="txtRequestHostGrpc"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TransportPathTip4}" />
<TextBox
x:Name="txtPathGrpc"
Grid.Row="2"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
</Grid>
<Grid
x:Name="gridTransportWs"
ColumnDefinitions="300,Auto"
IsVisible="False"
RowDefinitions="Auto,Auto">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostWs"
Grid.Row="0"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathWs"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
</Grid>
<Grid
x:Name="gridTransportHttpupgrade"
ColumnDefinitions="300,Auto"
IsVisible="False"
RowDefinitions="Auto,Auto">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostHttpupgrade"
Grid.Row="0"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathHttpupgrade"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}" />
</Grid>
</Grid>
</Grid> </Grid>
<Grid <Grid

View file

@ -16,6 +16,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => Close(); btnCancel.Click += (s, e) => Close();
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged; cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
cmbHeaderTypeRaw.SelectionChanged += CmbHeaderTypeRaw_SelectionChanged;
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged; cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
btnGUID.Click += btnGUID_Click; btnGUID.Click += btnGUID_Click;
btnGUID5.Click += btnGUID_Click; btnGUID5.Click += btnGUID_Click;
@ -24,6 +25,16 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty(); cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
cmbNetwork.ItemsSource = Global.Networks; cmbNetwork.ItemsSource = Global.Networks;
cmbHeaderTypeRaw.ItemsSource = new List<string> { Global.None, Global.RawHeaderHttp };
var kcpHeaderTypes = new List<string> { Global.None };
kcpHeaderTypes.AddRange(Global.KcpHeaderTypes);
cmbHeaderTypeKcp.ItemsSource = kcpHeaderTypes;
cmbHeaderTypeXhttp.ItemsSource = Global.XhttpMode;
cmbHeaderTypeGrpc.ItemsSource = new List<string> { Global.GrpcGunMode, Global.GrpcMultiMode };
cmbFingerprint.ItemsSource = Global.Fingerprints; cmbFingerprint.ItemsSource = Global.Fingerprints;
cmbFingerprint2.ItemsSource = Global.Fingerprints; cmbFingerprint2.ItemsSource = Global.Fingerprints;
cmbAllowInsecure.ItemsSource = Global.AllowInsecure; cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
@ -201,10 +212,27 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
break; break;
} }
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.RawHeaderType, v => v.cmbHeaderTypeRaw.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostRaw.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Path, v => v.txtPathRaw.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KcpHeaderType, v => v.cmbHeaderTypeKcp.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KcpSeed, v => v.txtKcpSeed.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostWs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathWs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostHttpupgrade.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathHttpupgrade.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.XhttpMode, v => v.cmbHeaderTypeXhttp.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.XhttpExtra, v => v.txtExtraXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcMode, v => v.cmbHeaderTypeGrpc.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcAuthority, v => v.txtRequestHostGrpc.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcServiceName, v => v.txtPathGrpc.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
@ -253,8 +281,12 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
private void CmbNetwork_SelectionChanged(object? sender, SelectionChangedEventArgs e) private void CmbNetwork_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{ {
SetHeaderType(); SetTransportGridVisibility();
SetTips(); }
private void CmbHeaderTypeRaw_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{
SetRawHttpFieldsVisibility();
} }
private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e) private void CmbStreamSecurity_SelectionChanged(object? sender, SelectionChangedEventArgs e)
@ -283,102 +315,60 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
txtId5.Text = Utils.GetGuid(); txtId5.Text = Utils.GetGuid();
} }
private void SetHeaderType() private void SetTransportGridVisibility()
{ {
var lstHeaderType = new List<string>(); var network = cmbNetwork.SelectedItem?.ToString();
var network = cmbNetwork.SelectedItem.ToString();
if (network.IsNullOrEmpty())
{
lstHeaderType.Add(Global.None);
cmbHeaderType.ItemsSource = lstHeaderType;
cmbHeaderType.SelectedIndex = 0;
return;
}
if (network == nameof(ETransport.tcp))
{
lstHeaderType.Add(Global.None);
lstHeaderType.Add(Global.TcpHeaderHttp);
}
else if (network is nameof(ETransport.kcp) or nameof(ETransport.quic))
{
lstHeaderType.Add(Global.None);
lstHeaderType.AddRange(Global.KcpHeaderTypes);
}
else if (network is nameof(ETransport.xhttp))
{
lstHeaderType.AddRange(Global.XhttpMode);
}
else if (network == nameof(ETransport.grpc))
{
lstHeaderType.Add(Global.GrpcGunMode);
lstHeaderType.Add(Global.GrpcMultiMode);
}
else
{
lstHeaderType.Add(Global.None);
}
cmbHeaderType.ItemsSource = lstHeaderType;
cmbHeaderType.SelectedIndex = 0;
}
private void SetTips()
{
var network = cmbNetwork.SelectedItem.ToString();
if (network.IsNullOrEmpty()) if (network.IsNullOrEmpty())
{ {
network = Global.DefaultNetwork; network = Global.DefaultNetwork;
} }
labHeaderType.IsVisible = true;
btnExtra.IsVisible = false; gridTransportRaw.IsVisible = false;
tipRequestHost.Text = gridTransportKcp.IsVisible = false;
tipPath.Text = gridTransportWs.IsVisible = false;
tipHeaderType.Text = string.Empty; gridTransportHttpupgrade.IsVisible = false;
gridTransportXhttp.IsVisible = false;
gridTransportGrpc.IsVisible = false;
switch (network) switch (network)
{ {
case nameof(ETransport.tcp): case nameof(ETransport.raw):
tipRequestHost.Text = ResUI.TransportRequestHostTip1; gridTransportRaw.IsVisible = true;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
break; break;
case nameof(ETransport.kcp): case nameof(ETransport.kcp):
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2; gridTransportKcp.IsVisible = true;
tipPath.Text = ResUI.TransportPathTip5;
break; break;
case nameof(ETransport.ws): case nameof(ETransport.ws):
gridTransportWs.IsVisible = true;
break;
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; gridTransportHttpupgrade.IsVisible = true;
tipPath.Text = ResUI.TransportPathTip1;
break; break;
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; gridTransportXhttp.IsVisible = true;
tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.IsVisible = false;
btnExtra.IsVisible = true;
break; break;
case nameof(ETransport.h2):
tipRequestHost.Text = ResUI.TransportRequestHostTip3;
tipPath.Text = ResUI.TransportPathTip2;
break;
case nameof(ETransport.quic):
tipRequestHost.Text = ResUI.TransportRequestHostTip4;
tipPath.Text = ResUI.TransportPathTip3;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
break;
case nameof(ETransport.grpc): case nameof(ETransport.grpc):
tipRequestHost.Text = ResUI.TransportRequestHostTip5; gridTransportGrpc.IsVisible = true;
tipPath.Text = ResUI.TransportPathTip4; break;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4; default:
labHeaderType.IsVisible = false; gridTransportRaw.IsVisible = true;
break; break;
} }
SetRawHttpFieldsVisibility();
}
private void SetRawHttpFieldsVisibility()
{
var network = cmbNetwork.SelectedItem?.ToString();
if (network.IsNullOrEmpty())
{
network = Global.DefaultNetwork;
}
var rawHeaderType = cmbHeaderTypeRaw.SelectedItem?.ToString();
var showRawHttpFields = network == nameof(ETransport.raw)
&& rawHeaderType == Global.RawHeaderHttp;
gridTransportRawHttp.IsVisible = showRawHttpFields;
} }
} }

View file

@ -53,7 +53,7 @@ public partial class JsonEditor : UserControl
var keyColor = dark ? "#9CDCFE" : "#0451A5"; var keyColor = dark ? "#9CDCFE" : "#0451A5";
var strColor = dark ? "#CE9178" : "#A31515"; var strColor = dark ? "#CE9178" : "#A31515";
var numColor = dark ? "#B5CEA8" : "#098658"; var numColor = dark ? "#B5CEA8" : "#098658";
var kwColor = dark ? "#569CD6" : "#0000FF"; var kwColor = dark ? "#569CD6" : "#0000FF";
var xshd = $""" var xshd = $"""
<?xml version="1.0"?> <?xml version="1.0"?>
<SyntaxDefinition name="JSON" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008"> <SyntaxDefinition name="JSON" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
@ -91,6 +91,8 @@ public partial class JsonEditor : UserControl
} }
private void Copy_Click(object? sender, RoutedEventArgs e) => Editor.Copy(); private void Copy_Click(object? sender, RoutedEventArgs e) => Editor.Copy();
private void Paste_Click(object? sender, RoutedEventArgs e) => Editor.Paste(); private void Paste_Click(object? sender, RoutedEventArgs e) => Editor.Paste();
private void SelectAll_Click(object? sender, RoutedEventArgs e) => Editor.SelectAll(); private void SelectAll_Click(object? sender, RoutedEventArgs e) => Editor.SelectAll();
} }

View file

@ -162,8 +162,8 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
else else
{ {
Title = $"{Utils.GetVersion()}"; Title = $"{Utils.GetVersion()}";
menuAddServerViaScan.IsVisible = false;
} }
menuAddServerViaScan.IsVisible = false;
if (_config.UiItem.AutoHideStartup && Utils.IsWindows()) if (_config.UiItem.AutoHideStartup && Utils.IsWindows())
{ {
@ -336,17 +336,17 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
public async Task ScanScreenTaskAsync() public async Task ScanScreenTaskAsync()
{ {
//ShowHideWindow(false); ShowHideWindow(false);
NoticeManager.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)"); await Task.Delay(200);
await Task.CompletedTask;
//if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
//{
// //var bytes = QRCodeHelper.CaptureScreen(desktop);
// //await ViewModel?.ScanScreenResult(bytes);
//}
//ShowHideWindow(true); var bytes = QRCodeAvaloniaUtils.CaptureScreen();
if (bytes != null && ViewModel != null)
{
await ViewModel.ScanScreenResult(bytes);
}
ShowHideWindow(true);
} }
private async Task ScanImageTaskAsync() private async Task ScanImageTaskAsync()

View file

@ -325,6 +325,27 @@
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock
Grid.Row="21"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbSettingsSendThrough}" />
<TextBox
x:Name="txtsendThrough"
Grid.Row="21"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
Watermark="0.0.0.0" />
<TextBlock
Grid.Row="21"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbSettingsSendThroughTip}"
TextWrapping="Wrap" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>

View file

@ -76,6 +76,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.sendThrough, v => v.txtsendThrough.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
@ -6,6 +6,7 @@
<BuiltInComInteropSupport>true</BuiltInComInteropSupport> <BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<AssemblyName>v2rayN</AssemblyName> <AssemblyName>v2rayN</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Action", "GitHub Act
..\.github\workflows\winget-publish.yml = ..\.github\workflows\winget-publish.yml ..\.github\workflows\winget-publish.yml = ..\.github\workflows\winget-publish.yml
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceLib.Tests", "ServiceLib.Tests\ServiceLib.Tests.csproj", "{E0B6C5C7-ED48-42EB-947A-877779E9F555}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -58,6 +60,10 @@ Global
{CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.Build.0 = Release|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.Build.0 = Release|Any CPU
{E0B6C5C7-ED48-42EB-947A-877779E9F555}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0B6C5C7-ED48-42EB-947A-877779E9F555}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0B6C5C7-ED48-42EB-947A-877779E9F555}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0B6C5C7-ED48-42EB-947A-877779E9F555}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View file

@ -16,6 +16,7 @@
</Folder> </Folder>
<Project Path="AmazTool/AmazTool.csproj" /> <Project Path="AmazTool/AmazTool.csproj" />
<Project Path="GlobalHotKeys/src/GlobalHotKeys/GlobalHotKeys.csproj" /> <Project Path="GlobalHotKeys/src/GlobalHotKeys/GlobalHotKeys.csproj" />
<Project Path="ServiceLib.Tests/ServiceLib.Tests.csproj" />
<Project Path="ServiceLib/ServiceLib.csproj" /> <Project Path="ServiceLib/ServiceLib.csproj" />
<Project Path="v2rayN.Desktop/v2rayN.Desktop.csproj" /> <Project Path="v2rayN.Desktop/v2rayN.Desktop.csproj" />
<Project Path="v2rayN/v2rayN.csproj" /> <Project Path="v2rayN/v2rayN.csproj" />

View file

@ -5,7 +5,7 @@ using Microsoft.Win32;
namespace v2rayN.Common; namespace v2rayN.Common;
internal static class WindowsUtils internal static partial class WindowsUtils
{ {
private static readonly string _tag = "WindowsUtils"; private static readonly string _tag = "WindowsUtils";
@ -39,8 +39,8 @@ internal static class WindowsUtils
} }
} }
[DllImport("dwmapi.dll")] [LibraryImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize); public static partial int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize);
public static ImageSource IconToImageSource(Icon icon) public static ImageSource IconToImageSource(Icon icon)
{ {

View file

@ -1,6 +1,6 @@
namespace v2rayN.Manager; namespace v2rayN.Manager;
public sealed class HotkeyManager public sealed partial class HotkeyManager
{ {
private static readonly Lazy<HotkeyManager> _instance = new(() => new()); private static readonly Lazy<HotkeyManager> _instance = new(() => new());
public static HotkeyManager Instance = _instance.Value; public static HotkeyManager Instance = _instance.Value;
@ -165,11 +165,13 @@ public sealed class HotkeyManager
} }
} }
[DllImport("user32.dll", SetLastError = true)] [LibraryImport("user32.dll", SetLastError = true)]
private static extern bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc); [return: MarshalAs(UnmanagedType.Bool)]
private static partial bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc);
[DllImport("user32.dll", SetLastError = true)] [LibraryImport("user32.dll", SetLastError = true)]
private static extern bool UnregisterHotKey(nint hWnd, int id); [return: MarshalAs(UnmanagedType.Bool)]
private static partial bool UnregisterHotKey(nint hWnd, int id);
[Flags] [Flags]
private enum KeyModifiers private enum KeyModifiers

View file

@ -150,7 +150,7 @@
<Grid <Grid
x:Name="gridVMess" x:Name="gridVMess"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -234,7 +234,7 @@
<Grid <Grid
x:Name="gridSs" x:Name="gridSs"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -308,7 +308,7 @@
<Grid <Grid
x:Name="gridSocks" x:Name="gridSocks"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -353,7 +353,7 @@
<Grid <Grid
x:Name="gridVLESS" x:Name="gridVLESS"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -437,7 +437,7 @@
<Grid <Grid
x:Name="gridTrojan" x:Name="gridTrojan"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -497,7 +497,7 @@
<Grid <Grid
x:Name="gridHysteria2" x:Name="gridHysteria2"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -610,7 +610,7 @@
<Grid <Grid
x:Name="gridTuic" x:Name="gridTuic"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -670,7 +670,7 @@
<Grid <Grid
x:Name="gridWireguard" x:Name="gridWireguard"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -767,7 +767,7 @@
<Grid <Grid
x:Name="gridAnytls" x:Name="gridAnytls"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -796,7 +796,7 @@
<Grid <Grid
x:Name="gridNaive" x:Name="gridNaive"
Grid.Row="2" Grid.Row="2"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -894,7 +894,6 @@
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
</Grid> </Grid>
<Separator <Separator
@ -908,143 +907,356 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
Grid.ColumnSpan="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
Style="{StaticResource ModuleTitle}" Style="{StaticResource ModuleTitle}"
Text="{x:Static resx:ResUI.GbTransport}" /> Text="{x:Static resx:ResUI.GbTransport}" />
<TextBlock <Grid Grid.Row="1">
Grid.Row="1" <Grid.ColumnDefinitions>
Grid.Column="0" <ColumnDefinition Width="300" />
Margin="{StaticResource Margin4}" <ColumnDefinition Width="Auto" />
VerticalAlignment="Center" <ColumnDefinition Width="Auto" />
Style="{StaticResource ToolbarTextBlock}" </Grid.ColumnDefinitions>
Text="{x:Static resx:ResUI.TbNetwork}" /> <TextBlock
<ComboBox Grid.Column="0"
x:Name="cmbNetwork" Margin="{StaticResource Margin4}"
Grid.Row="1" VerticalAlignment="Center"
Grid.Column="1" Style="{StaticResource ToolbarTextBlock}"
Width="200" Text="{x:Static resx:ResUI.TbNetwork}" />
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TipNetwork}" />
<TextBlock
x:Name="labHeaderType"
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbHeaderType}" />
<StackPanel
Grid.Row="2"
Grid.Column="1"
VerticalAlignment="Center"
Orientation="Horizontal">
<ComboBox <ComboBox
x:Name="cmbHeaderType" x:Name="cmbNetwork"
Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" /> Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TipNetwork}" />
</Grid>
<materialDesign:PopupBox <Grid Grid.Row="2">
x:Name="popExtra" <Grid x:Name="gridTransportRaw" Visibility="Collapsed">
HorizontalAlignment="Right" <Grid.RowDefinitions>
StaysOpen="True" <RowDefinition Height="Auto" />
Style="{StaticResource MaterialDesignToolForegroundPopupBox}"> <RowDefinition Height="Auto" />
<StackPanel> </Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock <TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TransportExtraTip}" /> Text="{x:Static resx:ResUI.TransportHeaderType1}" />
<TextBox <ComboBox
x:Name="txtExtra" x:Name="cmbHeaderTypeRaw"
Width="400" Grid.Row="0"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
</Grid>
<Grid
x:Name="gridTransportRawHttp"
Grid.Row="1"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
AcceptsReturn="True" Style="{StaticResource ToolbarTextBlock}"
MinLines="6" Text="{x:Static resx:ResUI.TbCamouflageDomain}" />
Style="{StaticResource MyOutlinedTextBox}" <TextBox
TextWrapping="Wrap" /> x:Name="txtRequestHostRaw"
</StackPanel> Grid.Row="0"
</materialDesign:PopupBox> Grid.Column="1"
</StackPanel> Width="400"
<TextBlock Margin="{StaticResource Margin4}"
x:Name="tipHeaderType" Style="{StaticResource DefTextBox}" />
Grid.Row="2" <TextBlock
Grid.Column="2" Grid.Row="1"
Margin="{StaticResource Margin4}" Grid.Column="0"
VerticalAlignment="Center" Margin="{StaticResource Margin4}"
Style="{StaticResource ToolbarTextBlock}" VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbHeaderType}" /> Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathRaw"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
</Grid>
</Grid>
<TextBlock <Grid x:Name="gridTransportXhttp" Visibility="Collapsed">
Grid.Row="3" <Grid.ColumnDefinitions>
Grid.Column="0" <ColumnDefinition Width="300" />
Margin="{StaticResource Margin4}" <ColumnDefinition Width="Auto" />
VerticalAlignment="Center" </Grid.ColumnDefinitions>
Style="{StaticResource ToolbarTextBlock}" <Grid.RowDefinitions>
Text="{x:Static resx:ResUI.TbRequestHost}" /> <RowDefinition Height="Auto" />
<TextBox <RowDefinition Height="Auto" />
x:Name="txtRequestHost" <RowDefinition Height="Auto" />
Grid.Row="3" <RowDefinition Height="Auto" />
Grid.Column="1" </Grid.RowDefinitions>
Width="400" <TextBlock
Margin="{StaticResource Margin4}" Grid.Row="0"
Style="{StaticResource DefTextBox}" /> Grid.Column="0"
<TextBlock Margin="{StaticResource Margin4}"
x:Name="tipRequestHost" VerticalAlignment="Center"
Grid.Row="3" Style="{StaticResource ToolbarTextBlock}"
Grid.Column="2" Text="{x:Static resx:ResUI.TransportHeaderType5}" />
Margin="{StaticResource Margin4}" <ComboBox
VerticalAlignment="Center" x:Name="cmbHeaderTypeXhttp"
Style="{StaticResource ToolbarTextBlock}" Grid.Row="0"
Text="{x:Static resx:ResUI.TbRequestHost}" /> Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostXhttp"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathXhttp"
Grid.Row="2"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Top"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TransportExtraTip}"
TextWrapping="Wrap" />
<TextBox
x:Name="txtExtraXhttp"
Grid.Row="3"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
AcceptsReturn="True"
MinLines="6"
Style="{StaticResource MyOutlinedTextBox}"
TextWrapping="Wrap" />
</Grid>
<TextBlock <Grid x:Name="gridTransportKcp" Visibility="Collapsed">
Grid.Row="4" <Grid.ColumnDefinitions>
Grid.Column="0" <ColumnDefinition Width="300" />
Margin="{StaticResource Margin4}" <ColumnDefinition Width="Auto" />
VerticalAlignment="Center" </Grid.ColumnDefinitions>
Style="{StaticResource ToolbarTextBlock}" <Grid.RowDefinitions>
Text="{x:Static resx:ResUI.TbPath}" /> <RowDefinition Height="Auto" />
<TextBox <RowDefinition Height="Auto" />
x:Name="txtPath" </Grid.RowDefinitions>
Grid.Row="4" <TextBlock
Grid.Column="1" Grid.Row="0"
Width="400" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" /> VerticalAlignment="Center"
<TextBlock Style="{StaticResource ToolbarTextBlock}"
x:Name="tipPath" Text="{x:Static resx:ResUI.TransportHeaderType2}" />
Grid.Row="4" <ComboBox
Grid.Column="2" x:Name="cmbHeaderTypeKcp"
Margin="{StaticResource Margin4}" Grid.Row="0"
VerticalAlignment="Center" Grid.Column="1"
Style="{StaticResource ToolbarTextBlock}" Width="200"
Text="{x:Static resx:ResUI.TbPath}" /> Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="Seed" />
<TextBox
x:Name="txtKcpSeed"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
</Grid>
<Grid x:Name="gridTransportGrpc" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TransportHeaderType4}" />
<ComboBox
x:Name="cmbHeaderTypeGrpc"
Grid.Row="0"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TransportRequestHostTip5}" />
<TextBox
x:Name="txtRequestHostGrpc"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TransportPathTip4}" />
<TextBox
x:Name="txtPathGrpc"
Grid.Row="2"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
</Grid>
<Grid x:Name="gridTransportWs" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostWs"
Grid.Row="0"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathWs"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
</Grid>
<Grid x:Name="gridTransportHttpupgrade" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbHost}" />
<TextBox
x:Name="txtRequestHostHttpupgrade"
Grid.Row="0"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbPath}" />
<TextBox
x:Name="txtPathHttpupgrade"
Grid.Row="1"
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
Style="{StaticResource DefTextBox}" />
</Grid>
</Grid>
</Grid> </Grid>
<Grid x:Name="gridFinalmask" Grid.Row="5"> <Grid x:Name="gridFinalmask" Grid.Row="5">
@ -1118,7 +1330,7 @@
<Grid <Grid
x:Name="gridTlsMore" x:Name="gridTlsMore"
Grid.Row="8" Grid.Row="8"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -1307,7 +1519,7 @@
<Grid <Grid
x:Name="gridRealityMore" x:Name="gridRealityMore"
Grid.Row="8" Grid.Row="8"
Visibility="Hidden"> Visibility="Collapsed">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />

View file

@ -11,6 +11,7 @@ public partial class AddServerWindow
Owner = Application.Current.MainWindow; Owner = Application.Current.MainWindow;
Loaded += Window_Loaded; Loaded += Window_Loaded;
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged; cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
cmbHeaderTypeRaw.SelectionChanged += CmbHeaderTypeRaw_SelectionChanged;
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged; cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
btnGUID.Click += btnGUID_Click; btnGUID.Click += btnGUID_Click;
btnGUID5.Click += btnGUID_Click; btnGUID5.Click += btnGUID_Click;
@ -19,6 +20,20 @@ public partial class AddServerWindow
cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty(); cmbCoreType.ItemsSource = Global.CoreTypes.AppendEmpty();
cmbNetwork.ItemsSource = Global.Networks; cmbNetwork.ItemsSource = Global.Networks;
if (ViewModel.SelectedSource.Network.IsNullOrEmpty() || !Global.Networks.Contains(ViewModel.SelectedSource.Network))
{
ViewModel.SelectedSource.Network = Global.DefaultNetwork;
}
cmbHeaderTypeRaw.ItemsSource = new List<string> { Global.None, Global.RawHeaderHttp };
var kcpHeaderTypes = new List<string> { Global.None };
kcpHeaderTypes.AddRange(Global.KcpHeaderTypes);
cmbHeaderTypeKcp.ItemsSource = kcpHeaderTypes;
cmbHeaderTypeXhttp.ItemsSource = Global.XhttpMode;
cmbHeaderTypeGrpc.ItemsSource = new List<string> { Global.GrpcGunMode, Global.GrpcMultiMode };
cmbFingerprint.ItemsSource = Global.Fingerprints; cmbFingerprint.ItemsSource = Global.Fingerprints;
cmbFingerprint2.ItemsSource = Global.Fingerprints; cmbFingerprint2.ItemsSource = Global.Fingerprints;
cmbAllowInsecure.ItemsSource = Global.AllowInsecure; cmbAllowInsecure.ItemsSource = Global.AllowInsecure;
@ -114,7 +129,7 @@ public partial class AddServerWindow
} }
cmbStreamSecurity.ItemsSource = lstStreamSecurity; cmbStreamSecurity.ItemsSource = lstStreamSecurity;
gridTlsMore.Visibility = Visibility.Hidden; gridTlsMore.Visibility = Visibility.Collapsed;
this.WhenActivated(disposables => this.WhenActivated(disposables =>
{ {
@ -195,10 +210,27 @@ public partial class AddServerWindow
break; break;
} }
this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.RawHeaderType, v => v.cmbHeaderTypeRaw.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostRaw.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Path, v => v.txtPathRaw.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KcpHeaderType, v => v.cmbHeaderTypeKcp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.KcpSeed, v => v.txtKcpSeed.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostWs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathWs.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostHttpupgrade.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathHttpupgrade.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.XhttpMode, v => v.cmbHeaderTypeXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Host, v => v.txtRequestHostXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Path, v => v.txtPathXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.XhttpExtra, v => v.txtExtraXhttp.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcMode, v => v.cmbHeaderTypeGrpc.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcAuthority, v => v.txtRequestHostGrpc.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.GrpcServiceName, v => v.txtPathGrpc.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables);
@ -249,8 +281,12 @@ public partial class AddServerWindow
private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e) private void CmbNetwork_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
SetHeaderType(); SetTransportGridVisibility();
SetTips(); }
private void CmbHeaderTypeRaw_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
SetRawHttpFieldsVisibility();
} }
private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e) private void CmbStreamSecurity_SelectionChanged(object sender, SelectionChangedEventArgs e)
@ -259,17 +295,17 @@ public partial class AddServerWindow
if (security == Global.StreamSecurityReality) if (security == Global.StreamSecurityReality)
{ {
gridRealityMore.Visibility = Visibility.Visible; gridRealityMore.Visibility = Visibility.Visible;
gridTlsMore.Visibility = Visibility.Hidden; gridTlsMore.Visibility = Visibility.Collapsed;
} }
else if (security == Global.StreamSecurity) else if (security == Global.StreamSecurity)
{ {
gridRealityMore.Visibility = Visibility.Hidden; gridRealityMore.Visibility = Visibility.Collapsed;
gridTlsMore.Visibility = Visibility.Visible; gridTlsMore.Visibility = Visibility.Visible;
} }
else else
{ {
gridRealityMore.Visibility = Visibility.Hidden; gridRealityMore.Visibility = Visibility.Collapsed;
gridTlsMore.Visibility = Visibility.Hidden; gridTlsMore.Visibility = Visibility.Collapsed;
} }
} }
@ -279,102 +315,62 @@ public partial class AddServerWindow
txtId5.Text = Utils.GetGuid(); txtId5.Text = Utils.GetGuid();
} }
private void SetHeaderType() private void SetTransportGridVisibility()
{ {
var lstHeaderType = new List<string>(); var network = cmbNetwork.SelectedItem?.ToString();
var network = cmbNetwork.SelectedItem.ToString();
if (network.IsNullOrEmpty())
{
lstHeaderType.Add(Global.None);
cmbHeaderType.ItemsSource = lstHeaderType;
cmbHeaderType.SelectedIndex = 0;
return;
}
if (network == nameof(ETransport.tcp))
{
lstHeaderType.Add(Global.None);
lstHeaderType.Add(Global.TcpHeaderHttp);
}
else if (network is nameof(ETransport.kcp) or nameof(ETransport.quic))
{
lstHeaderType.Add(Global.None);
lstHeaderType.AddRange(Global.KcpHeaderTypes);
}
else if (network is nameof(ETransport.xhttp))
{
lstHeaderType.AddRange(Global.XhttpMode);
}
else if (network == nameof(ETransport.grpc))
{
lstHeaderType.Add(Global.GrpcGunMode);
lstHeaderType.Add(Global.GrpcMultiMode);
}
else
{
lstHeaderType.Add(Global.None);
}
cmbHeaderType.ItemsSource = lstHeaderType;
cmbHeaderType.SelectedIndex = 0;
}
private void SetTips()
{
var network = cmbNetwork.SelectedItem.ToString();
if (network.IsNullOrEmpty()) if (network.IsNullOrEmpty())
{ {
network = Global.DefaultNetwork; network = Global.DefaultNetwork;
} }
labHeaderType.Visibility = Visibility.Visible;
popExtra.Visibility = Visibility.Hidden; gridTransportRaw.Visibility = Visibility.Collapsed;
tipRequestHost.Text = gridTransportKcp.Visibility = Visibility.Collapsed;
tipPath.Text = gridTransportWs.Visibility = Visibility.Collapsed;
tipHeaderType.Text = string.Empty; gridTransportHttpupgrade.Visibility = Visibility.Collapsed;
gridTransportXhttp.Visibility = Visibility.Collapsed;
gridTransportGrpc.Visibility = Visibility.Collapsed;
switch (network) switch (network)
{ {
case nameof(ETransport.tcp): case nameof(ETransport.raw):
tipRequestHost.Text = ResUI.TransportRequestHostTip1; gridTransportRaw.Visibility = Visibility.Visible;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
break; break;
case nameof(ETransport.kcp): case nameof(ETransport.kcp):
tipHeaderType.Text = ResUI.TransportHeaderTypeTip2; gridTransportKcp.Visibility = Visibility.Visible;
tipPath.Text = ResUI.TransportPathTip5;
break; break;
case nameof(ETransport.ws): case nameof(ETransport.ws):
gridTransportWs.Visibility = Visibility.Visible;
break;
case nameof(ETransport.httpupgrade): case nameof(ETransport.httpupgrade):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; gridTransportHttpupgrade.Visibility = Visibility.Visible;
tipPath.Text = ResUI.TransportPathTip1;
break; break;
case nameof(ETransport.xhttp): case nameof(ETransport.xhttp):
tipRequestHost.Text = ResUI.TransportRequestHostTip2; gridTransportXhttp.Visibility = Visibility.Visible;
tipPath.Text = ResUI.TransportPathTip1;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip5;
labHeaderType.Visibility = Visibility.Hidden;
popExtra.Visibility = Visibility.Visible;
break; break;
case nameof(ETransport.h2):
tipRequestHost.Text = ResUI.TransportRequestHostTip3;
tipPath.Text = ResUI.TransportPathTip2;
break;
case nameof(ETransport.quic):
tipRequestHost.Text = ResUI.TransportRequestHostTip4;
tipPath.Text = ResUI.TransportPathTip3;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
break;
case nameof(ETransport.grpc): case nameof(ETransport.grpc):
tipRequestHost.Text = ResUI.TransportRequestHostTip5; gridTransportGrpc.Visibility = Visibility.Visible;
tipPath.Text = ResUI.TransportPathTip4; break;
tipHeaderType.Text = ResUI.TransportHeaderTypeTip4; default:
labHeaderType.Visibility = Visibility.Hidden; gridTransportRaw.Visibility = Visibility.Visible;
break; break;
} }
SetRawHttpFieldsVisibility();
}
private void SetRawHttpFieldsVisibility()
{
var network = cmbNetwork.SelectedItem?.ToString();
if (network.IsNullOrEmpty())
{
network = Global.DefaultNetwork;
}
var rawHeaderType = cmbHeaderTypeRaw.SelectedItem?.ToString();
var showRawHttpFields = network == nameof(ETransport.raw)
&& rawHeaderType == Global.RawHeaderHttp;
gridTransportRawHttp.Visibility = showRawHttpFields
? Visibility.Visible
: Visibility.Collapsed;
} }
} }

View file

@ -391,6 +391,30 @@
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin8}" Margin="{StaticResource Margin8}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock
Grid.Row="21"
Grid.Column="0"
Margin="{StaticResource Margin8}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsSendThrough}" />
<TextBox
x:Name="txtsendThrough"
Grid.Row="21"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin8}"
Style="{StaticResource DefTextBox}"
materialDesign:HintAssist.Hint="0.0.0.0" />
<TextBlock
Grid.Row="21"
Grid.Column="2"
Margin="{StaticResource Margin8}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsSendThroughTip}"
TextWrapping="Wrap" />
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>
</TabItem> </TabItem>

View file

@ -73,6 +73,7 @@ public partial class OptionSettingWindow
this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defAllowInsecure, v => v.togdefAllowInsecure.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.sendThrough, v => v.txtsendThrough.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);

View file

@ -8,6 +8,7 @@
<ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon> <ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>