mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-16 04:25:45 +00:00
Compare commits
18 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bda022574 | ||
|
|
2ea9c5a2ff | ||
|
|
3cb2869920 | ||
|
|
43dcb90632 | ||
|
|
e56fca05fc | ||
|
|
495b5db4f1 | ||
|
|
dea143b20d | ||
|
|
0db611b7a9 | ||
|
|
c3d67d186a | ||
|
|
6b07ca63a0 | ||
|
|
6c8f22ab86 | ||
|
|
49f65579aa | ||
|
|
a69e407bda | ||
|
|
96e5c11fc7 | ||
|
|
53041906b3 | ||
|
|
f2d929f40e | ||
|
|
1160d8c154 | ||
|
|
75f2cbaef9 |
58 changed files with 1849 additions and 398 deletions
16
.github/workflows/build-all.yml
vendored
16
.github/workflows/build-all.yml
vendored
|
|
@ -13,7 +13,7 @@ jobs:
|
|||
steps:
|
||||
|
||||
- name: Trigger build windows
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
|
|
@ -22,12 +22,12 @@ jobs:
|
|||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build linux
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
|
|
@ -36,12 +36,12 @@ jobs:
|
|||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build osx
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
|
|
@ -50,12 +50,12 @@ jobs:
|
|||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
|
||||
- name: Trigger build windows desktop
|
||||
if: github.event.inputs.release_tag != ''
|
||||
if: inputs.release_tag != ''
|
||||
run: |
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
|
|
@ -64,6 +64,6 @@ jobs:
|
|||
-d "{
|
||||
\"ref\": \"master\",
|
||||
\"inputs\": {
|
||||
\"release_tag\": \"${{ github.event.inputs.release_tag }}\"
|
||||
\"release_tag\": \"${{ inputs.release_tag }}\"
|
||||
}
|
||||
}"
|
||||
168
.github/workflows/build-linux.yml
vendored
168
.github/workflows/build-linux.yml
vendored
|
|
@ -13,73 +13,29 @@ on:
|
|||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
OutputArch: "linux-64"
|
||||
OutputArchArm: "linux-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/linux-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/linux-arm64"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
target: linux
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
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
|
||||
target: linux
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
deb:
|
||||
needs: build
|
||||
name: build and release deb x64 & arm64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: debian:13
|
||||
container: debian:13
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
|
||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||
|
||||
steps:
|
||||
- name: Prepare tools (Debian)
|
||||
|
|
@ -115,12 +71,6 @@ jobs:
|
|||
echo "==== Dist tree ===="
|
||||
ls -R "$GITHUB_WORKSPACE/dist/deb" || true
|
||||
|
||||
- name: Upload DEB artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-deb
|
||||
path: dist/deb/**/*.deb
|
||||
|
||||
- name: Upload DEBs to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
|
|
@ -130,15 +80,14 @@ jobs:
|
|||
prerelease: true
|
||||
|
||||
rpm:
|
||||
needs: build
|
||||
name: build and release rpm x64 & arm64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag != '') ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
image: registry.access.redhat.com/ubi10/ubi
|
||||
container: registry.access.redhat.com/ubi10/ubi
|
||||
env:
|
||||
RELEASE_TAG: ${{ github.event.inputs.release_tag != '' && github.event.inputs.release_tag || github.ref_name }}
|
||||
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||
|
||||
steps:
|
||||
- name: Prepare tools (Red Hat)
|
||||
|
|
@ -207,12 +156,6 @@ jobs:
|
|||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: v2rayN-linux
|
||||
path: ${{ github.workspace }}/v2rayN/Release
|
||||
|
||||
- name: Ensure script permissions
|
||||
run: chmod 755 package-rhel.sh
|
||||
|
||||
|
|
@ -228,12 +171,6 @@ jobs:
|
|||
echo "==== Dist tree ===="
|
||||
ls -R "$GITHUB_WORKSPACE/dist/rpm" || true
|
||||
|
||||
- name: Upload RPM artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
with:
|
||||
name: v2rayN-rpm
|
||||
path: dist/rpm/**/*.rpm
|
||||
|
||||
- name: Upload RPMs to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
|
|
@ -241,3 +178,76 @@ jobs:
|
|||
tag: ${{ env.RELEASE_TAG }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
|
||||
rpm-riscv64:
|
||||
name: build and release rpm riscv64
|
||||
if: |
|
||||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
runs-on: ubuntu-24.04-riscv
|
||||
container: 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
|
||||
|
|
|
|||
94
.github/workflows/build-osx.yml
vendored
94
.github/workflows/build-osx.yml
vendored
|
|
@ -10,78 +10,62 @@ on:
|
|||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "macos-64"
|
||||
OutputArchArm: "macos-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/macos-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/macos-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
target: macos
|
||||
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
with:
|
||||
target: macos
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
||||
dmg:
|
||||
name: package and release macOS dmg
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
|
||||
arch: [ x64, arm64 ]
|
||||
runs-on: macos-latest
|
||||
|
||||
env:
|
||||
Arch: |-
|
||||
${{
|
||||
case(
|
||||
matrix.arch == 'x64', '64',
|
||||
matrix.arch
|
||||
)
|
||||
}}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Restore build artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
name: ${{ matrix.arch }}
|
||||
path: v2rayN-macos-${{ env.Arch }}
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
- name: Setup create-dmg
|
||||
run: brew install create-dmg
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd v2rayN
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-x64 -p:SelfContained=true -o $OutputPath64
|
||||
dotnet publish ./v2rayN.Desktop/v2rayN.Desktop.csproj -c Release -r osx-arm64 -p:SelfContained=true -o $OutputPathArm64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-x64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPath64
|
||||
dotnet publish ./AmazTool/AmazTool.csproj -c Release -r osx-arm64 -p:SelfContained=true -p:PublishTrimmed=true -o $OutputPathArm64
|
||||
- name: Ensure script permissions
|
||||
run: chmod 755 package-osx.sh
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7.0.0
|
||||
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: Package dmg
|
||||
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
||||
|
||||
- name: Upload dmg to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: github.event.inputs.release_tag != ''
|
||||
with:
|
||||
file: ${{ github.workspace }}/v2rayN*.dmg
|
||||
tag: ${{ github.event.inputs.release_tag }}
|
||||
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 }}
|
||||
tag: ${{ inputs.release_tag }}
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
63
.github/workflows/build-windows-desktop.yml
vendored
63
.github/workflows/build-windows-desktop.yml
vendored
|
|
@ -10,62 +10,19 @@ on:
|
|||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "windows-64"
|
||||
OutputArchArm: "windows-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: '0'
|
||||
target: windows
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
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
|
||||
target: windows-desktop
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
|
|
|||
59
.github/workflows/build-windows.yml
vendored
59
.github/workflows/build-windows.yml
vendored
|
|
@ -10,57 +10,20 @@ on:
|
|||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
OutputArch: "windows-64"
|
||||
OutputArchArm: "windows-arm64"
|
||||
OutputPath64: "${{ github.workspace }}/v2rayN/Release/windows-64"
|
||||
OutputPathArm64: "${{ github.workspace }}/v2rayN/Release/windows-arm64"
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
configuration: [Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
uses: ./.github/workflows/build.yml
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
target: windows
|
||||
project: ./v2rayN/v2rayN.csproj
|
||||
|
||||
- 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
|
||||
release-zip:
|
||||
if: inputs.release_tag != ''
|
||||
needs: build
|
||||
uses: ./.github/workflows/package-zip.yml
|
||||
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
|
||||
target: windows
|
||||
release_tag: ${{ inputs.release_tag }}
|
||||
|
|
|
|||
71
.github/workflows/build.yml
vendored
Normal file
71
.github/workflows/build.yml
vendored
Normal 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
64
.github/workflows/package-zip.yml
vendored
Normal 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
|
||||
|
|
@ -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
703
package-rhel-riscv.sh
Normal 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 "=============================================="
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.20.2</Version>
|
||||
<Version>7.20.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@
|
|||
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
||||
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
||||
<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="MaterialDesignThemes" Version="5.3.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.Fody" Version="19.5.41" />
|
||||
<PackageVersion Include="ReactiveUI.WPF" Version="23.2.1" />
|
||||
|
|
@ -26,6 +27,8 @@
|
|||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
||||
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||
<PackageVersion Include="xunit" Version="2.9.3" />
|
||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit ffb2850df0991495d0918e13cc5701737f26175a
|
||||
Subproject commit 50f615b671ff8d4a6a850aed19da5f94f58b5d96
|
||||
228
v2rayN/ServiceLib.Tests/CoreConfigV2rayServiceTests.cs
Normal file
228
v2rayN/ServiceLib.Tests/CoreConfigV2rayServiceTests.cs
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
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,
|
||||
tunProtectSsPort: 10811,
|
||||
proxyRelaySsPort: 10812));
|
||||
|
||||
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,
|
||||
int tunProtectSsPort = 0,
|
||||
int proxyRelaySsPort = 0)
|
||||
{
|
||||
return new CoreConfigContext
|
||||
{
|
||||
Node = node,
|
||||
RunCoreType = ECoreType.Xray,
|
||||
AppConfig = config ?? CreateConfig(),
|
||||
AllProxiesMap = allProxiesMap ?? new(),
|
||||
SimpleDnsItem = new SimpleDNSItem(),
|
||||
IsTunEnabled = isTunEnabled,
|
||||
TunProtectSocksPort = tunProtectSsPort,
|
||||
ProxyRelaySocksPort = proxyRelaySsPort,
|
||||
};
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
21
v2rayN/ServiceLib.Tests/ServiceLib.Tests.csproj
Normal file
21
v2rayN/ServiceLib.Tests/ServiceLib.Tests.csproj
Normal 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>
|
||||
|
|
@ -522,6 +522,23 @@ public class Utils
|
|||
return false;
|
||||
}
|
||||
|
||||
public static bool IsIpv4(string? ip)
|
||||
{
|
||||
if (ip.IsNullOrEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ip = ip.Trim();
|
||||
if (!IPAddress.TryParse(ip, out var address))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return address.AddressFamily == AddressFamily.InterNetwork
|
||||
&& ip.Count(c => c == '.') == 3;
|
||||
}
|
||||
|
||||
public static bool IsIpAddress(string? ip)
|
||||
{
|
||||
if (ip.IsNullOrEmpty())
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class Global
|
|||
@"https://cachefly.cachefly.net/50mb.test",
|
||||
@"https://speed.cloudflare.com/__down?bytes=10000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=50000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=100000000",
|
||||
@"https://speed.cloudflare.com/__down?bytes=99999999",
|
||||
];
|
||||
|
||||
public static readonly List<string> SpeedPingTestUrls =
|
||||
|
|
@ -189,7 +189,8 @@ public class Global
|
|||
{"safari","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15" },
|
||||
{"edge","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.70" },
|
||||
{"none",""},
|
||||
{"golang",""}
|
||||
{"golang","Go-http-client/1.1"},
|
||||
{"curl","curl/7.68.0"},
|
||||
};
|
||||
|
||||
public const string Hysteria2ProtocolShare = "hy2://";
|
||||
|
|
@ -393,7 +394,8 @@ public class Global
|
|||
"chrome",
|
||||
"firefox",
|
||||
"edge",
|
||||
"golang"
|
||||
"curl",
|
||||
"golang",
|
||||
];
|
||||
|
||||
public static readonly List<string> XhttpMode =
|
||||
|
|
@ -424,11 +426,12 @@ public class Global
|
|||
|
||||
public static readonly List<string> DomainDirectDNSAddress =
|
||||
[
|
||||
"https://dns.alidns.com/dns-query",
|
||||
"https://doh.pub/dns-query",
|
||||
"https://dns.alidns.com/dns-query,https://doh.pub/dns-query",
|
||||
"223.5.5.5",
|
||||
"119.29.29.29",
|
||||
"223.5.5.5",
|
||||
"119.29.29.29,223.5.5.5,https://doh.pub/dns-query",
|
||||
"https://doh.pub/dns-query",
|
||||
"https://dns.alidns.com/dns-query",
|
||||
"https://doh.pub/dns-query,https://dns.alidns.com/dns-query",
|
||||
"localhost"
|
||||
];
|
||||
|
||||
|
|
@ -440,7 +443,7 @@ public class Global
|
|||
"https://dns.cloudflare.com/dns-query",
|
||||
"https://doh.dns.sb/dns-query",
|
||||
"https://doh.opendns.com/dns-query",
|
||||
"https://common.dot.dns.yandex.net",
|
||||
"https://common.dot.dns.yandex.net/dns-query",
|
||||
"8.8.8.8",
|
||||
"1.1.1.1",
|
||||
"185.222.222.222",
|
||||
|
|
@ -450,8 +453,8 @@ public class Global
|
|||
|
||||
public static readonly List<string> DomainPureIPDNSAddress =
|
||||
[
|
||||
"223.5.5.5",
|
||||
"119.29.29.29",
|
||||
"223.5.5.5",
|
||||
"localhost"
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ServiceLib.Handler.Builder;
|
||||
|
||||
public record CoreConfigContextBuilderResult(CoreConfigContext Context, NodeValidatorResult ValidatorResult)
|
||||
|
|
@ -27,14 +25,14 @@ public record CoreConfigContextBuilderAllResult(
|
|||
[.. MainResult.ValidatorResult.Warnings, .. PreSocksResult?.ValidatorResult.Warnings ?? []]);
|
||||
|
||||
/// <summary>
|
||||
/// The main context with TunProtectSsPort/ProxyRelaySsPort and ProtectDomainList merged in
|
||||
/// The main context with TunProtectSocksPort/ProxyRelaySocksPort 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,
|
||||
TunProtectSocksPort = PreSocksResult.Context.TunProtectSocksPort,
|
||||
ProxyRelaySocksPort = PreSocksResult.Context.ProxyRelaySocksPort,
|
||||
ProtectDomainList = [.. MainResult.Context.ProtectDomainList ?? [], .. PreSocksResult.Context.ProtectDomainList ?? []],
|
||||
}
|
||||
: MainResult.Context;
|
||||
|
|
@ -60,8 +58,8 @@ public class CoreConfigContextBuilder
|
|||
IsTunEnabled = config.TunModeItem.EnableTun,
|
||||
SimpleDnsItem = config.SimpleDNSItem,
|
||||
ProtectDomainList = [],
|
||||
TunProtectSsPort = 0,
|
||||
ProxyRelaySsPort = 0,
|
||||
TunProtectSocksPort = 0,
|
||||
ProxyRelaySocksPort = 0,
|
||||
RawDnsItem = await AppManager.Instance.GetDNSItem(coreType),
|
||||
RoutingItem = await ConfigHandler.GetDefaultRouting(config),
|
||||
};
|
||||
|
|
@ -157,28 +155,23 @@ public class CoreConfigContextBuilder
|
|||
return null;
|
||||
}
|
||||
|
||||
var tunProtectSsPort = Utils.GetFreePort();
|
||||
var proxyRelaySsPort = Utils.GetFreePort();
|
||||
var tunProtectSocksPort = Utils.GetFreePort();
|
||||
var proxyRelaySocksPort = Utils.GetFreePort();
|
||||
var preItem = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.sing_box,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = proxyRelaySsPort,
|
||||
Password = Global.None,
|
||||
Port = proxyRelaySocksPort,
|
||||
};
|
||||
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,
|
||||
TunProtectSocksPort = tunProtectSocksPort,
|
||||
ProxyRelaySocksPort = proxyRelaySocksPort,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public static class ConfigHandler
|
|||
Loglevel = "warning",
|
||||
MuxEnabled = false,
|
||||
};
|
||||
config.CoreBasicItem.SendThrough = config.CoreBasicItem.SendThrough?.TrimEx();
|
||||
|
||||
if (config.Inbound == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ public sealed class AppManager
|
|||
}
|
||||
|
||||
#pragma warning disable CS0618
|
||||
|
||||
public async Task MigrateProfileExtra()
|
||||
{
|
||||
await MigrateProfileExtraGroup();
|
||||
|
|
@ -500,6 +501,7 @@ public sealed class AppManager
|
|||
|
||||
//await ProfileGroupItemManager.Instance.ClearAll();
|
||||
}
|
||||
|
||||
#pragma warning restore CS0618
|
||||
|
||||
#endregion SqliteHelper
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public sealed class CoreInfoManager
|
|||
DownloadUrlWinArm64 = urlN + "/download/{0}/v2rayN-windows-arm64.zip",
|
||||
DownloadUrlLinux64 = urlN + "/download/{0}/v2rayN-linux-64.zip",
|
||||
DownloadUrlLinuxArm64 = urlN + "/download/{0}/v2rayN-linux-arm64.zip",
|
||||
DownloadUrlLinuxRiscV64 = urlN + "/download/{0}/v2rayN-linux-riscv64.zip",
|
||||
DownloadUrlOSX64 = urlN + "/download/{0}/v2rayN-macos-64.zip",
|
||||
DownloadUrlOSXArm64 = urlN + "/download/{0}/v2rayN-macos-arm64.zip",
|
||||
},
|
||||
|
|
@ -111,6 +112,7 @@ public sealed class CoreInfoManager
|
|||
DownloadUrlWinArm64 = urlXray + "/download/{0}/Xray-windows-arm64-v8a.zip",
|
||||
DownloadUrlLinux64 = urlXray + "/download/{0}/Xray-linux-64.zip",
|
||||
DownloadUrlLinuxArm64 = urlXray + "/download/{0}/Xray-linux-arm64-v8a.zip",
|
||||
DownloadUrlLinuxRiscV64 = urlXray + "/download/{0}/Xray-linux-riscv64.zip",
|
||||
DownloadUrlOSX64 = urlXray + "/download/{0}/Xray-macos-64.zip",
|
||||
DownloadUrlOSXArm64 = urlXray + "/download/{0}/Xray-macos-arm64-v8a.zip",
|
||||
Match = "Xray",
|
||||
|
|
@ -133,6 +135,7 @@ public sealed class CoreInfoManager
|
|||
DownloadUrlWinArm64 = urlMihomo + "/download/{0}/mihomo-windows-arm64-{0}.zip",
|
||||
DownloadUrlLinux64 = urlMihomo + "/download/{0}/mihomo-linux-amd64-v1-{0}.gz",
|
||||
DownloadUrlLinuxArm64 = urlMihomo + "/download/{0}/mihomo-linux-arm64-{0}.gz",
|
||||
DownloadUrlLinuxRiscV64 = urlMihomo + "/download/{0}/mihomo-linux-riscv64-{0}.gz",
|
||||
DownloadUrlOSX64 = urlMihomo + "/download/{0}/mihomo-darwin-amd64-v1-{0}.gz",
|
||||
DownloadUrlOSXArm64 = urlMihomo + "/download/{0}/mihomo-darwin-arm64-{0}.gz",
|
||||
Match = "Mihomo",
|
||||
|
|
@ -175,6 +178,7 @@ public sealed class CoreInfoManager
|
|||
DownloadUrlWinArm64 = urlSingbox + "/download/{0}/sing-box-{1}-windows-arm64.zip",
|
||||
DownloadUrlLinux64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-amd64.tar.gz",
|
||||
DownloadUrlLinuxArm64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-arm64.tar.gz",
|
||||
DownloadUrlLinuxRiscV64 = urlSingbox + "/download/{0}/sing-box-{1}-linux-riscv64.tar.gz",
|
||||
DownloadUrlOSX64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-amd64.tar.gz",
|
||||
DownloadUrlOSXArm64 = urlSingbox + "/download/{0}/sing-box-{1}-darwin-arm64.tar.gz",
|
||||
Match = "sing-box",
|
||||
|
|
@ -265,6 +269,7 @@ public sealed class CoreInfoManager
|
|||
names.Add("mihomo-linux-amd64-v1");
|
||||
names.Add("mihomo-linux-amd64");
|
||||
names.Add("mihomo-linux-arm64");
|
||||
names.Add("mihomo-linux-riscv64");
|
||||
}
|
||||
else if (Utils.IsMacOS())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public class CoreBasicItem
|
|||
|
||||
public string DefUserAgent { get; set; }
|
||||
|
||||
public string? SendThrough { get; set; }
|
||||
|
||||
public bool EnableFragment { get; set; }
|
||||
|
||||
public bool EnableCacheFile4Sbox { get; set; } = true;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public record CoreConfigContext
|
|||
// -> tun inbound --(if routing proxy)--> relay outbound
|
||||
// -> proxy core (relay inbound --> proxy outbound --(dialerProxy)--> protect outbound)
|
||||
// -> protect inbound -> direct proxy outbound data -> internet
|
||||
public int TunProtectSsPort { get; init; } = 0;
|
||||
public int ProxyRelaySsPort { get; init; } = 0;
|
||||
public int TunProtectSocksPort { get; init; } = 0;
|
||||
public int ProxyRelaySocksPort { get; init; } = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public class CoreInfo
|
|||
public string? DownloadUrlWinArm64 { get; set; }
|
||||
public string? DownloadUrlLinux64 { get; set; }
|
||||
public string? DownloadUrlLinuxArm64 { get; set; }
|
||||
public string? DownloadUrlLinuxRiscV64 { get; set; }
|
||||
public string? DownloadUrlOSX64 { get; set; }
|
||||
public string? DownloadUrlOSXArm64 { get; set; }
|
||||
public string? Match { get; set; }
|
||||
|
|
|
|||
|
|
@ -237,6 +237,8 @@ public class Transport4Sbox
|
|||
public class Headers4Sbox
|
||||
{
|
||||
public string? Host { get; set; }
|
||||
[JsonPropertyName("User-Agent")]
|
||||
public string UserAgent { get; set; }
|
||||
}
|
||||
|
||||
public class HyObfs4Sbox
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ public class Outbounds4Ray
|
|||
|
||||
public string protocol { get; set; }
|
||||
|
||||
public string? sendThrough { get; set; }
|
||||
|
||||
public string? targetStrategy { get; set; }
|
||||
|
||||
public Outboundsettings4Ray settings { get; set; }
|
||||
|
|
|
|||
29
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
29
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -222,6 +222,15 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please fill in the correct IPv4 address for SendThrough. 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string FillCorrectSendThroughIPv4 {
|
||||
get {
|
||||
return ResourceManager.GetString("FillCorrectSendThroughIPv4", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Please enter the correct port format. 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
@ -3763,7 +3772,7 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 This parameter is valid only for tcp/http and ws 的本地化字符串。
|
||||
/// 查找类似 This parameter is valid only for tcp/http, ws, gRPC and xhttp 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsDefUserAgentTips {
|
||||
get {
|
||||
|
|
@ -4149,6 +4158,24 @@ namespace ServiceLib.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Local outbound address (SendThrough) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsSendThrough {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsSendThrough", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 For multi-interface environments, enter the local machine's IPv4 address 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsSendThroughTip {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsSendThroughTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Set Win10 UWP Loopback 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>این پارامتر فقط برای tcp/http و ws معتبر است</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>FontFamily (نیاز به راه اندازی مجدد)</value>
|
||||
|
|
@ -1698,4 +1698,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -937,7 +937,7 @@
|
|||
<value>Agent utilisateur (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Valable uniquement pour les protocoles tcp/http et ws</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Police actuelle (redémarrage requis)</value>
|
||||
|
|
@ -1317,6 +1317,15 @@
|
|||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>Le mot de passe sera vérifié en ligne de commande. En cas d’échec ou de dysfonctionnement, redémarrez l’application. Il n’est pas stocké et doit être saisi à chaque redémarrage.</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Adresse sortante locale (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>Pour environnement multi-interfaces, veuillez saisir l’adresse IPv4 de la machine locale.</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Veuillez saisir l’adresse IPv4 correcte de SendThrough.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*Mode XHTTP</value>
|
||||
</data>
|
||||
|
|
@ -1621,49 +1630,49 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<value>Finalmask</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeWarning" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} warning: {2}</value>
|
||||
<value>Règle de routage {0} nœud sortant {1} avertissement: {2}</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeError" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} error: {2}. Fallback to proxy node only.</value>
|
||||
<value>Règle {0} nœud VPN sortant {1} erreur : {2}. Repli nœud proxy uniquement.</value>
|
||||
</data>
|
||||
<data name="MsgGroupCycleDependency" xml:space="preserve">
|
||||
<value>Group {0} has a cycle dependency on child node {1}. Skipping this node.</value>
|
||||
<value>Le groupe {0} a une dépendance cyclique avec le nœud enfant {1}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildNodeWarning" xml:space="preserve">
|
||||
<value>Group {0} child node {1} warning: {2}</value>
|
||||
<value>Groupe {0} nœud enfant {1} avertissement : {2}</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildNodeError" xml:space="preserve">
|
||||
<value>Group {0} child node {1} error: {2}. Skipping this node.</value>
|
||||
<value>Groupe {0} nœud enfant {1} erreur : {2}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildGroupNodeWarning" xml:space="preserve">
|
||||
<value>Group {0} child group node {1} warning: {2}</value>
|
||||
<value>Groupe {0} nœud enfant groupe {1} avertissement: {2}</value>
|
||||
</data>
|
||||
<data name="MsgGroupChildGroupNodeError" xml:space="preserve">
|
||||
<value>Group {0} child group node {1} error: {2}. Skipping this node.</value>
|
||||
<value>Groupe {0} nœud groupe enfant {1} erreur: {2}. Nœud ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgGroupNoValidChildNode" xml:space="preserve">
|
||||
<value>Group {0} has no valid child node.</value>
|
||||
<value>Groupe {0} n’a aucun nœud enfant valide.</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleEmptyOutboundTag" xml:space="preserve">
|
||||
<value>Routing rule {0} has an empty outbound tag. Fallback to proxy node only.</value>
|
||||
<value>Règle de routage {0} tag sortant vide. Replié sur le nœud proxy uniquement.</value>
|
||||
</data>
|
||||
<data name="MsgRoutingRuleOutboundNodeNotFound" xml:space="preserve">
|
||||
<value>Routing rule {0} outbound node {1} not found. Fallback to proxy node only.</value>
|
||||
<value>Règle de routage {0} nœud sortant {1} introuvable. Repli sur le seul nœud proxy.</value>
|
||||
</data>
|
||||
<data name="MsgSubscriptionPrevProfileNotFound" xml:space="preserve">
|
||||
<value>Subscription previous proxy {0} not found. Skipping.</value>
|
||||
<value>Nœud proxy précédent de l’abonnement {0} introuvable. Ignoré.</value>
|
||||
</data>
|
||||
<data name="MsgSubscriptionNextProfileNotFound" xml:space="preserve">
|
||||
<value>Subscription next proxy {0} not found. Skipping.</value>
|
||||
<value>Nœud proxy suivant de l’abonnement {0} introuvable. Ignoré.</value>
|
||||
</data>
|
||||
<data name="menuGenGroupServer" xml:space="preserve">
|
||||
<value>Generate Policy Group</value>
|
||||
<value>Générer groupe de stratégie</value>
|
||||
</data>
|
||||
<data name="menuAllServers" xml:space="preserve">
|
||||
<value>All configurations</value>
|
||||
<value>Toutes configurations</value>
|
||||
</data>
|
||||
<data name="menuGenRegionGroup" xml:space="preserve">
|
||||
<value>Group by Region</value>
|
||||
<value>Grouper par région</value>
|
||||
</data>
|
||||
<data name="menuEditCopy" xml:space="preserve">
|
||||
<value>Copier</value>
|
||||
|
|
@ -1672,7 +1681,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<value>Tout sélect</value>
|
||||
</data>
|
||||
<data name="menuEditPaste" xml:space="preserve">
|
||||
<value>Paste</value>
|
||||
<value>Coller</value>
|
||||
</data>
|
||||
<data name="menuEditFormat" xml:space="preserve">
|
||||
<value>Format</value>
|
||||
|
|
@ -1687,12 +1696,15 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<value>Insecure Concurrency</value>
|
||||
</data>
|
||||
<data name="TbUsername" xml:space="preserve">
|
||||
<value>Username</value>
|
||||
<value>Nom d’utilisateur</value>
|
||||
</data>
|
||||
<data name="TbIcmpRoutingPolicy" xml:space="preserve">
|
||||
<value>ICMP routing policy</value>
|
||||
<value>Politique de routage ICMP</value>
|
||||
</data>
|
||||
<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 l’adresse IPv4 de la machine locale.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Ez a paraméter csak tcp/http és ws esetén érvényes</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Betűtípus (újraindítást igényel)</value>
|
||||
|
|
@ -1698,4 +1698,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
|||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>This parameter is valid only for tcp/http and ws</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Font family (requires restart)</value>
|
||||
|
|
@ -1320,6 +1320,15 @@
|
|||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>The password will be validated via the command line. If a validation error causes the application to malfunction, please restart the application. The password will not be stored and must be entered again after each restart.</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>Local outbound address (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>Please fill in the correct IPv4 address for SendThrough.</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*xhttp mode</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>User-Agent</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>Параметр действует только для TCP/HTTP и WebSocket (WS)</value>
|
||||
<value>This parameter is valid only for tcp/http, ws, gRPC and xhttp</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>Шрифт (требуется перезапуск)</value>
|
||||
|
|
@ -1698,4 +1698,7 @@
|
|||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Устаревшая защита TUN (Legacy Protect)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -937,7 +937,7 @@
|
|||
<value>用户代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>仅对 tcp/http、ws 协议生效</value>
|
||||
<value>仅对 tcp/http、ws、gRPC、xhttp 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>当前字体 (需重启)</value>
|
||||
|
|
@ -1317,6 +1317,15 @@
|
|||
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
|
||||
<value>密码将调用命令行校验,如果因为校验错误导致无法正常运行时,请重启本应用。 密码不会存储,每次重启后都需要再次输入。</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThrough" xml:space="preserve">
|
||||
<value>本地出站地址 (SendThrough)</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>用于多网口环境,请填写本机 IPv4 地址</value>
|
||||
</data>
|
||||
<data name="FillCorrectSendThroughIPv4" xml:space="preserve">
|
||||
<value>请填写正确的 SendThrough IPv4 地址。</value>
|
||||
</data>
|
||||
<data name="TransportHeaderTypeTip5" xml:space="preserve">
|
||||
<value>*XHTTP 模式</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@
|
|||
<value>使用者代理 (User-Agent)</value>
|
||||
</data>
|
||||
<data name="TbSettingsDefUserAgentTips" xml:space="preserve">
|
||||
<value>僅對 TCP/HTTP、WS 協定生效</value>
|
||||
<value>僅對 TCP/HTTP、WS、gRPC、XHTTP 生效</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamily" xml:space="preserve">
|
||||
<value>目前字型 (需重啟)</value>
|
||||
|
|
@ -1695,4 +1695,7 @@
|
|||
<data name="TbLegacyProtect" xml:space="preserve">
|
||||
<value>Legacy TUN Protect</value>
|
||||
</data>
|
||||
<data name="TbSettingsSendThroughTip" xml:space="preserve">
|
||||
<value>For multi-interface environments, enter the local machine's IPv4 address</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -1,5 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
trim() {
|
||||
local -n ref=$1
|
||||
ref="${ref#"${ref%%[![:space:]]*}"}"
|
||||
ref="${ref%"${ref##*[![:space:]]}"}"
|
||||
}
|
||||
|
||||
build_gsettings_array() {
|
||||
[[ -z "$1" ]] && echo "[]" && return
|
||||
local host joined hosts=()
|
||||
IFS=',' read -ra parts <<< "$1"
|
||||
for host in "${parts[@]}"; do
|
||||
trim host
|
||||
[[ -n "$host" ]] && hosts+=("$host")
|
||||
done
|
||||
[[ ${#hosts[@]} -eq 0 ]] && echo "[]" && return
|
||||
printf -v joined "'%s'," "${hosts[@]}"
|
||||
echo "[${joined%,}]"
|
||||
}
|
||||
|
||||
# Function to set proxy for GNOME
|
||||
set_gnome_proxy() {
|
||||
local MODE=$1
|
||||
|
|
@ -21,7 +40,7 @@ set_gnome_proxy() {
|
|||
done
|
||||
|
||||
# Set ignored hosts
|
||||
gsettings set org.gnome.system.proxy ignore-hosts "['$IGNORE_HOSTS']"
|
||||
gsettings set org.gnome.system.proxy ignore-hosts "$(build_gsettings_array "$IGNORE_HOSTS")"
|
||||
|
||||
echo "GNOME: Manual proxy settings applied."
|
||||
echo "Proxy IP: $PROXY_IP"
|
||||
|
|
|
|||
|
|
@ -57,21 +57,30 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
|||
|
||||
ConvertGeo2Ruleset();
|
||||
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
|
||||
ret.Data = ApplyFullConfigTemplate();
|
||||
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
|
||||
&& context.TunProtectSsPort is > 0 and <= 65535)
|
||||
&& context.TunProtectSocksPort is > 0 and <= 65535)
|
||||
{
|
||||
// Replace relay proxy outbound, avoid mux or other feature cause issue, and add a socks inbound for tun protect
|
||||
var relayProxyIndex = _coreConfig.outbounds.FindIndex(o => o.tag == Global.ProxyTag);
|
||||
_coreConfig.outbounds[relayProxyIndex] = new Outbound4Sbox()
|
||||
{
|
||||
type = Global.ProtocolTypes[EConfigType.SOCKS],
|
||||
tag = Global.ProxyTag,
|
||||
server = Global.Loopback,
|
||||
server_port = context.ProxyRelaySocksPort,
|
||||
};
|
||||
var ssInbound = new
|
||||
{
|
||||
type = "shadowsocks",
|
||||
tag = "tun-protect-ss",
|
||||
type = "socks",
|
||||
tag = "tun-protect-socks",
|
||||
listen = Global.Loopback,
|
||||
listen_port = context.TunProtectSsPort,
|
||||
method = "none",
|
||||
password = "none",
|
||||
listen_port = context.TunProtectSocksPort,
|
||||
};
|
||||
var directRule = new Rule4Sbox()
|
||||
{
|
||||
|
|
@ -214,6 +223,7 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
|||
_coreConfig.route.rules.Add(rule);
|
||||
}
|
||||
|
||||
ApplyOutboundSendThrough();
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
return ret;
|
||||
|
|
@ -272,6 +282,7 @@ public partial class CoreConfigSingboxService(CoreConfigContext context)
|
|||
listen_port = port,
|
||||
type = EInboundProtocol.mixed.ToString(),
|
||||
});
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
|
|
|
|||
|
|
@ -58,4 +58,40 @@ public partial class CoreConfigSingboxService
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public partial class CoreConfigSingboxService
|
|||
_coreConfig.inbounds = [];
|
||||
|
||||
if (!context.IsTunEnabled
|
||||
|| (context.IsTunEnabled && _node.Port != listenPort))
|
||||
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
|
||||
{
|
||||
var inbound = new Inbound4Sbox()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -345,14 +345,6 @@ public partial class CoreConfigSingboxService
|
|||
{
|
||||
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;
|
||||
if (muxEnabled && _config.Mux4SboxItem.Protocol.IsNotEmpty())
|
||||
{
|
||||
|
|
@ -372,21 +364,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)
|
||||
{
|
||||
try
|
||||
|
|
@ -461,6 +438,8 @@ public partial class CoreConfigSingboxService
|
|||
try
|
||||
{
|
||||
var transport = new Transport4Sbox();
|
||||
var useragent = _config.CoreBasicItem.DefUserAgent ?? string.Empty;
|
||||
var useragentValue = Global.TcpHttpUserAgentTexts.GetValueOrDefault(useragent, useragent);
|
||||
|
||||
switch (_node.GetNetwork())
|
||||
{
|
||||
|
|
@ -476,6 +455,11 @@ public partial class CoreConfigSingboxService
|
|||
transport.type = nameof(ETransport.http);
|
||||
transport.host = _node.RequestHost.IsNullOrEmpty() ? null : Utils.String2List(_node.RequestHost);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -517,12 +501,22 @@ public partial class CoreConfigSingboxService
|
|||
Host = _node.RequestHost
|
||||
};
|
||||
}
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(ETransport.httpupgrade):
|
||||
transport.type = nameof(ETransport.httpupgrade);
|
||||
transport.path = _node.Path.NullIfEmpty();
|
||||
transport.host = _node.RequestHost.NullIfEmpty();
|
||||
if (!useragentValue.IsNullOrEmpty())
|
||||
{
|
||||
transport.headers ??= new();
|
||||
transport.headers.UserAgent = useragentValue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ public partial class CoreConfigSingboxService
|
|||
_coreConfig.route.rules.Add(new()
|
||||
{
|
||||
port = [53],
|
||||
network = ["udp"],
|
||||
action = "hijack-dns"
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
{
|
||||
if (!context.AppConfig.TunModeItem.EnableLegacyProtect
|
||||
&& context.IsTunEnabled
|
||||
&& context.TunProtectSsPort is > 0 and <= 65535
|
||||
&& context.ProxyRelaySsPort is > 0 and <= 65535)
|
||||
&& context.TunProtectSocksPort is > 0 and <= 65535
|
||||
&& context.ProxyRelaySocksPort is > 0 and <= 65535)
|
||||
{
|
||||
return GenerateClientProxyRelayConfig();
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
GenDns();
|
||||
|
||||
GenStatistic();
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
var finalRule = BuildFinalRule();
|
||||
if (!string.IsNullOrEmpty(finalRule?.balancerTag))
|
||||
|
|
@ -195,6 +196,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
_coreConfig.routing.rules.Add(rule);
|
||||
}
|
||||
|
||||
ApplyOutboundSendThrough();
|
||||
//ret.Msg =string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
|
||||
ret.Success = true;
|
||||
ret.Data = JsonUtils.Serialize(_coreConfig);
|
||||
|
|
@ -255,6 +257,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
});
|
||||
|
||||
_coreConfig.routing.rules.Add(BuildFinalRule());
|
||||
ApplyOutboundSendThrough();
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
ret.Success = true;
|
||||
|
|
@ -309,17 +312,16 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
var protectNode = new ProfileItem()
|
||||
{
|
||||
CoreType = ECoreType.Xray,
|
||||
ConfigType = EConfigType.Shadowsocks,
|
||||
ConfigType = EConfigType.SOCKS,
|
||||
Address = Global.Loopback,
|
||||
Port = context.TunProtectSsPort,
|
||||
Password = Global.None,
|
||||
Port = context.TunProtectSocksPort,
|
||||
};
|
||||
protectNode.SetProtocolExtra(protectNode.GetProtocolExtra() with
|
||||
{
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
|
||||
const string protectTag = "tun-protect-ss";
|
||||
const string protectTag = "tun-protect-socks";
|
||||
foreach (var outbound in _coreConfig.outbounds
|
||||
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||
{
|
||||
|
|
@ -368,7 +370,7 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
||||
_coreConfig.routing.rules.Add(new()
|
||||
{
|
||||
inboundTag = ["proxy-relay-ss"],
|
||||
inboundTag = ["proxy-relay-socks"],
|
||||
outboundTag = hasBalancer ? null : Global.ProxyTag,
|
||||
balancerTag = hasBalancer ? Global.ProxyTag + Global.BalancerTagSuffix : null,
|
||||
type = "field"
|
||||
|
|
@ -376,19 +378,19 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
|||
|
||||
//_coreConfig.inbounds.Clear();
|
||||
|
||||
ApplyOutboundSendThrough();
|
||||
var configNode = JsonUtils.ParseJson(JsonUtils.Serialize(_coreConfig))!;
|
||||
configNode["inbounds"]!.AsArray().Add(new
|
||||
{
|
||||
listen = Global.Loopback,
|
||||
port = context.ProxyRelaySsPort,
|
||||
protocol = "shadowsocks",
|
||||
port = context.ProxyRelaySocksPort,
|
||||
protocol = "socks",
|
||||
settings = new
|
||||
{
|
||||
network = "tcp,udp",
|
||||
method = Global.None,
|
||||
password = Global.None,
|
||||
auth = "noauth",
|
||||
udp = true,
|
||||
},
|
||||
tag = "proxy-relay-ss",
|
||||
tag = "proxy-relay-socks",
|
||||
});
|
||||
|
||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, "");
|
||||
|
|
|
|||
|
|
@ -127,4 +127,43 @@ public partial class CoreConfigV2rayService
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,12 +225,13 @@ public partial class CoreConfigV2rayService
|
|||
usersItem.email = Global.UserEMail;
|
||||
usersItem.encryption = protocolExtra.VlessEncryption;
|
||||
|
||||
if (!protocolExtra.Flow.IsNullOrEmpty())
|
||||
if (protocolExtra.Flow.IsNullOrEmpty())
|
||||
{
|
||||
usersItem.flow = protocolExtra.Flow;
|
||||
FillOutboundMux(outbound, muxEnabled, muxEnabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
usersItem.flow = protocolExtra.Flow;
|
||||
FillOutboundMux(outbound, false, muxEnabled);
|
||||
}
|
||||
outbound.settings.servers = null;
|
||||
|
|
|
|||
|
|
@ -299,15 +299,22 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
|||
|
||||
return url;
|
||||
}
|
||||
|
||||
else if (Utils.IsLinux())
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
var arch = RuntimeInformation.ProcessArchitecture;
|
||||
if (arch.ToString().Equals("RiscV64", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return coreInfo?.DownloadUrlLinuxRiscV64;
|
||||
}
|
||||
return arch switch
|
||||
{
|
||||
Architecture.Arm64 => coreInfo?.DownloadUrlLinuxArm64,
|
||||
Architecture.X64 => coreInfo?.DownloadUrlLinux64,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
else if (Utils.IsMacOS())
|
||||
{
|
||||
return RuntimeInformation.ProcessArchitecture switch
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
[Reactive] public bool defAllowInsecure { get; set; }
|
||||
[Reactive] public string defFingerprint { get; set; }
|
||||
[Reactive] public string defUserAgent { get; set; }
|
||||
[Reactive] public string sendThrough { get; set; }
|
||||
[Reactive] public string mux4SboxProtocol { get; set; }
|
||||
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
||||
[Reactive] public int? hyUpMbps { get; set; }
|
||||
|
|
@ -154,6 +155,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure;
|
||||
defFingerprint = _config.CoreBasicItem.DefFingerprint;
|
||||
defUserAgent = _config.CoreBasicItem.DefUserAgent;
|
||||
sendThrough = _config.CoreBasicItem.SendThrough;
|
||||
mux4SboxProtocol = _config.Mux4SboxItem.Protocol;
|
||||
enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox;
|
||||
hyUpMbps = _config.HysteriaItem.UpMbps;
|
||||
|
|
@ -297,6 +299,12 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
||||
return;
|
||||
}
|
||||
var sendThroughValue = sendThrough?.TrimEx();
|
||||
if (sendThroughValue.IsNotEmpty() && !Utils.IsIpv4(sendThroughValue))
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.FillCorrectSendThroughIPv4);
|
||||
return;
|
||||
}
|
||||
var needReboot = EnableStatistics != _config.GuiItem.EnableStatistics
|
||||
|| DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed
|
||||
|| EnableDragDropSort != _config.UiItem.EnableDragDropSort
|
||||
|
|
@ -336,6 +344,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
|||
_config.CoreBasicItem.DefAllowInsecure = defAllowInsecure;
|
||||
_config.CoreBasicItem.DefFingerprint = defFingerprint;
|
||||
_config.CoreBasicItem.DefUserAgent = defUserAgent;
|
||||
_config.CoreBasicItem.SendThrough = sendThrough?.TrimEx();
|
||||
_config.Mux4SboxItem.Protocol = mux4SboxProtocol;
|
||||
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
|
||||
_config.HysteriaItem.UpMbps = hyUpMbps ?? 0;
|
||||
|
|
|
|||
189
v2rayN/v2rayN.Desktop/Common/QRCodeAvaloniaUtils.cs
Normal file
189
v2rayN/v2rayN.Desktop/Common/QRCodeAvaloniaUtils.cs
Normal 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
|
||||
}
|
||||
|
|
@ -91,6 +91,8 @@ public partial class JsonEditor : UserControl
|
|||
}
|
||||
|
||||
private void Copy_Click(object? sender, RoutedEventArgs e) => Editor.Copy();
|
||||
|
||||
private void Paste_Click(object? sender, RoutedEventArgs e) => Editor.Paste();
|
||||
|
||||
private void SelectAll_Click(object? sender, RoutedEventArgs e) => Editor.SelectAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
else
|
||||
{
|
||||
Title = $"{Utils.GetVersion()}";
|
||||
}
|
||||
menuAddServerViaScan.IsVisible = false;
|
||||
}
|
||||
|
||||
if (_config.UiItem.AutoHideStartup && Utils.IsWindows())
|
||||
{
|
||||
|
|
@ -336,17 +336,17 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
|
||||
public async Task ScanScreenTaskAsync()
|
||||
{
|
||||
//ShowHideWindow(false);
|
||||
ShowHideWindow(false);
|
||||
|
||||
NoticeManager.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)");
|
||||
await Task.CompletedTask;
|
||||
//if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
//{
|
||||
// //var bytes = QRCodeHelper.CaptureScreen(desktop);
|
||||
// //await ViewModel?.ScanScreenResult(bytes);
|
||||
//}
|
||||
await Task.Delay(200);
|
||||
|
||||
//ShowHideWindow(true);
|
||||
var bytes = QRCodeAvaloniaUtils.CaptureScreen();
|
||||
if (bytes != null && ViewModel != null)
|
||||
{
|
||||
await ViewModel.ScanScreenResult(bytes);
|
||||
}
|
||||
|
||||
ShowHideWindow(true);
|
||||
}
|
||||
|
||||
private async Task ScanImageTaskAsync()
|
||||
|
|
|
|||
|
|
@ -325,6 +325,27 @@
|
|||
Grid.Column="1"
|
||||
Margin="{StaticResource Margin4}"
|
||||
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>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
|
|
|||
|
|
@ -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.defFingerprint, v => v.cmbdefFingerprint.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.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||
<AssemblyName>v2rayN</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Action", "GitHub Act
|
|||
..\.github\workflows\winget-publish.yml = ..\.github\workflows\winget-publish.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceLib.Tests", "ServiceLib.Tests\ServiceLib.Tests.csproj", "{E0B6C5C7-ED48-42EB-947A-877779E9F555}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
</Folder>
|
||||
<Project Path="AmazTool/AmazTool.csproj" />
|
||||
<Project Path="GlobalHotKeys/src/GlobalHotKeys/GlobalHotKeys.csproj" />
|
||||
<Project Path="ServiceLib.Tests/ServiceLib.Tests.csproj" />
|
||||
<Project Path="ServiceLib/ServiceLib.csproj" />
|
||||
<Project Path="v2rayN.Desktop/v2rayN.Desktop.csproj" />
|
||||
<Project Path="v2rayN/v2rayN.csproj" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Microsoft.Win32;
|
|||
|
||||
namespace v2rayN.Common;
|
||||
|
||||
internal static class WindowsUtils
|
||||
internal static partial class WindowsUtils
|
||||
{
|
||||
private static readonly string _tag = "WindowsUtils";
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ internal static class WindowsUtils
|
|||
}
|
||||
}
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
public static extern int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize);
|
||||
[LibraryImport("dwmapi.dll")]
|
||||
public static partial int DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE attribute, ref int attributeValue, uint attributeSize);
|
||||
|
||||
public static ImageSource IconToImageSource(Icon icon)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace v2rayN.Manager;
|
||||
|
||||
public sealed class HotkeyManager
|
||||
public sealed partial class HotkeyManager
|
||||
{
|
||||
private static readonly Lazy<HotkeyManager> _instance = new(() => new());
|
||||
public static HotkeyManager Instance = _instance.Value;
|
||||
|
|
@ -165,11 +165,13 @@ public sealed class HotkeyManager
|
|||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc);
|
||||
[LibraryImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool RegisterHotKey(nint hWnd, int id, int fsModifiers, int vlc);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
private static extern bool UnregisterHotKey(nint hWnd, int id);
|
||||
[LibraryImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool UnregisterHotKey(nint hWnd, int id);
|
||||
|
||||
[Flags]
|
||||
private enum KeyModifiers
|
||||
|
|
|
|||
|
|
@ -894,7 +894,6 @@
|
|||
Grid.Column="1"
|
||||
Margin="{StaticResource Margin4}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<Separator
|
||||
|
|
|
|||
|
|
@ -391,6 +391,30 @@
|
|||
Grid.Column="1"
|
||||
Margin="{StaticResource Margin8}"
|
||||
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>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
|
|
|||
|
|
@ -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.defFingerprint, v => v.cmbdefFingerprint.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.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
<ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue