mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 09:44:09 +00:00
Compare commits
45 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a74ca3f9d0 | ||
|
|
ed61f5c420 | ||
|
|
bf98c4007f | ||
|
|
78dcf51c3c | ||
|
|
1e59344074 | ||
|
|
1d2442d58a | ||
|
|
3448782925 | ||
|
|
e6f4a57913 | ||
|
|
4ae5c021fd | ||
|
|
0a357fd1a7 | ||
|
|
5ba5a805ce | ||
|
|
807f0aba06 | ||
|
|
f4a2086dfb | ||
|
|
ccb0ffb3b6 | ||
|
|
1fa1246c0b | ||
|
|
14cc37d07a | ||
|
|
c7519f8ea7 | ||
|
|
0c796a157b | ||
|
|
a9824fe6ec | ||
|
|
f18758d4bf | ||
|
|
c1a009a409 | ||
|
|
0f3fc8e053 | ||
|
|
f7206f3405 | ||
|
|
460a674ebc | ||
|
|
e2428f2500 | ||
|
|
bc3cbb4277 | ||
|
|
ac9d0a0193 | ||
|
|
2291214b6f | ||
|
|
5b47d8ba05 | ||
|
|
b193c39ad7 | ||
|
|
e68842bb78 | ||
|
|
6c06c8a00a | ||
|
|
58d2641559 | ||
|
|
780777068d | ||
|
|
8446b4df8b | ||
|
|
3778d2058e | ||
|
|
5c85598cfa | ||
|
|
51b384e119 | ||
|
|
d1c9c0b536 | ||
|
|
cc57f952db | ||
|
|
8090799ccc | ||
|
|
700f98193a | ||
|
|
eee43288a4 | ||
|
|
61ff871dd2 | ||
|
|
f8bc706cda |
129 changed files with 4262 additions and 1505 deletions
|
|
@ -100,7 +100,6 @@ csharp_style_prefer_tuple_swap = true:warning
|
||||||
csharp_style_prefer_utf8_string_literals = true:warning
|
csharp_style_prefer_utf8_string_literals = true:warning
|
||||||
csharp_style_throw_expression = true:warning
|
csharp_style_throw_expression = true:warning
|
||||||
csharp_style_unused_value_assignment_preference = discard_variable:warning
|
csharp_style_unused_value_assignment_preference = discard_variable:warning
|
||||||
csharp_style_unused_value_expression_statement_preference = discard_variable:warning
|
|
||||||
csharp_using_directive_placement = outside_namespace:warning
|
csharp_using_directive_placement = outside_namespace:warning
|
||||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:warning
|
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:warning
|
||||||
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:warning
|
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:warning
|
||||||
|
|
|
||||||
253
.github/workflows/build-linux.yml
vendored
253
.github/workflows/build-linux.yml
vendored
|
|
@ -49,7 +49,7 @@ jobs:
|
||||||
libc6 libgcc-s1 libstdc++6 zlib1g libicu-dev libssl-dev
|
libc6 libgcc-s1 libstdc++6 zlib1g libicu-dev libssl-dev
|
||||||
|
|
||||||
- name: Checkout repo (for scripts)
|
- name: Checkout repo (for scripts)
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
@ -151,7 +151,7 @@ jobs:
|
||||||
dnf repolist | grep -i epel || true
|
dnf repolist | grep -i epel || true
|
||||||
|
|
||||||
- name: Checkout repo (for scripts)
|
- name: Checkout repo (for scripts)
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
@ -251,3 +251,252 @@ jobs:
|
||||||
--data-binary @"$f" \
|
--data-binary @"$f" \
|
||||||
"${upload_url}?name=${f##*/}"
|
"${upload_url}?name=${f##*/}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
deb-riscv64:
|
||||||
|
name: build and release deb 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: debian:13
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Prepare tools (Debian)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y sudo git rsync findutils tar gzip unzip which curl jq wget file \
|
||||||
|
ca-certificates desktop-file-utils xdg-utils fakeroot dpkg-dev \
|
||||||
|
gcc make libc6-dev libgcc-s1 libstdc++6 zlib1g libatomic1
|
||||||
|
|
||||||
|
- 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-debian-riscv.sh
|
||||||
|
|
||||||
|
- name: Package DEB (Debian-family)
|
||||||
|
run: ./package-debian-riscv.sh "${RELEASE_TAG}"
|
||||||
|
|
||||||
|
- name: Collect DEBs into workspace
|
||||||
|
run: |
|
||||||
|
mkdir -p "$GITHUB_WORKSPACE/dist/deb-riscv64"
|
||||||
|
rsync -av "$HOME/debbuild/" "$GITHUB_WORKSPACE/dist/deb-riscv64/" || true
|
||||||
|
find "$GITHUB_WORKSPACE/dist/deb-riscv64" -name "*.deb" \
|
||||||
|
-exec mv {} "$GITHUB_WORKSPACE/dist/deb-riscv64/v2rayN-linux-riscv64.deb" \; || true
|
||||||
|
echo "==== Dist tree ===="
|
||||||
|
ls -R "$GITHUB_WORKSPACE/dist/deb-riscv64" || true
|
||||||
|
|
||||||
|
- name: Upload DEBs to release
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
shopt -s globstar nullglob
|
||||||
|
|
||||||
|
files=(dist/deb-riscv64/**/*.deb)
|
||||||
|
(( ${#files[@]} )) || { echo "No DEBs 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/vnd.debian.binary-package" \
|
||||||
|
--data-binary @"$f" \
|
||||||
|
"${upload_url}?name=${f##*/}"
|
||||||
|
done
|
||||||
|
|
||||||
|
deb-loong64:
|
||||||
|
name: build and release deb loong64
|
||||||
|
if: |
|
||||||
|
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '') ||
|
||||||
|
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ case(inputs.release_tag != '', inputs.release_tag, github.ref_name) }}
|
||||||
|
QCOW2_URL: https://github.com/xujiegb/debian-loong64-qcow2/releases/download/13.5/debian13-loong64.qcow2
|
||||||
|
EFI_CODE_URL: https://github.com/xujiegb/debian-loong64-qcow2/releases/download/13.5/edk2-loongarch64-code.fd
|
||||||
|
EFI_VARS_URL: https://github.com/xujiegb/debian-loong64-qcow2/releases/download/13.5/edk2-loongarch64-vars.fd
|
||||||
|
QCOW2_IMAGE: debian13-loong64.qcow2
|
||||||
|
EFI_CODE: edk2-loongarch64-code.fd
|
||||||
|
EFI_VARS: edk2-loongarch64-vars.fd
|
||||||
|
QEMU_VERSION: 10.2.2
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Prepare host tools
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y rsync qemu-utils expect wget curl ca-certificates libfdt1 libglib2.0-0 libpixman-1-0 libslirp0
|
||||||
|
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Download QEMU prebuild
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
wget -O qemu-linux-x64.tar.gz \
|
||||||
|
"https://github.com/xujiegb/qemu-linux-prebuild/releases/download/${QEMU_VERSION}/qemu-linux-x64.tar.gz"
|
||||||
|
|
||||||
|
tar -xzf qemu-linux-x64.tar.gz
|
||||||
|
|
||||||
|
mkdir -p "$HOME/qemu-install"
|
||||||
|
|
||||||
|
rsync -a qemu-linux-x64/ "$HOME/qemu-install/"
|
||||||
|
|
||||||
|
"$HOME/qemu-install/bin/qemu-system-loongarch64" --version
|
||||||
|
|
||||||
|
- name: Download loong64 qcow2 and EFI firmware
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
wget -O "$QCOW2_IMAGE" "$QCOW2_URL"
|
||||||
|
wget -O "$EFI_CODE" "$EFI_CODE_URL"
|
||||||
|
wget -O "$EFI_VARS" "$EFI_VARS_URL"
|
||||||
|
|
||||||
|
qemu-img info "$QCOW2_IMAGE"
|
||||||
|
|
||||||
|
- name: Build loong64 DEB in VM through serial console
|
||||||
|
shell: bash
|
||||||
|
timeout-minutes: 180
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ env.RELEASE_TAG }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
mkdir -p "$GITHUB_WORKSPACE/dist/deb-loong64"
|
||||||
|
|
||||||
|
expect <<'EOF'
|
||||||
|
log_user 1
|
||||||
|
set timeout -1
|
||||||
|
|
||||||
|
set release_tag $env(RELEASE_TAG)
|
||||||
|
set qemu_bin "$env(HOME)/qemu-install/bin/qemu-system-loongarch64"
|
||||||
|
set qemu_rom_dir "$env(HOME)/qemu-install/share/qemu"
|
||||||
|
|
||||||
|
set workspace $env(GITHUB_WORKSPACE)
|
||||||
|
set repo $env(GITHUB_REPOSITORY)
|
||||||
|
set sha $env(GITHUB_SHA)
|
||||||
|
|
||||||
|
set qcow2 $env(QCOW2_IMAGE)
|
||||||
|
set efi_code $env(EFI_CODE)
|
||||||
|
set efi_vars $env(EFI_VARS)
|
||||||
|
|
||||||
|
proc wait_prompt {} {
|
||||||
|
expect {
|
||||||
|
-re "__CI_PROMPT__# " {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
eof { exit 1 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc run_cmd {cmd} {
|
||||||
|
send -- "$cmd\r"
|
||||||
|
wait_prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
spawn $qemu_bin \
|
||||||
|
-L $qemu_rom_dir \
|
||||||
|
-machine virt \
|
||||||
|
-accel tcg,thread=multi,tb-size=2048 \
|
||||||
|
-cpu la464 \
|
||||||
|
-m 9216 \
|
||||||
|
-smp 4 \
|
||||||
|
-drive if=pflash,format=raw,unit=0,file=$efi_code,readonly=on \
|
||||||
|
-drive if=pflash,format=raw,unit=1,file=$efi_vars \
|
||||||
|
-device virtio-blk-pci,drive=hd0,bootindex=1 \
|
||||||
|
-drive if=none,media=disk,id=hd0,file=$qcow2,format=qcow2 \
|
||||||
|
-netdev user,id=net0 \
|
||||||
|
-device virtio-net-pci,netdev=net0 \
|
||||||
|
-virtfs local,path=$workspace,mount_tag=workspace,security_model=none,id=workspace \
|
||||||
|
-display none \
|
||||||
|
-serial stdio \
|
||||||
|
-monitor none
|
||||||
|
|
||||||
|
expect -re "login:|debian login:"
|
||||||
|
send -- "root\r"
|
||||||
|
|
||||||
|
expect -re "Password:|密码:|密码:"
|
||||||
|
send -- "password\r"
|
||||||
|
|
||||||
|
expect {
|
||||||
|
-re "# " {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
eof { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
send -- "export TERM=dumb; export PS1='__CI_PROMPT__# '\r"
|
||||||
|
wait_prompt
|
||||||
|
|
||||||
|
run_cmd "mkdir -p /workspace"
|
||||||
|
run_cmd "mount -t 9p -o trans=virtio,version=9p2000.L workspace /workspace || mount -t 9p -o trans=virtio workspace /workspace"
|
||||||
|
run_cmd "IFACE=\$(ip -o link show | awk -F': ' '\$2 != \"lo\" {print \$2; exit}') ; ip link set \$IFACE up || true"
|
||||||
|
run_cmd "dhclient \$IFACE || true"
|
||||||
|
run_cmd "printf 'nameserver 10.0.2.3\nnameserver 1.1.1.1\n' >/etc/resolv.conf"
|
||||||
|
run_cmd "apt-get update || apt-get update || apt-get update"
|
||||||
|
run_cmd "DEBIAN_FRONTEND=noninteractive apt-get install -y sudo git rsync findutils tar gzip unzip which curl jq wget file ca-certificates desktop-file-utils xdg-utils fakeroot dpkg-dev gcc make libc6-dev libgcc-s1 libstdc++6 zlib1g libatomic1"
|
||||||
|
run_cmd "rm -rf /root/v2rayN-src"
|
||||||
|
run_cmd "git clone --recursive https://github.com/$repo.git /root/v2rayN-src"
|
||||||
|
run_cmd "cd /root/v2rayN-src && git fetch --depth=1 origin $sha && git checkout FETCH_HEAD && git submodule update --init --recursive"
|
||||||
|
run_cmd "cd /root/v2rayN-src && chmod 755 package-debian-loong.sh"
|
||||||
|
|
||||||
|
send -- "cd /root/v2rayN-src; cat >/tmp/run-loong-build.sh <<'SCRIPT'\nset +e\nset -o pipefail\nbash -x ./package-debian-loong.sh \"\$RELEASE_TAG\" 2>&1 | tee /tmp/build.log\nrc=\$?\nmkdir -p /workspace/dist/deb-loong64\ncp -av /root/debbuild/*.deb /workspace/dist/deb-loong64/ 2>/dev/null || true\necho __BUILD_DONE__\$rc\nSCRIPT\nRELEASE_TAG=\"$release_tag\" bash /tmp/run-loong-build.sh\r"
|
||||||
|
|
||||||
|
expect {
|
||||||
|
-re "__BUILD_DONE__0" {
|
||||||
|
send -- "poweroff\r"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Collect DEBs
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
mkdir -p "$GITHUB_WORKSPACE/dist/deb-loong64"
|
||||||
|
|
||||||
|
find "$GITHUB_WORKSPACE/dist/deb-loong64" -name "*.deb" \
|
||||||
|
-exec mv {} "$GITHUB_WORKSPACE/dist/deb-loong64/v2rayN-linux-loong64.deb" \; || true
|
||||||
|
|
||||||
|
echo "==== Dist tree ===="
|
||||||
|
ls -R "$GITHUB_WORKSPACE/dist/deb-loong64"
|
||||||
|
|
||||||
|
- name: Upload DEBs to release
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
with:
|
||||||
|
file: dist/deb-loong64/**/*.deb
|
||||||
|
tag: ${{ env.RELEASE_TAG }}
|
||||||
|
file_glob: true
|
||||||
|
prerelease: true
|
||||||
|
|
|
||||||
4
.github/workflows/build-osx.yml
vendored
4
.github/workflows/build-osx.yml
vendored
|
|
@ -45,7 +45,7 @@ jobs:
|
||||||
}}
|
}}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Restore build artifacts
|
- name: Restore build artifacts
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v8
|
||||||
|
|
@ -63,7 +63,7 @@ jobs:
|
||||||
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
run: ./package-osx.sh macos-$Arch v2rayN-macos-$Arch ${{ inputs.release_tag }}
|
||||||
|
|
||||||
- name: Sleep for race condition between matrix jobs
|
- name: Sleep for race condition between matrix jobs
|
||||||
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
run: sleep "$(od -An -N2 -tu2 /dev/urandom | awk 'NR==1{printf "%.2f", $1/5461}')"
|
||||||
|
|
||||||
- name: Upload dmg to release
|
- name: Upload dmg to release
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
|
|
||||||
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
|
@ -46,15 +46,15 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v5.2.0
|
uses: actions/setup-dotnet@v5.3.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '10.0.1xx'
|
||||||
|
|
||||||
- name: Build v2rayN
|
- name: Build v2rayN
|
||||||
working-directory: ./v2rayN
|
working-directory: ./v2rayN
|
||||||
|
|
|
||||||
4
.github/workflows/package-zip.yml
vendored
4
.github/workflows/package-zip.yml
vendored
|
|
@ -37,7 +37,7 @@ jobs:
|
||||||
}}
|
}}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Restore build artifacts
|
- name: Restore build artifacts
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v8
|
||||||
|
|
@ -56,7 +56,7 @@ jobs:
|
||||||
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
run: mv "v2rayN-$Target-$Arch.zip" "v2rayN-$Target-$Arch-desktop.zip"
|
||||||
|
|
||||||
- name: Sleep for race condition between matrix jobs
|
- name: Sleep for race condition between matrix jobs
|
||||||
run: sleep $(awk 'BEGIN { srand(); printf "%.3f", rand()*2 }')
|
run: sleep "$(od -An -N2 -tu2 /dev/urandom | awk 'NR==1{printf "%.2f", $1/5461}')"
|
||||||
|
|
||||||
- name: Upload zip archive to release
|
- name: Upload zip archive to release
|
||||||
uses: svenstaro/upload-release-action@v2
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
|
|
||||||
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -14,13 +14,13 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
fetch-depth: '0'
|
fetch-depth: '0'
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v5.2.0
|
uses: actions/setup-dotnet@v5.3.0
|
||||||
with:
|
with:
|
||||||
dotnet-version: '8.0.x'
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
|
|
|
||||||
742
package-debian-loong.sh
Normal file
742
package-debian-loong.sh
Normal file
|
|
@ -0,0 +1,742 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
VERSION_ARG=""
|
||||||
|
WITH_CORE="both"
|
||||||
|
FORCE_NETCORE=0
|
||||||
|
BUILD_FROM=""
|
||||||
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
|
MIN_KERNEL="5.10"
|
||||||
|
PKGROOT="v2rayN-publish"
|
||||||
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
|
OUTPUT_DIR="${HOME}/debbuild"
|
||||||
|
DOTNET_TFM="net10.0"
|
||||||
|
DOTNET_LOONGARCH_VERSION="10.0.108"
|
||||||
|
DOTNET_LOONGARCH_TAG="v10.0.108-loongarch64"
|
||||||
|
DOTNET_LOONGARCH_BASE="https://github.com/loongson/dotnet/releases/download"
|
||||||
|
DOTNET_LOONGARCH_FILE="dotnet-sdk-${DOTNET_LOONGARCH_VERSION}-linux-loongarch64.tar.gz"
|
||||||
|
DOTNET_SDK_URL="${DOTNET_LOONGARCH_BASE}/${DOTNET_LOONGARCH_TAG}/${DOTNET_LOONGARCH_FILE}"
|
||||||
|
|
||||||
|
OS_ID=""
|
||||||
|
OS_NAME=""
|
||||||
|
OS_VERSION_ID=""
|
||||||
|
HOST_ARCH=""
|
||||||
|
SCRIPT_DIR=""
|
||||||
|
PROJECT=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
declare -a BUILT_DEBS=()
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
|
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
||||||
|
VERSION_ARG="$first_arg"
|
||||||
|
shift || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
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 ;;
|
||||||
|
*)
|
||||||
|
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||||
|
die "You cannot specify both an explicit version and --buildfrom at the same time.
|
||||||
|
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_environment() {
|
||||||
|
local current_kernel=""
|
||||||
|
local lowest=""
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
|
||||||
|
OS_ID="${ID:-}"
|
||||||
|
OS_NAME="${NAME:-$OS_ID}"
|
||||||
|
OS_VERSION_ID="${VERSION_ID:-}"
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "$OS_ID" in
|
||||||
|
debian)
|
||||||
|
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
||||||
|
This script only supports: Debian."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
loongarch64) ;;
|
||||||
|
*) die "Only supports loongarch64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
current_kernel="$(uname -r)"
|
||||||
|
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
||||||
|
|
||||||
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
|
local install_ok=0
|
||||||
|
local tmp_dotnet=""
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install \
|
||||||
|
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
||||||
|
desktop-file-utils xdg-utils wget gcc make pkg-config \
|
||||||
|
libicu-dev libssl-dev libfontconfig1 libfreetype6 zlib1g
|
||||||
|
|
||||||
|
mkdir -p "$HOME/.dotnet"
|
||||||
|
tmp_dotnet="$(mktemp -d)"
|
||||||
|
curl -fL "$DOTNET_SDK_URL" -o "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
||||||
|
tar -C "$HOME/.dotnet" -xzf "$tmp_dotnet/$DOTNET_LOONGARCH_FILE"
|
||||||
|
rm -rf "$tmp_dotnet"
|
||||||
|
|
||||||
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
|
|
||||||
|
mkdir -p "$HOME/.nuget/NuGet"
|
||||||
|
|
||||||
|
cat > "$HOME/.nuget/NuGet/NuGet.Config" <<EOF
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<clear />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
<add key="loongnix" value="https://lnuget.loongnix.cn/v3/index.json" allowInsecureConnections="true" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
dotnet --info >/dev/null 2>&1 && install_ok=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
|
echo "dotnet-loongarch SDK, curl, unzip, tar, rsync, git, gcc, make, dpkg-deb, fakeroot, libicu-dev, libssl-dev"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_workspace() {
|
||||||
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
if [[ -f .gitmodules ]]; then
|
||||||
|
git submodule sync --recursive || true
|
||||||
|
git submodule update --init --recursive || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROJECT="$PROJECT_HINT"
|
||||||
|
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||||
|
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
||||||
|
}
|
||||||
|
|
||||||
|
choose_channel() {
|
||||||
|
local ch="latest"
|
||||||
|
local sel=""
|
||||||
|
|
||||||
|
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||||
|
case "$BUILD_FROM" in
|
||||||
|
1) echo "latest"; return 0 ;;
|
||||||
|
2) echo "prerelease"; return 0 ;;
|
||||||
|
3) echo "keep"; return 0 ;;
|
||||||
|
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
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//'
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_submodules() {
|
||||||
|
if [[ -f .gitmodules ]]; then
|
||||||
|
git submodule sync --recursive || true
|
||||||
|
git submodule update --init --recursive || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_try_checkout() {
|
||||||
|
local want="$1"
|
||||||
|
local ref=""
|
||||||
|
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
git fetch --tags --force --prune --depth=1 || true
|
||||||
|
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
||||||
|
|
||||||
|
if [[ -n "$ref" ]]; then
|
||||||
|
echo "[OK] Found ref '${ref}', checking out..."
|
||||||
|
git checkout -f "$ref"
|
||||||
|
sync_submodules
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_channel_or_keep() {
|
||||||
|
local ch="$1"
|
||||||
|
local 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..."
|
||||||
|
|
||||||
|
case "$ch" in
|
||||||
|
latest) tag="$(get_latest_tag_latest || true)" ;;
|
||||||
|
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
||||||
|
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
||||||
|
|
||||||
|
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||||
|
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
||||||
|
VERSION="${tag#v}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||||
|
local clean_ver="${VERSION_ARG#v}"
|
||||||
|
|
||||||
|
if git_try_checkout "$clean_ver"; then
|
||||||
|
VERSION="$clean_ver"
|
||||||
|
else
|
||||||
|
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||||
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
|
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}"
|
||||||
|
}
|
||||||
|
|
||||||
|
xray_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-loongarch64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
singbox_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-loongarch64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-loong64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-loongarch64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-loong64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
download_xray() {
|
||||||
|
local outdir="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local ver="${XRAY_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
|
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; }
|
||||||
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
||||||
|
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
||||||
|
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
||||||
|
rm -rf "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
download_singbox() {
|
||||||
|
local outdir="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local ver="${SING_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local bin=""
|
||||||
|
local 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; }
|
||||||
|
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
|
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" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
|
|
||||||
|
rm -rf "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
unify_geo_layout() {
|
||||||
|
local outroot="$1"
|
||||||
|
local n
|
||||||
|
local names=(
|
||||||
|
geosite.dat
|
||||||
|
geoip.dat
|
||||||
|
geoip-only-cn-private.dat
|
||||||
|
Country.mmdb
|
||||||
|
geoip.metadb
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin"
|
||||||
|
|
||||||
|
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_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local bin_dir="$outroot/bin"
|
||||||
|
local srss_dir="$bin_dir/srss"
|
||||||
|
local f=""
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
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/refs/heads/rule-set-geoip/$f"
|
||||||
|
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/refs/heads/rule-set-geosite/$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
unify_geo_layout "$outroot"
|
||||||
|
}
|
||||||
|
|
||||||
|
populate_assets_zip_mode() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local nested_dir=""
|
||||||
|
|
||||||
|
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
||||||
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; 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
|
||||||
|
|
||||||
|
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_geo_layout "$outroot"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
|
echo "[+] Bundle extracted to $outroot"
|
||||||
|
}
|
||||||
|
|
||||||
|
populate_assets_netcore_mode() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
|
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
|
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_runtime_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
|
echo "[*] Using v2rayN bundle archive."
|
||||||
|
else
|
||||||
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[*] --netcore specified: use separate core + rules."
|
||||||
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
describe_target() {
|
||||||
|
local short="$1"
|
||||||
|
|
||||||
|
case "$short" in
|
||||||
|
loongarch64) printf '%s\n%s\n' "linux-loongarch64" "loong64" ;;
|
||||||
|
*) echo "Unknown arch '$short' (use loongarch64)" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
publish_binary() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
dotnet clean "$PROJECT" -c Release
|
||||||
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
|
dotnet restore "$PROJECT"
|
||||||
|
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
||||||
|
}
|
||||||
|
|
||||||
|
write_launcher_file() {
|
||||||
|
local stage="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
DIR="/opt/v2rayN"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
if [[ -x "$DIR/v2rayN" ]]; then
|
||||||
|
exec "$DIR/v2rayN" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
write_desktop_file() {
|
||||||
|
local stage="$1"
|
||||||
|
|
||||||
|
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF'
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=v2rayN
|
||||||
|
Comment=v2rayN for Debian GNU Linux
|
||||||
|
Exec=v2rayn
|
||||||
|
Icon=v2rayn
|
||||||
|
Terminal=false
|
||||||
|
Categories=Network;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
write_maintainer_scripts() {
|
||||||
|
local debian_dir="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
package_binary() {
|
||||||
|
local short="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local deb_arch="$3"
|
||||||
|
local pubdir=""
|
||||||
|
local workdir=""
|
||||||
|
local stage=""
|
||||||
|
local debian_dir=""
|
||||||
|
local project_dir=""
|
||||||
|
local icon_candidate=""
|
||||||
|
local shlibs_depends=""
|
||||||
|
local extra_depends=""
|
||||||
|
local final_depends=""
|
||||||
|
local multiarch=""
|
||||||
|
local sys_libdir=""
|
||||||
|
local sys_usrlibdir=""
|
||||||
|
local deb_out=""
|
||||||
|
|
||||||
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
|
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
||||||
|
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
|
|
||||||
|
stage="$workdir/${PKGROOT}_${VERSION}_${deb_arch}"
|
||||||
|
debian_dir="$stage/DEBIAN"
|
||||||
|
|
||||||
|
mkdir -p "$stage/opt/v2rayN" "$stage/usr/bin" "$stage/usr/share/applications" "$stage/usr/share/icons/hicolor/256x256/apps" "$debian_dir"
|
||||||
|
cp -a "$pubdir/." "$stage/opt/v2rayN/"
|
||||||
|
|
||||||
|
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
||||||
|
icon_candidate="$project_dir/v2rayN.png"
|
||||||
|
[[ -f "$icon_candidate" ]] && cp "$icon_candidate" "$stage/usr/share/icons/hicolor/256x256/apps/v2rayn.png" || true
|
||||||
|
|
||||||
|
stage_runtime_assets "$stage/opt/v2rayN" "$rid"
|
||||||
|
write_launcher_file "$stage"
|
||||||
|
write_desktop_file "$stage"
|
||||||
|
write_maintainer_scripts "$debian_dir"
|
||||||
|
|
||||||
|
extra_depends="libc6 (>= 2.34), fontconfig (>= 2.13.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 8.32), bash (>= 5.1), libfreetype6 (>= 2.11)"
|
||||||
|
|
||||||
|
mkdir -p "$workdir/debian"
|
||||||
|
cat > "$workdir/debian/control" <<EOF
|
||||||
|
Source: v2rayn
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: 2dust <noreply@github.com>
|
||||||
|
Standards-Version: 4.7.0
|
||||||
|
|
||||||
|
Package: v2rayn
|
||||||
|
Architecture: ${deb_arch}
|
||||||
|
Description: v2rayN
|
||||||
|
EOF
|
||||||
|
|
||||||
|
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
||||||
|
sys_libdir="/lib/$multiarch"
|
||||||
|
sys_usrlibdir="/usr/lib/$multiarch"
|
||||||
|
|
||||||
|
: > "$debian_dir/substvars"
|
||||||
|
|
||||||
|
mapfile -t ELF_FILES < <(
|
||||||
|
find "$stage/opt/v2rayN" -type f \( -name "*.so*" -o -perm -111 \) ! -name 'libcoreclrtraceptprovider.so'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ "${#ELF_FILES[@]}" -gt 0 ]]; then
|
||||||
|
(
|
||||||
|
cd "$workdir"
|
||||||
|
dpkg-shlibdeps \
|
||||||
|
-l"$stage/opt/v2rayN" \
|
||||||
|
-l"$sys_libdir" \
|
||||||
|
-l"$sys_usrlibdir" \
|
||||||
|
-T"$debian_dir/substvars" \
|
||||||
|
"${ELF_FILES[@]}"
|
||||||
|
) >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
||||||
|
|
||||||
|
if [[ -n "$shlibs_depends" ]]; then
|
||||||
|
shlibs_depends="$(echo "$shlibs_depends" \
|
||||||
|
| sed -E 's/ *\([^)]*\)//g' \
|
||||||
|
| sed -E 's/ *, */, /g' \
|
||||||
|
| sed -E 's/^, *//; s/, *$//')"
|
||||||
|
final_depends="${shlibs_depends}, ${extra_depends}"
|
||||||
|
else
|
||||||
|
final_depends="${extra_depends}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > "$debian_dir/control" <<EOF
|
||||||
|
Package: v2rayn
|
||||||
|
Version: ${VERSION}
|
||||||
|
Architecture: ${deb_arch}
|
||||||
|
Maintainer: 2dust <noreply@github.com>
|
||||||
|
Homepage: https://github.com/2dust/v2rayN
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Depends: ${final_depends}
|
||||||
|
Description: v2rayN (Avalonia) GUI client for Linux
|
||||||
|
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
||||||
|
Shadowsocks / tuic / WireGuard.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
||||||
|
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
||||||
|
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
||||||
|
|
||||||
|
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
||||||
|
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
||||||
|
|
||||||
|
echo "Build done for $short. DEB at:"
|
||||||
|
echo " $deb_out"
|
||||||
|
BUILT_DEBS+=("$deb_out")
|
||||||
|
}
|
||||||
|
|
||||||
|
select_targets() {
|
||||||
|
printf '%s\n' loongarch64
|
||||||
|
}
|
||||||
|
|
||||||
|
build_one_target() {
|
||||||
|
local short="$1"
|
||||||
|
local meta=()
|
||||||
|
local rid=""
|
||||||
|
local deb_arch=""
|
||||||
|
|
||||||
|
mapfile -t meta < <(describe_target "$short") || return 1
|
||||||
|
rid="${meta[0]}"
|
||||||
|
deb_arch="${meta[1]}"
|
||||||
|
|
||||||
|
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
||||||
|
publish_binary "$rid"
|
||||||
|
package_binary "$short" "$rid" "$deb_arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
local pkg=""
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "================ Build Summary ================="
|
||||||
|
if [[ "${#BUILT_DEBS[@]}" -gt 0 ]]; then
|
||||||
|
echo "Output directory: $OUTPUT_DIR"
|
||||||
|
for pkg in "${BUILT_DEBS[@]}"; do
|
||||||
|
echo "$pkg"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "No DEBs detected in summary (check build logs above)."
|
||||||
|
fi
|
||||||
|
echo "==============================================="
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local targets=()
|
||||||
|
local arch=""
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
detect_environment
|
||||||
|
install_dependencies
|
||||||
|
prepare_workspace
|
||||||
|
resolve_version
|
||||||
|
|
||||||
|
mapfile -t targets < <(select_targets)
|
||||||
|
|
||||||
|
for arch in "${targets[@]}"; do
|
||||||
|
build_one_target "$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
727
package-debian-riscv.sh
Normal file
727
package-debian-riscv.sh
Normal file
|
|
@ -0,0 +1,727 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
VERSION_ARG=""
|
||||||
|
WITH_CORE="both"
|
||||||
|
FORCE_NETCORE=0
|
||||||
|
BUILD_FROM=""
|
||||||
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
|
MIN_KERNEL="5.10"
|
||||||
|
PKGROOT="v2rayN-publish"
|
||||||
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
|
OUTPUT_DIR="${HOME}/debbuild"
|
||||||
|
DOTNET_RISCV_VERSION="10.0.108"
|
||||||
|
DOTNET_RISCV_BASE="https://github.com/xujiegb/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}"
|
||||||
|
|
||||||
|
OS_ID=""
|
||||||
|
OS_NAME=""
|
||||||
|
OS_VERSION_ID=""
|
||||||
|
HOST_ARCH=""
|
||||||
|
SCRIPT_DIR=""
|
||||||
|
PROJECT=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
declare -a BUILT_DEBS=()
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
|
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
||||||
|
VERSION_ARG="$first_arg"
|
||||||
|
shift || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
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 ;;
|
||||||
|
*)
|
||||||
|
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||||
|
die "You cannot specify both an explicit version and --buildfrom at the same time.
|
||||||
|
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_environment() {
|
||||||
|
local current_kernel=""
|
||||||
|
local lowest=""
|
||||||
|
|
||||||
|
. /etc/os-release
|
||||||
|
|
||||||
|
OS_ID="${ID:-}"
|
||||||
|
OS_NAME="${NAME:-$OS_ID}"
|
||||||
|
OS_VERSION_ID="${VERSION_ID:-}"
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "$OS_ID" in
|
||||||
|
debian)
|
||||||
|
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
||||||
|
This script only supports: Debian."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
riscv64) ;;
|
||||||
|
*) die "Only supports riscv64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
current_kernel="$(uname -r)"
|
||||||
|
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
||||||
|
|
||||||
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
|
local install_ok=0
|
||||||
|
local tmp_dotnet=""
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get -y install \
|
||||||
|
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
||||||
|
desktop-file-utils xdg-utils wget gcc make pkg-config \
|
||||||
|
libicu-dev libssl-dev libfontconfig1 libfreetype6 zlib1g
|
||||||
|
|
||||||
|
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=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
|
echo "dotnet-riscv SDK, curl, unzip, tar, rsync, git, gcc, make, dpkg-deb, fakeroot, libicu-dev, libssl-dev"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_workspace() {
|
||||||
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
if [[ -f .gitmodules ]]; then
|
||||||
|
git submodule sync --recursive || true
|
||||||
|
git submodule update --init --recursive || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROJECT="$PROJECT_HINT"
|
||||||
|
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||||
|
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
||||||
|
}
|
||||||
|
|
||||||
|
choose_channel() {
|
||||||
|
local ch="latest"
|
||||||
|
local sel=""
|
||||||
|
|
||||||
|
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||||
|
case "$BUILD_FROM" in
|
||||||
|
1) echo "latest"; return 0 ;;
|
||||||
|
2) echo "prerelease"; return 0 ;;
|
||||||
|
3) echo "keep"; return 0 ;;
|
||||||
|
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
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//'
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_submodules() {
|
||||||
|
if [[ -f .gitmodules ]]; then
|
||||||
|
git submodule sync --recursive || true
|
||||||
|
git submodule update --init --recursive || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_try_checkout() {
|
||||||
|
local want="$1"
|
||||||
|
local ref=""
|
||||||
|
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
git fetch --tags --force --prune --depth=1 || true
|
||||||
|
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
||||||
|
|
||||||
|
if [[ -n "$ref" ]]; then
|
||||||
|
echo "[OK] Found ref '${ref}', checking out..."
|
||||||
|
git checkout -f "$ref"
|
||||||
|
sync_submodules
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_channel_or_keep() {
|
||||||
|
local ch="$1"
|
||||||
|
local 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..."
|
||||||
|
|
||||||
|
case "$ch" in
|
||||||
|
latest) tag="$(get_latest_tag_latest || true)" ;;
|
||||||
|
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
||||||
|
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
||||||
|
|
||||||
|
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||||
|
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
||||||
|
VERSION="${tag#v}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||||
|
local clean_ver="${VERSION_ARG#v}"
|
||||||
|
|
||||||
|
if git_try_checkout "$clean_ver"; then
|
||||||
|
VERSION="$clean_ver"
|
||||||
|
else
|
||||||
|
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||||
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
|
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}"
|
||||||
|
}
|
||||||
|
|
||||||
|
xray_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
singbox_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
download_xray() {
|
||||||
|
local outdir="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local ver="${XRAY_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
|
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; }
|
||||||
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
||||||
|
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
||||||
|
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
||||||
|
rm -rf "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
download_singbox() {
|
||||||
|
local outdir="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local ver="${SING_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local bin=""
|
||||||
|
local 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; }
|
||||||
|
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
|
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" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
|
|
||||||
|
rm -rf "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
unify_geo_layout() {
|
||||||
|
local outroot="$1"
|
||||||
|
local n
|
||||||
|
local names=(
|
||||||
|
geosite.dat
|
||||||
|
geoip.dat
|
||||||
|
geoip-only-cn-private.dat
|
||||||
|
Country.mmdb
|
||||||
|
geoip.metadb
|
||||||
|
)
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin"
|
||||||
|
|
||||||
|
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_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local bin_dir="$outroot/bin"
|
||||||
|
local srss_dir="$bin_dir/srss"
|
||||||
|
local f=""
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
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/refs/heads/rule-set-geoip/$f"
|
||||||
|
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/refs/heads/rule-set-geosite/$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
unify_geo_layout "$outroot"
|
||||||
|
}
|
||||||
|
|
||||||
|
populate_assets_zip_mode() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local nested_dir=""
|
||||||
|
|
||||||
|
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
||||||
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; 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
|
||||||
|
|
||||||
|
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_geo_layout "$outroot"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
|
echo "[+] Bundle extracted to $outroot"
|
||||||
|
}
|
||||||
|
|
||||||
|
populate_assets_netcore_mode() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
|
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
|
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_runtime_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
|
echo "[*] Using v2rayN bundle archive."
|
||||||
|
else
|
||||||
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[*] --netcore specified: use separate core + rules."
|
||||||
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
describe_target() {
|
||||||
|
local short="$1"
|
||||||
|
|
||||||
|
case "$short" in
|
||||||
|
riscv64) printf '%s\n%s\n' "linux-riscv64" "riscv64" ;;
|
||||||
|
*) echo "Unknown arch '$short' (use riscv64)" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
publish_binary() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
dotnet clean "$PROJECT" -c Release
|
||||||
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
|
dotnet restore "$PROJECT"
|
||||||
|
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
||||||
|
}
|
||||||
|
|
||||||
|
write_launcher_file() {
|
||||||
|
local stage="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF'
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
DIR="/opt/v2rayN"
|
||||||
|
cd "$DIR"
|
||||||
|
|
||||||
|
if [[ -x "$DIR/v2rayN" ]]; then
|
||||||
|
exec "$DIR/v2rayN" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
write_desktop_file() {
|
||||||
|
local stage="$1"
|
||||||
|
|
||||||
|
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF'
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=v2rayN
|
||||||
|
Comment=v2rayN for Debian GNU Linux
|
||||||
|
Exec=v2rayn
|
||||||
|
Icon=v2rayn
|
||||||
|
Terminal=false
|
||||||
|
Categories=Network;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
write_maintainer_scripts() {
|
||||||
|
local debian_dir="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
package_binary() {
|
||||||
|
local short="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local deb_arch="$3"
|
||||||
|
local pubdir=""
|
||||||
|
local workdir=""
|
||||||
|
local stage=""
|
||||||
|
local debian_dir=""
|
||||||
|
local project_dir=""
|
||||||
|
local icon_candidate=""
|
||||||
|
local shlibs_depends=""
|
||||||
|
local extra_depends=""
|
||||||
|
local final_depends=""
|
||||||
|
local multiarch=""
|
||||||
|
local sys_libdir=""
|
||||||
|
local sys_usrlibdir=""
|
||||||
|
local deb_out=""
|
||||||
|
|
||||||
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
|
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
||||||
|
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
|
|
||||||
|
stage="$workdir/${PKGROOT}_${VERSION}_${deb_arch}"
|
||||||
|
debian_dir="$stage/DEBIAN"
|
||||||
|
|
||||||
|
mkdir -p "$stage/opt/v2rayN" "$stage/usr/bin" "$stage/usr/share/applications" "$stage/usr/share/icons/hicolor/256x256/apps" "$debian_dir"
|
||||||
|
cp -a "$pubdir/." "$stage/opt/v2rayN/"
|
||||||
|
|
||||||
|
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
||||||
|
icon_candidate="$project_dir/v2rayN.png"
|
||||||
|
[[ -f "$icon_candidate" ]] && cp "$icon_candidate" "$stage/usr/share/icons/hicolor/256x256/apps/v2rayn.png" || true
|
||||||
|
|
||||||
|
stage_runtime_assets "$stage/opt/v2rayN" "$rid"
|
||||||
|
write_launcher_file "$stage"
|
||||||
|
write_desktop_file "$stage"
|
||||||
|
write_maintainer_scripts "$debian_dir"
|
||||||
|
|
||||||
|
extra_depends="libc6 (>= 2.34), fontconfig (>= 2.13.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 8.32), bash (>= 5.1), libfreetype6 (>= 2.11)"
|
||||||
|
|
||||||
|
mkdir -p "$workdir/debian"
|
||||||
|
cat > "$workdir/debian/control" <<EOF
|
||||||
|
Source: v2rayn
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Maintainer: 2dust <noreply@github.com>
|
||||||
|
Standards-Version: 4.7.0
|
||||||
|
|
||||||
|
Package: v2rayn
|
||||||
|
Architecture: ${deb_arch}
|
||||||
|
Description: v2rayN
|
||||||
|
EOF
|
||||||
|
|
||||||
|
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
||||||
|
sys_libdir="/lib/$multiarch"
|
||||||
|
sys_usrlibdir="/usr/lib/$multiarch"
|
||||||
|
|
||||||
|
: > "$debian_dir/substvars"
|
||||||
|
|
||||||
|
mapfile -t ELF_FILES < <(
|
||||||
|
find "$stage/opt/v2rayN" -type f \( -name "*.so*" -o -perm -111 \) ! -name 'libcoreclrtraceptprovider.so'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ "${#ELF_FILES[@]}" -gt 0 ]]; then
|
||||||
|
(
|
||||||
|
cd "$workdir"
|
||||||
|
dpkg-shlibdeps \
|
||||||
|
-l"$stage/opt/v2rayN" \
|
||||||
|
-l"$sys_libdir" \
|
||||||
|
-l"$sys_usrlibdir" \
|
||||||
|
-T"$debian_dir/substvars" \
|
||||||
|
"${ELF_FILES[@]}"
|
||||||
|
) >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
||||||
|
|
||||||
|
if [[ -n "$shlibs_depends" ]]; then
|
||||||
|
shlibs_depends="$(echo "$shlibs_depends" \
|
||||||
|
| sed -E 's/ *\([^)]*\)//g' \
|
||||||
|
| sed -E 's/ *, */, /g' \
|
||||||
|
| sed -E 's/^, *//; s/, *$//')"
|
||||||
|
final_depends="${shlibs_depends}, ${extra_depends}"
|
||||||
|
else
|
||||||
|
final_depends="${extra_depends}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > "$debian_dir/control" <<EOF
|
||||||
|
Package: v2rayn
|
||||||
|
Version: ${VERSION}
|
||||||
|
Architecture: ${deb_arch}
|
||||||
|
Maintainer: 2dust <noreply@github.com>
|
||||||
|
Homepage: https://github.com/2dust/v2rayN
|
||||||
|
Section: net
|
||||||
|
Priority: optional
|
||||||
|
Depends: ${final_depends}
|
||||||
|
Description: v2rayN (Avalonia) GUI client for Linux
|
||||||
|
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
||||||
|
Shadowsocks / tuic / WireGuard.
|
||||||
|
EOF
|
||||||
|
|
||||||
|
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
||||||
|
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
||||||
|
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
||||||
|
|
||||||
|
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
||||||
|
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
||||||
|
|
||||||
|
echo "Build done for $short. DEB at:"
|
||||||
|
echo " $deb_out"
|
||||||
|
BUILT_DEBS+=("$deb_out")
|
||||||
|
}
|
||||||
|
|
||||||
|
select_targets() {
|
||||||
|
printf '%s\n' riscv64
|
||||||
|
}
|
||||||
|
|
||||||
|
build_one_target() {
|
||||||
|
local short="$1"
|
||||||
|
local meta=()
|
||||||
|
local rid=""
|
||||||
|
local deb_arch=""
|
||||||
|
|
||||||
|
mapfile -t meta < <(describe_target "$short") || return 1
|
||||||
|
rid="${meta[0]}"
|
||||||
|
deb_arch="${meta[1]}"
|
||||||
|
|
||||||
|
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
||||||
|
publish_binary "$rid"
|
||||||
|
package_binary "$short" "$rid" "$deb_arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
local pkg=""
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "================ Build Summary ================="
|
||||||
|
if [[ "${#BUILT_DEBS[@]}" -gt 0 ]]; then
|
||||||
|
echo "Output directory: $OUTPUT_DIR"
|
||||||
|
for pkg in "${BUILT_DEBS[@]}"; do
|
||||||
|
echo "$pkg"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "No DEBs detected in summary (check build logs above)."
|
||||||
|
fi
|
||||||
|
echo "==============================================="
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local targets=()
|
||||||
|
local arch=""
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
detect_environment
|
||||||
|
install_dependencies
|
||||||
|
prepare_workspace
|
||||||
|
resolve_version
|
||||||
|
|
||||||
|
mapfile -t targets < <(select_targets)
|
||||||
|
|
||||||
|
for arch in "${targets[@]}"; do
|
||||||
|
build_one_target "$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
@ -1,48 +1,42 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Require Debian base branch
|
|
||||||
. /etc/os-release
|
|
||||||
|
|
||||||
case "${ID:-}" in
|
|
||||||
debian)
|
|
||||||
echo "Detected supported system: ${NAME:-$ID} ${VERSION_ID:-}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported system: ${NAME:-unknown} (${ID:-unknown})."
|
|
||||||
echo "This script only supports: Debian."
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Kernel version
|
|
||||||
MIN_KERNEL="6.11"
|
|
||||||
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
|
|
||||||
ARCH_OVERRIDE="" # --arch x64|arm64|all (optional compile target)
|
|
||||||
BUILD_FROM="" # --buildfrom 1|2|3 to select channel non-interactively
|
|
||||||
|
|
||||||
# If the first argument starts with --, do not treat it as a version number
|
|
||||||
if [[ "${VERSION_ARG:-}" == --* ]]; then
|
|
||||||
VERSION_ARG=""
|
VERSION_ARG=""
|
||||||
fi
|
WITH_CORE="both"
|
||||||
# Take the first non --* argument as version, discard it
|
FORCE_NETCORE=0
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then shift || true; fi
|
ARCH_OVERRIDE=""
|
||||||
|
BUILD_FROM=""
|
||||||
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
|
MIN_KERNEL="6.12"
|
||||||
|
PKGROOT="v2rayN-publish"
|
||||||
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
|
OUTPUT_DIR="${HOME}/debbuild"
|
||||||
|
|
||||||
|
OS_ID=""
|
||||||
|
OS_NAME=""
|
||||||
|
OS_VERSION_ID=""
|
||||||
|
HOST_ARCH=""
|
||||||
|
SCRIPT_DIR=""
|
||||||
|
PROJECT=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
declare -a BUILT_DEBS=()
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
|
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
||||||
|
VERSION_ARG="$first_arg"
|
||||||
|
shift || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse remaining optional arguments
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
||||||
|
|
@ -52,23 +46,56 @@ while [[ $# -gt 0 ]]; do
|
||||||
--arch) ARCH_OVERRIDE="${2:-}"; shift 2 ;;
|
--arch) ARCH_OVERRIDE="${2:-}"; shift 2 ;;
|
||||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
||||||
*)
|
*)
|
||||||
if [[ -z "${VERSION_ARG:-}" ]]; then VERSION_ARG="$1"; fi
|
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
||||||
shift;;
|
shift
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Conflict: version number AND --buildfrom cannot be used together
|
|
||||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||||
echo "You cannot specify both an explicit version and --buildfrom at the same time."
|
die "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."
|
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check and install dependencies
|
detect_environment() {
|
||||||
host_arch="$(uname -m)"
|
local current_kernel=""
|
||||||
[[ "$host_arch" == "aarch64" || "$host_arch" == "x86_64" ]] || { echo "Only supports aarch64 / x86_64"; exit 1; }
|
local lowest=""
|
||||||
|
|
||||||
install_ok=0
|
. /etc/os-release
|
||||||
|
|
||||||
|
OS_ID="${ID:-}"
|
||||||
|
OS_NAME="${NAME:-$OS_ID}"
|
||||||
|
OS_VERSION_ID="${VERSION_ID:-}"
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "$OS_ID" in
|
||||||
|
debian)
|
||||||
|
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
||||||
|
This script only supports: Debian."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
x86_64|aarch64) ;;
|
||||||
|
*) die "Only supports aarch64 / x86_64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
current_kernel="$(uname -r)"
|
||||||
|
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
||||||
|
|
||||||
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
|
local install_ok=0
|
||||||
|
local foreign_arch=""
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR"
|
||||||
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
@ -76,22 +103,24 @@ if command -v apt-get >/dev/null 2>&1; then
|
||||||
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
curl unzip tar jq rsync ca-certificates git dpkg-dev fakeroot file \
|
||||||
desktop-file-utils xdg-utils wget
|
desktop-file-utils xdg-utils wget
|
||||||
|
|
||||||
if [[ "$host_arch" == "aarch64" ]]; then
|
case "$HOST_ARCH" in
|
||||||
sudo dpkg --add-architecture amd64 || true
|
aarch64) foreign_arch="amd64" ;;
|
||||||
sudo apt-get update
|
x86_64) foreign_arch="arm64" ;;
|
||||||
sudo apt-get -y install \
|
*) die "Only supports aarch64 / x86_64" ;;
|
||||||
libc6:amd64 libgcc-s1:amd64 libstdc++6:amd64 zlib1g:amd64 libfontconfig1:amd64
|
esac
|
||||||
elif [[ "$host_arch" == "x86_64" ]]; then
|
|
||||||
sudo dpkg --add-architecture arm64 || true
|
sudo dpkg --add-architecture "$foreign_arch" || true
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get -y install \
|
sudo apt-get -y install \
|
||||||
libc6:arm64 libgcc-s1:arm64 libstdc++6:arm64 zlib1g:arm64 libfontconfig1:arm64
|
"libc6:${foreign_arch}" \
|
||||||
fi
|
"libgcc-s1:${foreign_arch}" \
|
||||||
|
"libstdc++6:${foreign_arch}" \
|
||||||
|
"zlib1g:${foreign_arch}" \
|
||||||
|
"libfontconfig1:${foreign_arch}"
|
||||||
|
|
||||||
# Install .NET SDK 8 via official script
|
|
||||||
wget -q https://dot.net/v1/dotnet-install.sh
|
wget -q https://dot.net/v1/dotnet-install.sh
|
||||||
chmod +x dotnet-install.sh
|
chmod +x dotnet-install.sh
|
||||||
./dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
|
./dotnet-install.sh --channel 10.0.1xx --install-dir "$HOME/.dotnet"
|
||||||
|
|
||||||
export PATH="$HOME/.dotnet:$PATH"
|
export PATH="$HOME/.dotnet:$PATH"
|
||||||
export DOTNET_ROOT="$HOME/.dotnet"
|
export DOTNET_ROOT="$HOME/.dotnet"
|
||||||
|
|
@ -100,42 +129,39 @@ if command -v apt-get >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
echo "Could not auto-install dependencies for '$ID'. Make sure these are available:"
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
echo "dotnet-sdk 8.x, curl, unzip, tar, rsync, git, dpkg-deb, desktop-file-utils, xdg-utils"
|
echo "dotnet-sdk 10.x, curl, unzip, tar, rsync, git, dpkg-deb, desktop-file-utils, xdg-utils"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Root directory
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
# Git submodules (best effort)
|
|
||||||
if [[ -f .gitmodules ]]; then
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Locate project
|
PROJECT="$PROJECT_HINT"
|
||||||
PROJECT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||||
if [[ ! -f "$PROJECT" ]]; then
|
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
||||||
PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
}
|
||||||
fi
|
|
||||||
[[ -f "$PROJECT" ]] || { echo "v2rayN.Desktop.csproj not found"; exit 1; }
|
|
||||||
|
|
||||||
choose_channel() {
|
choose_channel() {
|
||||||
# If --buildfrom provided, map it directly and skip interaction.
|
local ch="latest"
|
||||||
|
local sel=""
|
||||||
|
|
||||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||||
case "$BUILD_FROM" in
|
case "$BUILD_FROM" in
|
||||||
1) echo "latest"; return 0 ;;
|
1) echo "latest"; return 0 ;;
|
||||||
2) echo "prerelease"; return 0 ;;
|
2) echo "prerelease"; return 0 ;;
|
||||||
3) echo "keep"; return 0 ;;
|
3) echo "keep"; return 0 ;;
|
||||||
*) echo "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." >&2; exit 1;;
|
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print menu to stderr and read from /dev/tty so stdout only carries the token.
|
|
||||||
local ch="latest" sel=""
|
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
echo "[?] Choose v2rayN release channel:" >&2
|
echo "[?] Choose v2rayN release channel:" >&2
|
||||||
echo " 1) Latest (stable) [default]" >&2
|
echo " 1) Latest (stable) [default]" >&2
|
||||||
|
|
@ -166,28 +192,35 @@ get_latest_tag_prerelease() {
|
||||||
| sed 's/^v//'
|
| sed 's/^v//'
|
||||||
}
|
}
|
||||||
|
|
||||||
git_try_checkout() {
|
sync_submodules() {
|
||||||
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
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_try_checkout() {
|
||||||
|
local want="$1"
|
||||||
|
local ref=""
|
||||||
|
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
git fetch --tags --force --prune --depth=1 || true
|
||||||
|
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
||||||
|
|
||||||
|
if [[ -n "$ref" ]]; then
|
||||||
|
echo "[OK] Found ref '${ref}', checking out..."
|
||||||
|
git checkout -f "$ref"
|
||||||
|
sync_submodules
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_channel_or_keep() {
|
apply_channel_or_keep() {
|
||||||
local ch="$1" tag
|
local ch="$1"
|
||||||
|
local tag=""
|
||||||
|
|
||||||
if [[ "$ch" == "keep" ]]; then
|
if [[ "$ch" == "keep" ]]; then
|
||||||
echo "[*] Keep current repository state (no checkout)."
|
echo "[*] Keep current repository state (no checkout)."
|
||||||
|
|
@ -197,31 +230,33 @@ apply_channel_or_keep() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
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; }
|
case "$ch" in
|
||||||
|
latest) tag="$(get_latest_tag_latest || true)" ;;
|
||||||
|
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
||||||
|
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
||||||
|
|
||||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||||
git_try_checkout "$tag" || { echo "Failed to checkout '${tag}'."; exit 1; }
|
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
||||||
VERSION="${tag#v}"
|
VERSION="${tag#v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||||
clean_ver="${VERSION_ARG#v}"
|
local clean_ver="${VERSION_ARG#v}"
|
||||||
|
|
||||||
if git_try_checkout "$clean_ver"; then
|
if git_try_checkout "$clean_ver"; then
|
||||||
VERSION="$clean_ver"
|
VERSION="$clean_ver"
|
||||||
else
|
else
|
||||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Current directory is not a git repo; proceeding on current tree."
|
echo "Current directory is not a git repo; proceeding on current tree."
|
||||||
|
|
@ -230,66 +265,119 @@ fi
|
||||||
|
|
||||||
VERSION="${VERSION#v}"
|
VERSION="${VERSION#v}"
|
||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
|
}
|
||||||
|
|
||||||
|
xray_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
||||||
|
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
singbox_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
||||||
|
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
||||||
|
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
download_xray() {
|
download_xray() {
|
||||||
local outdir="$1" rid="$2" ver="${XRAY_VER:-}" url tmp zipname="xray.zip"
|
local outdir="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local ver="${XRAY_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
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
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||||
url="https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip"
|
|
||||||
else
|
|
||||||
url="https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip"
|
|
||||||
fi
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$zipname"
|
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$tmp/$zipname" -d "$tmp"
|
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray"
|
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_singbox() {
|
download_singbox() {
|
||||||
# Download sing-box
|
local outdir="$1"
|
||||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin cronet
|
local rid="$2"
|
||||||
|
local ver="${SING_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local bin=""
|
||||||
|
local cronet=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
| head -n1)" || true
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||||
url="https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz"
|
|
||||||
else
|
|
||||||
url="https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz"
|
|
||||||
fi
|
|
||||||
echo "[+] Download sing-box: $url"
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$tarname"
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
tar -C "$tmp" -xzf "$tmp/$tarname"
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$bin" "$outdir/sing-box"
|
|
||||||
|
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
unify_geo_layout() {
|
unify_geo_layout() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
mkdir -p "$outroot/bin"
|
local n
|
||||||
local names=(
|
local names=(
|
||||||
"geosite.dat"
|
geosite.dat
|
||||||
"geoip.dat"
|
geoip.dat
|
||||||
"geoip-only-cn-private.dat"
|
geoip-only-cn-private.dat
|
||||||
"Country.mmdb"
|
Country.mmdb
|
||||||
"geoip.metadb"
|
geoip.metadb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin"
|
||||||
|
|
||||||
for n in "${names[@]}"; do
|
for n in "${names[@]}"; do
|
||||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
||||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
||||||
|
|
@ -301,52 +389,44 @@ download_geo_assets() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
local bin_dir="$outroot/bin"
|
local bin_dir="$outroot/bin"
|
||||||
local srss_dir="$bin_dir/srss"
|
local srss_dir="$bin_dir/srss"
|
||||||
|
local f=""
|
||||||
|
|
||||||
mkdir -p "$bin_dir" "$srss_dir"
|
mkdir -p "$bin_dir" "$srss_dir"
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
echo "[+] Download Xray Geo to ${bin_dir}"
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" \
|
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/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.dat" \
|
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
||||||
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
||||||
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"
|
echo "[+] Download sing-box rule DB & rule-sets"
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" \
|
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
||||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb" || true
|
|
||||||
|
|
||||||
for f in \
|
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
|
||||||
geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs \
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
||||||
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
|
done
|
||||||
|
|
||||||
for f in \
|
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
|
||||||
geosite-cn.srs geosite-gfw.srs geosite-google.srs geosite-greatfire.srs \
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
||||||
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
|
done
|
||||||
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_v2rayn_bundle() {
|
populate_assets_zip_mode() {
|
||||||
local outroot="$1" rid="$2"
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
local url=""
|
local url=""
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
local tmp=""
|
||||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip"
|
local nested_dir=""
|
||||||
else
|
|
||||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip"
|
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||||
fi
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
local tmp zipname
|
|
||||||
tmp="$(mktemp -d)"; zipname="$tmp/v2rayn.zip"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$zipname" || { echo "[!] Bundle download failed"; return 1; }
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$zipname" -d "$tmp" || { echo "[!] Bundle unzip failed"; return 1; }
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
if [[ -d "$tmp/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -358,7 +438,6 @@ download_v2rayn_bundle() {
|
||||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 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)"
|
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -366,90 +445,71 @@ download_v2rayn_bundle() {
|
||||||
rm -rf "$nested_dir"
|
rm -rf "$nested_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unify to bin/
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
echo "[+] Bundle extracted to $outroot"
|
echo "[+] Bundle extracted to $outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILT_DEBS=()
|
populate_assets_netcore_mode() {
|
||||||
BUILT_ALL=0
|
|
||||||
OUTPUT_DIR="$HOME/debbuild"
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
|
||||||
|
|
||||||
build_for_arch() {
|
|
||||||
local short="$1"
|
|
||||||
local rid deb_arch outdir_name
|
|
||||||
case "$short" in
|
|
||||||
x64) rid="linux-x64"; deb_arch="amd64"; outdir_name="amd64" ;;
|
|
||||||
arm64) rid="linux-arm64"; deb_arch="arm64"; outdir_name="arm64" ;;
|
|
||||||
*) echo "Unknown arch '$short' (use x64|arm64)"; return 1 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
|
||||||
|
|
||||||
dotnet clean "$PROJECT" -c Release
|
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net8.0" || true
|
|
||||||
|
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" \
|
|
||||||
-c Release -r "$rid" \
|
|
||||||
-p:PublishSingleFile=false \
|
|
||||||
-p:SelfContained=true
|
|
||||||
|
|
||||||
local RID_DIR="$rid"
|
|
||||||
local PUBDIR
|
|
||||||
PUBDIR="$(dirname "$PROJECT")/bin/Release/net8.0/${RID_DIR}/publish"
|
|
||||||
[[ -d "$PUBDIR" ]] || { echo "Publish directory not found: $PUBDIR"; return 1; }
|
|
||||||
|
|
||||||
local WORKDIR PKGROOT STAGE DEBIAN_DIR
|
|
||||||
WORKDIR="$(mktemp -d)"
|
|
||||||
PKGROOT="v2rayN-publish"
|
|
||||||
STAGE="$WORKDIR/${PKGROOT}_${VERSION}_${deb_arch}"
|
|
||||||
DEBIAN_DIR="$STAGE/DEBIAN"
|
|
||||||
|
|
||||||
mkdir -p "$STAGE/opt/v2rayN"
|
|
||||||
mkdir -p "$STAGE/usr/bin"
|
|
||||||
mkdir -p "$STAGE/usr/share/applications"
|
|
||||||
mkdir -p "$STAGE/usr/share/icons/hicolor/256x256/apps"
|
|
||||||
mkdir -p "$DEBIAN_DIR"
|
|
||||||
|
|
||||||
# Stage publish content from source build
|
|
||||||
cp -a "$PUBDIR/." "$STAGE/opt/v2rayN/"
|
|
||||||
|
|
||||||
local ICON_CANDIDATE
|
|
||||||
PROJECT_DIR="$(cd "$(dirname "$PROJECT")" && pwd)"
|
|
||||||
ICON_CANDIDATE="$PROJECT_DIR/v2rayN.png"
|
|
||||||
[[ -f "$ICON_CANDIDATE" ]] && cp "$ICON_CANDIDATE" "$STAGE/usr/share/icons/hicolor/256x256/apps/v2rayn.png" || true
|
|
||||||
|
|
||||||
mkdir -p "$STAGE/opt/v2rayN/bin/xray" "$STAGE/opt/v2rayN/bin/sing_box"
|
|
||||||
|
|
||||||
fetch_separate_cores_and_rules() {
|
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_xray "$outroot/bin/xray" "$RID_DIR" || echo "[!] xray download failed (skipped)"
|
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_singbox "$outroot/bin/sing_box" "$RID_DIR" || echo "[!] sing-box download failed (skipped)"
|
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage_runtime_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
if download_v2rayn_bundle "$STAGE/opt/v2rayN" "$RID_DIR"; then
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
echo "[*] Using v2rayN bundle bin assets."
|
echo "[*] Using v2rayN bundle bin assets."
|
||||||
else
|
else
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$STAGE/opt/v2rayN"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[*] --netcore specified: use separate core + rules."
|
echo "[*] --netcore specified: use separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$STAGE/opt/v2rayN"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Wrapper
|
describe_target() {
|
||||||
install -m 755 /dev/stdin "$STAGE/usr/bin/v2rayn" <<'EOF'
|
local short="$1"
|
||||||
|
|
||||||
|
case "$short" in
|
||||||
|
x64) printf '%s\n%s\n' "linux-x64" "amd64" ;;
|
||||||
|
arm64) printf '%s\n%s\n' "linux-arm64" "arm64" ;;
|
||||||
|
*) echo "Unknown arch '$short' (use x64|arm64)" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
publish_binary() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
dotnet clean "$PROJECT" -c Release
|
||||||
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
|
dotnet restore "$PROJECT"
|
||||||
|
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
||||||
|
}
|
||||||
|
|
||||||
|
write_launcher_file() {
|
||||||
|
local stage="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$stage/usr/bin/v2rayn" <<'EOF'
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
DIR="/opt/v2rayN"
|
DIR="/opt/v2rayN"
|
||||||
|
|
@ -469,12 +529,90 @@ echo "v2rayN launcher: no executable found in $DIR" >&2
|
||||||
ls -l "$DIR" >&2 || true
|
ls -l "$DIR" >&2 || true
|
||||||
exit 1
|
exit 1
|
||||||
EOF
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
SHLIBS_DEPENDS=""
|
write_desktop_file() {
|
||||||
EXTRA_DEPENDS="libc6 (>= 2.34), fontconfig (>= 2.13.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 8.32), bash (>= 5.1), libfreetype6 (>= 2.11)"
|
local stage="$1"
|
||||||
|
|
||||||
mkdir -p "$WORKDIR/debian"
|
install -m 644 /dev/stdin "$stage/usr/share/applications/v2rayn.desktop" <<'EOF'
|
||||||
cat > "$WORKDIR/debian/control" <<EOF
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=v2rayN
|
||||||
|
Comment=v2rayN for Debian GNU Linux
|
||||||
|
Exec=v2rayn
|
||||||
|
Icon=v2rayn
|
||||||
|
Terminal=false
|
||||||
|
Categories=Network;
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
write_maintainer_scripts() {
|
||||||
|
local debian_dir="$1"
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postinst" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
|
||||||
|
install -m 755 /dev/stdin "$debian_dir/postrm" <<'EOF'
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
package_binary() {
|
||||||
|
local short="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local deb_arch="$3"
|
||||||
|
local pubdir=""
|
||||||
|
local workdir=""
|
||||||
|
local stage=""
|
||||||
|
local debian_dir=""
|
||||||
|
local project_dir=""
|
||||||
|
local icon_candidate=""
|
||||||
|
local shlibs_depends=""
|
||||||
|
local extra_depends=""
|
||||||
|
local final_depends=""
|
||||||
|
local multiarch=""
|
||||||
|
local sys_libdir=""
|
||||||
|
local sys_usrlibdir=""
|
||||||
|
local deb_out=""
|
||||||
|
|
||||||
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
|
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
||||||
|
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
|
|
||||||
|
stage="$workdir/${PKGROOT}_${VERSION}_${deb_arch}"
|
||||||
|
debian_dir="$stage/DEBIAN"
|
||||||
|
|
||||||
|
mkdir -p "$stage/opt/v2rayN" "$stage/usr/bin" "$stage/usr/share/applications" "$stage/usr/share/icons/hicolor/256x256/apps" "$debian_dir"
|
||||||
|
cp -a "$pubdir/." "$stage/opt/v2rayN/"
|
||||||
|
|
||||||
|
project_dir="$(cd "$(dirname "$PROJECT")" && pwd)"
|
||||||
|
icon_candidate="$project_dir/v2rayN.png"
|
||||||
|
[[ -f "$icon_candidate" ]] && cp "$icon_candidate" "$stage/usr/share/icons/hicolor/256x256/apps/v2rayn.png" || true
|
||||||
|
|
||||||
|
stage_runtime_assets "$stage/opt/v2rayN" "$rid"
|
||||||
|
write_launcher_file "$stage"
|
||||||
|
write_desktop_file "$stage"
|
||||||
|
write_maintainer_scripts "$debian_dir"
|
||||||
|
|
||||||
|
extra_depends="libc6 (>= 2.34), fontconfig (>= 2.13.1), desktop-file-utils (>= 0.26), xdg-utils (>= 1.1.3), coreutils (>= 8.32), bash (>= 5.1), libfreetype6 (>= 2.11)"
|
||||||
|
|
||||||
|
mkdir -p "$workdir/debian"
|
||||||
|
cat > "$workdir/debian/control" <<EOF
|
||||||
Source: v2rayn
|
Source: v2rayn
|
||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
|
|
@ -486,55 +624,41 @@ Architecture: ${deb_arch}
|
||||||
Description: v2rayN
|
Description: v2rayN
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
local SYS_LIBDIR=""
|
|
||||||
local SYS_USRLIBDIR=""
|
|
||||||
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
multiarch="$(dpkg-architecture -a"$deb_arch" -qDEB_HOST_MULTIARCH)"
|
||||||
|
sys_libdir="/lib/$multiarch"
|
||||||
|
sys_usrlibdir="/usr/lib/$multiarch"
|
||||||
|
|
||||||
SYS_LIBDIR="/lib/$multiarch"
|
: > "$debian_dir/substvars"
|
||||||
SYS_USRLIBDIR="/usr/lib/$multiarch"
|
|
||||||
|
|
||||||
: > "$DEBIAN_DIR/substvars"
|
|
||||||
mapfile -t ELF_FILES < <(
|
mapfile -t ELF_FILES < <(
|
||||||
find "$STAGE/opt/v2rayN" -type f \( -name "*.so*" -o -perm -111 \) ! -name 'libcoreclrtraceptprovider.so'
|
find "$stage/opt/v2rayN" -type f \( -name "*.so*" -o -perm -111 \) ! -name 'libcoreclrtraceptprovider.so'
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ "${#ELF_FILES[@]}" -gt 0 ]]; then
|
if [[ "${#ELF_FILES[@]}" -gt 0 ]]; then
|
||||||
(
|
(
|
||||||
cd "$WORKDIR"
|
cd "$workdir"
|
||||||
dpkg-shlibdeps \
|
dpkg-shlibdeps \
|
||||||
-l"$STAGE/opt/v2rayN" \
|
-l"$stage/opt/v2rayN" \
|
||||||
-l"$SYS_LIBDIR" \
|
-l"$sys_libdir" \
|
||||||
-l"$SYS_USRLIBDIR" \
|
-l"$sys_usrlibdir" \
|
||||||
-T"$DEBIAN_DIR/substvars" \
|
-T"$debian_dir/substvars" \
|
||||||
"${ELF_FILES[@]}"
|
"${ELF_FILES[@]}"
|
||||||
) >/dev/null 2>&1 || true
|
) >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SHLIBS_DEPENDS="$(sed -n 's/^shlibs:Depends=//p' "$DEBIAN_DIR/substvars" | head -n1 || true)"
|
shlibs_depends="$(sed -n 's/^shlibs:Depends=//p' "$debian_dir/substvars" | head -n1 || true)"
|
||||||
|
|
||||||
if [[ -n "$SHLIBS_DEPENDS" ]]; then
|
if [[ -n "$shlibs_depends" ]]; then
|
||||||
SHLIBS_DEPENDS="$(echo "$SHLIBS_DEPENDS" \
|
shlibs_depends="$(echo "$shlibs_depends" \
|
||||||
| sed -E 's/ *\([^)]*\)//g' \
|
| sed -E 's/ *\([^)]*\)//g' \
|
||||||
| sed -E 's/ *, */, /g' \
|
| sed -E 's/ *, */, /g' \
|
||||||
| sed -E 's/^, *//; s/, *$//')"
|
| sed -E 's/^, *//; s/, *$//')"
|
||||||
FINAL_DEPENDS="${SHLIBS_DEPENDS}, ${EXTRA_DEPENDS}"
|
final_depends="${shlibs_depends}, ${extra_depends}"
|
||||||
else
|
else
|
||||||
FINAL_DEPENDS="${EXTRA_DEPENDS}"
|
final_depends="${extra_depends}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Desktop file
|
cat > "$debian_dir/control" <<EOF
|
||||||
install -m 644 /dev/stdin "$STAGE/usr/share/applications/v2rayn.desktop" <<'EOF'
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=v2rayN
|
|
||||||
Comment=v2rayN for Debian GNU Linux
|
|
||||||
Exec=v2rayn
|
|
||||||
Icon=v2rayn
|
|
||||||
Terminal=false
|
|
||||||
Categories=Network;
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Control file
|
|
||||||
cat > "$DEBIAN_DIR/control" <<EOF
|
|
||||||
Package: v2rayn
|
Package: v2rayn
|
||||||
Version: ${VERSION}
|
Version: ${VERSION}
|
||||||
Architecture: ${deb_arch}
|
Architecture: ${deb_arch}
|
||||||
|
|
@ -542,62 +666,60 @@ Maintainer: 2dust <noreply@github.com>
|
||||||
Homepage: https://github.com/2dust/v2rayN
|
Homepage: https://github.com/2dust/v2rayN
|
||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Depends: ${FINAL_DEPENDS}
|
Depends: ${final_depends}
|
||||||
Description: v2rayN (Avalonia) GUI client for Linux
|
Description: v2rayN (Avalonia) GUI client for Linux
|
||||||
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
Support vless / vmess / Trojan / http / socks / Anytls / Hysteria2 /
|
||||||
Shadowsocks / tuic / WireGuard.
|
Shadowsocks / tuic / WireGuard.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# postinst
|
find "$stage/opt/v2rayN" -type d -exec chmod 0755 {} +
|
||||||
install -m 755 /dev/stdin "$DEBIAN_DIR/postinst" <<'EOF'
|
find "$stage/opt/v2rayN" -type f -exec chmod 0644 {} +
|
||||||
#!/bin/sh
|
[[ -f "$stage/opt/v2rayN/v2rayN" ]] && chmod 0755 "$stage/opt/v2rayN/v2rayN" || true
|
||||||
set -e
|
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
|
||||||
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|
||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# postrm
|
|
||||||
install -m 755 /dev/stdin "$DEBIAN_DIR/postrm" <<'EOF'
|
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
update-desktop-database /usr/share/applications >/dev/null 2>&1 || true
|
|
||||||
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
|
||||||
gtk-update-icon-cache -f /usr/share/icons/hicolor >/dev/null 2>&1 || true
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Normalize permissions
|
|
||||||
find "$STAGE/opt/v2rayN" -type d -exec chmod 0755 {} +
|
|
||||||
find "$STAGE/opt/v2rayN" -type f -exec chmod 0644 {} +
|
|
||||||
[[ -f "$STAGE/opt/v2rayN/v2rayN" ]] && chmod 0755 "$STAGE/opt/v2rayN/v2rayN" || true
|
|
||||||
|
|
||||||
local deb_out
|
|
||||||
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
deb_out="$OUTPUT_DIR/v2rayn_${VERSION}_${deb_arch}.deb"
|
||||||
|
dpkg-deb --root-owner-group --build "$stage" "$deb_out"
|
||||||
dpkg-deb --root-owner-group --build "$STAGE" "$deb_out"
|
|
||||||
|
|
||||||
echo "Build done for $short. DEB at:"
|
echo "Build done for $short. DEB at:"
|
||||||
echo " $deb_out"
|
echo " $deb_out"
|
||||||
BUILT_DEBS+=("$deb_out")
|
BUILT_DEBS+=("$deb_out")
|
||||||
|
|
||||||
rm -rf "$WORKDIR"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select_targets() {
|
||||||
case "${ARCH_OVERRIDE:-}" in
|
case "${ARCH_OVERRIDE:-}" in
|
||||||
all) targets=(x64 arm64); BUILT_ALL=1 ;;
|
all) printf '%s\n' x64 arm64 ;;
|
||||||
x64|amd64) targets=(x64) ;;
|
x64|amd64) printf '%s\n' x64 ;;
|
||||||
arm64|aarch64) targets=(arm64) ;;
|
arm64|aarch64) printf '%s\n' arm64 ;;
|
||||||
"") targets=($([[ "$host_arch" == "aarch64" ]] && echo arm64 || echo x64)) ;;
|
"")
|
||||||
*) echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all."; exit 1 ;;
|
case "$HOST_ARCH" in
|
||||||
|
x86_64) printf '%s\n' x64 ;;
|
||||||
|
aarch64) printf '%s\n' arm64 ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all." >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
build_one_target() {
|
||||||
build_for_arch "$arch"
|
local short="$1"
|
||||||
done
|
local meta=()
|
||||||
|
local rid=""
|
||||||
|
local deb_arch=""
|
||||||
|
|
||||||
|
mapfile -t meta < <(describe_target "$short") || return 1
|
||||||
|
rid="${meta[0]}"
|
||||||
|
deb_arch="${meta[1]}"
|
||||||
|
|
||||||
|
echo "[*] Building for target: $short (RID=$rid, DEB arch=$deb_arch)"
|
||||||
|
publish_binary "$rid"
|
||||||
|
package_binary "$short" "$rid" "$deb_arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
local pkg=""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "================ Build Summary ================="
|
echo "================ Build Summary ================="
|
||||||
|
|
@ -610,3 +732,25 @@ else
|
||||||
echo "No DEBs detected in summary (check build logs above)."
|
echo "No DEBs detected in summary (check build logs above)."
|
||||||
fi
|
fi
|
||||||
echo "==============================================="
|
echo "==============================================="
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local targets=()
|
||||||
|
local arch=""
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
detect_environment
|
||||||
|
install_dependencies
|
||||||
|
prepare_workspace
|
||||||
|
resolve_version
|
||||||
|
|
||||||
|
mapfile -t targets < <(select_targets)
|
||||||
|
|
||||||
|
for arch in "${targets[@]}"; do
|
||||||
|
build_one_target "$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
@ -1,53 +1,45 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Require Red Hat base branch
|
VERSION_ARG=""
|
||||||
. /etc/os-release
|
WITH_CORE="both"
|
||||||
|
FORCE_NETCORE=0
|
||||||
|
BUILD_FROM=""
|
||||||
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
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"
|
MIN_KERNEL="5.10"
|
||||||
CURRENT_KERNEL="$(uname -r)"
|
PKGROOT="v2rayN-publish"
|
||||||
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$CURRENT_KERNEL" | sort -V | head -n1)"
|
RPM_TOPDIR="${HOME}/rpmbuild"
|
||||||
|
DOTNET_RISCV_VERSION="10.0.108"
|
||||||
if [[ "$lowest" != "$MIN_KERNEL" ]]; then
|
DOTNET_RISCV_BASE="https://github.com/xujiegb/dotnet-riscv/releases/download"
|
||||||
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_RISCV_FILE="dotnet-sdk-${DOTNET_RISCV_VERSION}-linux-riscv64.tar.gz"
|
||||||
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
DOTNET_SDK_URL="${DOTNET_RISCV_BASE}/${DOTNET_RISCV_VERSION}/${DOTNET_RISCV_FILE}"
|
||||||
SKIA_VER="${SKIA_VER:-3.119.2}"
|
|
||||||
HARFBUZZ_VER="${HARFBUZZ_VER:-8.3.1.1}"
|
|
||||||
|
|
||||||
# If the first argument starts with --, do not treat it as a version number
|
OS_ID=""
|
||||||
if [[ "${VERSION_ARG:-}" == --* ]]; then
|
OS_NAME=""
|
||||||
VERSION_ARG=""
|
OS_VERSION_ID=""
|
||||||
|
HOST_ARCH=""
|
||||||
|
SCRIPT_DIR=""
|
||||||
|
PROJECT=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
declare -a BUILT_RPMS=()
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
|
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
||||||
|
VERSION_ARG="$first_arg"
|
||||||
|
shift || true
|
||||||
fi
|
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
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
||||||
|
|
@ -56,125 +48,58 @@ while [[ $# -gt 0 ]]; do
|
||||||
--netcore) FORCE_NETCORE=1; shift ;;
|
--netcore) FORCE_NETCORE=1; shift ;;
|
||||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
||||||
*)
|
*)
|
||||||
if [[ -z "${VERSION_ARG:-}" ]]; then VERSION_ARG="$1"; fi
|
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
||||||
shift;;
|
shift
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Conflict: version number AND --buildfrom cannot be used together
|
|
||||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||||
echo "You cannot specify both an explicit version and --buildfrom at the same time."
|
die "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."
|
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
apply_riscv_patch() {
|
|
||||||
# Upgrade net8.0 -> net10.0
|
|
||||||
find . -type f \( -name "*.csproj" -o -name "*.props" -o -name "*.targets" \) \
|
|
||||||
-exec sed -i 's/net8\.0/net10.0/g' {} +
|
|
||||||
|
|
||||||
# Patch all Directory.Packages.props for SkiaSharp/HarfBuzzSharp
|
|
||||||
while IFS= read -r -d '' f; do
|
|
||||||
# replace existing versions if present
|
|
||||||
sed -i \
|
|
||||||
-e "s#<PackageVersion Include=\"SkiaSharp\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"SkiaSharp\" Version=\"$SKIA_VER\" />#g" \
|
|
||||||
-e "s#<PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"$SKIA_VER\" />#g" \
|
|
||||||
-e "s#<PackageVersion Include=\"HarfBuzzSharp\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"HarfBuzzSharp\" Version=\"$HARFBUZZ_VER\" />#g" \
|
|
||||||
-e "s#<PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"[^\"]*\" */>#<PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"$HARFBUZZ_VER\" />#g" \
|
|
||||||
"$f"
|
|
||||||
|
|
||||||
grep -q 'PackageVersion Include="SkiaSharp"' "$f" || \
|
|
||||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"SkiaSharp\" Version=\"$SKIA_VER\" />" "$f"
|
|
||||||
|
|
||||||
grep -q 'PackageVersion Include="SkiaSharp.NativeAssets.Linux"' "$f" || \
|
|
||||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"SkiaSharp.NativeAssets.Linux\" Version=\"$SKIA_VER\" />" "$f"
|
|
||||||
|
|
||||||
grep -q 'PackageVersion Include="HarfBuzzSharp"' "$f" || \
|
|
||||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"HarfBuzzSharp\" Version=\"$HARFBUZZ_VER\" />" "$f"
|
|
||||||
|
|
||||||
grep -q 'PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux"' "$f" || \
|
|
||||||
sed -i "/<\/ItemGroup>/i\ <PackageVersion Include=\"HarfBuzzSharp.NativeAssets.Linux\" Version=\"$HARFBUZZ_VER\" />" "$f"
|
|
||||||
done < <(find . -type f -name 'Directory.Packages.props' -print0)
|
|
||||||
|
|
||||||
# Patch SDK bundled RIDs
|
|
||||||
f="$(find "$DOTNET_ROOT/sdk/$(dotnet --version)" -type f -name 'Microsoft.NETCoreSdk.BundledVersions.props' | head -n1 || true)"
|
|
||||||
[[ -f "$f" ]] && sed -i \
|
|
||||||
-e 's/linux-arm64/&;linux-riscv64/g' \
|
|
||||||
-e 's/linux-musl-arm64/&;linux-musl-riscv64/g' \
|
|
||||||
"$f"
|
|
||||||
}
|
|
||||||
|
|
||||||
build_sqlite_native_riscv64() {
|
|
||||||
local outdir="$1"
|
|
||||||
local workdir sqlite_year sqlite_ver sqlite_zip srcdir
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
workdir="$(mktemp -d)"
|
|
||||||
|
|
||||||
# SQLite 3.51.3 amalgamation
|
|
||||||
sqlite_year="2026"
|
|
||||||
sqlite_ver="3510300"
|
|
||||||
sqlite_zip="sqlite-amalgamation-${sqlite_ver}.zip"
|
|
||||||
|
|
||||||
echo "[+] Download SQLite amalgamation: ${sqlite_zip}"
|
|
||||||
curl -fL "https://www.sqlite.org/${sqlite_year}/${sqlite_zip}" -o "${workdir}/${sqlite_zip}"
|
|
||||||
|
|
||||||
unzip -q "${workdir}/${sqlite_zip}" -d "$workdir"
|
|
||||||
srcdir="$(find "$workdir" -maxdepth 1 -type d -name 'sqlite-amalgamation-*' | head -n1 || true)"
|
|
||||||
[[ -n "$srcdir" ]] || { echo "[!] SQLite source unpack failed"; rm -rf "$workdir"; return 1; }
|
|
||||||
|
|
||||||
echo "[+] Build libe_sqlite3.so for riscv64"
|
|
||||||
gcc -shared -fPIC -O2 \
|
|
||||||
-DSQLITE_THREADSAFE=1 \
|
|
||||||
-DSQLITE_ENABLE_FTS5 \
|
|
||||||
-DSQLITE_ENABLE_RTREE \
|
|
||||||
-DSQLITE_ENABLE_JSON1 \
|
|
||||||
-o "${outdir}/libe_sqlite3.so" "${srcdir}/sqlite3.c" -ldl -lpthread
|
|
||||||
|
|
||||||
rm -rf "$workdir"
|
|
||||||
}
|
|
||||||
|
|
||||||
copy_skiasharp_native_riscv64() {
|
|
||||||
local outdir="$1"
|
|
||||||
local skia_so=""
|
|
||||||
local harfbuzz_so=""
|
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
|
||||||
|
|
||||||
skia_so="$(find "$HOME/.nuget/packages" -path "*/skiasharp.nativeassets.linux/${SKIA_VER}/runtimes/linux-riscv64/native/libSkiaSharp.so" | head -n1 || true)"
|
|
||||||
if [[ -z "$skia_so" ]]; then
|
|
||||||
skia_so="$(find "$HOME/.nuget/packages" -path "*/runtimes/linux-riscv64/native/libSkiaSharp.so" | head -n1 || true)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
harfbuzz_so="$(find "$HOME/.nuget/packages" -path "*/harfbuzzsharp.nativeassets.linux/${HARFBUZZ_VER}/runtimes/linux-riscv64/native/libHarfBuzzSharp.so" | head -n1 || true)"
|
|
||||||
if [[ -z "$harfbuzz_so" ]]; then
|
|
||||||
harfbuzz_so="$(find "$HOME/.nuget/packages" -path "*/runtimes/linux-riscv64/native/libHarfBuzzSharp.so" | head -n1 || true)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$skia_so" && -f "$skia_so" ]]; then
|
|
||||||
echo "[+] Copy libSkiaSharp.so from NuGet cache"
|
|
||||||
install -m 755 "$skia_so" "$outdir/libSkiaSharp.so"
|
|
||||||
else
|
|
||||||
echo "[WARN] libSkiaSharp.so for linux-riscv64 not found in NuGet cache"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$harfbuzz_so" && -f "$harfbuzz_so" ]]; then
|
|
||||||
echo "[+] Copy libHarfBuzzSharp.so from NuGet cache"
|
|
||||||
install -m 755 "$harfbuzz_so" "$outdir/libHarfBuzzSharp.so"
|
|
||||||
else
|
|
||||||
echo "[WARN] libHarfBuzzSharp.so for linux-riscv64 not found in NuGet cache"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check and install dependencies
|
detect_environment() {
|
||||||
host_arch="$(uname -m)"
|
local current_kernel=""
|
||||||
[[ "$host_arch" == "riscv64" ]] || { echo "Only supports riscv64"; exit 1; }
|
local lowest=""
|
||||||
|
|
||||||
install_ok=0
|
. /etc/os-release
|
||||||
|
|
||||||
|
OS_ID="${ID:-}"
|
||||||
|
OS_NAME="${NAME:-$OS_ID}"
|
||||||
|
OS_VERSION_ID="${VERSION_ID:-}"
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "$OS_ID" in
|
||||||
|
rhel|rocky|almalinux|fedora|centos)
|
||||||
|
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
||||||
|
This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
riscv64) ;;
|
||||||
|
*) die "Only supports riscv64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
current_kernel="$(uname -r)"
|
||||||
|
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
||||||
|
|
||||||
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
|
local install_ok=0
|
||||||
|
local tmp_dotnet=""
|
||||||
|
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
sudo dnf -y install \
|
sudo dnf -y install \
|
||||||
rpm-build rpmdevtools curl unzip tar jq rsync git python3 gcc make \
|
rpm-build rpmdevtools curl unzip tar jq rsync git python3 \
|
||||||
glibc-devel kernel-headers libatomic file ca-certificates libicu \
|
glibc-devel kernel-headers libatomic file ca-certificates libicu \
|
||||||
&& install_ok=1
|
&& install_ok=1
|
||||||
|
|
||||||
|
|
@ -191,42 +116,39 @@ if command -v dnf >/dev/null 2>&1; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
echo "Could not auto-install dependencies for '$ID'. Make sure these are available:"
|
echo "Could not auto-install dependencies for '$OS_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)"
|
echo "dotnet-riscv SDK, curl, unzip, tar, rsync, git, python3, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Root directory
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
# Git submodules (best effort)
|
|
||||||
if [[ -f .gitmodules ]]; then
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Locate project
|
PROJECT="$PROJECT_HINT"
|
||||||
PROJECT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||||
if [[ ! -f "$PROJECT" ]]; then
|
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
||||||
PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
}
|
||||||
fi
|
|
||||||
[[ -f "$PROJECT" ]] || { echo "v2rayN.Desktop.csproj not found"; exit 1; }
|
|
||||||
|
|
||||||
choose_channel() {
|
choose_channel() {
|
||||||
# If --buildfrom provided, map it directly and skip interaction.
|
local ch="latest"
|
||||||
|
local sel=""
|
||||||
|
|
||||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||||
case "$BUILD_FROM" in
|
case "$BUILD_FROM" in
|
||||||
1) echo "latest"; return 0 ;;
|
1) echo "latest"; return 0 ;;
|
||||||
2) echo "prerelease"; return 0 ;;
|
2) echo "prerelease"; return 0 ;;
|
||||||
3) echo "keep"; return 0 ;;
|
3) echo "keep"; return 0 ;;
|
||||||
*) echo "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." >&2; exit 1;;
|
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print menu to stderr and read from /dev/tty so stdout only carries the token.
|
|
||||||
local ch="latest" sel=""
|
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
echo "[?] Choose v2rayN release channel:" >&2
|
echo "[?] Choose v2rayN release channel:" >&2
|
||||||
echo " 1) Latest (stable) [default]" >&2
|
echo " 1) Latest (stable) [default]" >&2
|
||||||
|
|
@ -257,29 +179,35 @@ get_latest_tag_prerelease() {
|
||||||
| sed 's/^v//'
|
| sed 's/^v//'
|
||||||
}
|
}
|
||||||
|
|
||||||
git_try_checkout() {
|
sync_submodules() {
|
||||||
# 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
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_try_checkout() {
|
||||||
|
local want="$1"
|
||||||
|
local ref=""
|
||||||
|
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
git fetch --tags --force --prune --depth=1 || true
|
||||||
|
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
||||||
|
|
||||||
|
if [[ -n "$ref" ]]; then
|
||||||
|
echo "[OK] Found ref '${ref}', checking out..."
|
||||||
|
git checkout -f "$ref"
|
||||||
|
sync_submodules
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_channel_or_keep() {
|
apply_channel_or_keep() {
|
||||||
local ch="$1" tag
|
local ch="$1"
|
||||||
|
local tag=""
|
||||||
|
|
||||||
if [[ "$ch" == "keep" ]]; then
|
if [[ "$ch" == "keep" ]]; then
|
||||||
echo "[*] Keep current repository state (no checkout)."
|
echo "[*] Keep current repository state (no checkout)."
|
||||||
|
|
@ -289,31 +217,33 @@ apply_channel_or_keep() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
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; }
|
case "$ch" in
|
||||||
|
latest) tag="$(get_latest_tag_latest || true)" ;;
|
||||||
|
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
||||||
|
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
||||||
|
|
||||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||||
git_try_checkout "$tag" || { echo "Failed to checkout '${tag}'."; exit 1; }
|
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
||||||
VERSION="${tag#v}"
|
VERSION="${tag#v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||||
clean_ver="${VERSION_ARG#v}"
|
local clean_ver="${VERSION_ARG#v}"
|
||||||
|
|
||||||
if git_try_checkout "$clean_ver"; then
|
if git_try_checkout "$clean_ver"; then
|
||||||
VERSION="$clean_ver"
|
VERSION="$clean_ver"
|
||||||
else
|
else
|
||||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Current directory is not a git repo; proceeding on current tree."
|
echo "Current directory is not a git repo; proceeding on current tree."
|
||||||
|
|
@ -322,70 +252,116 @@ fi
|
||||||
|
|
||||||
VERSION="${VERSION#v}"
|
VERSION="${VERSION#v}"
|
||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
|
}
|
||||||
|
|
||||||
# riscv64 patch
|
xray_url_for_rid() {
|
||||||
apply_riscv_patch
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-riscv64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
singbox_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-riscv64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-riscv64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Helpers for core
|
|
||||||
download_xray() {
|
download_xray() {
|
||||||
# Download Xray core
|
local outdir="$1"
|
||||||
local outdir="$1" rid="$2" ver="${XRAY_VER:-}" url="" tmp zipname="xray.zip"
|
local rid="$2"
|
||||||
|
local ver="${XRAY_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
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
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||||
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"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$zipname"
|
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$tmp/$zipname" -d "$tmp"
|
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray"
|
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_singbox() {
|
download_singbox() {
|
||||||
# Download sing-box
|
local outdir="$1"
|
||||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url="" tmp tarname="singbox.tar.gz" bin cronet
|
local rid="$2"
|
||||||
|
local ver="${SING_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local bin=""
|
||||||
|
local cronet=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
| head -n1)" || true
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||||
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"
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$tarname"
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
tar -C "$tmp" -xzf "$tmp/$tarname"
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$bin" "$outdir/sing-box"
|
|
||||||
|
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move geo files to outroot/bin
|
|
||||||
unify_geo_layout() {
|
unify_geo_layout() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
mkdir -p "$outroot/bin"
|
local n
|
||||||
local names=( \
|
local names=(
|
||||||
"geosite.dat" \
|
geosite.dat
|
||||||
"geoip.dat" \
|
geoip.dat
|
||||||
"geoip-only-cn-private.dat" \
|
geoip-only-cn-private.dat
|
||||||
"Country.mmdb" \
|
Country.mmdb
|
||||||
"geoip.metadb" \
|
geoip.metadb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin"
|
||||||
|
|
||||||
for n in "${names[@]}"; do
|
for n in "${names[@]}"; do
|
||||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
||||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
||||||
|
|
@ -393,57 +369,48 @@ unify_geo_layout() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download geo/rule assets
|
|
||||||
download_geo_assets() {
|
download_geo_assets() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
local bin_dir="$outroot/bin"
|
local bin_dir="$outroot/bin"
|
||||||
local srss_dir="$bin_dir/srss"
|
local srss_dir="$bin_dir/srss"
|
||||||
|
local f=""
|
||||||
|
|
||||||
mkdir -p "$bin_dir" "$srss_dir"
|
mkdir -p "$bin_dir" "$srss_dir"
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
echo "[+] Download Xray Geo to ${bin_dir}"
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" \
|
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/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.dat" \
|
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
||||||
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
||||||
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"
|
echo "[+] Download sing-box rule DB & rule-sets"
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" \
|
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
||||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb" || true
|
|
||||||
|
|
||||||
for f in \
|
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
|
||||||
geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs \
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
||||||
geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
done
|
||||||
curl -fsSL -o "$srss_dir/$f" \
|
|
||||||
"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-geoip/$f" || true
|
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
|
||||||
done
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
||||||
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
|
done
|
||||||
|
|
||||||
# Unify to bin
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prefer the prebuilt v2rayN core bundle; then unify geo layout
|
populate_assets_zip_mode() {
|
||||||
download_v2rayn_bundle() {
|
local outroot="$1"
|
||||||
local outroot="$1" rid="$2"
|
local rid="$2"
|
||||||
local url=""
|
local url=""
|
||||||
if [[ "$rid" == "linux-riscv64" ]]; then
|
local tmp=""
|
||||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-riscv64.zip"
|
local nested_dir=""
|
||||||
fi
|
|
||||||
[[ -n "$url" ]] || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||||
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
local tmp zipname
|
|
||||||
tmp="$(mktemp -d)"; zipname="$tmp/v2rayn.zip"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$zipname" || { echo "[!] Bundle download failed"; return 1; }
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$zipname" -d "$tmp" || { echo "[!] Bundle unzip failed"; return 1; }
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
if [[ -d "$tmp/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -455,7 +422,6 @@ download_v2rayn_bundle() {
|
||||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 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)"
|
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -463,111 +429,73 @@ download_v2rayn_bundle() {
|
||||||
rm -rf "$nested_dir"
|
rm -rf "$nested_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unify to bin/
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
echo "[+] Bundle extracted to $outroot"
|
echo "[+] Bundle extracted to $outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===== Build results collection ========================================================
|
populate_assets_netcore_mode() {
|
||||||
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"
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_xray "$outroot/bin/xray" "$RID_DIR" || echo "[!] xray download failed (skipped)"
|
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_singbox "$outroot/bin/sing_box" "$RID_DIR" || echo "[!] sing-box download failed (skipped)"
|
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage_runtime_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
if download_v2rayn_bundle "$WORKDIR/$PKGROOT" "$RID_DIR"; then
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
echo "[*] Using v2rayN bundle archive."
|
echo "[*] Using v2rayN bundle archive."
|
||||||
else
|
else
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[*] --netcore specified: use separate core + rules."
|
echo "[*] --netcore specified: use separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Tarball
|
describe_target() {
|
||||||
mkdir -p "$SOURCEDIR"
|
local short="$1"
|
||||||
tar -C "$WORKDIR" -czf "$SOURCEDIR/$PKGROOT.tar.gz" "$PKGROOT"
|
|
||||||
|
|
||||||
# SPEC
|
case "$short" in
|
||||||
local SPECFILE="$SPECDIR/v2rayN.spec"
|
riscv64) printf '%s\n%s\n%s\n' "linux-riscv64" "riscv64" "riscv64" ;;
|
||||||
mkdir -p "$SPECDIR"
|
*) echo "Unknown arch '$short' (use riscv64)" >&2; return 1 ;;
|
||||||
cat > "$SPECFILE" <<'SPEC'
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
publish_binary() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
dotnet clean "$PROJECT" -c Release
|
||||||
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
|
dotnet restore "$PROJECT"
|
||||||
|
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
||||||
|
}
|
||||||
|
|
||||||
|
write_spec_file() {
|
||||||
|
local specfile="$1"
|
||||||
|
|
||||||
|
cat > "$specfile" <<'SPEC'
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
%undefine _debuginfo_subpackages
|
%undefine _debuginfo_subpackages
|
||||||
%undefine _debugsource_packages
|
%undefine _debugsource_packages
|
||||||
# Ignore outdated LTTng dependencies incorrectly reported by the .NET runtime (to avoid installation failures)
|
|
||||||
%global __requires_exclude ^liblttng-ust\.so\..*$
|
%global __requires_exclude ^liblttng-ust\.so\..*$
|
||||||
|
|
||||||
Name: v2rayN
|
Name: v2rayN
|
||||||
|
|
@ -580,7 +508,6 @@ BugURL: https://github.com/2dust/v2rayN/issues
|
||||||
ExclusiveArch: riscv64
|
ExclusiveArch: riscv64
|
||||||
Source0: __PKGROOT__.tar.gz
|
Source0: __PKGROOT__.tar.gz
|
||||||
|
|
||||||
# Runtime dependencies (Avalonia / X11 / Fonts / GL)
|
|
||||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
||||||
Requires: glibc >= 2.34
|
Requires: glibc >= 2.34
|
||||||
Requires: fontconfig >= 2.13.1
|
Requires: fontconfig >= 2.13.1
|
||||||
|
|
@ -601,32 +528,23 @@ https://github.com/2dust/v2rayN
|
||||||
%setup -q -n __PKGROOT__
|
%setup -q -n __PKGROOT__
|
||||||
|
|
||||||
%build
|
%build
|
||||||
# no build
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
install -dm0755 %{buildroot}/opt/v2rayN
|
install -dm0755 %{buildroot}/opt/v2rayN
|
||||||
cp -a * %{buildroot}/opt/v2rayN/
|
cp -a * %{buildroot}/opt/v2rayN/
|
||||||
|
|
||||||
# Normalize permissions
|
|
||||||
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
||||||
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
||||||
[ -f %{buildroot}/opt/v2rayN/v2rayN ] && chmod 0755 %{buildroot}/opt/v2rayN/v2rayN || :
|
[ -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 -dm0755 %{buildroot}%{_bindir}
|
||||||
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
DIR="/opt/v2rayN"
|
DIR="/opt/v2rayN"
|
||||||
export LD_LIBRARY_PATH="$DIR:${LD_LIBRARY_PATH:-}"
|
|
||||||
|
|
||||||
# Prefer native apphost
|
|
||||||
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
||||||
|
|
||||||
# DLL fallback
|
|
||||||
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
||||||
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
||||||
done
|
done
|
||||||
|
|
@ -636,7 +554,6 @@ ls -l "$DIR" >&2 || true
|
||||||
exit 1
|
exit 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Desktop file
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/applications
|
install -dm0755 %{buildroot}%{_datadir}/applications
|
||||||
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
|
|
@ -649,7 +566,6 @@ Terminal=false
|
||||||
Categories=Network;
|
Categories=Network;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Icon
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
||||||
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||||
|
|
||||||
|
|
@ -668,28 +584,82 @@ install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons
|
||||||
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||||
SPEC
|
SPEC
|
||||||
|
|
||||||
# Replace placeholders
|
sed -i "s/__VERSION__/${VERSION}/g" "$specfile"
|
||||||
sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE"
|
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$specfile"
|
||||||
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE"
|
}
|
||||||
|
|
||||||
# Build RPM for this arch
|
package_binary() {
|
||||||
rpmbuild -ba "$SPECFILE" --target "$rpm_target"
|
local short="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local rpm_target="$3"
|
||||||
|
local archdir="$4"
|
||||||
|
local pubdir=""
|
||||||
|
local workdir=""
|
||||||
|
local specfile=""
|
||||||
|
local sourcedir=""
|
||||||
|
local specdir=""
|
||||||
|
local project_dir=""
|
||||||
|
local icon_candidate=""
|
||||||
|
local f=""
|
||||||
|
|
||||||
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
|
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
||||||
|
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
|
|
||||||
|
mkdir -p "$workdir/$PKGROOT"
|
||||||
|
cp -a "$pubdir/." "$workdir/$PKGROOT/"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
stage_runtime_assets "$workdir/$PKGROOT" "$rid"
|
||||||
|
|
||||||
|
rpmdev-setuptree
|
||||||
|
sourcedir="${RPM_TOPDIR}/SOURCES"
|
||||||
|
specdir="${RPM_TOPDIR}/SPECS"
|
||||||
|
specfile="${specdir}/v2rayN.spec"
|
||||||
|
|
||||||
|
mkdir -p "$sourcedir" "$specdir"
|
||||||
|
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
||||||
|
|
||||||
|
write_spec_file "$specfile"
|
||||||
|
rpmbuild -ba "$specfile" --target "$rpm_target"
|
||||||
|
|
||||||
echo "Build done for $short. RPM at:"
|
echo "Build done for $short. RPM at:"
|
||||||
local f
|
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
||||||
for f in "${TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
|
||||||
[[ -e "$f" ]] || continue
|
[[ -e "$f" ]] || continue
|
||||||
echo " $f"
|
echo " $f"
|
||||||
BUILT_RPMS+=("$f")
|
BUILT_RPMS+=("$f")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===== Arch selection and build orchestration =========================================
|
select_targets() {
|
||||||
targets=(riscv64)
|
printf '%s\n' riscv64
|
||||||
|
}
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
build_one_target() {
|
||||||
build_for_arch "$arch"
|
local short="$1"
|
||||||
done
|
local meta=()
|
||||||
|
local rid=""
|
||||||
|
local rpm_target=""
|
||||||
|
local archdir=""
|
||||||
|
|
||||||
|
mapfile -t meta < <(describe_target "$short") || return 1
|
||||||
|
rid="${meta[0]}"
|
||||||
|
rpm_target="${meta[1]}"
|
||||||
|
archdir="${meta[2]}"
|
||||||
|
|
||||||
|
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
||||||
|
publish_binary "$rid"
|
||||||
|
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
local rp=""
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "================ Build Summary ================"
|
echo "================ Build Summary ================"
|
||||||
|
|
@ -701,3 +671,25 @@ else
|
||||||
echo "No RPMs detected in summary (check build logs above)."
|
echo "No RPMs detected in summary (check build logs above)."
|
||||||
fi
|
fi
|
||||||
echo "=============================================="
|
echo "=============================================="
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local targets=()
|
||||||
|
local arch=""
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
detect_environment
|
||||||
|
install_dependencies
|
||||||
|
prepare_workspace
|
||||||
|
resolve_version
|
||||||
|
|
||||||
|
mapfile -t targets < <(select_targets)
|
||||||
|
|
||||||
|
for arch in "${targets[@]}"; do
|
||||||
|
build_one_target "$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
|
||||||
627
package-rhel.sh
627
package-rhel.sh
|
|
@ -1,48 +1,43 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
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="6.11"
|
|
||||||
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
|
|
||||||
ARCH_OVERRIDE="" # --arch x64|arm64|all (optional compile target)
|
|
||||||
BUILD_FROM="" # --buildfrom 1|2|3 to select channel non-interactively
|
|
||||||
|
|
||||||
# If the first argument starts with --, do not treat it as a version number
|
|
||||||
if [[ "${VERSION_ARG:-}" == --* ]]; then
|
|
||||||
VERSION_ARG=""
|
VERSION_ARG=""
|
||||||
fi
|
WITH_CORE="both"
|
||||||
# Take the first non --* argument as version, discard it
|
FORCE_NETCORE=0
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then shift || true; fi
|
ARCH_OVERRIDE=""
|
||||||
|
BUILD_FROM=""
|
||||||
|
XRAY_VER="${XRAY_VER:-}"
|
||||||
|
SING_VER="${SING_VER:-}"
|
||||||
|
|
||||||
|
MIN_KERNEL="6.12"
|
||||||
|
PKGROOT="v2rayN-publish"
|
||||||
|
PROJECT_HINT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
||||||
|
RPM_TOPDIR="${HOME}/rpmbuild"
|
||||||
|
|
||||||
|
OS_ID=""
|
||||||
|
OS_NAME=""
|
||||||
|
OS_VERSION_ID=""
|
||||||
|
HOST_ARCH=""
|
||||||
|
SCRIPT_DIR=""
|
||||||
|
PROJECT=""
|
||||||
|
VERSION=""
|
||||||
|
BUILT_ALL=0
|
||||||
|
|
||||||
|
declare -a BUILT_RPMS=()
|
||||||
|
|
||||||
|
die() {
|
||||||
|
echo "$*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_args() {
|
||||||
|
local first_arg="${1:-}"
|
||||||
|
|
||||||
|
if [[ -n "$first_arg" && "$first_arg" != --* ]]; then
|
||||||
|
VERSION_ARG="$first_arg"
|
||||||
|
shift || true
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse remaining optional arguments
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
--with-core) WITH_CORE="${2:-both}"; shift 2 ;;
|
||||||
|
|
@ -52,65 +47,93 @@ while [[ $# -gt 0 ]]; do
|
||||||
--arch) ARCH_OVERRIDE="${2:-}"; shift 2 ;;
|
--arch) ARCH_OVERRIDE="${2:-}"; shift 2 ;;
|
||||||
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
--buildfrom) BUILD_FROM="${2:-}"; shift 2 ;;
|
||||||
*)
|
*)
|
||||||
if [[ -z "${VERSION_ARG:-}" ]]; then VERSION_ARG="$1"; fi
|
[[ -n "${VERSION_ARG:-}" ]] || VERSION_ARG="$1"
|
||||||
shift;;
|
shift
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Conflict: version number AND --buildfrom cannot be used together
|
|
||||||
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" && -n "${BUILD_FROM:-}" ]]; then
|
||||||
echo "You cannot specify both an explicit version and --buildfrom at the same time."
|
die "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."
|
Provide either a version (e.g. 7.14.0) OR --buildfrom 1|2|3."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check and install dependencies
|
detect_environment() {
|
||||||
host_arch="$(uname -m)"
|
local current_kernel=""
|
||||||
[[ "$host_arch" == "aarch64" || "$host_arch" == "x86_64" ]] || { echo "Only supports aarch64 / x86_64"; exit 1; }
|
local lowest=""
|
||||||
|
|
||||||
install_ok=0
|
. /etc/os-release
|
||||||
|
|
||||||
|
OS_ID="${ID:-}"
|
||||||
|
OS_NAME="${NAME:-$OS_ID}"
|
||||||
|
OS_VERSION_ID="${VERSION_ID:-}"
|
||||||
|
HOST_ARCH="$(uname -m)"
|
||||||
|
|
||||||
|
case "$OS_ID" in
|
||||||
|
rhel|rocky|almalinux|fedora|centos)
|
||||||
|
echo "Detected supported system: ${OS_NAME:-$OS_ID} ${OS_VERSION_ID:-}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
die "Unsupported system: ${OS_NAME:-unknown} (${OS_ID:-unknown}).
|
||||||
|
This script only supports: RHEL / Rocky / AlmaLinux / Fedora / CentOS."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$HOST_ARCH" in
|
||||||
|
x86_64|aarch64) ;;
|
||||||
|
*) die "Only supports aarch64 / x86_64" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
current_kernel="$(uname -r)"
|
||||||
|
lowest="$(printf '%s\n%s\n' "$MIN_KERNEL" "$current_kernel" | sort -V | head -n1)"
|
||||||
|
|
||||||
|
[[ "$lowest" == "$MIN_KERNEL" ]] || die "Kernel $current_kernel is below $MIN_KERNEL"
|
||||||
|
echo "[OK] Kernel $current_kernel verified."
|
||||||
|
}
|
||||||
|
|
||||||
|
install_dependencies() {
|
||||||
|
local install_ok=0
|
||||||
|
|
||||||
if command -v dnf >/dev/null 2>&1; then
|
if command -v dnf >/dev/null 2>&1; then
|
||||||
sudo dnf -y install rpm-build rpmdevtools curl unzip tar jq rsync dotnet-sdk-8.0 \
|
sudo dnf -y install rpm-build rpmdevtools curl unzip tar jq rsync dotnet-sdk-10.0 \
|
||||||
&& install_ok=1
|
&& install_ok=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$install_ok" -ne 1 ]]; then
|
if [[ "$install_ok" -ne 1 ]]; then
|
||||||
echo "Could not auto-install dependencies for '$ID'. Make sure these are available:"
|
echo "Could not auto-install dependencies for '$OS_ID'. Make sure these are available:"
|
||||||
echo "dotnet-sdk 8.x, curl, unzip, tar, rsync, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
echo "dotnet-sdk 10.x, curl, unzip, tar, rsync, rpm, rpmdevtools, rpm-build (on Red Hat branch)"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Root directory
|
prepare_workspace() {
|
||||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
# Git submodules (best effort)
|
|
||||||
if [[ -f .gitmodules ]]; then
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Locate project
|
PROJECT="$PROJECT_HINT"
|
||||||
PROJECT="v2rayN.Desktop/v2rayN.Desktop.csproj"
|
[[ -f "$PROJECT" ]] || PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
||||||
if [[ ! -f "$PROJECT" ]]; then
|
[[ -f "$PROJECT" ]] || die "v2rayN.Desktop.csproj not found"
|
||||||
PROJECT="$(find . -maxdepth 3 -name 'v2rayN.Desktop.csproj' | head -n1 || true)"
|
}
|
||||||
fi
|
|
||||||
[[ -f "$PROJECT" ]] || { echo "v2rayN.Desktop.csproj not found"; exit 1; }
|
|
||||||
|
|
||||||
choose_channel() {
|
choose_channel() {
|
||||||
# If --buildfrom provided, map it directly and skip interaction.
|
local ch="latest"
|
||||||
|
local sel=""
|
||||||
|
|
||||||
if [[ -n "${BUILD_FROM:-}" ]]; then
|
if [[ -n "${BUILD_FROM:-}" ]]; then
|
||||||
case "$BUILD_FROM" in
|
case "$BUILD_FROM" in
|
||||||
1) echo "latest"; return 0 ;;
|
1) echo "latest"; return 0 ;;
|
||||||
2) echo "prerelease"; return 0 ;;
|
2) echo "prerelease"; return 0 ;;
|
||||||
3) echo "keep"; return 0 ;;
|
3) echo "keep"; return 0 ;;
|
||||||
*) echo "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." >&2; exit 1;;
|
*) die "[ERROR] Invalid --buildfrom value: ${BUILD_FROM}. Use 1|2|3." ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Print menu to stderr and read from /dev/tty so stdout only carries the token.
|
|
||||||
local ch="latest" sel=""
|
|
||||||
|
|
||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
echo "[?] Choose v2rayN release channel:" >&2
|
echo "[?] Choose v2rayN release channel:" >&2
|
||||||
echo " 1) Latest (stable) [default]" >&2
|
echo " 1) Latest (stable) [default]" >&2
|
||||||
|
|
@ -141,29 +164,35 @@ get_latest_tag_prerelease() {
|
||||||
| sed 's/^v//'
|
| sed 's/^v//'
|
||||||
}
|
}
|
||||||
|
|
||||||
git_try_checkout() {
|
sync_submodules() {
|
||||||
# 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
|
if [[ -f .gitmodules ]]; then
|
||||||
git submodule sync --recursive || true
|
git submodule sync --recursive || true
|
||||||
git submodule update --init --recursive || true
|
git submodule update --init --recursive || true
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_try_checkout() {
|
||||||
|
local want="$1"
|
||||||
|
local ref=""
|
||||||
|
|
||||||
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
|
git fetch --tags --force --prune --depth=1 || true
|
||||||
|
git rev-parse "refs/tags/${want}" >/dev/null 2>&1 && ref="$want"
|
||||||
|
|
||||||
|
if [[ -n "$ref" ]]; then
|
||||||
|
echo "[OK] Found ref '${ref}', checking out..."
|
||||||
|
git checkout -f "$ref"
|
||||||
|
sync_submodules
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_channel_or_keep() {
|
apply_channel_or_keep() {
|
||||||
local ch="$1" tag
|
local ch="$1"
|
||||||
|
local tag=""
|
||||||
|
|
||||||
if [[ "$ch" == "keep" ]]; then
|
if [[ "$ch" == "keep" ]]; then
|
||||||
echo "[*] Keep current repository state (no checkout)."
|
echo "[*] Keep current repository state (no checkout)."
|
||||||
|
|
@ -173,31 +202,33 @@ apply_channel_or_keep() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[*] Resolving ${ch} tag from GitHub releases..."
|
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; }
|
case "$ch" in
|
||||||
|
latest) tag="$(get_latest_tag_latest || true)" ;;
|
||||||
|
prerelease) tag="$(get_latest_tag_prerelease || true)" ;;
|
||||||
|
*) die "Failed to resolve latest tag for channel '${ch}'." ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[[ -n "$tag" ]] || die "Failed to resolve latest tag for channel '${ch}'."
|
||||||
|
|
||||||
echo "[*] Latest tag for '${ch}': ${tag}"
|
echo "[*] Latest tag for '${ch}': ${tag}"
|
||||||
git_try_checkout "$tag" || { echo "Failed to checkout '${tag}'."; exit 1; }
|
git_try_checkout "$tag" || die "Failed to checkout '${tag}'."
|
||||||
VERSION="${tag#v}"
|
VERSION="${tag#v}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||||
if [[ -n "${VERSION_ARG:-}" ]]; then
|
if [[ -n "${VERSION_ARG:-}" ]]; then
|
||||||
clean_ver="${VERSION_ARG#v}"
|
local clean_ver="${VERSION_ARG#v}"
|
||||||
|
|
||||||
if git_try_checkout "$clean_ver"; then
|
if git_try_checkout "$clean_ver"; then
|
||||||
VERSION="$clean_ver"
|
VERSION="$clean_ver"
|
||||||
else
|
else
|
||||||
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
echo "[WARN] Tag '${VERSION_ARG}' not found."
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ch="$(choose_channel)"
|
apply_channel_or_keep "$(choose_channel)"
|
||||||
apply_channel_or_keep "$ch"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Current directory is not a git repo; proceeding on current tree."
|
echo "Current directory is not a git repo; proceeding on current tree."
|
||||||
|
|
@ -206,69 +237,119 @@ fi
|
||||||
|
|
||||||
VERSION="${VERSION#v}"
|
VERSION="${VERSION#v}"
|
||||||
echo "[*] GUI version resolved as: ${VERSION}"
|
echo "[*] GUI version resolved as: ${VERSION}"
|
||||||
|
}
|
||||||
|
|
||||||
|
xray_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip" ;;
|
||||||
|
linux-arm64) echo "https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
singbox_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
local ver="$2"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz" ;;
|
||||||
|
linux-arm64) echo "https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle_url_for_rid() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
case "$rid" in
|
||||||
|
linux-x64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip" ;;
|
||||||
|
linux-arm64) echo "https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip" ;;
|
||||||
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# Helpers for core
|
|
||||||
download_xray() {
|
download_xray() {
|
||||||
# Download Xray core
|
local outdir="$1"
|
||||||
local outdir="$1" rid="$2" ver="${XRAY_VER:-}" url tmp zipname="xray.zip"
|
local rid="$2"
|
||||||
|
local ver="${XRAY_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/XTLS/Xray-core/releases/latest \
|
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
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[xray] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
url="$(xray_url_for_rid "$rid" "$ver")" || { echo "[xray] Unsupported RID: $rid"; return 1; }
|
||||||
url="https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-arm64-v8a.zip"
|
|
||||||
else
|
|
||||||
url="https://github.com/XTLS/Xray-core/releases/download/v${ver}/Xray-linux-64.zip"
|
|
||||||
fi
|
|
||||||
echo "[+] Download xray: $url"
|
echo "[+] Download xray: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$zipname"
|
curl -fL "$url" -o "$tmp/xray.zip" || { rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$tmp/$zipname" -d "$tmp"
|
unzip -q "$tmp/xray.zip" -d "$tmp" || { rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$tmp/xray" "$outdir/xray"
|
install -m 755 "$tmp/xray" "$outdir/xray" || { rm -rf "$tmp"; return 1; }
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_singbox() {
|
download_singbox() {
|
||||||
# Download sing-box
|
local outdir="$1"
|
||||||
local outdir="$1" rid="$2" ver="${SING_VER:-}" url tmp tarname="singbox.tar.gz" bin cronet
|
local rid="$2"
|
||||||
|
local ver="${SING_VER:-}"
|
||||||
|
local url=""
|
||||||
|
local tmp=""
|
||||||
|
local bin=""
|
||||||
|
local cronet=""
|
||||||
|
|
||||||
mkdir -p "$outdir"
|
mkdir -p "$outdir"
|
||||||
|
|
||||||
if [[ -z "$ver" ]]; then
|
if [[ -z "$ver" ]]; then
|
||||||
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
ver="$(curl -fsSL https://api.github.com/repos/SagerNet/sing-box/releases/latest \
|
||||||
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
| grep -Eo '"tag_name":\s*"v[^"]+"' \
|
||||||
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
| sed -E 's/.*"v([^"]+)".*/\1/' \
|
||||||
| head -n1)" || true
|
| head -n1)" || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
[[ -n "$ver" ]] || { echo "[sing-box] Failed to get version"; return 1; }
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
url="$(singbox_url_for_rid "$rid" "$ver")" || { echo "[sing-box] Unsupported RID: $rid"; return 1; }
|
||||||
url="https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-arm64.tar.gz"
|
|
||||||
else
|
|
||||||
url="https://github.com/SagerNet/sing-box/releases/download/v${ver}/sing-box-${ver}-linux-amd64.tar.gz"
|
|
||||||
fi
|
|
||||||
echo "[+] Download sing-box: $url"
|
echo "[+] Download sing-box: $url"
|
||||||
|
|
||||||
tmp="$(mktemp -d)"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$tmp/$tarname"
|
curl -fL "$url" -o "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
tar -C "$tmp" -xzf "$tmp/$tarname"
|
tar -C "$tmp" -xzf "$tmp/singbox.tar.gz" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
bin="$(find "$tmp" -type f -name 'sing-box' | head -n1 || true)"
|
||||||
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
[[ -n "$bin" ]] || { echo "[!] sing-box unpack failed"; rm -rf "$tmp"; return 1; }
|
||||||
install -m 755 "$bin" "$outdir/sing-box"
|
|
||||||
|
install -m 755 "$bin" "$outdir/sing-box" || { rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
cronet="$(find "$tmp" -type f -name 'libcronet*.so*' | head -n1 || true)"
|
||||||
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so"
|
[[ -n "$cronet" ]] && install -m 644 "$cronet" "$outdir/libcronet.so" || true
|
||||||
|
|
||||||
rm -rf "$tmp"
|
rm -rf "$tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move geo files to outroot/bin
|
|
||||||
unify_geo_layout() {
|
unify_geo_layout() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
mkdir -p "$outroot/bin"
|
local n
|
||||||
local names=( \
|
local names=(
|
||||||
"geosite.dat" \
|
geosite.dat
|
||||||
"geoip.dat" \
|
geoip.dat
|
||||||
"geoip-only-cn-private.dat" \
|
geoip-only-cn-private.dat
|
||||||
"Country.mmdb" \
|
Country.mmdb
|
||||||
"geoip.metadb" \
|
geoip.metadb
|
||||||
)
|
)
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin"
|
||||||
|
|
||||||
for n in "${names[@]}"; do
|
for n in "${names[@]}"; do
|
||||||
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
if [[ -f "$outroot/bin/xray/$n" ]]; then
|
||||||
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
mv -f "$outroot/bin/xray/$n" "$outroot/bin/$n"
|
||||||
|
|
@ -276,58 +357,48 @@ unify_geo_layout() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download geo/rule assets
|
|
||||||
download_geo_assets() {
|
download_geo_assets() {
|
||||||
local outroot="$1"
|
local outroot="$1"
|
||||||
local bin_dir="$outroot/bin"
|
local bin_dir="$outroot/bin"
|
||||||
local srss_dir="$bin_dir/srss"
|
local srss_dir="$bin_dir/srss"
|
||||||
|
local f=""
|
||||||
|
|
||||||
mkdir -p "$bin_dir" "$srss_dir"
|
mkdir -p "$bin_dir" "$srss_dir"
|
||||||
|
|
||||||
echo "[+] Download Xray Geo to ${bin_dir}"
|
echo "[+] Download Xray Geo to ${bin_dir}"
|
||||||
curl -fsSL -o "$bin_dir/geosite.dat" \
|
curl -fsSL -o "$bin_dir/geosite.dat" "https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/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.dat" \
|
curl -fsSL -o "$bin_dir/geoip-only-cn-private.dat" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/geoip-only-cn-private.dat"
|
||||||
"https://github.com/Loyalsoldier/V2ray-rules-dat/releases/latest/download/geoip.dat"
|
curl -fsSL -o "$bin_dir/Country.mmdb" "https://raw.githubusercontent.com/Loyalsoldier/geoip/release/Country.mmdb"
|
||||||
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"
|
echo "[+] Download sing-box rule DB & rule-sets"
|
||||||
curl -fsSL -o "$bin_dir/geoip.metadb" \
|
curl -fsSL -o "$bin_dir/geoip.metadb" "https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb"
|
||||||
"https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb" || true
|
|
||||||
|
|
||||||
for f in \
|
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
|
||||||
geoip-private.srs geoip-cn.srs geoip-facebook.srs geoip-fastly.srs \
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geoip/$f"
|
||||||
geoip-google.srs geoip-netflix.srs geoip-telegram.srs geoip-twitter.srs; do
|
done
|
||||||
curl -fsSL -o "$srss_dir/$f" \
|
|
||||||
"https://raw.githubusercontent.com/2dust/sing-box-rules/rule-set-geoip/$f" || true
|
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
|
||||||
done
|
curl -fsSL -o "$srss_dir/$f" "https://raw.githubusercontent.com/2dust/sing-box-rules/refs/heads/rule-set-geosite/$f"
|
||||||
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
|
done
|
||||||
|
|
||||||
# Unify to bin
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prefer the prebuilt v2rayN core bundle; then unify geo layout
|
populate_assets_zip_mode() {
|
||||||
download_v2rayn_bundle() {
|
local outroot="$1"
|
||||||
local outroot="$1" rid="$2"
|
local rid="$2"
|
||||||
local url=""
|
local url=""
|
||||||
if [[ "$rid" == "linux-arm64" ]]; then
|
local tmp=""
|
||||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-arm64.zip"
|
local nested_dir=""
|
||||||
else
|
|
||||||
url="https://raw.githubusercontent.com/2dust/v2rayN-core-bin/refs/heads/master/v2rayN-linux-64.zip"
|
url="$(bundle_url_for_rid "$rid")" || { echo "[!] Bundle unsupported RID: $rid"; return 1; }
|
||||||
fi
|
|
||||||
echo "[+] Try v2rayN bundle archive: $url"
|
echo "[+] Try v2rayN bundle archive: $url"
|
||||||
local tmp zipname
|
|
||||||
tmp="$(mktemp -d)"; zipname="$tmp/v2rayn.zip"
|
tmp="$(mktemp -d)"
|
||||||
curl -fL "$url" -o "$zipname" || { echo "[!] Bundle download failed"; return 1; }
|
curl -fL "$url" -o "$tmp/v2rayn.zip" || { echo "[!] Bundle download failed"; rm -rf "$tmp"; return 1; }
|
||||||
unzip -q "$zipname" -d "$tmp" || { echo "[!] Bundle unzip failed"; return 1; }
|
unzip -q "$tmp/v2rayn.zip" -d "$tmp" || { echo "[!] Bundle unzip failed"; rm -rf "$tmp"; return 1; }
|
||||||
|
|
||||||
if [[ -d "$tmp/bin" ]]; then
|
if [[ -d "$tmp/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -339,7 +410,6 @@ download_v2rayn_bundle() {
|
||||||
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
rm -f "$outroot/v2rayn.zip" 2>/dev/null || true
|
||||||
find "$outroot" -type d -name "mihomo" -prune -exec rm -rf {} + 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)"
|
nested_dir="$(find "$outroot" -maxdepth 1 -type d -name 'v2rayN-linux-*' | head -n1 || true)"
|
||||||
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
if [[ -n "$nested_dir" && -d "$nested_dir/bin" ]]; then
|
||||||
mkdir -p "$outroot/bin"
|
mkdir -p "$outroot/bin"
|
||||||
|
|
@ -347,109 +417,74 @@ download_v2rayn_bundle() {
|
||||||
rm -rf "$nested_dir"
|
rm -rf "$nested_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unify to bin/
|
|
||||||
unify_geo_layout "$outroot"
|
unify_geo_layout "$outroot"
|
||||||
|
rm -rf "$tmp"
|
||||||
|
|
||||||
echo "[+] Bundle extracted to $outroot"
|
echo "[+] Bundle extracted to $outroot"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===== Build results collection for --arch all ========================================
|
populate_assets_netcore_mode() {
|
||||||
BUILT_RPMS=() # Will collect absolute paths of built RPMs
|
|
||||||
BUILT_ALL=0 # Flag to know if we should print the final summary
|
|
||||||
|
|
||||||
# ===== Build (single-arch) function ====================================================
|
|
||||||
build_for_arch() {
|
|
||||||
# $1: target short arch: x64 | arm64
|
|
||||||
local short="$1"
|
|
||||||
local rid rpm_target archdir
|
|
||||||
case "$short" in
|
|
||||||
x64) rid="linux-x64"; rpm_target="x86_64"; archdir="x86_64" ;;
|
|
||||||
arm64) rid="linux-arm64"; rpm_target="aarch64"; archdir="aarch64" ;;
|
|
||||||
*) echo "Unknown arch '$short' (use x64|arm64)"; 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
|
|
||||||
rm -rf "$(dirname "$PROJECT")/bin/Release/net8.0" || true
|
|
||||||
|
|
||||||
dotnet restore "$PROJECT"
|
|
||||||
dotnet publish "$PROJECT" \
|
|
||||||
-c Release -r "$rid" \
|
|
||||||
-p:PublishSingleFile=false \
|
|
||||||
-p:SelfContained=true
|
|
||||||
|
|
||||||
# Per-arch variables (scoped)
|
|
||||||
local RID_DIR="$rid"
|
|
||||||
local PUBDIR
|
|
||||||
PUBDIR="$(dirname "$PROJECT")/bin/Release/net8.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
|
|
||||||
rpmdev-setuptree
|
|
||||||
TOPDIR="${HOME}/rpmbuild"
|
|
||||||
SPECDIR="${TOPDIR}/SPECS"
|
|
||||||
SOURCEDIR="${TOPDIR}/SOURCES"
|
|
||||||
|
|
||||||
# Stage publish content
|
|
||||||
mkdir -p "$WORKDIR/$PKGROOT"
|
|
||||||
cp -a "$PUBDIR/." "$WORKDIR/$PKGROOT/"
|
|
||||||
|
|
||||||
# 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"
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "xray" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_xray "$outroot/bin/xray" "$RID_DIR" || echo "[!] xray download failed (skipped)"
|
download_xray "$outroot/bin/xray" "$rid" || echo "[!] xray download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
if [[ "$WITH_CORE" == "sing-box" || "$WITH_CORE" == "both" ]]; then
|
||||||
download_singbox "$outroot/bin/sing_box" "$RID_DIR" || echo "[!] sing-box download failed (skipped)"
|
download_singbox "$outroot/bin/sing_box" "$rid" || echo "[!] sing-box download failed (skipped)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
download_geo_assets "$outroot" || echo "[!] Geo rules download failed (skipped)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage_runtime_assets() {
|
||||||
|
local outroot="$1"
|
||||||
|
local rid="$2"
|
||||||
|
|
||||||
|
mkdir -p "$outroot/bin/xray" "$outroot/bin/sing_box"
|
||||||
|
|
||||||
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
if [[ "$FORCE_NETCORE" -eq 0 ]]; then
|
||||||
if download_v2rayn_bundle "$WORKDIR/$PKGROOT" "$RID_DIR"; then
|
if populate_assets_zip_mode "$outroot" "$rid"; then
|
||||||
echo "[*] Using v2rayN bundle archive."
|
echo "[*] Using v2rayN bundle archive."
|
||||||
else
|
else
|
||||||
echo "[*] Bundle failed, fallback to separate core + rules."
|
echo "[*] Bundle failed, fallback to separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[*] --netcore specified: use separate core + rules."
|
echo "[*] --netcore specified: use separate core + rules."
|
||||||
fetch_separate_cores_and_rules "$WORKDIR/$PKGROOT"
|
populate_assets_netcore_mode "$outroot" "$rid"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Tarball
|
describe_target() {
|
||||||
mkdir -p "$SOURCEDIR"
|
local short="$1"
|
||||||
tar -C "$WORKDIR" -czf "$SOURCEDIR/$PKGROOT.tar.gz" "$PKGROOT"
|
|
||||||
|
|
||||||
# SPEC
|
case "$short" in
|
||||||
local SPECFILE="$SPECDIR/v2rayN.spec"
|
x64) printf '%s\n%s\n%s\n' "linux-x64" "x86_64" "x86_64" ;;
|
||||||
mkdir -p "$SPECDIR"
|
arm64) printf '%s\n%s\n%s\n' "linux-arm64" "aarch64" "aarch64" ;;
|
||||||
cat > "$SPECFILE" <<'SPEC'
|
*) echo "Unknown arch '$short' (use x64|arm64)" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
publish_binary() {
|
||||||
|
local rid="$1"
|
||||||
|
|
||||||
|
dotnet clean "$PROJECT" -c Release
|
||||||
|
rm -rf "$(dirname "$PROJECT")/bin/Release/net10.0" || true
|
||||||
|
dotnet restore "$PROJECT"
|
||||||
|
dotnet publish "$PROJECT" -c Release -r "$rid" -p:PublishSingleFile=false -p:SelfContained=true
|
||||||
|
}
|
||||||
|
|
||||||
|
write_spec_file() {
|
||||||
|
local specfile="$1"
|
||||||
|
|
||||||
|
cat > "$specfile" <<'SPEC'
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
%undefine _debuginfo_subpackages
|
%undefine _debuginfo_subpackages
|
||||||
%undefine _debugsource_packages
|
%undefine _debugsource_packages
|
||||||
# Ignore outdated LTTng dependencies incorrectly reported by the .NET runtime (to avoid installation failures)
|
|
||||||
%global __requires_exclude ^liblttng-ust\.so\..*$
|
%global __requires_exclude ^liblttng-ust\.so\..*$
|
||||||
|
|
||||||
Name: v2rayN
|
Name: v2rayN
|
||||||
|
|
@ -462,7 +497,6 @@ BugURL: https://github.com/2dust/v2rayN/issues
|
||||||
ExclusiveArch: aarch64 x86_64
|
ExclusiveArch: aarch64 x86_64
|
||||||
Source0: __PKGROOT__.tar.gz
|
Source0: __PKGROOT__.tar.gz
|
||||||
|
|
||||||
# Runtime dependencies (Avalonia / X11 / Fonts / GL)
|
|
||||||
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
Requires: cairo, pango, openssl, mesa-libEGL, mesa-libGL
|
||||||
Requires: glibc >= 2.34
|
Requires: glibc >= 2.34
|
||||||
Requires: fontconfig >= 2.13.1
|
Requires: fontconfig >= 2.13.1
|
||||||
|
|
@ -483,28 +517,23 @@ https://github.com/2dust/v2rayN
|
||||||
%setup -q -n __PKGROOT__
|
%setup -q -n __PKGROOT__
|
||||||
|
|
||||||
%build
|
%build
|
||||||
# no build
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
install -dm0755 %{buildroot}/opt/v2rayN
|
install -dm0755 %{buildroot}/opt/v2rayN
|
||||||
cp -a * %{buildroot}/opt/v2rayN/
|
cp -a * %{buildroot}/opt/v2rayN/
|
||||||
|
|
||||||
# Normalize permissions
|
|
||||||
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
find %{buildroot}/opt/v2rayN -type d -exec chmod 0755 {} +
|
||||||
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
find %{buildroot}/opt/v2rayN -type f -exec chmod 0644 {} +
|
||||||
[ -f %{buildroot}/opt/v2rayN/v2rayN ] && chmod 0755 %{buildroot}/opt/v2rayN/v2rayN || :
|
[ -f %{buildroot}/opt/v2rayN/v2rayN ] && chmod 0755 %{buildroot}/opt/v2rayN/v2rayN || :
|
||||||
|
|
||||||
# Launcher (prefer native ELF first, then DLL fallback)
|
|
||||||
install -dm0755 %{buildroot}%{_bindir}
|
install -dm0755 %{buildroot}%{_bindir}
|
||||||
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
install -m0755 /dev/stdin %{buildroot}%{_bindir}/v2rayn << 'EOF'
|
||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
DIR="/opt/v2rayN"
|
DIR="/opt/v2rayN"
|
||||||
|
|
||||||
# Prefer native apphost
|
|
||||||
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
if [[ -x "$DIR/v2rayN" ]]; then exec "$DIR/v2rayN" "$@"; fi
|
||||||
|
|
||||||
# DLL fallback
|
|
||||||
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
for dll in v2rayN.Desktop.dll v2rayN.dll; do
|
||||||
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
if [[ -f "$DIR/$dll" ]]; then exec /usr/bin/dotnet "$DIR/$dll" "$@"; fi
|
||||||
done
|
done
|
||||||
|
|
@ -514,7 +543,6 @@ ls -l "$DIR" >&2 || true
|
||||||
exit 1
|
exit 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Desktop file
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/applications
|
install -dm0755 %{buildroot}%{_datadir}/applications
|
||||||
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
install -m0644 /dev/stdin %{buildroot}%{_datadir}/applications/v2rayn.desktop << 'EOF'
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
|
|
@ -527,7 +555,6 @@ Terminal=false
|
||||||
Categories=Network;
|
Categories=Network;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Icon
|
|
||||||
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
install -dm0755 %{buildroot}%{_datadir}/icons/hicolor/256x256/apps
|
||||||
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||||
|
|
||||||
|
|
@ -546,37 +573,98 @@ install -m0644 %{_builddir}/__PKGROOT__/v2rayn.png %{buildroot}%{_datadir}/icons
|
||||||
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
%{_datadir}/icons/hicolor/256x256/apps/v2rayn.png
|
||||||
SPEC
|
SPEC
|
||||||
|
|
||||||
# Replace placeholders
|
sed -i "s/__VERSION__/${VERSION}/g" "$specfile"
|
||||||
sed -i "s/__VERSION__/${VERSION}/g" "$SPECFILE"
|
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$specfile"
|
||||||
sed -i "s/__PKGROOT__/${PKGROOT}/g" "$SPECFILE"
|
}
|
||||||
|
|
||||||
# Build RPM for this arch
|
package_binary() {
|
||||||
rpmbuild -ba "$SPECFILE" --target "$rpm_target"
|
local short="$1"
|
||||||
|
local rid="$2"
|
||||||
|
local rpm_target="$3"
|
||||||
|
local archdir="$4"
|
||||||
|
local pubdir=""
|
||||||
|
local workdir=""
|
||||||
|
local specfile=""
|
||||||
|
local sourcedir=""
|
||||||
|
local specdir=""
|
||||||
|
local project_dir=""
|
||||||
|
local icon_candidate=""
|
||||||
|
local f=""
|
||||||
|
|
||||||
|
pubdir="$(dirname "$PROJECT")/bin/Release/net10.0/${rid}/publish"
|
||||||
|
[[ -d "$pubdir" ]] || { echo "Publish directory not found: $pubdir"; return 1; }
|
||||||
|
|
||||||
|
workdir="$(mktemp -d)"
|
||||||
|
trap '[[ -n "${workdir:-}" ]] && rm -rf "$workdir"' RETURN
|
||||||
|
|
||||||
|
mkdir -p "$workdir/$PKGROOT"
|
||||||
|
cp -a "$pubdir/." "$workdir/$PKGROOT/"
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
stage_runtime_assets "$workdir/$PKGROOT" "$rid"
|
||||||
|
|
||||||
|
rpmdev-setuptree
|
||||||
|
sourcedir="${RPM_TOPDIR}/SOURCES"
|
||||||
|
specdir="${RPM_TOPDIR}/SPECS"
|
||||||
|
specfile="${specdir}/v2rayN.spec"
|
||||||
|
|
||||||
|
mkdir -p "$sourcedir" "$specdir"
|
||||||
|
tar -C "$workdir" -czf "$sourcedir/$PKGROOT.tar.gz" "$PKGROOT"
|
||||||
|
|
||||||
|
write_spec_file "$specfile"
|
||||||
|
rpmbuild -ba "$specfile" --target "$rpm_target"
|
||||||
|
|
||||||
echo "Build done for $short. RPM at:"
|
echo "Build done for $short. RPM at:"
|
||||||
local f
|
for f in "${RPM_TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
||||||
for f in "${TOPDIR}/RPMS/${archdir}/v2rayN-${VERSION}-1"*.rpm; do
|
|
||||||
[[ -e "$f" ]] || continue
|
[[ -e "$f" ]] || continue
|
||||||
echo " $f"
|
echo " $f"
|
||||||
BUILT_RPMS+=("$f")
|
BUILT_RPMS+=("$f")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# ===== Arch selection and build orchestration =========================================
|
select_targets() {
|
||||||
case "${ARCH_OVERRIDE:-}" in
|
case "${ARCH_OVERRIDE:-}" in
|
||||||
all) targets=(x64 arm64); BUILT_ALL=1 ;;
|
all) printf '%s\n' x64 arm64 ;;
|
||||||
x64|amd64) targets=(x64) ;;
|
x64|amd64) printf '%s\n' x64 ;;
|
||||||
arm64|aarch64) targets=(arm64) ;;
|
arm64|aarch64) printf '%s\n' arm64 ;;
|
||||||
"") targets=($([[ "$host_arch" == "aarch64" ]] && echo arm64 || echo x64)) ;;
|
"")
|
||||||
*) echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all."; exit 1 ;;
|
case "$HOST_ARCH" in
|
||||||
|
x86_64) printf '%s\n' x64 ;;
|
||||||
|
aarch64) printf '%s\n' arm64 ;;
|
||||||
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown --arch '${ARCH_OVERRIDE}'. Use x64|arm64|all." >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
for arch in "${targets[@]}"; do
|
build_one_target() {
|
||||||
build_for_arch "$arch"
|
local short="$1"
|
||||||
done
|
local meta=()
|
||||||
|
local rid=""
|
||||||
|
local rpm_target=""
|
||||||
|
local archdir=""
|
||||||
|
|
||||||
# Print Both arches information
|
mapfile -t meta < <(describe_target "$short") || return 1
|
||||||
|
rid="${meta[0]}"
|
||||||
|
rpm_target="${meta[1]}"
|
||||||
|
archdir="${meta[2]}"
|
||||||
|
|
||||||
|
echo "[*] Building for target: $short (RID=$rid, RPM --target $rpm_target)"
|
||||||
|
publish_binary "$rid"
|
||||||
|
package_binary "$short" "$rid" "$rpm_target" "$archdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
if [[ "$BUILT_ALL" -eq 1 ]]; then
|
if [[ "$BUILT_ALL" -eq 1 ]]; then
|
||||||
|
local rp=""
|
||||||
echo ""
|
echo ""
|
||||||
echo "================ Build Summary (both architectures) ================"
|
echo "================ Build Summary (both architectures) ================"
|
||||||
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
if [[ "${#BUILT_RPMS[@]}" -gt 0 ]]; then
|
||||||
|
|
@ -588,3 +676,26 @@ if [[ "$BUILT_ALL" -eq 1 ]]; then
|
||||||
fi
|
fi
|
||||||
echo "===================================================================="
|
echo "===================================================================="
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local targets=()
|
||||||
|
local arch=""
|
||||||
|
|
||||||
|
parse_args "$@"
|
||||||
|
detect_environment
|
||||||
|
install_dependencies
|
||||||
|
prepare_workspace
|
||||||
|
resolve_version
|
||||||
|
|
||||||
|
mapfile -t targets < <(select_targets)
|
||||||
|
[[ "${ARCH_OVERRIDE:-}" == "all" ]] && BUILT_ALL=1 || BUILT_ALL=0
|
||||||
|
|
||||||
|
for arch in "${targets[@]}"; do
|
||||||
|
build_one_target "$arch"
|
||||||
|
done
|
||||||
|
|
||||||
|
print_summary
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>7.21.2</Version>
|
<Version>7.22.4</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||||
<NoWarn>CA1031;CS1591;NU1507;CA1416;IDE0058;IDE0053;IDE0200</NoWarn>
|
|
||||||
<Nullable>annotations</Nullable>
|
<Nullable>annotations</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Authors>2dust</Authors>
|
<Authors>2dust</Authors>
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,33 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="11.4.1" />
|
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="11.4.1" />
|
||||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Desktop" Version="11.3.16" />
|
||||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.13" />
|
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.16" />
|
||||||
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
|
<PackageVersion Include="AwesomeAssertions" Version="9.4.0" />
|
||||||
<PackageVersion Include="DialogHost.Avalonia" Version="0.11.0" />
|
<PackageVersion Include="DialogHost.Avalonia" Version="0.11.0" />
|
||||||
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
||||||
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
||||||
<PackageVersion Include="Downloader" Version="5.2.0" />
|
<PackageVersion Include="Downloader" Version="5.5.0" />
|
||||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
|
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
|
||||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||||
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
|
<PackageVersion Include="MaterialDesignThemes" Version="5.3.2" />
|
||||||
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
||||||
<PackageVersion Include="ReactiveUI" Version="23.2.1" />
|
<PackageVersion Include="ReactiveUI" Version="23.2.27" />
|
||||||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||||
<PackageVersion Include="ReactiveUI.WPF" Version="23.2.1" />
|
<PackageVersion Include="ReactiveUI.WPF" Version="23.2.27" />
|
||||||
<PackageVersion Include="Semi.Avalonia" Version="11.3.7.3" />
|
<PackageVersion Include="Semi.Avalonia" Version="11.3.14" />
|
||||||
<PackageVersion Include="Semi.Avalonia.AvaloniaEdit" Version="11.2.0.2" />
|
<PackageVersion Include="Semi.Avalonia.AvaloniaEdit" Version="11.2.0.2" />
|
||||||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.3.7.3" />
|
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.3.7.3" />
|
||||||
<PackageVersion Include="NLog" Version="6.1.2" />
|
<PackageVersion Include="NLog" Version="6.1.3" />
|
||||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageVersion Include="sqlite-net-e" Version="1.11.0" />
|
||||||
|
<PackageVersion Include="Repobot.SQLite.Unofficial" Version="3.53.1.7" />
|
||||||
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
||||||
|
<PackageVersion Include="Tmds.DBus.Protocol" Version="0.21.3" />
|
||||||
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||||
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||||
<PackageVersion Include="xunit.v3" Version="3.2.2" />
|
<PackageVersion Include="xunit.v3" Version="3.2.2" />
|
||||||
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
<PackageVersion Include="YamlDotNet" Version="17.1.0" />
|
||||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.22" />
|
||||||
|
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4-preview.1.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 50f615b671ff8d4a6a850aed19da5f94f58b5d96
|
Subproject commit 569a95bb0fd2280d8d5581250aae54ecc2122d10
|
||||||
|
|
@ -99,7 +99,8 @@ public class CoreConfigContextBuilderTests
|
||||||
{
|
{
|
||||||
return message.Contains("cycle dependency", StringComparison.OrdinalIgnoreCase)
|
return message.Contains("cycle dependency", StringComparison.OrdinalIgnoreCase)
|
||||||
|| message.Contains("循环依赖", StringComparison.Ordinal)
|
|| message.Contains("循环依赖", StringComparison.Ordinal)
|
||||||
|| message.Contains("循環依賴", StringComparison.Ordinal);
|
|| message.Contains("循環依賴", StringComparison.Ordinal)
|
||||||
|
|| message.Contains("циклическую зависимость", StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task UpsertProfilesAsync(params ProfileItem[] profiles)
|
private static async Task UpsertProfilesAsync(params ProfileItem[] profiles)
|
||||||
|
|
|
||||||
40
v2rayN/ServiceLib.Tests/GlobalUsings.cs
Normal file
40
v2rayN/ServiceLib.Tests/GlobalUsings.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
global using System.Collections.Concurrent;
|
||||||
|
global using System.Diagnostics;
|
||||||
|
global using System.Net;
|
||||||
|
global using System.Net.NetworkInformation;
|
||||||
|
global using System.Net.Sockets;
|
||||||
|
global using System.Reactive;
|
||||||
|
global using System.Reactive.Disposables;
|
||||||
|
global using System.Reactive.Linq;
|
||||||
|
global using System.Reflection;
|
||||||
|
global using System.Runtime.InteropServices;
|
||||||
|
global using System.Security.Cryptography;
|
||||||
|
global using System.Text;
|
||||||
|
global using System.Text.Encodings.Web;
|
||||||
|
global using System.Text.Json;
|
||||||
|
global using System.Text.Json.Nodes;
|
||||||
|
global using System.Text.Json.Serialization;
|
||||||
|
global using System.Text.RegularExpressions;
|
||||||
|
global using DynamicData;
|
||||||
|
global using DynamicData.Binding;
|
||||||
|
global using ReactiveUI;
|
||||||
|
global using ReactiveUI.Fody.Helpers;
|
||||||
|
global using ServiceLib.Base;
|
||||||
|
global using ServiceLib.Common;
|
||||||
|
global using ServiceLib.Enums;
|
||||||
|
global using ServiceLib.Events;
|
||||||
|
global using ServiceLib.Handler;
|
||||||
|
global using ServiceLib.Handler.Builder;
|
||||||
|
global using ServiceLib.Handler.Fmt;
|
||||||
|
global using ServiceLib.Handler.SysProxy;
|
||||||
|
global using ServiceLib.Helper;
|
||||||
|
global using ServiceLib.Manager;
|
||||||
|
global using ServiceLib.Models.CoreConfigs;
|
||||||
|
global using ServiceLib.Models.Configs;
|
||||||
|
global using ServiceLib.Models.Dto;
|
||||||
|
global using ServiceLib.Models.Entities;
|
||||||
|
global using ServiceLib.Resx;
|
||||||
|
global using ServiceLib.Services;
|
||||||
|
global using ServiceLib.Services.CoreConfig;
|
||||||
|
global using ServiceLib.Services.Statistics;
|
||||||
|
global using SQLite;
|
||||||
92
v2rayN/ServiceLib/Common/CountryExtension.cs
Normal file
92
v2rayN/ServiceLib/Common/CountryExtension.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods for country code utilities
|
||||||
|
/// </summary>
|
||||||
|
public static class CountryExtension
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Country code to emoji flag mapping for common countries
|
||||||
|
/// </summary>
|
||||||
|
private static readonly Dictionary<string, string> CountryEmojiMap = new(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
// Asia
|
||||||
|
{ "CN", "🇨🇳" }, // China
|
||||||
|
{ "HK", "🇭🇰" }, // Hong Kong
|
||||||
|
{ "TW", "🇹🇼" }, // Taiwan
|
||||||
|
{ "JP", "🇯🇵" }, // Japan
|
||||||
|
{ "SG", "🇸🇬" }, // Singapore
|
||||||
|
{ "KR", "🇰🇷" }, // South Korea
|
||||||
|
{ "TH", "🇹🇭" }, // Thailand
|
||||||
|
{ "VN", "🇻🇳" }, // Vietnam
|
||||||
|
{ "ID", "🇮🇩" }, // Indonesia
|
||||||
|
{ "PH", "🇵🇭" }, // Philippines
|
||||||
|
{ "MY", "🇲🇾" }, // Malaysia
|
||||||
|
{ "IN", "🇮🇳" }, // India
|
||||||
|
{ "PK", "🇵🇰" }, // Pakistan
|
||||||
|
{ "BD", "🇧🇩" }, // Bangladesh
|
||||||
|
{ "LK", "🇱🇰" }, // Sri Lanka
|
||||||
|
{ "KH", "🇰🇭" }, // Cambodia
|
||||||
|
{ "LA", "🇱🇦" }, // Laos
|
||||||
|
{ "MM", "🇲🇲" }, // Myanmar
|
||||||
|
|
||||||
|
// Americas
|
||||||
|
{ "US", "🇺🇸" }, // United States
|
||||||
|
{ "CA", "🇨🇦" }, // Canada
|
||||||
|
{ "MX", "🇲🇽" }, // Mexico
|
||||||
|
{ "BR", "🇧🇷" }, // Brazil
|
||||||
|
{ "AR", "🇦🇷" }, // Argentina
|
||||||
|
{ "CL", "🇨🇱" }, // Chile
|
||||||
|
{ "CO", "🇨🇴" }, // Colombia
|
||||||
|
|
||||||
|
// Europe
|
||||||
|
{ "GB", "🇬🇧" }, // United Kingdom
|
||||||
|
{ "DE", "🇩🇪" }, // Germany
|
||||||
|
{ "FR", "🇫🇷" }, // France
|
||||||
|
{ "IT", "🇮🇹" }, // Italy
|
||||||
|
{ "ES", "🇪🇸" }, // Spain
|
||||||
|
{ "RU", "🇷🇺" }, // Russia
|
||||||
|
{ "NL", "🇳🇱" }, // Netherlands
|
||||||
|
{ "CH", "🇨🇭" }, // Switzerland
|
||||||
|
{ "SE", "🇸🇪" }, // Sweden
|
||||||
|
{ "NO", "🇳🇴" }, // Norway
|
||||||
|
{ "DK", "🇩🇰" }, // Denmark
|
||||||
|
{ "FI", "🇫🇮" }, // Finland
|
||||||
|
{ "PL", "🇵🇱" }, // Poland
|
||||||
|
{ "CZ", "🇨🇿" }, // Czech Republic
|
||||||
|
{ "AT", "🇦🇹" }, // Austria
|
||||||
|
{ "GR", "🇬🇷" }, // Greece
|
||||||
|
{ "PT", "🇵🇹" }, // Portugal
|
||||||
|
{ "TR", "🇹🇷" }, // Turkey
|
||||||
|
{ "UA", "🇺🇦" }, // Ukraine
|
||||||
|
{ "RO", "🇷🇴" }, // Romania
|
||||||
|
|
||||||
|
// Middle East & Central Asia
|
||||||
|
{ "AE", "🇦🇪" }, // United Arab Emirates
|
||||||
|
{ "SA", "🇸🇦" }, // Saudi Arabia
|
||||||
|
{ "IL", "🇮🇱" }, // Israel
|
||||||
|
{ "KZ", "🇰🇿" }, // Kazakhstan
|
||||||
|
|
||||||
|
// Oceania
|
||||||
|
{ "AU", "🇦🇺" }, // Australia
|
||||||
|
{ "NZ", "🇳🇿" }, // New Zealand
|
||||||
|
|
||||||
|
// Africa
|
||||||
|
{ "ZA", "🇿🇦" }, // South Africa
|
||||||
|
{ "EG", "🇪🇬" }, // Egypt
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts country code to flag emoji using predefined mapping
|
||||||
|
/// Example: "US" -> "🇺🇸", "CN" -> "🇨🇳"
|
||||||
|
/// </summary>
|
||||||
|
public static string? CountryToEmoji(this string? countryCode)
|
||||||
|
{
|
||||||
|
if (countryCode.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CountryEmojiMap.TryGetValue(countryCode, out var emoji) ? emoji : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -863,6 +863,8 @@ public class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, string> GetSystemHosts()
|
public static Dictionary<string, string> GetSystemHosts()
|
||||||
|
{
|
||||||
|
if (IsWindows())
|
||||||
{
|
{
|
||||||
var hosts = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts");
|
var hosts = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts");
|
||||||
var hostsIcs = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts.ics");
|
var hostsIcs = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts.ics");
|
||||||
|
|
@ -875,6 +877,14 @@ public class Utils
|
||||||
return hosts;
|
return hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsLinux() || IsMacOS())
|
||||||
|
{
|
||||||
|
return GetSystemHosts("/etc/hosts");
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Dictionary<string, string>();
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string?> GetCliWrapOutput(string filePath, string? arg)
|
public static async Task<string?> GetCliWrapOutput(string filePath, string? arg)
|
||||||
{
|
{
|
||||||
return await GetCliWrapOutput(filePath, arg != null ? new List<string>() { arg } : null);
|
return await GetCliWrapOutput(filePath, arg != null ? new List<string>() { arg } : null);
|
||||||
|
|
@ -1114,12 +1124,16 @@ public class Utils
|
||||||
|
|
||||||
#region Platform
|
#region Platform
|
||||||
|
|
||||||
|
[SupportedOSPlatformGuard("windows")]
|
||||||
public static bool IsWindows() => OperatingSystem.IsWindows();
|
public static bool IsWindows() => OperatingSystem.IsWindows();
|
||||||
|
|
||||||
|
[SupportedOSPlatformGuard("linux")]
|
||||||
public static bool IsLinux() => OperatingSystem.IsLinux();
|
public static bool IsLinux() => OperatingSystem.IsLinux();
|
||||||
|
|
||||||
|
[SupportedOSPlatformGuard("macos")]
|
||||||
public static bool IsMacOS() => OperatingSystem.IsMacOS();
|
public static bool IsMacOS() => OperatingSystem.IsMacOS();
|
||||||
|
|
||||||
|
[UnsupportedOSPlatformGuard("windows")]
|
||||||
public static bool IsNonWindows() => !OperatingSystem.IsWindows();
|
public static bool IsNonWindows() => !OperatingSystem.IsWindows();
|
||||||
|
|
||||||
public static string GetExeName(string name)
|
public static string GetExeName(string name)
|
||||||
|
|
@ -1214,6 +1228,16 @@ public class Utils
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SetUnixFileMode(string? fileName)
|
public static bool SetUnixFileMode(string? fileName)
|
||||||
|
{
|
||||||
|
if (IsWindows())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return SetUnixFileModeInternal(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnsupportedOSPlatform("windows")]
|
||||||
|
private static bool SetUnixFileModeInternal(string? fileName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ using Microsoft.Win32;
|
||||||
|
|
||||||
namespace ServiceLib.Common;
|
namespace ServiceLib.Common;
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
internal static class WindowsUtils
|
internal static class WindowsUtils
|
||||||
{
|
{
|
||||||
private static readonly string _tag = "WindowsUtils";
|
private static readonly string _tag = "WindowsUtils";
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ public enum EServerColName
|
||||||
SubRemarks,
|
SubRemarks,
|
||||||
DelayVal,
|
DelayVal,
|
||||||
SpeedVal,
|
SpeedVal,
|
||||||
|
IpInfo,
|
||||||
|
|
||||||
TodayDown,
|
TodayDown,
|
||||||
TodayUp,
|
TodayUp,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ public static class AppEvents
|
||||||
public static readonly EventChannel<Unit> AddServerViaScanRequested = new();
|
public static readonly EventChannel<Unit> AddServerViaScanRequested = new();
|
||||||
public static readonly EventChannel<Unit> AddServerViaClipboardRequested = new();
|
public static readonly EventChannel<Unit> AddServerViaClipboardRequested = new();
|
||||||
public static readonly EventChannel<bool> SubscriptionsUpdateRequested = new();
|
public static readonly EventChannel<bool> SubscriptionsUpdateRequested = new();
|
||||||
|
public static readonly EventChannel<bool> HasUpdateNotified = new();
|
||||||
|
|
||||||
public static readonly EventChannel<Unit> ProfilesRefreshRequested = new();
|
public static readonly EventChannel<Unit> ProfilesRefreshRequested = new();
|
||||||
public static readonly EventChannel<Unit> SubscriptionsRefreshRequested = new();
|
public static readonly EventChannel<Unit> SubscriptionsRefreshRequested = new();
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class Global
|
||||||
public const string DnsOutboundTag = "dns";
|
public const string DnsOutboundTag = "dns";
|
||||||
public const string DnsTag = "dns-module";
|
public const string DnsTag = "dns-module";
|
||||||
public const string DirectDnsTag = "direct-dns";
|
public const string DirectDnsTag = "direct-dns";
|
||||||
public const string BalancerTagSuffix = "-round";
|
public const string BalancerTagSuffix = "-balancer";
|
||||||
public const string StreamSecurity = "tls";
|
public const string StreamSecurity = "tls";
|
||||||
public const string StreamSecurityReality = "reality";
|
public const string StreamSecurityReality = "reality";
|
||||||
public const string Loopback = "127.0.0.1";
|
public const string Loopback = "127.0.0.1";
|
||||||
|
|
@ -149,6 +149,9 @@ public class Global
|
||||||
public static readonly List<string> SpeedTestUrls =
|
public static readonly List<string> SpeedTestUrls =
|
||||||
[
|
[
|
||||||
@"https://cachefly.cachefly.net/50mb.test",
|
@"https://cachefly.cachefly.net/50mb.test",
|
||||||
|
@"https://cachefly.cachefly.net/100mb.test",
|
||||||
|
@"https://cachefly.cachefly.net/1mb.test",
|
||||||
|
@"https://cachefly.cachefly.net/10mb.test",
|
||||||
@"https://speed.cloudflare.com/__down?bytes=10000000",
|
@"https://speed.cloudflare.com/__down?bytes=10000000",
|
||||||
@"https://speed.cloudflare.com/__down?bytes=50000000",
|
@"https://speed.cloudflare.com/__down?bytes=50000000",
|
||||||
@"https://speed.cloudflare.com/__down?bytes=99999999",
|
@"https://speed.cloudflare.com/__down?bytes=99999999",
|
||||||
|
|
@ -157,6 +160,8 @@ public class Global
|
||||||
public static readonly List<string> SpeedPingTestUrls =
|
public static readonly List<string> SpeedPingTestUrls =
|
||||||
[
|
[
|
||||||
@"https://www.google.com/generate_204",
|
@"https://www.google.com/generate_204",
|
||||||
|
@"https://www.youtube.com/generate_204",
|
||||||
|
@"https://www.googlevideo.com/generate_204",
|
||||||
@"https://www.gstatic.com/generate_204",
|
@"https://www.gstatic.com/generate_204",
|
||||||
@"https://www.apple.com/library/test/success.html",
|
@"https://www.apple.com/library/test/success.html",
|
||||||
@"http://www.msftconnecttest.com/connecttest.txt"
|
@"http://www.msftconnecttest.com/connecttest.txt"
|
||||||
|
|
@ -207,6 +212,10 @@ public class Global
|
||||||
|
|
||||||
public const string NaiveQuicProtocolShare = "naive+quic://";
|
public const string NaiveQuicProtocolShare = "naive+quic://";
|
||||||
|
|
||||||
|
public const string SOCKS5Protocol = "socks5://";
|
||||||
|
|
||||||
|
public const string SOCKS4Protocol = "socks4://";
|
||||||
|
|
||||||
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
||||||
{
|
{
|
||||||
{ EConfigType.VMess, "vmess://" },
|
{ EConfigType.VMess, "vmess://" },
|
||||||
|
|
@ -505,6 +514,7 @@ public class Global
|
||||||
|
|
||||||
public static readonly List<string> InboundTags =
|
public static readonly List<string> InboundTags =
|
||||||
[
|
[
|
||||||
|
"tun",
|
||||||
"socks",
|
"socks",
|
||||||
"socks2",
|
"socks2",
|
||||||
"socks3"
|
"socks3"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ global using System.Reactive.Disposables;
|
||||||
global using System.Reactive.Linq;
|
global using System.Reactive.Linq;
|
||||||
global using System.Reflection;
|
global using System.Reflection;
|
||||||
global using System.Runtime.InteropServices;
|
global using System.Runtime.InteropServices;
|
||||||
|
global using System.Runtime.Versioning;
|
||||||
global using System.Security.Cryptography;
|
global using System.Security.Cryptography;
|
||||||
global using System.Text;
|
global using System.Text;
|
||||||
global using System.Text.Encodings.Web;
|
global using System.Text.Encodings.Web;
|
||||||
|
|
@ -29,7 +30,10 @@ global using ServiceLib.Handler.Fmt;
|
||||||
global using ServiceLib.Handler.SysProxy;
|
global using ServiceLib.Handler.SysProxy;
|
||||||
global using ServiceLib.Helper;
|
global using ServiceLib.Helper;
|
||||||
global using ServiceLib.Manager;
|
global using ServiceLib.Manager;
|
||||||
global using ServiceLib.Models;
|
global using ServiceLib.Models.CoreConfigs;
|
||||||
|
global using ServiceLib.Models.Configs;
|
||||||
|
global using ServiceLib.Models.Dto;
|
||||||
|
global using ServiceLib.Models.Entities;
|
||||||
global using ServiceLib.Resx;
|
global using ServiceLib.Resx;
|
||||||
global using ServiceLib.Services;
|
global using ServiceLib.Services;
|
||||||
global using ServiceLib.Services.CoreConfig;
|
global using ServiceLib.Services.CoreConfig;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ public static class AutoStartupHandler
|
||||||
|
|
||||||
#region Windows
|
#region Windows
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
private static async Task ClearTaskWindows()
|
private static async Task ClearTaskWindows()
|
||||||
{
|
{
|
||||||
var autoRunName = GetAutoRunNameWindows();
|
var autoRunName = GetAutoRunNameWindows();
|
||||||
|
|
@ -53,6 +54,7 @@ public static class AutoStartupHandler
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
private static async Task SetTaskWindows()
|
private static async Task SetTaskWindows()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -82,6 +84,7 @@ public static class AutoStartupHandler
|
||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <param name="description"></param>
|
/// <param name="description"></param>
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static void AutoStartTaskService(string taskName, string fileName, string description)
|
public static void AutoStartTaskService(string taskName, string fileName, string description)
|
||||||
{
|
{
|
||||||
if (taskName.IsNullOrEmpty())
|
if (taskName.IsNullOrEmpty())
|
||||||
|
|
@ -108,7 +111,8 @@ public static class AutoStartupHandler
|
||||||
task.Settings.RunOnlyIfIdle = false;
|
task.Settings.RunOnlyIfIdle = false;
|
||||||
task.Settings.IdleSettings.StopOnIdleEnd = false;
|
task.Settings.IdleSettings.StopOnIdleEnd = false;
|
||||||
task.Settings.ExecutionTimeLimit = TimeSpan.Zero;
|
task.Settings.ExecutionTimeLimit = TimeSpan.Zero;
|
||||||
task.Triggers.Add(new Microsoft.Win32.TaskScheduler.LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromSeconds(30) });
|
task.Settings.Priority = ProcessPriorityClass.Normal;
|
||||||
|
task.Triggers.Add(new Microsoft.Win32.TaskScheduler.LogonTrigger { UserId = logonUser });
|
||||||
task.Principal.RunLevel = Microsoft.Win32.TaskScheduler.TaskRunLevel.Highest;
|
task.Principal.RunLevel = Microsoft.Win32.TaskScheduler.TaskRunLevel.Highest;
|
||||||
task.Actions.Add(new Microsoft.Win32.TaskScheduler.ExecAction(fileName.AppendQuotes(), null, Path.GetDirectoryName(fileName)));
|
task.Actions.Add(new Microsoft.Win32.TaskScheduler.ExecAction(fileName.AppendQuotes(), null, Path.GetDirectoryName(fileName)));
|
||||||
|
|
||||||
|
|
@ -124,6 +128,7 @@ public static class AutoStartupHandler
|
||||||
|
|
||||||
#region Linux
|
#region Linux
|
||||||
|
|
||||||
|
[SupportedOSPlatform("linux")]
|
||||||
private static async Task ClearTaskLinux()
|
private static async Task ClearTaskLinux()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -137,6 +142,7 @@ public static class AutoStartupHandler
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("linux")]
|
||||||
private static async Task SetTaskLinux()
|
private static async Task SetTaskLinux()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -157,6 +163,7 @@ public static class AutoStartupHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("linux")]
|
||||||
private static string GetHomePathLinux()
|
private static string GetHomePathLinux()
|
||||||
{
|
{
|
||||||
var homePath = Path.Combine(Utils.GetHomePath(), ".config", "autostart", $"{Global.AppName}.desktop");
|
var homePath = Path.Combine(Utils.GetHomePath(), ".config", "autostart", $"{Global.AppName}.desktop");
|
||||||
|
|
@ -168,6 +175,7 @@ public static class AutoStartupHandler
|
||||||
|
|
||||||
#region macOS
|
#region macOS
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
private static async Task ClearTaskOSX()
|
private static async Task ClearTaskOSX()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -187,6 +195,7 @@ public static class AutoStartupHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
private static async Task SetTaskOSX()
|
private static async Task SetTaskOSX()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -204,6 +213,7 @@ public static class AutoStartupHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
private static string GetLaunchAgentPathMacOS()
|
private static string GetLaunchAgentPathMacOS()
|
||||||
{
|
{
|
||||||
var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
var homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
|
|
@ -212,6 +222,7 @@ public static class AutoStartupHandler
|
||||||
return launchAgentPath;
|
return launchAgentPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
private static string GenerateLaunchAgentPlist()
|
private static string GenerateLaunchAgentPlist()
|
||||||
{
|
{
|
||||||
var exePath = Utils.GetExePath();
|
var exePath = Utils.GetExePath();
|
||||||
|
|
|
||||||
|
|
@ -923,6 +923,7 @@ public static class ConfigHandler
|
||||||
Delay = t33?.Delay ?? 0,
|
Delay = t33?.Delay ?? 0,
|
||||||
Speed = t33?.Speed ?? 0,
|
Speed = t33?.Speed ?? 0,
|
||||||
Sort = t33?.Sort ?? 0,
|
Sort = t33?.Sort ?? 0,
|
||||||
|
IpInfo = t33?.IpInfo ?? string.Empty,
|
||||||
TodayDown = (t22?.TodayDown ?? 0).ToString("D16"),
|
TodayDown = (t22?.TodayDown ?? 0).ToString("D16"),
|
||||||
TodayUp = (t22?.TodayUp ?? 0).ToString("D16"),
|
TodayUp = (t22?.TodayUp ?? 0).ToString("D16"),
|
||||||
TotalDown = (t22?.TotalDown ?? 0).ToString("D16"),
|
TotalDown = (t22?.TotalDown ?? 0).ToString("D16"),
|
||||||
|
|
@ -943,6 +944,7 @@ public static class ConfigHandler
|
||||||
EServerColName.StreamSecurity => lstProfile.OrderBy(t => t.StreamSecurity).ToList(),
|
EServerColName.StreamSecurity => lstProfile.OrderBy(t => t.StreamSecurity).ToList(),
|
||||||
EServerColName.DelayVal => lstProfile.OrderBy(t => t.Delay).ToList(),
|
EServerColName.DelayVal => lstProfile.OrderBy(t => t.Delay).ToList(),
|
||||||
EServerColName.SpeedVal => lstProfile.OrderBy(t => t.Speed).ToList(),
|
EServerColName.SpeedVal => lstProfile.OrderBy(t => t.Speed).ToList(),
|
||||||
|
EServerColName.IpInfo => lstProfile.OrderBy(t => t.IpInfo).ToList(),
|
||||||
EServerColName.SubRemarks => lstProfile.OrderBy(t => t.Subid).ToList(),
|
EServerColName.SubRemarks => lstProfile.OrderBy(t => t.Subid).ToList(),
|
||||||
EServerColName.TodayDown => lstProfile.OrderBy(t => t.TodayDown).ToList(),
|
EServerColName.TodayDown => lstProfile.OrderBy(t => t.TodayDown).ToList(),
|
||||||
EServerColName.TodayUp => lstProfile.OrderBy(t => t.TodayUp).ToList(),
|
EServerColName.TodayUp => lstProfile.OrderBy(t => t.TodayUp).ToList(),
|
||||||
|
|
@ -963,6 +965,7 @@ public static class ConfigHandler
|
||||||
EServerColName.StreamSecurity => lstProfile.OrderByDescending(t => t.StreamSecurity).ToList(),
|
EServerColName.StreamSecurity => lstProfile.OrderByDescending(t => t.StreamSecurity).ToList(),
|
||||||
EServerColName.DelayVal => lstProfile.OrderByDescending(t => t.Delay).ToList(),
|
EServerColName.DelayVal => lstProfile.OrderByDescending(t => t.Delay).ToList(),
|
||||||
EServerColName.SpeedVal => lstProfile.OrderByDescending(t => t.Speed).ToList(),
|
EServerColName.SpeedVal => lstProfile.OrderByDescending(t => t.Speed).ToList(),
|
||||||
|
EServerColName.IpInfo => lstProfile.OrderByDescending(t => t.IpInfo).ToList(),
|
||||||
EServerColName.SubRemarks => lstProfile.OrderByDescending(t => t.Subid).ToList(),
|
EServerColName.SubRemarks => lstProfile.OrderByDescending(t => t.Subid).ToList(),
|
||||||
EServerColName.TodayDown => lstProfile.OrderByDescending(t => t.TodayDown).ToList(),
|
EServerColName.TodayDown => lstProfile.OrderByDescending(t => t.TodayDown).ToList(),
|
||||||
EServerColName.TodayUp => lstProfile.OrderByDescending(t => t.TodayUp).ToList(),
|
EServerColName.TodayUp => lstProfile.OrderByDescending(t => t.TodayUp).ToList(),
|
||||||
|
|
@ -1816,9 +1819,9 @@ public static class ConfigHandler
|
||||||
ProfileItem? activeProfile = null;
|
ProfileItem? activeProfile = null;
|
||||||
if (isSub && subid.IsNotEmpty())
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, true);
|
|
||||||
lstOriSub = await AppManager.Instance.ProfileItems(subid);
|
lstOriSub = await AppManager.Instance.ProfileItems(subid);
|
||||||
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
||||||
|
await RemoveServersViaSubid(config, subid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
|
@ -1847,7 +1850,19 @@ public static class ConfigHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
//May be standard uri mixed with internal uri
|
//May be standard uri mixed with internal uri
|
||||||
var innerUriCount = await AddBatchServers4InnerUri(config, strData, subid, isSub);
|
var innerUriCount = 0;
|
||||||
|
if (Utils.IsBase64String(strData))
|
||||||
|
{
|
||||||
|
innerUriCount = await AddBatchServers4InnerUri(config, Utils.Base64Decode(strData), subid, isSub);
|
||||||
|
}
|
||||||
|
if (innerUriCount < 1)
|
||||||
|
{
|
||||||
|
innerUriCount = await AddBatchServers4InnerUri(config, strData, subid, isSub);
|
||||||
|
}
|
||||||
|
if (innerUriCount < 1)
|
||||||
|
{
|
||||||
|
innerUriCount = await AddBatchServers4InnerUri(config, Utils.Base64Decode(strData), subid, isSub);
|
||||||
|
}
|
||||||
if (innerUriCount > 0)
|
if (innerUriCount > 0)
|
||||||
{
|
{
|
||||||
if (counter > 0)
|
if (counter > 0)
|
||||||
|
|
|
||||||
|
|
@ -4,53 +4,41 @@ public static class ConnectionHandler
|
||||||
{
|
{
|
||||||
private static readonly string _tag = "ConnectionHandler";
|
private static readonly string _tag = "ConnectionHandler";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs ping and IP checks and returns a formatted result string.
|
||||||
|
/// </summary>
|
||||||
public static async Task<string> RunAvailabilityCheck()
|
public static async Task<string> RunAvailabilityCheck()
|
||||||
{
|
{
|
||||||
var time = await GetRealPingTimeInfo();
|
var time = await GetRealPingTimeInfo();
|
||||||
var ip = time > 0 ? await GetIPInfo() ?? Global.None : Global.None;
|
var ip = time > 0 ? await GetIPInfo() : Global.None;
|
||||||
|
|
||||||
return string.Format(ResUI.TestMeOutput, time, ip);
|
return string.Format(ResUI.TestMeOutput, time, ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets IP information using the default local proxy.
|
||||||
|
/// </summary>
|
||||||
private static async Task<string?> GetIPInfo()
|
private static async Task<string?> GetIPInfo()
|
||||||
{
|
{
|
||||||
var url = AppManager.Instance.Config.SpeedTestItem.IPAPIUrl;
|
var webProxy = await GetWebProxy();
|
||||||
if (url.IsNullOrEmpty())
|
|
||||||
{
|
var ipInfo = await GetIPInfo(webProxy);
|
||||||
return null;
|
return ipInfo?.ToString() ?? Global.None;
|
||||||
}
|
|
||||||
|
|
||||||
var downloadHandle = new DownloadService();
|
|
||||||
var result = await downloadHandle.TryDownloadString(url, true, "");
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var ipInfo = JsonUtils.Deserialize<IPAPIInfo>(result);
|
|
||||||
if (ipInfo == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var ip = ipInfo.ip ?? ipInfo.clientIp ?? ipInfo.ip_addr ?? ipInfo.query;
|
|
||||||
var country = ipInfo.country_code ?? ipInfo.country ?? ipInfo.countryCode ?? ipInfo.location?.country_code;
|
|
||||||
|
|
||||||
return $"({country ?? "unknown"}) {ip}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Measures real ping time using configured test URL.
|
||||||
|
/// </summary>
|
||||||
private static async Task<int> GetRealPingTimeInfo()
|
private static async Task<int> GetRealPingTimeInfo()
|
||||||
{
|
{
|
||||||
var responseTime = -1;
|
var responseTime = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
var webProxy = await GetWebProxy();
|
||||||
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{port}");
|
|
||||||
var url = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
|
|
||||||
|
|
||||||
for (var i = 0; i < 2; i++)
|
for (var i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
responseTime = await GetRealPingTime(url, webProxy, 10);
|
responseTime = await GetRealPingTime(webProxy, 10);
|
||||||
if (responseTime > 0)
|
if (responseTime > 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
|
@ -66,8 +54,21 @@ public static class ConnectionHandler
|
||||||
return responseTime;
|
return responseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<int> GetRealPingTime(string url, IWebProxy? webProxy, int downloadTimeout)
|
/// <summary>
|
||||||
|
/// Creates local SOCKS proxy instance.
|
||||||
|
/// </summary>
|
||||||
|
private static async Task<WebProxy?> GetWebProxy()
|
||||||
{
|
{
|
||||||
|
var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
|
return new WebProxy($"socks5://{Global.Loopback}:{port}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Measures response time by sending HTTP requests through proxy.
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<int> GetRealPingTime(IWebProxy? webProxy, int downloadTimeout)
|
||||||
|
{
|
||||||
|
var url = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
|
||||||
var responseTime = -1;
|
var responseTime = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -95,4 +96,41 @@ public static class ConnectionHandler
|
||||||
}
|
}
|
||||||
return responseTime;
|
return responseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets IP and country information through specified proxy.
|
||||||
|
/// </summary>
|
||||||
|
public static async Task<IpInfoResult?> GetIPInfo(IWebProxy? webProxy)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var url = AppManager.Instance.Config.SpeedTestItem.IPAPIUrl;
|
||||||
|
if (url.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var downloadHandle = new DownloadService();
|
||||||
|
var result = await downloadHandle.TryDownloadString(url, webProxy, "");
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ipInfo = JsonUtils.Deserialize<IPAPIInfo>(result);
|
||||||
|
if (ipInfo == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ip = ipInfo.ip ?? ipInfo.clientIp ?? ipInfo.ip_addr ?? ipInfo.query;
|
||||||
|
var country = ipInfo.country_code ?? ipInfo.country ?? ipInfo.countryCode ?? ipInfo.location?.country_code ?? "unknown";
|
||||||
|
|
||||||
|
return new IpInfoResult(country, ip);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,9 @@ public class FmtHandler
|
||||||
{
|
{
|
||||||
return ShadowsocksFmt.Resolve(str, out msg);
|
return ShadowsocksFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS]))
|
else if (str.StartsWith(Global.ProtocolShares[EConfigType.SOCKS])
|
||||||
|
|| str.StartsWith(Global.SOCKS5Protocol)
|
||||||
|
|| str.StartsWith(Global.SOCKS4Protocol))
|
||||||
{
|
{
|
||||||
return SocksFmt.Resolve(str, out msg);
|
return SocksFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +67,8 @@ public class FmtHandler
|
||||||
{
|
{
|
||||||
return VLESSFmt.Resolve(str, out msg);
|
return VLESSFmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2]) || str.StartsWith(Global.Hysteria2ProtocolShare))
|
else if (str.StartsWith(Global.ProtocolShares[EConfigType.Hysteria2])
|
||||||
|
|| str.StartsWith(Global.Hysteria2ProtocolShare))
|
||||||
{
|
{
|
||||||
return Hysteria2Fmt.Resolve(str, out msg);
|
return Hysteria2Fmt.Resolve(str, out msg);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,9 @@ public class InnerFmt
|
||||||
jsonObj["TransportExtraObj"] = transportExtraObj;
|
jsonObj["TransportExtraObj"] = transportExtraObj;
|
||||||
jsonObj.Remove("TransportExtra");
|
jsonObj.Remove("TransportExtra");
|
||||||
}
|
}
|
||||||
|
// remove subid and isSub
|
||||||
|
jsonObj.Remove("Subid");
|
||||||
|
jsonObj.Remove("IsSub");
|
||||||
// Remove empty properties to reduce the length of the exported string
|
// Remove empty properties to reduce the length of the exported string
|
||||||
RemoveEmptyJson(jsonObj);
|
RemoveEmptyJson(jsonObj);
|
||||||
var jsonStr = JsonUtils.Serialize(jsonObj, false);
|
var jsonStr = JsonUtils.Serialize(jsonObj, false);
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,17 @@ public class SocksFmt : BaseFmt
|
||||||
};
|
};
|
||||||
// parse base64 UserInfo
|
// parse base64 UserInfo
|
||||||
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo);
|
||||||
var userInfo = Utils.Base64Decode(rawUserInfo);
|
if (rawUserInfo.IsNotEmpty())
|
||||||
var userInfoParts = userInfo.Split([':'], 2);
|
{
|
||||||
|
var userInfoParts = rawUserInfo.Contains(':')
|
||||||
|
? rawUserInfo.Split(":", 2)
|
||||||
|
: Utils.Base64Decode(rawUserInfo).Split(":", 2);
|
||||||
|
|
||||||
if (userInfoParts.Length == 2)
|
if (userInfoParts.Length == 2)
|
||||||
{
|
{
|
||||||
item.Username = userInfoParts.First();
|
item.Username = userInfoParts.First();
|
||||||
item.Password = userInfoParts[1];
|
item.Password = userInfoParts.Last();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
namespace ServiceLib.Handler.SysProxy;
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
[SupportedOSPlatform("linux")]
|
||||||
public static class ProxySettingLinux
|
public static class ProxySettingLinux
|
||||||
{
|
{
|
||||||
private static readonly string _proxySetFileName = $"{Global.ProxySetLinuxShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
private static readonly string _proxySetFileName = $"{Global.ProxySetLinuxShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
namespace ServiceLib.Handler.SysProxy;
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
[SupportedOSPlatform("macos")]
|
||||||
public static class ProxySettingOSX
|
public static class ProxySettingOSX
|
||||||
{
|
{
|
||||||
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
private static readonly string _proxySetFileName = $"{Global.ProxySetOSXShellFileName.Replace(Global.NamespaceSample, "")}.sh";
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ using static ServiceLib.Handler.SysProxy.ProxySettingWindows.InternetConnectionO
|
||||||
|
|
||||||
namespace ServiceLib.Handler.SysProxy;
|
namespace ServiceLib.Handler.SysProxy;
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public static class ProxySettingWindows
|
public static class ProxySettingWindows
|
||||||
{
|
{
|
||||||
private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
|
private const string _regPath = @"Software\Microsoft\Windows\CurrentVersion\Internet Settings";
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ public static class SysProxyHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
private static async Task SetWindowsProxyPac(int port)
|
private static async Task SetWindowsProxyPac(int port)
|
||||||
{
|
{
|
||||||
var portPac = AppManager.Instance.GetLocalPort(EInboundProtocol.pac);
|
var portPac = AppManager.Instance.GetLocalPort(EInboundProtocol.pac);
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@ public sealed class AppManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<ECoreType, string> LastCheckUpdateResults { get; set; } = new();
|
||||||
|
|
||||||
|
public void SetLastCheckUpdateResult(ECoreType coreType, string result)
|
||||||
|
{
|
||||||
|
LastCheckUpdateResults[coreType] = result;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Property
|
#endregion Property
|
||||||
|
|
||||||
#region App
|
#region App
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using static ServiceLib.Models.ClashProxies;
|
using static ServiceLib.Models.Dto.ClashProxies;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,50 @@ public sealed class CoreInfoManager
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ECoreType> GetCheckUpdateCoreTypes()
|
||||||
|
{
|
||||||
|
var lst = new List<ECoreType>();
|
||||||
|
|
||||||
|
if (RuntimeInformation.ProcessArchitecture != Architecture.X86)
|
||||||
|
{
|
||||||
|
if (IsCheckUpdateSupported(ECoreType.v2rayN))
|
||||||
|
{
|
||||||
|
lst.Add(ECoreType.v2rayN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Utils.IsWindows() && Environment.OSVersion.Version.Major < 10))
|
||||||
|
{
|
||||||
|
lst.Add(ECoreType.Xray);
|
||||||
|
lst.Add(ECoreType.mihomo);
|
||||||
|
lst.Add(ECoreType.sing_box);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsCheckUpdateSupported(ECoreType type)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
ECoreType.v2rayN => !Utils.IsPackagedInstall(),
|
||||||
|
ECoreType.Xray => true,
|
||||||
|
ECoreType.mihomo => true,
|
||||||
|
ECoreType.sing_box => true,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetCheckPreRelease(ECoreType type, bool preRelease)
|
||||||
|
{
|
||||||
|
return type switch
|
||||||
|
{
|
||||||
|
ECoreType.v2rayN => preRelease,
|
||||||
|
ECoreType.Xray => preRelease,
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void InitCoreInfo()
|
private void InitCoreInfo()
|
||||||
{
|
{
|
||||||
var urlN = GetCoreUrl(ECoreType.v2rayN);
|
var urlN = GetCoreUrl(ECoreType.v2rayN);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ public class CoreManager
|
||||||
private static readonly Lazy<CoreManager> _instance = new(() => new());
|
private static readonly Lazy<CoreManager> _instance = new(() => new());
|
||||||
public static CoreManager Instance => _instance.Value;
|
public static CoreManager Instance => _instance.Value;
|
||||||
private Config _config;
|
private Config _config;
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
private WindowsJobService? _processJob;
|
private WindowsJobService? _processJob;
|
||||||
private ProcessService? _processService;
|
private ProcessService? _processService;
|
||||||
private ProcessService? _processPreService;
|
private ProcessService? _processPreService;
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,14 @@ public class ProfileExManager
|
||||||
IndexIdEnqueue(indexId);
|
IndexIdEnqueue(indexId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetTestIpInfo(string indexId, string ipInfo)
|
||||||
|
{
|
||||||
|
var profileEx = GetProfileExItem(indexId);
|
||||||
|
|
||||||
|
profileEx.IpInfo = ipInfo;
|
||||||
|
IndexIdEnqueue(indexId);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSort(string indexId, int sort)
|
public void SetSort(string indexId, int sort)
|
||||||
{
|
{
|
||||||
var profileEx = GetProfileExItem(indexId);
|
var profileEx = GetProfileExItem(indexId);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,18 @@ public class TaskManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Execute once 24 hour
|
||||||
|
if (numOfExecuted % 1440 == 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await UpdateTaskRunCheckUpdate();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog("ScheduledTasks - UpdateTaskRunCheckUpdate", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
numOfExecuted++;
|
numOfExecuted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,4 +129,23 @@ public class TaskManager
|
||||||
}).UpdateGeoFileAll();
|
}).UpdateGeoFileAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task UpdateTaskRunCheckUpdate()
|
||||||
|
{
|
||||||
|
Logging.SaveLog("Execute check update");
|
||||||
|
|
||||||
|
var updateService = new UpdateService(_config, async (success, msg) => await Task.CompletedTask);
|
||||||
|
|
||||||
|
var msgs = await updateService.CheckHasUpdateOnlyAll(_config.CheckUpdateItem.CheckPreReleaseUpdate);
|
||||||
|
foreach (var msg in msgs)
|
||||||
|
{
|
||||||
|
await _updateFunc?.Invoke(false, msg);
|
||||||
|
}
|
||||||
|
NoticeManager.Instance.Enqueue(string.Join("\n", msgs));
|
||||||
|
|
||||||
|
if (msgs.Count > 0)
|
||||||
|
{
|
||||||
|
AppEvents.HasUpdateNotified.Publish(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Configs;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class Config
|
public class Config
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Configs;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CoreBasicItem
|
public class CoreBasicItem
|
||||||
|
|
@ -159,6 +159,8 @@ public class SpeedTestItem
|
||||||
public int MixedConcurrencyCount { get; set; }
|
public int MixedConcurrencyCount { get; set; }
|
||||||
public string IPAPIUrl { get; set; }
|
public string IPAPIUrl { get; set; }
|
||||||
public string UdpTestTarget { get; set; }
|
public string UdpTestTarget { get; set; }
|
||||||
|
public int? SpeedTestPageSize { get; set; }
|
||||||
|
public int? SpeedTestDelayInterval { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
public record CoreConfigContext
|
public record CoreConfigContext
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class CoreInfo
|
public class CoreInfo
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
public class SingboxConfig
|
public class SingboxConfig
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
public class V2rayConfig
|
public class V2rayConfig
|
||||||
{
|
{
|
||||||
|
|
@ -276,6 +276,7 @@ public class BalancersItem4Ray
|
||||||
public List<string>? selector { get; set; }
|
public List<string>? selector { get; set; }
|
||||||
public BalancersStrategy4Ray? strategy { get; set; }
|
public BalancersStrategy4Ray? strategy { get; set; }
|
||||||
public string? tag { get; set; }
|
public string? tag { get; set; }
|
||||||
|
public string? fallbackTag { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BalancersStrategy4Ray
|
public class BalancersStrategy4Ray
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
internal class V2rayMetricsVars
|
internal class V2rayMetricsVars
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.CoreConfigs;
|
||||||
|
|
||||||
public class V2rayTcpRequest
|
public class V2rayTcpRequest
|
||||||
{
|
{
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class CheckUpdateModel : ReactiveObject
|
public class CheckUpdateModel : ReactiveObject
|
||||||
{
|
{
|
||||||
public bool? IsSelected { get; set; }
|
public bool? IsSelected { get; set; }
|
||||||
public string? CoreType { get; set; }
|
public ECoreType? CoreType { get; set; }
|
||||||
[Reactive] public string? Remarks { get; set; }
|
[Reactive] public string? Remarks { get; set; }
|
||||||
public string? FileName { get; set; }
|
public string? FileName { get; set; }
|
||||||
public bool? IsFinished { get; set; }
|
public bool? IsFinished { get; set; }
|
||||||
|
public bool IsGeoFile { get; set; }
|
||||||
|
public string CoreTypeForStorage => IsGeoFile ? "GeoFiles" : (CoreType?.ToString() ?? "");
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class ClashConnectionModel
|
public class ClashConnectionModel
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class ClashConnections
|
public class ClashConnections
|
||||||
{
|
{
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using static ServiceLib.Models.ClashProxies;
|
using static ServiceLib.Models.Dto.ClashProxies;
|
||||||
|
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class ClashProviders
|
public class ClashProviders
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class ClashProxies
|
public class ClashProxies
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ClashProxyModel : ReactiveObject
|
public class ClashProxyModel : ReactiveObject
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class CmdItem
|
public class CmdItem
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class ComboItem
|
public class ComboItem
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class GitHubReleaseAsset
|
public class GitHubReleaseAsset
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
internal class IPAPIInfo
|
internal class IPAPIInfo
|
||||||
{
|
{
|
||||||
|
|
@ -17,3 +17,12 @@ public class LocationInfo
|
||||||
{
|
{
|
||||||
public string? country_code { get; set; }
|
public string? country_code { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly record struct IpInfoResult(string Country, string? Ip)
|
||||||
|
{
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
var emoji = Country.CountryToEmoji();
|
||||||
|
return $"{emoji}({Country}) {Ip}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ProfileItemModel : ReactiveObject
|
public class ProfileItemModel : ReactiveObject
|
||||||
|
|
@ -26,6 +26,9 @@ public class ProfileItemModel : ReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string SpeedVal { get; set; }
|
public string SpeedVal { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public string IpInfo { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string TodayUp { get; set; }
|
public string TodayUp { get; set; }
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class RetResult
|
public class RetResult
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RoutingItemModel : RoutingItem
|
public class RoutingItemModel : RoutingItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RoutingTemplate
|
public class RoutingTemplate
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RulesItemModel : RulesItem
|
public class RulesItemModel : RulesItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class SemanticVersion
|
public class SemanticVersion
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ServerSpeedItem : ServerStatItem
|
public class ServerSpeedItem : ServerStatItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ServerTestItem
|
public class ServerTestItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SpeedTestResult
|
public class SpeedTestResult
|
||||||
|
|
@ -8,4 +8,6 @@ public class SpeedTestResult
|
||||||
public string? Delay { get; set; }
|
public string? Delay { get; set; }
|
||||||
|
|
||||||
public string? Speed { get; set; }
|
public string? Speed { get; set; }
|
||||||
|
|
||||||
|
public string? IpInfo { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class SsSIP008
|
public class SsSIP008
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
public class UpdateResult
|
public class UpdateResult
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Dto;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// https://github.com/2dust/v2rayN/wiki/
|
/// https://github.com/2dust/v2rayN/wiki/
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class DNSItem
|
public class DNSItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class FullConfigTemplateItem
|
public class FullConfigTemplateItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ProfileExItem
|
public class ProfileExItem
|
||||||
|
|
@ -10,4 +10,5 @@ public class ProfileExItem
|
||||||
public decimal Speed { get; set; }
|
public decimal Speed { get; set; }
|
||||||
public int Sort { get; set; }
|
public int Sort { get; set; }
|
||||||
public string? Message { get; set; }
|
public string? Message { get; set; }
|
||||||
|
public string? IpInfo { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Obsolete("Use ProtocolExtraItem instead.")]
|
[Obsolete("Use ProtocolExtraItem instead.")]
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ProfileItem
|
public class ProfileItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
public record ProtocolExtraItem
|
public record ProtocolExtraItem
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RoutingItem
|
public class RoutingItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RulesItem
|
public class RulesItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ServerStatItem
|
public class ServerStatItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class SubItem
|
public class SubItem
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models.Entities;
|
||||||
|
|
||||||
public record TransportExtraItem
|
public record TransportExtraItem
|
||||||
{
|
{
|
||||||
51
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
51
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
|
|
@ -564,6 +564,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 IP Info 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string LvTestIpInfo {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("LvTestIpInfo", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Speed (MB/s) 的本地化字符串。
|
/// 查找类似 Speed (MB/s) 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -870,6 +879,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Only Check 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string menuCheckOnly {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("menuCheckOnly", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Check Update 的本地化字符串。
|
/// 查找类似 Check Update 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1302,6 +1320,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 New Update 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string menuNewUpdate {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("menuNewUpdate", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Open the storage location 的本地化字符串。
|
/// 查找类似 Open the storage location 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1887,6 +1914,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 {0} has a new version available: {1} 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgCheckUpdateHasNewVersion {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgCheckUpdateHasNewVersion", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Core '{0}' does not support network type '{1}' 的本地化字符串。
|
/// 查找类似 Core '{0}' does not support network type '{1}' 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -2040,6 +2076,15 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Not Support 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string MsgNotSupport {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgNotSupport", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Not support protocol '{0}' 的本地化字符串。
|
/// 查找类似 Not support protocol '{0}' 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -3484,7 +3529,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 socks: local port, socks2: second local port, socks3: LAN port 的本地化字符串。
|
/// 查找类似 tun: TUN inbound, socks: local port, socks2: second local port, socks3: LAN port 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TbRoutingInboundTagTips {
|
public static string TbRoutingInboundTagTips {
|
||||||
get {
|
get {
|
||||||
|
|
@ -3718,7 +3763,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode 的本地化字符串。
|
/// 查找类似 For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TbSettingsBindInterfaceTip {
|
public static string TbSettingsBindInterfaceTip {
|
||||||
get {
|
get {
|
||||||
|
|
@ -3925,7 +3970,7 @@ namespace ServiceLib.Resx {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 Check for pre-release updates 的本地化字符串。
|
/// 查找类似 Check for pre-release 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string TbSettingsEnableCheckPreReleaseUpdate {
|
public static string TbSettingsEnableCheckPreReleaseUpdate {
|
||||||
get {
|
get {
|
||||||
|
|
|
||||||
|
|
@ -1723,7 +1723,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<value>Bind Interface</value>
|
<value>Bind Interface</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
|
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>PreSharedKey</value>
|
||||||
|
|
@ -1731,4 +1731,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} has a new version available: {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>Only Check</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>Not Support</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP Info</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>New Update</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -1728,4 +1728,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} has a new version available: {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>Only Check</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>Not Support</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP Info</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>New Update</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -1723,7 +1723,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<value>Bind Interface</value>
|
<value>Bind Interface</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
|
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>PreSharedKey</value>
|
||||||
|
|
@ -1731,4 +1731,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} has a new version available: {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>Only Check</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>Not Support</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP Info</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>New Update</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -691,7 +691,7 @@
|
||||||
<value>Automatically adjust column width after subscription update</value>
|
<value>Automatically adjust column width after subscription update</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
||||||
<value>Check for pre-release updates</value>
|
<value>Check for pre-release</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsException" xml:space="preserve">
|
<data name="TbSettingsException" xml:space="preserve">
|
||||||
<value>Exception</value>
|
<value>Exception</value>
|
||||||
|
|
@ -1336,7 +1336,7 @@
|
||||||
<value>Enable second mixed port</value>
|
<value>Enable second mixed port</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRoutingInboundTagTips" xml:space="preserve">
|
<data name="TbRoutingInboundTagTips" xml:space="preserve">
|
||||||
<value>socks: local port, socks2: second local port, socks3: LAN port</value>
|
<value>tun: TUN inbound, socks: local port, socks2: second local port, socks3: LAN port</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsTheme" xml:space="preserve">
|
<data name="TbSettingsTheme" xml:space="preserve">
|
||||||
<value>Theme</value>
|
<value>Theme</value>
|
||||||
|
|
@ -1723,7 +1723,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<value>Bind Interface</value>
|
<value>Bind Interface</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||||
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems and TUN mode</value>
|
<value>For multi-interface environments, enter the name of the interface to bind. Only effective on Windows systems or TUN mode</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>PreSharedKey</value>
|
||||||
|
|
@ -1731,4 +1731,19 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} has a new version available: {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>Only Check</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>Not Support</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP Info</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>New Update</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -1726,9 +1726,24 @@
|
||||||
<value>Для среды с несколькими сетевыми интерфейсами укажите имя интерфейса для привязки. Работает только в Windows и режиме TUN</value>
|
<value>Для среды с несколькими сетевыми интерфейсами укажите имя интерфейса для привязки. Работает только в Windows и режиме TUN</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>Общий ключ (PSK)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>Export v2rayN Internal Share Link to Clipboard</value>
|
<value>Экспорт внутренней ссылки v2rayN в буфер обмена</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} has a new version available: {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>Only Check</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>Not Support</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP Info</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>New Update</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -691,7 +691,7 @@
|
||||||
<value>自动调整配置列宽在更新订阅后</value>
|
<value>自动调整配置列宽在更新订阅后</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
||||||
<value>检查 Pre-Release 更新 (请谨慎启用)</value>
|
<value>检查 Pre-Release</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsException" xml:space="preserve">
|
<data name="TbSettingsException" xml:space="preserve">
|
||||||
<value>例外</value>
|
<value>例外</value>
|
||||||
|
|
@ -1333,7 +1333,7 @@
|
||||||
<value>开启第二个本地监听端口</value>
|
<value>开启第二个本地监听端口</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbRoutingInboundTagTips" xml:space="preserve">
|
<data name="TbRoutingInboundTagTips" xml:space="preserve">
|
||||||
<value>Socks:本地端口,Socks2:第二个本地端口,Socks3:局域网端口</value>
|
<value>Tun:TUN 入站,Socks:本地端口,Socks2:第二个本地端口,Socks3:局域网端口</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsTheme" xml:space="preserve">
|
<data name="TbSettingsTheme" xml:space="preserve">
|
||||||
<value>主题</value>
|
<value>主题</value>
|
||||||
|
|
@ -1720,7 +1720,7 @@
|
||||||
<value>绑定网口</value>
|
<value>绑定网口</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||||
<value>用于多网口环境,填写要绑定的网口名称,仅生效于 Windows 系统和 TUN 模式</value>
|
<value>用于多网口环境,填写要绑定的网口名称,仅生效于 Windows 系统或 TUN 模式</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>PreSharedKey</value>
|
||||||
|
|
@ -1728,4 +1728,19 @@
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>导出 v2rayN 内部分享链接至剪贴板 (多选)</value>
|
<value>导出 v2rayN 内部分享链接至剪贴板 (多选)</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} 有新版本可用:{1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>仅检查</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>不支持</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP 信息</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>有更新</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -691,7 +691,7 @@
|
||||||
<value>在更新訂閱後自動調整列寬</value>
|
<value>在更新訂閱後自動調整列寬</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
<data name="TbSettingsEnableCheckPreReleaseUpdate" xml:space="preserve">
|
||||||
<value>檢查 Pre-Release 更新 (請謹慎啟用)</value>
|
<value>檢查 Pre-Release</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsException" xml:space="preserve">
|
<data name="TbSettingsException" xml:space="preserve">
|
||||||
<value>例外</value>
|
<value>例外</value>
|
||||||
|
|
@ -1720,7 +1720,7 @@
|
||||||
<value>綁定網路介面</value>
|
<value>綁定網路介面</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
<data name="TbSettingsBindInterfaceTip" xml:space="preserve">
|
||||||
<value>適用於多網路介面環境,請填寫要綁定的介面名稱;Windows 系統有效,其他系統僅在 TUN 模式下生效。</value>
|
<value>適用於多網路介面環境,請填寫要綁定的介面名稱;Windows 系統有效,其他系統僅在 TUN 模式下生效</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="TbPreSharedKey" xml:space="preserve">
|
<data name="TbPreSharedKey" xml:space="preserve">
|
||||||
<value>PreSharedKey</value>
|
<value>PreSharedKey</value>
|
||||||
|
|
@ -1728,4 +1728,19 @@
|
||||||
<data name="menuExport2InnerUri" xml:space="preserve">
|
<data name="menuExport2InnerUri" xml:space="preserve">
|
||||||
<value>匯出 v2rayN 內部分享連結至剪貼簿(多選)</value>
|
<value>匯出 v2rayN 內部分享連結至剪貼簿(多選)</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MsgCheckUpdateHasNewVersion" xml:space="preserve">
|
||||||
|
<value>{0} 有新版本可用:{1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuCheckOnly" xml:space="preserve">
|
||||||
|
<value>僅檢查</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgNotSupport" xml:space="preserve">
|
||||||
|
<value>不支援</value>
|
||||||
|
</data>
|
||||||
|
<data name="LvTestIpInfo" xml:space="preserve">
|
||||||
|
<value>IP 資訊</value>
|
||||||
|
</data>
|
||||||
|
<data name="menuNewUpdate" xml:space="preserve">
|
||||||
|
<value>有更新</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"type": "tun",
|
"type": "tun",
|
||||||
"tag": "tun-in",
|
"tag": "tun",
|
||||||
"interface_name": "singbox_tun",
|
"interface_name": "singbox_tun",
|
||||||
"address": [
|
"address": [
|
||||||
"172.18.0.1/30",
|
"172.18.0.1/30",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
<TreatAsUsed>true</TreatAsUsed>
|
<TreatAsUsed>true</TreatAsUsed>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ReactiveUI.Fody" />
|
<PackageReference Include="ReactiveUI.Fody" />
|
||||||
<PackageReference Include="sqlite-net-pcl" />
|
<PackageReference Include="sqlite-net-e" />
|
||||||
|
<PackageReference Include="Repobot.SQLite.Unofficial" />
|
||||||
<PackageReference Include="NLog" />
|
<PackageReference Include="NLog" />
|
||||||
<PackageReference Include="WebDav.Client" />
|
<PackageReference Include="WebDav.Client" />
|
||||||
<PackageReference Include="YamlDotNet" />
|
<PackageReference Include="YamlDotNet" />
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,14 @@ public partial class CoreConfigSingboxService
|
||||||
});
|
});
|
||||||
_coreConfig.route.rules.Add(new()
|
_coreConfig.route.rules.Add(new()
|
||||||
{
|
{
|
||||||
protocol = ["dns"],
|
type = "logical",
|
||||||
action = "hijack-dns"
|
mode = "or",
|
||||||
|
action = "hijack-dns",
|
||||||
|
rules =
|
||||||
|
[
|
||||||
|
new() { port = [53] },
|
||||||
|
new() { protocol = ["dns"] },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -96,7 +102,7 @@ public partial class CoreConfigSingboxService
|
||||||
_coreConfig.route.rules.Add(new()
|
_coreConfig.route.rules.Add(new()
|
||||||
{
|
{
|
||||||
port = [53],
|
port = [53],
|
||||||
action = "hijack-dns"
|
action = "hijack-dns",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ public partial class CoreConfigV2rayService
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
tag = balancerTag,
|
tag = balancerTag,
|
||||||
|
fallbackTag = multipleLoad == EMultipleLoad.Fallback ? Global.DirectTag : null,
|
||||||
};
|
};
|
||||||
_coreConfig.routing.balancers ??= new();
|
_coreConfig.routing.balancers ??= new();
|
||||||
_coreConfig.routing.balancers.Add(balancer);
|
_coreConfig.routing.balancers.Add(balancer);
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ public partial class CoreConfigV2rayService
|
||||||
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
var listenPort = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
_coreConfig.inbounds = [];
|
_coreConfig.inbounds = [];
|
||||||
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
|
var inbound = BuildInbound(_config.Inbound.First(), EInboundProtocol.socks, true);
|
||||||
|
var isUsingLocalMixedPort = _node.Address == Global.Loopback && _node.Port == listenPort;
|
||||||
|
|
||||||
if (!context.IsTunEnabled
|
if (!context.IsTunEnabled || !isUsingLocalMixedPort)
|
||||||
|| (context.IsTunEnabled && _node.Address != Global.Loopback && _node.Port != listenPort))
|
|
||||||
{
|
{
|
||||||
_coreConfig.inbounds.Add(inbound);
|
_coreConfig.inbounds.Add(inbound);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,6 @@ public partial class CoreConfigV2rayService
|
||||||
//ws
|
//ws
|
||||||
case nameof(ETransport.ws):
|
case nameof(ETransport.ws):
|
||||||
WsSettings4Ray wsSettings = new();
|
WsSettings4Ray wsSettings = new();
|
||||||
wsSettings.headers = new Headers4Ray();
|
|
||||||
|
|
||||||
if (host.IsNotEmpty())
|
if (host.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -503,6 +502,7 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
if (useragent.IsNotEmpty())
|
if (useragent.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
wsSettings.headers ??= new Headers4Ray();
|
||||||
wsSettings.headers.UserAgent = useragent;
|
wsSettings.headers.UserAgent = useragent;
|
||||||
}
|
}
|
||||||
streamSettings.wsSettings = wsSettings;
|
streamSettings.wsSettings = wsSettings;
|
||||||
|
|
@ -522,6 +522,7 @@ public partial class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
if (useragent.IsNotEmpty())
|
if (useragent.IsNotEmpty())
|
||||||
{
|
{
|
||||||
|
httpupgradeSettings.headers ??= new Headers4Ray();
|
||||||
httpupgradeSettings.headers.UserAgent = useragent;
|
httpupgradeSettings.headers.UserAgent = useragent;
|
||||||
}
|
}
|
||||||
streamSettings.httpupgradeSettings = httpupgradeSettings;
|
streamSettings.httpupgradeSettings = httpupgradeSettings;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public partial class CoreConfigV2rayService
|
||||||
});
|
});
|
||||||
_coreConfig.routing.rules.Add(new()
|
_coreConfig.routing.rules.Add(new()
|
||||||
{
|
{
|
||||||
|
inboundTag = ["tun"],
|
||||||
port = "53",
|
port = "53",
|
||||||
outboundTag = Global.DnsOutboundTag,
|
outboundTag = Global.DnsOutboundTag,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,10 @@ public class DownloadService
|
||||||
|
|
||||||
private static readonly string _tag = "DownloadService";
|
private static readonly string _tag = "DownloadService";
|
||||||
|
|
||||||
public async Task<int> DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout, Func<bool, string, Task> updateFunc)
|
/// <summary>
|
||||||
|
/// Downloads data with the specified proxy and reports progress messages.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<int> DownloadDataAsync(string url, IWebProxy webProxy, int downloadTimeout, Func<bool, string, Task> updateFunc)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -36,6 +39,9 @@ public class DownloadService
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Downloads a file and reports progress through events.
|
||||||
|
/// </summary>
|
||||||
public async Task DownloadFileAsync(string url, string fileName, bool blProxy, int downloadTimeout)
|
public async Task DownloadFileAsync(string url, string fileName, bool blProxy, int downloadTimeout)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -64,6 +70,9 @@ public class DownloadService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets redirect target URL without following redirects automatically.
|
||||||
|
/// </summary>
|
||||||
public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
|
public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
|
||||||
{
|
{
|
||||||
var webRequestHandler = new SocketsHttpHandler
|
var webRequestHandler = new SocketsHttpHandler
|
||||||
|
|
@ -86,11 +95,23 @@ public class DownloadService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to download string content using proxy switch setting.
|
||||||
|
/// </summary>
|
||||||
public async Task<string?> TryDownloadString(string url, bool blProxy, string userAgent)
|
public async Task<string?> TryDownloadString(string url, bool blProxy, string userAgent)
|
||||||
|
{
|
||||||
|
var webProxy = await GetWebProxy(blProxy);
|
||||||
|
return await TryDownloadString(url, webProxy, userAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to download string content with a specified proxy.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<string?> TryDownloadString(string url, IWebProxy? webProxy, string userAgent)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result1 = await DownloadStringAsync(url, blProxy, userAgent, 15);
|
var result1 = await DownloadStringAsync(url, webProxy, userAgent, 15);
|
||||||
if (result1.IsNotEmpty())
|
if (result1.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return result1;
|
return result1;
|
||||||
|
|
@ -108,7 +129,7 @@ public class DownloadService
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result2 = await DownloadStringViaDownloader(url, blProxy, userAgent, 15);
|
var result2 = await DownloadStringViaDownloader(url, webProxy, userAgent, 15);
|
||||||
if (result2.IsNotEmpty())
|
if (result2.IsNotEmpty())
|
||||||
{
|
{
|
||||||
return result2;
|
return result2;
|
||||||
|
|
@ -128,14 +149,12 @@ public class DownloadService
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DownloadString
|
/// Downloads string content via HttpClient.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url"></param>
|
private async Task<string?> DownloadStringAsync(string url, IWebProxy? webProxy, string userAgent, int timeout)
|
||||||
private async Task<string?> DownloadStringAsync(string url, bool blProxy, string userAgent, int timeout)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
|
||||||
var client = new HttpClient(new SocketsHttpHandler()
|
var client = new HttpClient(new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
Proxy = webProxy,
|
Proxy = webProxy,
|
||||||
|
|
@ -172,15 +191,12 @@ public class DownloadService
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DownloadString
|
/// Downloads string content via DownloaderHelper.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url"></param>
|
private async Task<string?> DownloadStringViaDownloader(string url, IWebProxy? webProxy, string userAgent, int timeout)
|
||||||
private async Task<string?> DownloadStringViaDownloader(string url, bool blProxy, string userAgent, int timeout)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
|
||||||
|
|
||||||
if (userAgent.IsNullOrEmpty())
|
if (userAgent.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
userAgent = Utils.GetVersion(false);
|
userAgent = Utils.GetVersion(false);
|
||||||
|
|
@ -200,6 +216,9 @@ public class DownloadService
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates local SOCKS proxy when proxy switch is enabled.
|
||||||
|
/// </summary>
|
||||||
private async Task<WebProxy?> GetWebProxy(bool blProxy)
|
private async Task<WebProxy?> GetWebProxy(bool blProxy)
|
||||||
{
|
{
|
||||||
if (!blProxy)
|
if (!blProxy)
|
||||||
|
|
@ -215,6 +234,9 @@ public class DownloadService
|
||||||
return new WebProxy($"socks5://{Global.Loopback}:{port}");
|
return new WebProxy($"socks5://{Global.Loopback}:{port}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the specified TCP endpoint is reachable.
|
||||||
|
/// </summary>
|
||||||
private async Task<bool> SocketCheck(string ip, int port)
|
private async Task<bool> SocketCheck(string ip, int port)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
private readonly Config? _config = config;
|
private readonly Config? _config = config;
|
||||||
private readonly Func<SpeedTestResult, Task>? _updateFunc = updateFunc;
|
private readonly Func<SpeedTestResult, Task>? _updateFunc = updateFunc;
|
||||||
private static readonly ConcurrentBag<string> _lstExitLoop = new();
|
private static readonly ConcurrentBag<string> _lstExitLoop = new();
|
||||||
|
private readonly int _speedTestPageSize = config.SpeedTestItem.SpeedTestPageSize ?? Global.SpeedTestPageSize;
|
||||||
|
private readonly TimeSpan _delayInterval = TimeSpan.FromSeconds(config.SpeedTestItem.SpeedTestDelayInterval ?? 1);
|
||||||
|
|
||||||
public void RunLoop(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
public void RunLoop(ESpeedActionType actionType, List<ProfileItem> selecteds)
|
||||||
{
|
{
|
||||||
|
|
@ -134,9 +136,14 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunTcpingAsync(List<ServerTestItem> selecteds)
|
private async Task RunTcpingAsync(List<ServerTestItem> selecteds)
|
||||||
|
{
|
||||||
|
var pageSize = Math.Min(selecteds.Count, _speedTestPageSize);
|
||||||
|
var lstBatch = GetTestBatchItem(selecteds, pageSize);
|
||||||
|
|
||||||
|
foreach (var lst in lstBatch)
|
||||||
{
|
{
|
||||||
List<Task> tasks = [];
|
List<Task> tasks = [];
|
||||||
foreach (var it in selecteds)
|
foreach (var it in lst)
|
||||||
{
|
{
|
||||||
tasks.Add(Task.Run(async () =>
|
tasks.Add(Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
|
@ -154,13 +161,15 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
await Task.WhenAll(tasks);
|
await Task.WhenAll(tasks);
|
||||||
|
await Task.Delay(_delayInterval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunRealPingBatchAsync(List<ServerTestItem> lstSelected, string exitLoopKey, int pageSize = 0)
|
private async Task RunRealPingBatchAsync(List<ServerTestItem> lstSelected, string exitLoopKey, int pageSize = 0)
|
||||||
{
|
{
|
||||||
if (pageSize <= 0)
|
if (pageSize <= 0)
|
||||||
{
|
{
|
||||||
pageSize = lstSelected.Count < Global.SpeedTestPageSize ? lstSelected.Count : Global.SpeedTestPageSize;
|
pageSize = Math.Min(lstSelected.Count, _speedTestPageSize);
|
||||||
}
|
}
|
||||||
var lstTest = GetTestBatchItem(lstSelected, pageSize);
|
var lstTest = GetTestBatchItem(lstSelected, pageSize);
|
||||||
|
|
||||||
|
|
@ -172,7 +181,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
{
|
{
|
||||||
lstFailed.AddRange(lst);
|
lstFailed.AddRange(lst);
|
||||||
}
|
}
|
||||||
await Task.Delay(100);
|
await Task.Delay(_delayInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retest the failed part
|
//Retest the failed part
|
||||||
|
|
@ -249,7 +258,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
{
|
{
|
||||||
if (pageSize <= 0)
|
if (pageSize <= 0)
|
||||||
{
|
{
|
||||||
pageSize = lstSelected.Count < Global.SpeedTestPageSize ? lstSelected.Count : Global.SpeedTestPageSize;
|
pageSize = Math.Min(lstSelected.Count, _speedTestPageSize);
|
||||||
}
|
}
|
||||||
var lstTest = GetTestBatchItem(lstSelected, pageSize);
|
var lstTest = GetTestBatchItem(lstSelected, pageSize);
|
||||||
|
|
||||||
|
|
@ -261,7 +270,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
{
|
{
|
||||||
lstFailed.AddRange(lst);
|
lstFailed.AddRange(lst);
|
||||||
}
|
}
|
||||||
await Task.Delay(100);
|
await Task.Delay(_delayInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retest the failed part
|
//Retest the failed part
|
||||||
|
|
@ -392,10 +401,23 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
private async Task<int> DoRealPing(ServerTestItem it)
|
private async Task<int> DoRealPing(ServerTestItem it)
|
||||||
{
|
{
|
||||||
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
|
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
|
||||||
var responseTime = await ConnectionHandler.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
|
var responseTime = await ConnectionHandler.GetRealPingTime(webProxy, 10);
|
||||||
|
|
||||||
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
||||||
await UpdateFunc(it.IndexId, responseTime.ToString());
|
await UpdateFunc(it.IndexId, responseTime.ToString());
|
||||||
|
|
||||||
|
if (responseTime > 0)
|
||||||
|
{
|
||||||
|
var ipInfo = await ConnectionHandler.GetIPInfo(webProxy);
|
||||||
|
var ipStr = ipInfo?.ToString() ?? Global.None;
|
||||||
|
ProfileExManager.Instance.SetTestIpInfo(it.IndexId, ipStr);
|
||||||
|
await UpdateIpInfoFunc(it.IndexId, ipStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await UpdateIpInfoFunc(it.IndexId, ResUI.SpeedtestingSkip);
|
||||||
|
}
|
||||||
|
|
||||||
return responseTime;
|
return responseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -491,4 +513,9 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
|
||||||
ProfileExManager.Instance.SetTestMessage(indexId, speed);
|
ProfileExManager.Instance.SetTestMessage(indexId, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task UpdateIpInfoFunc(string indexId, string ip)
|
||||||
|
{
|
||||||
|
await _updateFunc?.Invoke(new() { IndexId = indexId, IpInfo = ip });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,43 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<UpdateResult> CheckHasUpdateOnly(ECoreType type, bool preRelease)
|
||||||
|
{
|
||||||
|
if (!CoreInfoManager.Instance.IsCheckUpdateSupported(type))
|
||||||
|
{
|
||||||
|
return new UpdateResult(false, ResUI.MsgNotSupport);
|
||||||
|
}
|
||||||
|
|
||||||
|
var downloadHandle = new DownloadService();
|
||||||
|
var checkPreRelease = CoreInfoManager.Instance.GetCheckPreRelease(type, preRelease);
|
||||||
|
return await CheckUpdateAsync(downloadHandle, type, checkPreRelease);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<string>> CheckHasUpdateOnlyAll(bool preRelease)
|
||||||
|
{
|
||||||
|
var msgs = new List<string>();
|
||||||
|
foreach (var type in CoreInfoManager.Instance.GetCheckUpdateCoreTypes())
|
||||||
|
{
|
||||||
|
if (!(_config.CheckUpdateItem.SelectedCoreTypes?.Contains(type.ToString()) ?? true))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await CheckHasUpdateOnly(type, preRelease);
|
||||||
|
if (result.Success && result.Version != null)
|
||||||
|
{
|
||||||
|
var msg = string.Format(ResUI.MsgCheckUpdateHasNewVersion, type, result.Version);
|
||||||
|
msgs.Add(msg);
|
||||||
|
AppManager.Instance.SetLastCheckUpdateResult(type, msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AppManager.Instance.SetLastCheckUpdateResult(type, result.Msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task UpdateGeoFileAll()
|
public async Task UpdateGeoFileAll()
|
||||||
{
|
{
|
||||||
await UpdateGeoFiles();
|
await UpdateGeoFiles();
|
||||||
|
|
@ -301,14 +338,10 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||||
}
|
}
|
||||||
else if (Utils.IsLinux())
|
else if (Utils.IsLinux())
|
||||||
{
|
{
|
||||||
var arch = RuntimeInformation.ProcessArchitecture;
|
return RuntimeInformation.ProcessArchitecture switch
|
||||||
if (arch.ToString().Equals("RiscV64", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return coreInfo?.DownloadUrlLinuxRiscV64;
|
|
||||||
}
|
|
||||||
return arch switch
|
|
||||||
{
|
{
|
||||||
Architecture.Arm64 => coreInfo?.DownloadUrlLinuxArm64,
|
Architecture.Arm64 => coreInfo?.DownloadUrlLinuxArm64,
|
||||||
|
Architecture.RiscV64 => coreInfo?.DownloadUrlLinuxRiscV64,
|
||||||
Architecture.X64 => coreInfo?.DownloadUrlLinux64,
|
Architecture.X64 => coreInfo?.DownloadUrlLinux64,
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ namespace ServiceLib.Services;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// http://stackoverflow.com/questions/6266820/working-example-of-createjobobject-setinformationjobobject-pinvoke-in-net
|
/// http://stackoverflow.com/questions/6266820/working-example-of-createjobobject-setinformationjobobject-pinvoke-in-net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
public sealed class WindowsJobService : IDisposable
|
public sealed class WindowsJobService : IDisposable
|
||||||
{
|
{
|
||||||
private nint handle = nint.Zero;
|
private nint handle = nint.Zero;
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@ namespace ServiceLib.ViewModels;
|
||||||
public class CheckUpdateViewModel : MyReactiveObject
|
public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
private const string _geo = "GeoFiles";
|
private const string _geo = "GeoFiles";
|
||||||
private readonly string _v2rayN = ECoreType.v2rayN.ToString();
|
private readonly ECoreType _v2rayN = ECoreType.v2rayN;
|
||||||
private List<CheckUpdateModel> _lstUpdated = [];
|
private List<CheckUpdateModel> _lstUpdated = [];
|
||||||
private static readonly string _tag = "CheckUpdateViewModel";
|
private static readonly string _tag = "CheckUpdateViewModel";
|
||||||
|
|
||||||
public IObservableCollection<CheckUpdateModel> CheckUpdateModels { get; } = new ObservableCollectionExtended<CheckUpdateModel>();
|
public IObservableCollection<CheckUpdateModel> CheckUpdateModels { get; } = new ObservableCollectionExtended<CheckUpdateModel>();
|
||||||
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> CheckOnlyCmd { get; }
|
||||||
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
|
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
|
||||||
|
|
||||||
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
|
|
@ -23,12 +24,19 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
_ = UpdateView(_v2rayN, ex.Message);
|
_ = UpdateView(_v2rayN, ex.Message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CheckOnlyCmd = ReactiveCommand.CreateFromTask(CheckOnly);
|
||||||
|
CheckOnlyCmd.ThrownExceptions.Subscribe(ex =>
|
||||||
|
{
|
||||||
|
Logging.SaveLog(_tag, ex);
|
||||||
|
_ = UpdateView(_v2rayN, ex.Message);
|
||||||
|
});
|
||||||
|
|
||||||
EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate;
|
EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate;
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.EnableCheckPreReleaseUpdate,
|
x => x.EnableCheckPreReleaseUpdate,
|
||||||
y => y == true)
|
y => y == true)
|
||||||
.Subscribe(c => _config.CheckUpdateItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate);
|
.Subscribe(c => _ = OnCheckPreReleaseUpdateChanged());
|
||||||
|
|
||||||
RefreshCheckUpdateItems();
|
RefreshCheckUpdateItems();
|
||||||
}
|
}
|
||||||
|
|
@ -37,21 +45,15 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
CheckUpdateModels.Clear();
|
CheckUpdateModels.Clear();
|
||||||
|
|
||||||
if (RuntimeInformation.ProcessArchitecture != Architecture.X86)
|
foreach (var type in CoreInfoManager.Instance.GetCheckUpdateCoreTypes())
|
||||||
{
|
{
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(_v2rayN));
|
CheckUpdateModels.Add(GetCheckUpdateModel(type));
|
||||||
//Not Windows and under Win10
|
|
||||||
if (!(Utils.IsWindows() && Environment.OSVersion.Version.Major < 10))
|
|
||||||
{
|
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(ECoreType.Xray.ToString()));
|
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(ECoreType.mihomo.ToString()));
|
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(ECoreType.sing_box.ToString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckUpdateModel GetCheckUpdateModel(string coreType)
|
CheckUpdateModels.Add(GetGeoFileCheckUpdateModel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private CheckUpdateModel GetCheckUpdateModel(ECoreType coreType)
|
||||||
{
|
{
|
||||||
if (coreType == _v2rayN && Utils.IsPackagedInstall())
|
if (coreType == _v2rayN && Utils.IsPackagedInstall())
|
||||||
{
|
{
|
||||||
|
|
@ -59,34 +61,64 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
IsSelected = false,
|
IsSelected = false,
|
||||||
CoreType = coreType,
|
CoreType = coreType,
|
||||||
Remarks = ResUI.menuCheckUpdate + " (Not Support)",
|
IsGeoFile = false,
|
||||||
|
Remarks = ResUI.menuCheckUpdate + $" ({ResUI.MsgNotSupport})",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppManager.Instance.LastCheckUpdateResults.TryGetValue(coreType, out var lastResult);
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
IsSelected = _config.CheckUpdateItem.SelectedCoreTypes?.Contains(coreType) ?? true,
|
IsSelected = _config.CheckUpdateItem.SelectedCoreTypes?.Contains(coreType.ToString()) ?? true,
|
||||||
CoreType = coreType,
|
CoreType = coreType,
|
||||||
|
IsGeoFile = false,
|
||||||
|
Remarks = lastResult ?? ResUI.menuCheckUpdate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private CheckUpdateModel GetGeoFileCheckUpdateModel()
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
IsSelected = _config.CheckUpdateItem.SelectedCoreTypes?.Contains(_geo) ?? true,
|
||||||
|
CoreType = null,
|
||||||
|
IsGeoFile = true,
|
||||||
Remarks = ResUI.menuCheckUpdate,
|
Remarks = ResUI.menuCheckUpdate,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task OnCheckPreReleaseUpdateChanged()
|
||||||
|
{
|
||||||
|
if (_config.CheckUpdateItem.CheckPreReleaseUpdate == EnableCheckPreReleaseUpdate)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_config.CheckUpdateItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate;
|
||||||
|
await SaveSelectedCoreTypes();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task SaveSelectedCoreTypes()
|
private async Task SaveSelectedCoreTypes()
|
||||||
{
|
{
|
||||||
_config.CheckUpdateItem.SelectedCoreTypes = CheckUpdateModels.Where(t => t.IsSelected == true).Select(t => t.CoreType ?? "").ToList();
|
_config.CheckUpdateItem.SelectedCoreTypes =
|
||||||
|
CheckUpdateModels.Where(t => t.IsSelected == true)
|
||||||
|
.Select(t => t.CoreTypeForStorage)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckOnly()
|
||||||
|
{
|
||||||
|
await Task.Run(CheckOnlyTask);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task CheckUpdate()
|
private async Task CheckUpdate()
|
||||||
{
|
{
|
||||||
await Task.Run(CheckUpdateTask);
|
await Task.Run(CheckUpdateTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckUpdateTask()
|
private async Task CheckOnlyTask()
|
||||||
{
|
{
|
||||||
_lstUpdated.Clear();
|
|
||||||
_lstUpdated = CheckUpdateModels.Where(x => x.IsSelected == true)
|
|
||||||
.Select(x => new CheckUpdateModel() { CoreType = x.CoreType }).ToList();
|
|
||||||
await SaveSelectedCoreTypes();
|
await SaveSelectedCoreTypes();
|
||||||
|
|
||||||
for (var k = CheckUpdateModels.Count - 1; k >= 0; k--)
|
for (var k = CheckUpdateModels.Count - 1; k >= 0; k--)
|
||||||
|
|
@ -98,7 +130,56 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
|
|
||||||
await UpdateView(item.CoreType, "...");
|
await UpdateView(item.CoreType, "...");
|
||||||
if (item.CoreType == _geo)
|
|
||||||
|
if (item.IsGeoFile || item.CoreType == null)
|
||||||
|
{
|
||||||
|
await UpdateView(item.CoreType, ResUI.menuCheckOnly + $" ({ResUI.MsgNotSupport})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.CoreType == null)
|
||||||
|
{
|
||||||
|
await UpdateView(item.CoreType, ResUI.MsgNotSupport);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var updateService = new UpdateService(_config, async (success, msg) => await Task.CompletedTask);
|
||||||
|
var result = await updateService.CheckHasUpdateOnly(item.CoreType.Value, EnableCheckPreReleaseUpdate);
|
||||||
|
if (result.Success && result.Version != null)
|
||||||
|
{
|
||||||
|
await UpdateView(item.CoreType, string.Format(ResUI.MsgCheckUpdateHasNewVersion, item.CoreType, result.Version));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await UpdateView(item.CoreType, result.Msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task CheckUpdateTask()
|
||||||
|
{
|
||||||
|
_lstUpdated.Clear();
|
||||||
|
_lstUpdated = CheckUpdateModels
|
||||||
|
.Where(x => x.IsSelected == true)
|
||||||
|
.Select(x => new CheckUpdateModel()
|
||||||
|
{
|
||||||
|
CoreType = x.CoreType,
|
||||||
|
IsGeoFile = x.IsGeoFile
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
await SaveSelectedCoreTypes();
|
||||||
|
|
||||||
|
for (var k = CheckUpdateModels.Count - 1; k >= 0; k--)
|
||||||
|
{
|
||||||
|
var item = CheckUpdateModels[k];
|
||||||
|
if (item.IsSelected != true)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await UpdateView(item.CoreType, "...");
|
||||||
|
|
||||||
|
if (item.IsGeoFile)
|
||||||
{
|
{
|
||||||
await CheckUpdateGeo();
|
await CheckUpdateGeo();
|
||||||
}
|
}
|
||||||
|
|
@ -106,16 +187,16 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (Utils.IsPackagedInstall())
|
if (Utils.IsPackagedInstall())
|
||||||
{
|
{
|
||||||
await UpdateView(_v2rayN, "Not Support");
|
await UpdateView(_v2rayN, ResUI.MsgNotSupport);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await CheckUpdateN(EnableCheckPreReleaseUpdate);
|
await CheckUpdateN(EnableCheckPreReleaseUpdate);
|
||||||
}
|
}
|
||||||
else if (item.CoreType == ECoreType.Xray.ToString())
|
else if (item.CoreType == ECoreType.Xray)
|
||||||
{
|
{
|
||||||
await CheckUpdateCore(item, EnableCheckPreReleaseUpdate);
|
await CheckUpdateCore(item, EnableCheckPreReleaseUpdate);
|
||||||
}
|
}
|
||||||
else
|
else if (item.CoreType.HasValue)
|
||||||
{
|
{
|
||||||
await CheckUpdateCore(item, false);
|
await CheckUpdateCore(item, false);
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +205,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
await UpdateFinished();
|
await UpdateFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatedPlusPlus(string coreType, string fileName)
|
private void UpdatedPlusPlus(ECoreType? coreType, string fileName)
|
||||||
{
|
{
|
||||||
var item = _lstUpdated.FirstOrDefault(x => x.CoreType == coreType);
|
var item = _lstUpdated.FirstOrDefault(x => x.CoreType == coreType);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
|
|
@ -142,14 +223,14 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
async Task _updateUI(bool success, string msg)
|
async Task _updateUI(bool success, string msg)
|
||||||
{
|
{
|
||||||
await UpdateView(_geo, msg);
|
await UpdateView(null, msg);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
UpdatedPlusPlus(_geo, "");
|
UpdatedPlusPlus(null, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await new UpdateService(_config, _updateUI).UpdateGeoFileAll()
|
await new UpdateService(_config, _updateUI).UpdateGeoFileAll()
|
||||||
.ContinueWith(t => UpdatedPlusPlus(_geo, ""));
|
.ContinueWith(t => UpdatedPlusPlus(null, ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckUpdateN(bool preRelease)
|
private async Task CheckUpdateN(bool preRelease)
|
||||||
|
|
@ -175,14 +256,16 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
await UpdateView(model.CoreType, ResUI.MsgUpdateV2rayCoreSuccessfullyMore);
|
await UpdateView(model.CoreType, ResUI.MsgUpdateV2rayCoreSuccessfullyMore);
|
||||||
|
|
||||||
UpdatedPlusPlus(model.CoreType, msg);
|
UpdatedPlusPlus(model.CoreType, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var type = (ECoreType)Enum.Parse(typeof(ECoreType), model.CoreType);
|
|
||||||
await new UpdateService(_config, _updateUI).CheckUpdateCore(type, preRelease)
|
if (model.CoreType.HasValue)
|
||||||
|
{
|
||||||
|
await new UpdateService(_config, _updateUI).CheckUpdateCore(model.CoreType.Value, preRelease)
|
||||||
.ContinueWith(t => UpdatedPlusPlus(model.CoreType, ""));
|
.ContinueWith(t => UpdatedPlusPlus(model.CoreType, ""));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateFinished()
|
private async Task UpdateFinished()
|
||||||
{
|
{
|
||||||
|
|
@ -257,7 +340,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
foreach (var item in _lstUpdated)
|
foreach (var item in _lstUpdated)
|
||||||
{
|
{
|
||||||
if (item.FileName.IsNullOrEmpty())
|
if (item.FileName.IsNullOrEmpty() || item.IsGeoFile)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +350,9 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var toPath = Utils.GetBinPath("", item.CoreType);
|
|
||||||
|
var coreTypeStr = item.CoreType?.ToString() ?? "";
|
||||||
|
var toPath = Utils.GetBinPath("", coreTypeStr);
|
||||||
|
|
||||||
if (fileName.Contains(".tar.gz"))
|
if (fileName.Contains(".tar.gz"))
|
||||||
{
|
{
|
||||||
|
|
@ -284,7 +369,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else if (fileName.Contains(".gz"))
|
else if (fileName.Contains(".gz"))
|
||||||
{
|
{
|
||||||
FileUtils.DecompressFile(fileName, toPath, item.CoreType);
|
FileUtils.DecompressFile(fileName, toPath, coreTypeStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -296,7 +381,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
var filesList = new DirectoryInfo(toPath).GetFiles().Select(u => u.FullName).ToList();
|
var filesList = new DirectoryInfo(toPath).GetFiles().Select(u => u.FullName).ToList();
|
||||||
foreach (var file in filesList)
|
foreach (var file in filesList)
|
||||||
{
|
{
|
||||||
await Utils.SetLinuxChmod(Path.Combine(toPath, item.CoreType.ToLower()));
|
await Utils.SetLinuxChmod(Path.Combine(toPath, coreTypeStr.ToLower()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,11 +394,12 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateView(string coreType, string msg)
|
private async Task UpdateView(ECoreType? coreType, string msg)
|
||||||
{
|
{
|
||||||
var item = new CheckUpdateModel()
|
var item = new CheckUpdateModel()
|
||||||
{
|
{
|
||||||
CoreType = coreType,
|
CoreType = coreType,
|
||||||
|
IsGeoFile = coreType == null,
|
||||||
Remarks = msg,
|
Remarks = msg,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -327,7 +413,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
|
|
||||||
public async Task UpdateViewResult(CheckUpdateModel model)
|
public async Task UpdateViewResult(CheckUpdateModel model)
|
||||||
{
|
{
|
||||||
var found = CheckUpdateModels.FirstOrDefault(t => t.CoreType == model.CoreType);
|
var found = CheckUpdateModels.FirstOrDefault(t => t.CoreType == model.CoreType && t.IsGeoFile == model.IsGeoFile);
|
||||||
if (found == null)
|
if (found == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue