Compare commits
237 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35fe8b0ef8 | |||
| 1f393fc37f | |||
| 764e1ba165 | |||
| fed5298156 | |||
| 456aed053e | |||
| 3a5b17b103 | |||
| 722005f345 | |||
| 02c67d9232 | |||
| 84e6aa5e21 | |||
| 0042d3e7f4 | |||
| d21993804c | |||
| 9d35e02e0e | |||
| 135fcb0cda | |||
| 11505a5c05 | |||
| 237707b31c | |||
| ae4581d17b | |||
| 0b099f60c5 | |||
| 5ce40e300a | |||
| 1f0a3a25f1 | |||
| e74944065b | |||
| 1ef0ffa60e | |||
| 51cf30f429 | |||
| 14ea27292f | |||
| 6ba547331e | |||
| f4e08c8ae3 | |||
| 4424565da4 | |||
| 93dd02f53e | |||
| 7b5b30ca8f | |||
| 4caddb800d | |||
| f50be0bb41 | |||
| 7bfd753bb0 | |||
| 654249deb6 | |||
| efe6bca87c | |||
| a721c85955 | |||
| 69d79e5d91 | |||
| 2deb250a23 | |||
| 14c889f948 | |||
| e76ca2ea9d | |||
| 775b9b57bc | |||
| c70f0f97b3 | |||
| 86379818a2 | |||
| 8a07d2df7e | |||
| 7d63da8be3 | |||
| 06ee9cfce2 | |||
| 13d475da20 | |||
| fbf46a72b0 | |||
| 5bb15ff2c9 | |||
| 5812d6a827 | |||
| 083f19324f | |||
| dd07abf501 | |||
| 0202a3e055 | |||
| 66ca82c635 | |||
| 85d42ee91c | |||
| bdc25bb3d6 | |||
| e6689ae2dc | |||
| 688e0c3e23 | |||
| d996e7171b | |||
| 76e91aa9b8 | |||
| af5bd9f75d | |||
| 0fd36e4e6d | |||
| 0f29e2ad31 | |||
| 4ce3647670 | |||
| 90976cded1 | |||
| f5714eccee | |||
| e84f7530e3 | |||
| 63cc7ca957 | |||
| c8432fda54 | |||
| 022574a1d7 | |||
| 76ab5e2ccc | |||
| 10ba989175 | |||
| 46434a6b3f | |||
| c5e07ba076 | |||
| d5c6bdaeff | |||
| f69b55f721 | |||
| 3c9d178709 | |||
| 14013b7d70 | |||
| 9d367fb83d | |||
| 0ef5db4846 | |||
| 94cc29edf5 | |||
| 40e2b4cc8a | |||
| 2b0006f8c8 | |||
| 216a76051e | |||
| a0d7bcc829 | |||
| 87e3118d6b | |||
| 9bc4fe843b | |||
| b779e3b825 | |||
| 4e97afebab | |||
| 3de228ebcd | |||
| abd1c378d5 | |||
| de7197cc58 | |||
| 7a4c010a45 | |||
| 09e94c6213 | |||
| fc88f5a509 | |||
| 1c34e146c1 | |||
| de30e17707 | |||
| 7a9f3196c7 | |||
| 65e51f8aea | |||
| d31a78b625 | |||
| d6c4d9a497 | |||
| 7b979b95d4 | |||
| 64979e6725 | |||
| 0e3e2d0b18 | |||
| 6d52ad13c5 | |||
| 7c406cfd1c | |||
| c5ccfb6ead | |||
| 5aa5393ada | |||
| 15d171f94e | |||
| 7751c8fce0 | |||
| 9d1ad833f9 | |||
| e6f7354ce7 | |||
| a2c3033f5a | |||
| 03cda07c9d | |||
| fb999b4ee8 | |||
| e3ebfcf721 | |||
| 33071deb53 | |||
| 9b3b8d4540 | |||
| 98bf124078 | |||
| abc73a6525 | |||
| 2276175354 | |||
| 7f24735677 | |||
| 4d1544864d | |||
| 4aadee7ca0 | |||
| 6aba1354d5 | |||
| 63b229143d | |||
| f861950c50 | |||
| 97d1694bfa | |||
| 2d28d9b409 | |||
| 560c41acbe | |||
| e3c33bf649 | |||
| 216db63551 | |||
| 05d8a6bf85 | |||
| 1e6c2b9598 | |||
| f006323f54 | |||
| f3bfe9bb9a | |||
| ffbab9682a | |||
| 123813dc90 | |||
| 7bc7468cf3 | |||
| 12addde548 | |||
| e54cca19fa | |||
| a67ec6f58e | |||
| f913591af0 | |||
| 38f7c131a2 | |||
| 7c0478d7f4 | |||
| b26aa8d53c | |||
| fb12a27d62 | |||
| 82c7b43f06 | |||
| 05880ed3b3 | |||
| 1b13fd6839 | |||
| 44fd5f767b | |||
| 9135033dfd | |||
| b1a61584b1 | |||
| b2a0ccfe02 | |||
| 590f6871af | |||
| 282a24b8fc | |||
| af1d34a762 | |||
| 69da810426 | |||
| 8f98050964 | |||
| 1c14c1ce9c | |||
| f2ccba3cd2 | |||
| 5ad8d61002 | |||
| f7e40023c4 | |||
| 975150420c | |||
| 9c3db8cc2b | |||
| 55b6272204 | |||
| 371eb9ece8 | |||
| e883a8e153 | |||
| f608f0bba0 | |||
| 4c73fa6d58 | |||
| d13cac69c6 | |||
| 13990b68d2 | |||
| 4068096fce | |||
| a20a926332 | |||
| 50ef6cd225 | |||
| dd7e81c557 | |||
| 58fd5f17cf | |||
| 13117843ec | |||
| 60b0b3c878 | |||
| 825a8d9fd9 | |||
| 58105be433 | |||
| 98db6d2445 | |||
| cd3d4e6451 | |||
| 1e3d1b9ed3 | |||
| a794cace54 | |||
| 6520a8dc9c | |||
| 8ccd60cb74 | |||
| c9d89540d3 | |||
| c2d33d2a1e | |||
| fe4fa9b9e6 | |||
| 1d23f5a1df | |||
| 349d490a65 | |||
| 11326d7cc1 | |||
| d2827d013b | |||
| f239574e41 | |||
| bc05aed51f | |||
| ff791d0a27 | |||
| 319e3b1eba | |||
| 12a24ec617 | |||
| 92c742987e | |||
| 4dabe656c9 | |||
| 03fff53260 | |||
| f65cb2ca06 | |||
| 36938aee41 | |||
| d82af6f9bd | |||
| 6b785c3404 | |||
| df1a271efa | |||
| bd9bd8590c | |||
| d186875ab7 | |||
| 3f7657c080 | |||
| a5f4c46066 | |||
| 596dc8a884 | |||
| 6c97ad8871 | |||
| 5b77dded66 | |||
| 73cf4d5b7e | |||
| 1991091444 | |||
| f69c74b09c | |||
| 118baf12df | |||
| fc410c9a8d | |||
| d873c86ef8 | |||
| 855a838599 | |||
| 354378e038 | |||
| 8b431f4da8 | |||
| 0a08e9f834 | |||
| a10950499b | |||
| bac2580be7 | |||
| d21deda218 | |||
| 6ad2a7af70 | |||
| 59d2c652e6 | |||
| 1c0c5f61c6 | |||
| 97d3b10e2f | |||
| d50695067e | |||
| 5bfd60176f | |||
| 9dd63f83da | |||
| 045f368c27 | |||
| a1e9ef00a1 | |||
| 11215b96ae | |||
| 1535338e0b | |||
| f6be2dd12e |
@@ -10,6 +10,8 @@ main
|
||||
tmp
|
||||
.sync*
|
||||
*.tar.gz
|
||||
frontend/node_modules
|
||||
frontend/.vite
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
buy_me_a_coffee: alireza7
|
||||
github: alireza0
|
||||
|
||||
+148
-45
@@ -6,51 +6,154 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
frontend-build:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
alireza7/s-ui
|
||||
ghcr.io/alireza0/s-ui
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=pep440,pattern={{version}}
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 25
|
||||
- name: Install dependencies and build frontend
|
||||
run: |
|
||||
cd frontend
|
||||
npm install
|
||||
npm run build
|
||||
- name: Upload frontend build artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist/
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
build:
|
||||
needs: frontend-build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { platform: linux/amd64 }
|
||||
- { platform: linux/386 }
|
||||
- { platform: linux/arm64/v8 }
|
||||
- { platform: linux/arm/v7 }
|
||||
- { platform: linux/arm/v6 }
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.2
|
||||
- name: Download frontend build artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend_dist
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform="${{ matrix.platform }}"
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
alireza7/s-ui
|
||||
ghcr.io/alireza0/s-ui
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=pep440,pattern={{version}}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ matrix.platform }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-${{ matrix.platform }}-
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push by digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.frontend-artifact
|
||||
platforms: ${{ matrix.platform }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
tags: |
|
||||
alireza7/s-ui
|
||||
ghcr.io/alireza0/s-ui
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
||||
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
|
||||
- name: Export digest
|
||||
run: |
|
||||
mkdir -p ${{ runner.temp }}/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
echo "${digest#sha256:}" > "${{ runner.temp }}/digests/${digest#sha256:}"
|
||||
- name: Upload digest
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: digests-${{ env.PLATFORM_PAIR }}
|
||||
path: ${{ runner.temp }}/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64, linux/arm64/v8, linux/arm/v7, linux/arm/v6, linux/386
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
merge:
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: ${{ runner.temp }}/digests
|
||||
pattern: digests-*
|
||||
merge-multiple: true
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_TOKEN }}
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: |
|
||||
alireza7/s-ui
|
||||
ghcr.io/alireza0/s-ui
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=tag
|
||||
type=pep440,pattern={{version}}
|
||||
- name: Create manifest list and push
|
||||
env:
|
||||
DOCKER_METADATA_OUTPUT_JSON: ${{ steps.meta.outputs.json }}
|
||||
working-directory: ${{ runner.temp }}/digests
|
||||
run: |
|
||||
set -e
|
||||
for img in alireza7/s-ui ghcr.io/alireza0/s-ui; do
|
||||
TAGS_ARGS=$(echo "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr --arg img "$img" '.tags | map(select(startswith($img))) | map("-t " + .) | join(" ")')
|
||||
DIGEST_REFS=$(for f in *; do echo -n "${img}@sha256:$(cat "$f") "; done)
|
||||
docker buildx imagetools create $TAGS_ARGS $DIGEST_REFS
|
||||
done
|
||||
|
||||
+162
-73
@@ -1,58 +1,45 @@
|
||||
name: Release S-UI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "*"
|
||||
workflow_dispatch:
|
||||
paths:
|
||||
- '.github/workflows/release.yml'
|
||||
- 'frontend/**'
|
||||
- '**.sh'
|
||||
- '**.go'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 's-ui.service'
|
||||
|
||||
env:
|
||||
NODE_VERSION: "25"
|
||||
CRONET_GO_VERSION: "2fef65f9dba90ddb89a87d00a6eb6165487c10c1"
|
||||
CRONET_GO_REPO: https://github.com/sagernet/cronet-go.git
|
||||
BOOTLIN_BASE_URL: https://toolchains.bootlin.com/downloads/releases/toolchains
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- amd64
|
||||
- arm64
|
||||
- armv7
|
||||
- armv6
|
||||
- armv5
|
||||
- 386
|
||||
- s390x
|
||||
runs-on: ubuntu-20.04
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.2
|
||||
- name: Checkout repository (frontend only)
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
cache: false
|
||||
go-version-file: go.mod
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
if [ "${{ matrix.platform }}" == "arm64" ]; then
|
||||
sudo apt install gcc-aarch64-linux-gnu
|
||||
elif [ "${{ matrix.platform }}" == "armv7" ]; then
|
||||
sudo apt install gcc-arm-linux-gnueabihf
|
||||
elif [ "${{ matrix.platform }}" == "armv6" ]; then
|
||||
sudo apt install gcc-arm-linux-gnueabihf
|
||||
elif [ "${{ matrix.platform }}" == "armv5" ]; then
|
||||
sudo apt install gcc-arm-linux-gnueabi
|
||||
elif [ "${{ matrix.platform }}" == "386" ]; then
|
||||
sudo apt install gcc-i686-linux-gnu
|
||||
elif [ "${{ matrix.platform }}" == "s390x" ]; then
|
||||
sudo apt install gcc-s390x-linux-gnu
|
||||
fi
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Build frontend
|
||||
run: |
|
||||
@@ -60,39 +47,131 @@ jobs:
|
||||
npm install
|
||||
npm run build
|
||||
cd ..
|
||||
mv frontend/dist web/html
|
||||
rm -fr frontend
|
||||
|
||||
- name: Upload frontend dist
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist/
|
||||
|
||||
build-linux:
|
||||
name: build-${{ matrix.platform }}
|
||||
needs: build-frontend
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { platform: amd64, arch: amd64, bootlin: x86-64, naive: true }
|
||||
- { platform: arm64, arch: arm64, bootlin: aarch64, naive: true }
|
||||
- { platform: armv7, arch: arm, goarm: "7", bootlin: armv7-eabihf, naive: true }
|
||||
- { platform: armv6, arch: arm, goarm: "6", bootlin: armv6-eabihf, naive: true }
|
||||
- { platform: armv5, arch: arm, goarm: "5", bootlin: armv5-eabi, naive: false }
|
||||
- { platform: "386", arch: "386", bootlin: x86-i686, naive: true }
|
||||
- { platform: s390x, arch: s390x, bootlin: s390x-z13, naive: false }
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Download frontend dist
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: web/html
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
cache: false
|
||||
go-version-file: go.mod
|
||||
|
||||
# Naive platforms: use cronet toolchain only (no Bootlin).
|
||||
- name: Clone cronet-go (cronet toolchain for naive)
|
||||
if: matrix.naive
|
||||
run: |
|
||||
set -e
|
||||
git init ~/cronet-go
|
||||
git -C ~/cronet-go remote add origin ${{ env.CRONET_GO_REPO }}
|
||||
git -C ~/cronet-go fetch --depth=1 origin "${{ env.CRONET_GO_VERSION }}"
|
||||
git -C ~/cronet-go checkout FETCH_HEAD
|
||||
git -C ~/cronet-go submodule update --init --recursive --depth=1
|
||||
|
||||
- name: Regenerate Debian keyring (cronet sysroot)
|
||||
if: matrix.naive
|
||||
run: |
|
||||
set -e
|
||||
rm -f ~/cronet-go/naiveproxy/src/build/linux/sysroot_scripts/keyring.gpg
|
||||
cd ~/cronet-go
|
||||
GPG_TTY=/dev/null ./naiveproxy/src/build/linux/sysroot_scripts/generate_keyring.sh
|
||||
|
||||
- name: Cache Chromium toolchain
|
||||
if: matrix.naive
|
||||
id: cache-chromium-toolchain
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: |
|
||||
~/cronet-go/naiveproxy/src/third_party/llvm-build/
|
||||
~/cronet-go/naiveproxy/src/gn/out/
|
||||
~/cronet-go/naiveproxy/src/chrome/build/pgo_profiles/
|
||||
~/cronet-go/naiveproxy/src/out/sysroot-build/
|
||||
key: chromium-toolchain-${{ matrix.platform }}-musl-${{ env.CRONET_GO_VERSION }}
|
||||
|
||||
- name: Build cronet lib and set toolchain env (CC, CXX, CGO_LDFLAGS, PATH)
|
||||
if: matrix.naive
|
||||
run: |
|
||||
set -e
|
||||
cd ~/cronet-go
|
||||
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} --libc=musl download-toolchain
|
||||
go run ./cmd/build-naive --target=linux/${{ matrix.arch }} --libc=musl env | while IFS= read -r line; do
|
||||
line="${line#export }"
|
||||
[[ -z "$line" ]] && continue
|
||||
echo "$line" >> $GITHUB_ENV
|
||||
done
|
||||
|
||||
- name: Set Go build env (all platforms)
|
||||
run: |
|
||||
echo "CGO_ENABLED=1" >> $GITHUB_ENV
|
||||
echo "GOOS=linux" >> $GITHUB_ENV
|
||||
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV
|
||||
if [ -n "${{ matrix.goarm }}" ]; then echo "GOARM=${{ matrix.goarm }}" >> $GITHUB_ENV; fi
|
||||
|
||||
# Non-naive platforms only: Bootlin musl (armv5, s390x).
|
||||
- name: Set up Bootlin musl (armv5, s390x)
|
||||
if: ${{ matrix.naive != true }}
|
||||
run: |
|
||||
set -e
|
||||
BOOTLIN_ARCH="${{ matrix.bootlin }}"
|
||||
echo "Resolving Bootlin musl toolchain for arch=$BOOTLIN_ARCH (platform=${{ matrix.platform }})"
|
||||
TARBALL_BASE="${{ env.BOOTLIN_BASE_URL }}/$BOOTLIN_ARCH/tarballs/"
|
||||
TARBALL_URL=$(curl -fsSL "$TARBALL_BASE" | grep -oE "${BOOTLIN_ARCH}--musl--stable-[^\"]+\\.tar\\.xz" | sort -r | head -n1)
|
||||
[ -z "$TARBALL_URL" ] && { echo "Failed to locate Bootlin musl toolchain for arch=$BOOTLIN_ARCH" >&2; exit 1; }
|
||||
echo "Downloading: $TARBALL_URL"
|
||||
cd /tmp
|
||||
curl -fL -sS -o "$(basename "$TARBALL_URL")" "$TARBALL_BASE/$TARBALL_URL"
|
||||
tar -xf "$(basename "$TARBALL_URL")"
|
||||
TOOLCHAIN_DIR=$(find . -maxdepth 1 -type d -name "${BOOTLIN_ARCH}--musl--stable-*" | head -n1)
|
||||
TOOLCHAIN_DIR="$(realpath "$TOOLCHAIN_DIR")"
|
||||
BIN_DIR="$TOOLCHAIN_DIR/bin"
|
||||
echo "PATH=$BIN_DIR:$PATH" >> $GITHUB_ENV
|
||||
CC=$(find "$BIN_DIR" -maxdepth 1 \( -name '*-gcc.br_real' -o -name '*-gcc' \) -type f -executable 2>/dev/null | grep -v g++ | head -n1)
|
||||
[ -z "$CC" ] && { echo "No gcc found in $BIN_DIR" >&2; exit 1; }
|
||||
echo "CC=$(realpath "$CC")" >> $GITHUB_ENV
|
||||
SYSROOT=""
|
||||
F=$(find "$TOOLCHAIN_DIR" -name "libc-header-start.h" 2>/dev/null | head -1)
|
||||
if [ -n "$F" ]; then SYSROOT=$(dirname "$(dirname "$(dirname "$(dirname "$F")")")"); fi
|
||||
if [ -n "$SYSROOT" ] && [ -d "$SYSROOT" ]; then
|
||||
echo "CGO_CFLAGS=--sysroot=$SYSROOT" >> $GITHUB_ENV
|
||||
echo "CGO_LDFLAGS=--sysroot=$SYSROOT -static" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Build s-ui
|
||||
run: |
|
||||
export CGO_ENABLED=1
|
||||
export GOOS=linux
|
||||
export GOARCH=${{ matrix.platform }}
|
||||
if [ "${{ matrix.platform }}" == "arm64" ]; then
|
||||
export GOARCH=arm64
|
||||
export CC=aarch64-linux-gnu-gcc
|
||||
elif [ "${{ matrix.platform }}" == "armv7" ]; then
|
||||
export GOARCH=arm
|
||||
export GOARM=7
|
||||
export CC=arm-linux-gnueabihf-gcc
|
||||
elif [ "${{ matrix.platform }}" == "armv6" ]; then
|
||||
export GOARCH=arm
|
||||
export GOARM=6
|
||||
export CC=arm-linux-gnueabihf-gcc
|
||||
elif [ "${{ matrix.platform }}" == "armv5" ]; then
|
||||
export GOARCH=arm
|
||||
export GOARM=5
|
||||
export CC=arm-linux-gnueabi-gcc
|
||||
elif [ "${{ matrix.platform }}" == "386" ]; then
|
||||
export GOARCH=386
|
||||
export CC=i686-linux-gnu-gcc
|
||||
elif [ "${{ matrix.platform }}" == "s390x" ]; then
|
||||
export GOARCH=s390x
|
||||
export CC=s390x-linux-gnu-gcc
|
||||
fi
|
||||
|
||||
### Build s-ui
|
||||
go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_ech,with_utls,with_reality_server,with_acme,with_gvisor" -o sui main.go
|
||||
set -e
|
||||
BUILD_TAGS="with_quic,with_grpc,with_utls,with_acme,with_gvisor,badlinkname,tfogo_checklinkname0,with_tailscale"
|
||||
[ "${{ matrix.naive }}" = "true" ] && BUILD_TAGS="${BUILD_TAGS},with_naive_outbound,with_musl"
|
||||
go build -ldflags="-w -s -checklinkname=0 -linkmode external -extldflags '-static'" -tags "$BUILD_TAGS" -o sui main.go
|
||||
file sui
|
||||
ldd sui 2>/dev/null || echo "Static binary confirmed"
|
||||
|
||||
mkdir s-ui
|
||||
cp sui s-ui/
|
||||
@@ -102,11 +181,21 @@ jobs:
|
||||
- name: Package
|
||||
run: tar -zcvf s-ui-linux-${{ matrix.platform }}.tar.gz s-ui
|
||||
|
||||
- name: Upload
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: s-ui-linux-${{ matrix.platform }}
|
||||
path: ./s-ui-linux-${{ matrix.platform }}.tar.gz
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload to Release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: |
|
||||
(github.event_name == 'release' && github.event.action == 'published') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ github.ref }}
|
||||
tag: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
|
||||
file: s-ui-linux-${{ matrix.platform }}.tar.gz
|
||||
asset_name: s-ui-linux-${{ matrix.platform }}.tar.gz
|
||||
prerelease: true
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
name: Build S-UI for Windows
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "*"
|
||||
paths:
|
||||
- '.github/workflows/windows.yml'
|
||||
- 'frontend/**'
|
||||
- '**.go'
|
||||
- 'go.mod'
|
||||
- 'go.sum'
|
||||
- 'windows/**'
|
||||
|
||||
env:
|
||||
NODE_VERSION: "25"
|
||||
TAGS: "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_naive_outbound,with_purego,badlinkname,tfogo_checklinkname0,with_tailscale"
|
||||
LIBCRONET_BASE_URL: "https://github.com/SagerNet/cronet-go/releases/latest/download"
|
||||
|
||||
jobs:
|
||||
build-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.2
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Build frontend
|
||||
run: |
|
||||
cd frontend
|
||||
npm install
|
||||
npm run build
|
||||
cd ..
|
||||
|
||||
- name: Upload frontend artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: frontend/dist
|
||||
retention-days: 1
|
||||
|
||||
build-windows:
|
||||
needs: build-frontend
|
||||
name: build-windows-${{ matrix.arch }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { arch: amd64, runner: windows-latest, cgo: "1" }
|
||||
- { arch: arm64, runner: ubuntu-latest, cgo: "0" }
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Download frontend artifact
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: frontend-dist
|
||||
path: web/html
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
cache: false
|
||||
go-version-file: go.mod
|
||||
|
||||
- name: Install zip for Windows
|
||||
if: matrix.arch == 'amd64'
|
||||
shell: powershell
|
||||
run: |
|
||||
# Install Chocolatey if not available
|
||||
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force
|
||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
||||
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
||||
}
|
||||
# Install zip
|
||||
choco install zip -y
|
||||
|
||||
- name: Build s-ui
|
||||
shell: bash
|
||||
run: |
|
||||
export CGO_ENABLED=${{ matrix.cgo }}
|
||||
export GOOS=windows
|
||||
export GOARCH=${{ matrix.arch }}
|
||||
|
||||
echo "Building for Windows ${{ matrix.arch }}"
|
||||
go version
|
||||
go env GOOS GOARCH
|
||||
|
||||
go build -ldflags="-w -s -checklinkname=0" -tags "${{ env.TAGS }}" -o sui.exe main.go
|
||||
file sui.exe
|
||||
|
||||
mkdir s-ui-windows
|
||||
cp sui.exe s-ui-windows/
|
||||
cp -r windows/* s-ui-windows/
|
||||
|
||||
- name: Download libcronet-go
|
||||
shell: bash
|
||||
run: |
|
||||
curl -qsL -o s-ui-windows/libcronet.dll ${{ env.LIBCRONET_BASE_URL }}/libcronet-windows-${{ matrix.arch }}.dll
|
||||
|
||||
- name: Package
|
||||
shell: bash
|
||||
run: |
|
||||
zip -r "s-ui-windows-${{ matrix.arch }}.zip" s-ui-windows
|
||||
|
||||
- name: Upload files to Artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: s-ui-windows-${{ matrix.arch }}
|
||||
path: ./s-ui-windows-${{ matrix.arch }}.zip
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload to Release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: |
|
||||
(github.event_name == 'release' && github.event.action == 'published') ||
|
||||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: ${{ github.ref }}
|
||||
file: s-ui-windows-${{ matrix.arch }}.zip
|
||||
asset_name: s-ui-windows-${{ matrix.arch }}.zip
|
||||
prerelease: true
|
||||
overwrite: true
|
||||
@@ -20,6 +20,14 @@ frontend/
|
||||
*.log*
|
||||
.cache
|
||||
|
||||
# Windows build artifacts
|
||||
*.exe
|
||||
*.zip
|
||||
s-ui-windows/
|
||||
sui-*.exe
|
||||
sui-*.zip
|
||||
windows/sui-*.exe
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
# Contributing to S-UI
|
||||
|
||||
Thank you for your interest in contributing to S-UI. This document explains how to set up a development environment, follow project conventions, and submit changes. Your contributions help make the **multi-inbound-per-user** approach and the rest of the project better for everyone.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Development Environment Setup](#development-environment-setup)
|
||||
- [Coding Conventions and Style Guide](#coding-conventions-and-style-guide)
|
||||
- [Testing](#testing)
|
||||
- [Features That Need Help](#features-that-need-help)
|
||||
- [Pull Request Process](#pull-request-process)
|
||||
- [Adding This Guide in Your Repository](#adding-this-guide-in-your-repository)
|
||||
- [Reporting Bugs and Requesting Features](#reporting-bugs-and-requesting-features)
|
||||
|
||||
---
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please be respectful and constructive when interacting with maintainers and other contributors. This project is for personal learning and communication; use it responsibly and legally.
|
||||
|
||||
---
|
||||
|
||||
## Development Environment Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Go**: 1.25 or later (see `go.mod` for the exact version).
|
||||
- **Git**: For cloning and submodules.
|
||||
- **C compiler**: Required for CGO (e.g. `gcc`, `musl-dev` on Alpine).
|
||||
- **Node.js** (optional): Only if you plan to work on or rebuild the frontend. The repo can be run with pre-built frontend assets.
|
||||
|
||||
### Clone and Submodules
|
||||
|
||||
```bash
|
||||
git clone https://github.com/alireza0/s-ui
|
||||
cd s-ui
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
The **frontend** lives in a submodule. If you only work on the backend, you can use the existing `web/html` contents or build the frontend once (see below).
|
||||
|
||||
### Backend-Only Development (quickest)
|
||||
|
||||
1. Build and run with the provided script (builds backend and runs with debug + local DB):
|
||||
|
||||
```bash
|
||||
./runSUI.sh
|
||||
```
|
||||
|
||||
This runs `./build.sh` then `SUI_DB_FOLDER="db" SUI_DEBUG=true ./sui`.
|
||||
|
||||
2. Or build manually:
|
||||
|
||||
```bash
|
||||
./build.sh
|
||||
SUI_DB_FOLDER=db SUI_DEBUG=true ./sui
|
||||
```
|
||||
|
||||
Default panel: **http://localhost:2095/app/** (user: `admin`, password: `admin` — change in production).
|
||||
|
||||
### Full Stack (Backend + Frontend)
|
||||
|
||||
1. **Frontend** (separate repo in submodule):
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
npm install
|
||||
npm run build
|
||||
cd ..
|
||||
```
|
||||
|
||||
2. **Replace web assets and build backend**:
|
||||
|
||||
```bash
|
||||
mkdir -p web/html
|
||||
rm -rf web/html/*
|
||||
cp -R frontend/dist/* web/html/
|
||||
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_tailscale" -o sui main.go
|
||||
```
|
||||
|
||||
3. Run:
|
||||
|
||||
```bash
|
||||
SUI_DB_FOLDER=db SUI_DEBUG=true ./sui
|
||||
```
|
||||
|
||||
### Build Tags
|
||||
|
||||
The backend is built with these tags for full functionality:
|
||||
|
||||
- `with_quic`, `with_grpc`, `with_utls`, `with_acme`, `with_gvisor`, `with_tailscale`
|
||||
|
||||
Use the same tags when building locally if you need feature parity with releases.
|
||||
|
||||
### Environment Variables (development)
|
||||
|
||||
| Variable | Description | Example |
|
||||
|----------------|--------------------------------|-----------|
|
||||
| `SUI_DB_FOLDER`| Directory for SQLite DB files | `db` |
|
||||
| `SUI_DEBUG` | Enable debug mode | `true` |
|
||||
| `SUI_LOG_LEVEL`| Log level | `debug` |
|
||||
| `SUI_BIN_FOLDER` | Directory for binaries | `bin` |
|
||||
|
||||
### Docker (optional)
|
||||
|
||||
```bash
|
||||
git clone https://github.com/alireza0/s-ui
|
||||
cd s-ui
|
||||
git submodule update --init --recursive
|
||||
docker build -t s-ui .
|
||||
# or: docker compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Coding Conventions and Style Guide
|
||||
|
||||
### General
|
||||
|
||||
- Write clear, maintainable code. Prefer small, focused functions and packages.
|
||||
- Comment non-obvious logic and public APIs.
|
||||
- Handle errors explicitly; avoid ignoring `err` unless intentional.
|
||||
|
||||
### Go Style
|
||||
|
||||
- Follow **standard Go style** and **[Effective Go](https://go.dev/doc/effective_go)**.
|
||||
- Run **gofmt** (or **goimports**) before committing:
|
||||
|
||||
```bash
|
||||
gofmt -w .
|
||||
# or: goimports -w .
|
||||
```
|
||||
|
||||
- Use **camelCase** for unexported names and **PascalCase** for exported names.
|
||||
- Keep package names short and lowercase (e.g. `api`, `service`, `util`).
|
||||
- Group imports: standard library, then third-party, then project imports (as in existing files).
|
||||
|
||||
### Project Structure Conventions
|
||||
|
||||
- **`api/`**: HTTP handlers and API routing (e.g. `apiHandler.go`, `apiV2Handler.go`).
|
||||
- **`service/`**: Business logic and panel/core operations.
|
||||
- **`database/model/`**: GORM models and DB entities.
|
||||
- **`util/`**: Shared utilities (e.g. link/sub conversion, JSON).
|
||||
- **`core/`**: sing-box integration and core runtime.
|
||||
- **`sub/`**: Subscription (link/json) handling.
|
||||
|
||||
When adding new features, place code in the appropriate layer (handler → service → model/util) and avoid circular dependencies.
|
||||
|
||||
### Naming and Patterns
|
||||
|
||||
- Handlers: suffix `Handler` (e.g. `APIHandler`, `APIv2Handler`).
|
||||
- Services: suffix `Service` or use package name (e.g. `ApiService`, `LinkService`).
|
||||
- Models: clear struct names with JSON/gorm tags (see `database/model/`).
|
||||
|
||||
---
|
||||
|
||||
## Testing
|
||||
|
||||
### Current State
|
||||
|
||||
- The project does not yet have a formal test suite (no `*_test.go` files in the repo).
|
||||
- CI currently focuses on **builds** (e.g. `release.yml`) rather than automated tests.
|
||||
|
||||
### What You Can Do Now
|
||||
|
||||
1. **Build verification**: Before submitting a PR, ensure the project builds:
|
||||
|
||||
```bash
|
||||
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_tailscale" -o sui main.go
|
||||
```
|
||||
|
||||
2. **Manual testing**: Run with `./runSUI.sh`, test the changed area (panel, API, subscription, etc.).
|
||||
|
||||
3. **Future tests**: Contributions that add **unit tests** (e.g. for `util/`, `service/`, or API handlers) or **integration tests** are very welcome. Prefer the standard library `testing` package and table-driven tests where appropriate.
|
||||
|
||||
### Running the Linter (optional)
|
||||
|
||||
```bash
|
||||
go vet ./...
|
||||
# Optional: staticcheck, golangci-lint, etc.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Features That Need Help
|
||||
|
||||
Community help is especially valuable in these areas. Check the [Issues](https://github.com/alireza0/s-ui/issues) for current tasks and ideas.
|
||||
|
||||
### High-Value Areas
|
||||
|
||||
- **Multi-inbound per user**: Core differentiator of S-UI; improvements to UX, docs, and robustness are welcome.
|
||||
- **API (v1 and v2)**: Completeness, consistency, and documentation (see [API Documentation](https://github.com/alireza0/s-ui/wiki/API-Documentation)).
|
||||
- **Subscription service**: Link conversion, JSON subscription, and info endpoints (`sub/`, `util/`).
|
||||
- **Testing**: Adding unit and integration tests for critical paths.
|
||||
- **Documentation**: User docs, API examples, and contribution docs (like this file).
|
||||
- **Platform support**: macOS is experimental; Windows and Linux improvements are welcome (see `windows/` and `.github/workflows/`).
|
||||
|
||||
### How to Find Tasks
|
||||
|
||||
- **Good first issue**: Look for issues labeled `good first issue` or `help wanted`.
|
||||
- **Feature requests**: [Feature request template](.github/ISSUE_TEMPLATE/feature_request.md).
|
||||
- **Bugs**: [Bug report template](.github/ISSUE_TEMPLATE/bug_report.md).
|
||||
|
||||
If you want to work on a larger feature, open an issue first to discuss approach and avoid duplicate work.
|
||||
|
||||
---
|
||||
|
||||
## Pull Request Process
|
||||
|
||||
1. **Fork and branch**
|
||||
|
||||
- Fork the repository on GitHub.
|
||||
- Create a branch from `main`: e.g. `git checkout -b fix/issue-123` or `feature/sub-improvements`.
|
||||
|
||||
2. **Make your changes**
|
||||
|
||||
- Follow the [Coding Conventions](#coding-conventions-and-style-guide).
|
||||
- Run `gofmt` and ensure the project builds (see [Testing](#testing)).
|
||||
- Keep commits focused and messages clear (e.g. "Fix link conversion for VMess", "Add tests for outJson").
|
||||
|
||||
3. **Push and open a PR**
|
||||
|
||||
- Push your branch and open a Pull Request against `main`.
|
||||
- Use the PR description to explain:
|
||||
- What problem or feature the PR addresses.
|
||||
- What you changed and how to verify it.
|
||||
- Reference any related issue (e.g. "Fixes #123").
|
||||
|
||||
4. **Review and CI**
|
||||
|
||||
- Maintainers will review your code. CI (e.g. build workflows) must pass.
|
||||
- Address feedback by pushing new commits to the same branch.
|
||||
|
||||
5. **Merge**
|
||||
|
||||
- Once approved and CI is green, a maintainer will merge your PR. Thank you for contributing!
|
||||
|
||||
### PR Guidelines
|
||||
|
||||
- Prefer **small, reviewable PRs**. Split large features into logical steps.
|
||||
- Avoid unrelated changes (e.g. formatting-only or refactors in a feature PR).
|
||||
- Ensure your branch is up to date with `main` before submitting (rebase or merge as the project prefers).
|
||||
|
||||
---
|
||||
|
||||
## Adding This Guide in Your Repository
|
||||
|
||||
If you maintain a fork or your own repository and want the contribution guide to be visible and linked properly:
|
||||
|
||||
1. **Keep `CONTRIBUTING.md` in the repository root**
|
||||
GitHub automatically discovers a file named `CONTRIBUTING.md` (or `CONTRIBUTING`) in the root. When someone opens a new issue or pull request, GitHub can show a link to it. The community profile also uses it for the “Contributing” section.
|
||||
|
||||
2. **Link from README**
|
||||
Add a short line in your main `README.md` so new contributors see it when they land on the repo, for example:
|
||||
```markdown
|
||||
**Want to contribute?** See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, and the pull request process.
|
||||
```
|
||||
|
||||
3. **Optional: GitHub “Contributing” link**
|
||||
In the repository **Settings → General → Features**, ensure “Issues” (and optionally “Discussions”) are enabled. The link to `CONTRIBUTING.md` appears when users create a new issue or PR; no extra config is needed as long as the file is in the root.
|
||||
|
||||
4. **When forking**
|
||||
If you fork S-UI, `CONTRIBUTING.md` is already in the repo. Update the clone URLs and repo names in this file if you want your fork’s contribution instructions to point to your own repository.
|
||||
|
||||
---
|
||||
|
||||
## Reporting Bugs and Requesting Features
|
||||
|
||||
- **Bugs**: Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.md). Include version, OS, steps to reproduce, and expected vs actual behavior.
|
||||
- **Features**: Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.md). Describe the use case and, if possible, a proposed approach.
|
||||
- **Questions**: Use the [question template](.github/ISSUE_TEMPLATE/question-template.md) or discussions if enabled.
|
||||
|
||||
---
|
||||
|
||||
Thank you for helping S-UI grow. Your contributions make it possible for more users to adopt S-UI in production and benefit from its multi-inbound-per-user design.
|
||||
+33
-10
@@ -3,23 +3,46 @@ WORKDIR /app
|
||||
COPY frontend/ ./
|
||||
RUN npm install && npm run build
|
||||
|
||||
FROM golang:1.23-alpine AS backend-builder
|
||||
FROM golang:1.25-alpine AS backend-builder
|
||||
WORKDIR /app
|
||||
ARG TARGETARCH
|
||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||
ARG TARGETVARIANT
|
||||
ENV CGO_ENABLED=1
|
||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||
ENV GOARCH=$TARGETARCH
|
||||
RUN apk update && apk --no-cache --update add build-base gcc wget unzip
|
||||
COPY . .
|
||||
COPY --from=front-builder /app/dist/ /app/web/html/
|
||||
RUN go build -ldflags="-w -s" -tags "with_quic,with_grpc,with_ech,with_utls,with_reality_server,with_acme,with_gvisor" -o sui main.go
|
||||
|
||||
FROM --platform=$TARGETPLATFORM alpine
|
||||
RUN apk update && apk add --no-cache \
|
||||
gcc \
|
||||
musl-dev \
|
||||
libc-dev \
|
||||
make \
|
||||
git \
|
||||
wget \
|
||||
unzip \
|
||||
bash \
|
||||
curl
|
||||
|
||||
ENV CC=gcc
|
||||
|
||||
RUN CRONET_ARCH="$TARGETARCH" && \
|
||||
CRONET_URL="https://github.com/SagerNet/cronet-go/releases/latest/download/libcronet-linux-${CRONET_ARCH}.so"; \
|
||||
echo "Downloading $CRONET_URL" && \
|
||||
wget -q -O ./libcronet.so "$CRONET_URL" && \
|
||||
chmod 755 ./libcronet.so
|
||||
|
||||
COPY . .
|
||||
COPY --from=front-builder /app/dist/ /app/web/html/
|
||||
|
||||
RUN if [ "$TARGETARCH" = "arm" ]; then export GOARM=7; [ "$TARGETVARIANT" = "v6" ] && export GOARM=6; fi; \
|
||||
go build -ldflags="-w -s" \
|
||||
-tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_naive_outbound,with_purego,with_tailscale" \
|
||||
-o sui main.go
|
||||
|
||||
FROM alpine
|
||||
LABEL org.opencontainers.image.authors="alireza7@gmail.com"
|
||||
ENV TZ=Asia/Tehran
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache --update ca-certificates tzdata
|
||||
COPY --from=backend-builder /app/sui /app/
|
||||
RUN set -ex && apk add --no-cache --upgrade bash tzdata ca-certificates nftables
|
||||
COPY --from=backend-builder /app/sui /app/libcronet.so /app/
|
||||
COPY entrypoint.sh /app/
|
||||
VOLUME [ "s-ui" ]
|
||||
ENTRYPOINT [ "./entrypoint.sh" ]
|
||||
@@ -0,0 +1,43 @@
|
||||
FROM golang:1.25-alpine AS backend-builder
|
||||
WORKDIR /app
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
ENV CGO_ENABLED=1
|
||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||
ENV GOARCH=$TARGETARCH
|
||||
|
||||
RUN apk update && apk add --no-cache \
|
||||
gcc \
|
||||
musl-dev \
|
||||
libc-dev \
|
||||
make \
|
||||
git \
|
||||
wget \
|
||||
unzip \
|
||||
bash \
|
||||
curl
|
||||
|
||||
ENV CC=gcc
|
||||
|
||||
RUN CRONET_ARCH="$TARGETARCH" && \
|
||||
CRONET_URL="https://github.com/SagerNet/cronet-go/releases/latest/download/libcronet-linux-${CRONET_ARCH}.so"; \
|
||||
echo "Downloading $CRONET_URL" && \
|
||||
wget -q -O ./libcronet.so "$CRONET_URL" && \
|
||||
chmod 755 ./libcronet.so
|
||||
|
||||
COPY . .
|
||||
COPY frontend_dist/ /app/web/html/
|
||||
|
||||
RUN if [ "$TARGETARCH" = "arm" ]; then export GOARM=7; [ "$TARGETVARIANT" = "v6" ] && export GOARM=6; fi; \
|
||||
go build -ldflags="-w -s" \
|
||||
-tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_naive_outbound,with_purego,with_tailscale" \
|
||||
-o sui main.go
|
||||
|
||||
FROM alpine
|
||||
LABEL org.opencontainers.image.authors="alireza7@gmail.com"
|
||||
ENV TZ=Asia/Tehran
|
||||
WORKDIR /app
|
||||
RUN set -ex && apk add --no-cache --upgrade bash tzdata ca-certificates nftables
|
||||
COPY --from=backend-builder /app/sui /app/libcronet.so /app/
|
||||
COPY entrypoint.sh /app/
|
||||
ENTRYPOINT [ "./entrypoint.sh" ]
|
||||
@@ -11,9 +11,13 @@
|
||||
|
||||
**If you think this project is helpful to you, you may wish to give a**:star2:
|
||||
|
||||
**Want to contribute?** See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding conventions, testing, and the pull request process.
|
||||
|
||||
[](https://www.buymeacoffee.com/alireza7)
|
||||
|
||||
- USDT (TRC20): `TYTq73Gj6dJ67qe58JVPD9zpjW2cc9XgVz`
|
||||
<a href="https://nowpayments.io/donation/alireza7" target="_blank" rel="noreferrer noopener">
|
||||
<img src="https://nowpayments.io/images/embeds/donation-button-white.svg" alt="Crypto donation button by NOWPayments">
|
||||
</a>
|
||||
|
||||
## Quick Overview
|
||||
| Features | Enable? |
|
||||
@@ -23,10 +27,23 @@
|
||||
| Multi-Client/Inbound | :heavy_check_mark: |
|
||||
| Advanced Traffic Routing Interface | :heavy_check_mark: |
|
||||
| Client & Traffic & System Status | :heavy_check_mark: |
|
||||
| Subscription Service (link/json + info)| :heavy_check_mark: |
|
||||
| Subscription Link (link/json/clash + info)| :heavy_check_mark: |
|
||||
| Dark/Light Theme | :heavy_check_mark: |
|
||||
| API Interface | :heavy_check_mark: |
|
||||
|
||||
## Supported Platforms
|
||||
| Platform | Architecture | Status |
|
||||
|----------|--------------|---------|
|
||||
| Linux | amd64, arm64, armv7, armv6, armv5, 386, s390x | ✅ Supported |
|
||||
| Windows | amd64, 386, arm64 | ✅ Supported |
|
||||
| macOS | amd64, arm64 | 🚧 Experimental |
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
[Other UI Screenshots](https://github.com/alireza0/s-ui-frontend/blob/main/screenshots.md)
|
||||
|
||||
## API Documentation
|
||||
|
||||
[API-Documentation Wiki](https://github.com/alireza0/s-ui/wiki/API-Documentation)
|
||||
@@ -40,10 +57,17 @@
|
||||
|
||||
## Install & Upgrade to Latest Version
|
||||
|
||||
### Linux/macOS
|
||||
```sh
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui/master/install.sh)
|
||||
```
|
||||
|
||||
### Windows
|
||||
1. Download the latest Windows release from [GitHub Releases](https://github.com/alireza0/s-ui/releases/latest)
|
||||
2. Extract the ZIP file
|
||||
3. Run `install-windows.bat` as Administrator
|
||||
4. Follow the installation wizard
|
||||
|
||||
## Install legacy Version
|
||||
|
||||
**Step 1:** To install your desired legacy version, add the version to the end of the installation command. e.g., ver `1.0.0`:
|
||||
@@ -54,6 +78,7 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui
|
||||
|
||||
## Manual installation
|
||||
|
||||
### Linux/macOS
|
||||
1. Get the latest version of S-UI based on your OS/Architecture from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest)
|
||||
2. **OPTIONAL** Get the latest version of `s-ui.sh` [https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh](https://raw.githubusercontent.com/alireza0/s-ui/master/s-ui.sh)
|
||||
3. **OPTIONAL** Copy `s-ui.sh` to /usr/bin/ and run `chmod +x /usr/bin/s-ui`.
|
||||
@@ -62,6 +87,14 @@ VERSION=1.0.0 && bash <(curl -Ls https://raw.githubusercontent.com/alireza0/s-ui
|
||||
6. Enable autostart and start S-UI service using `systemctl enable s-ui --now`
|
||||
7. Start sing-box service using `systemctl enable sing-box --now`
|
||||
|
||||
### Windows
|
||||
1. Get the latest Windows version from GitHub: [https://github.com/alireza0/s-ui/releases/latest](https://github.com/alireza0/s-ui/releases/latest)
|
||||
2. Download the appropriate Windows package (e.g., `s-ui-windows-amd64.zip`)
|
||||
3. Extract the ZIP file to a directory of your choice
|
||||
4. Run `install-windows.bat` as Administrator
|
||||
5. Follow the installation wizard
|
||||
6. Access the panel at http://localhost:2095/app
|
||||
|
||||
## Uninstall S-UI
|
||||
|
||||
```sh
|
||||
@@ -105,7 +138,7 @@ docker compose up -d
|
||||
mkdir s-ui && cd s-ui
|
||||
docker run -itd \
|
||||
-p 2095:2095 -p 2096:2096 -p 443:443 -p 80:80 \
|
||||
-v $PWD/db/:/usr/local/s-ui/db/ \
|
||||
-v $PWD/db/:/app/db/ \
|
||||
-v $PWD/cert/:/root/cert/ \
|
||||
--name s-ui --restart=unless-stopped \
|
||||
alireza7/s-ui:latest
|
||||
@@ -188,21 +221,6 @@ To run backend (from root folder of repository):
|
||||
- HTTPS for secure access to the web panel and subscription service (self-provided domain + SSL certificate)
|
||||
- Dark/Light theme
|
||||
|
||||
## Recommended OS
|
||||
|
||||
- Ubuntu 20.04+
|
||||
- Debian 11+
|
||||
- CentOS 8+
|
||||
- Fedora 36+
|
||||
- Arch Linux
|
||||
- Parch Linux
|
||||
- Manjaro
|
||||
- Armbian
|
||||
- AlmaLinux 9+
|
||||
- Rocky Linux 9+
|
||||
- Oracle Linux 8+
|
||||
- OpenSUSE Tubleweed
|
||||
|
||||
## Environment Variables
|
||||
|
||||
<details>
|
||||
|
||||
+9
-2
@@ -1,9 +1,10 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"s-ui/util/common"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -47,6 +48,8 @@ func (a *APIHandler) postHandler(c *gin.Context) {
|
||||
a.ApiService.RestartSb(c)
|
||||
case "linkConvert":
|
||||
a.ApiService.LinkConvert(c)
|
||||
case "subConvert":
|
||||
a.ApiService.SubConvert(c)
|
||||
case "importdb":
|
||||
a.ApiService.ImportDb(c)
|
||||
case "addToken":
|
||||
@@ -68,7 +71,7 @@ func (a *APIHandler) getHandler(c *gin.Context) {
|
||||
a.ApiService.Logout(c)
|
||||
case "load":
|
||||
a.ApiService.LoadData(c)
|
||||
case "inbounds", "outbounds", "endpoints", "tls", "clients", "config":
|
||||
case "inbounds", "outbounds", "endpoints", "services", "tls", "clients", "config":
|
||||
err := a.ApiService.LoadPartialData(c, []string{action})
|
||||
if err != nil {
|
||||
jsonMsg(c, action, err)
|
||||
@@ -94,6 +97,10 @@ func (a *APIHandler) getHandler(c *gin.Context) {
|
||||
a.ApiService.GetDb(c)
|
||||
case "tokens":
|
||||
a.ApiService.GetTokens(c)
|
||||
case "singbox-config":
|
||||
a.ApiService.GetSingboxConfig(c)
|
||||
case "checkOutbound":
|
||||
a.ApiService.GetCheckOutbound(c)
|
||||
default:
|
||||
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
|
||||
}
|
||||
|
||||
+48
-6
@@ -2,14 +2,14 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/database"
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"s-ui/util"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ type ApiService struct {
|
||||
service.InboundService
|
||||
service.OutboundService
|
||||
service.EndpointService
|
||||
service.ServicesService
|
||||
service.PanelService
|
||||
service.StatsService
|
||||
service.ServerService
|
||||
@@ -81,7 +82,15 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
subURI, err := a.SettingService.GetFinalSubURI(strings.Split(c.Request.Host, ":")[0])
|
||||
services, err := a.ServicesService.GetAll()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
subURI, err := a.SettingService.GetFinalSubURI(getHostname(c))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
trafficAge, err := a.SettingService.GetTrafficAge()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -91,7 +100,9 @@ func (a *ApiService) getData(c *gin.Context) (interface{}, error) {
|
||||
data["inbounds"] = inbounds
|
||||
data["outbounds"] = outbounds
|
||||
data["endpoints"] = endpoints
|
||||
data["services"] = services
|
||||
data["subURI"] = subURI
|
||||
data["enableTraffic"] = trafficAge > 0
|
||||
data["onlines"] = onlines
|
||||
} else {
|
||||
data["onlines"] = onlines
|
||||
@@ -124,6 +135,12 @@ func (a *ApiService) LoadPartialData(c *gin.Context, objs []string) error {
|
||||
return err
|
||||
}
|
||||
data[obj] = endpoints
|
||||
case "services":
|
||||
services, err := a.ServicesService.GetAll()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data[obj] = services
|
||||
case "tls":
|
||||
tlsConfigs, err := a.TlsService.GetAll()
|
||||
if err != nil {
|
||||
@@ -313,6 +330,12 @@ func (a *ApiService) LinkConvert(c *gin.Context) {
|
||||
jsonObj(c, result, err)
|
||||
}
|
||||
|
||||
func (a *ApiService) SubConvert(c *gin.Context) {
|
||||
link := c.Request.FormValue("link")
|
||||
result, err := util.GetExternalSub(link)
|
||||
jsonObj(c, result, err)
|
||||
}
|
||||
|
||||
func (a *ApiService) ImportDb(c *gin.Context) {
|
||||
file, _, err := c.Request.FormFile("db")
|
||||
if err != nil {
|
||||
@@ -361,3 +384,22 @@ func (a *ApiService) DeleteToken(c *gin.Context) {
|
||||
err := a.UserService.DeleteToken(tokenId)
|
||||
jsonMsg(c, "", err)
|
||||
}
|
||||
|
||||
func (a *ApiService) GetSingboxConfig(c *gin.Context) {
|
||||
rawConfig, err := a.ConfigService.GetConfig("")
|
||||
if err != nil {
|
||||
c.Status(400)
|
||||
c.Writer.WriteString(err.Error())
|
||||
return
|
||||
}
|
||||
c.Header("Content-Type", "application/json")
|
||||
c.Header("Content-Disposition", "attachment; filename=config_"+time.Now().Format("20060102-150405")+".json")
|
||||
c.Writer.Write(*rawConfig)
|
||||
}
|
||||
|
||||
func (a *ApiService) GetCheckOutbound(c *gin.Context) {
|
||||
tag := c.Query("tag")
|
||||
link := c.Query("link")
|
||||
result := a.ConfigService.CheckOutbound(tag, link)
|
||||
jsonObj(c, result, nil)
|
||||
}
|
||||
|
||||
+8
-3
@@ -2,10 +2,11 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -48,6 +49,8 @@ func (a *APIv2Handler) postHandler(c *gin.Context) {
|
||||
a.ApiService.RestartSb(c)
|
||||
case "linkConvert":
|
||||
a.ApiService.LinkConvert(c)
|
||||
case "subConvert":
|
||||
a.ApiService.SubConvert(c)
|
||||
case "importdb":
|
||||
a.ApiService.ImportDb(c)
|
||||
default:
|
||||
@@ -61,7 +64,7 @@ func (a *APIv2Handler) getHandler(c *gin.Context) {
|
||||
switch action {
|
||||
case "load":
|
||||
a.ApiService.LoadData(c)
|
||||
case "inbounds", "outbounds", "endpoints", "tls", "clients", "config":
|
||||
case "inbounds", "outbounds", "endpoints", "services", "tls", "clients", "config":
|
||||
err := a.ApiService.LoadPartialData(c, []string{action})
|
||||
if err != nil {
|
||||
jsonMsg(c, action, err)
|
||||
@@ -85,6 +88,8 @@ func (a *APIv2Handler) getHandler(c *gin.Context) {
|
||||
a.ApiService.GetKeypairs(c)
|
||||
case "getdb":
|
||||
a.ApiService.GetDb(c)
|
||||
case "checkOutbound":
|
||||
a.ApiService.GetCheckOutbound(c)
|
||||
default:
|
||||
jsonMsg(c, "failed", common.NewError("unknown action: ", action))
|
||||
}
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"s-ui/database/model"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
+6
-2
@@ -3,9 +3,10 @@ package api
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"s-ui/logger"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -29,8 +30,11 @@ func getRemoteIp(c *gin.Context) string {
|
||||
|
||||
func getHostname(c *gin.Context) string {
|
||||
host := c.Request.Host
|
||||
if colonIndex := strings.LastIndex(host, ":"); colonIndex != -1 {
|
||||
if strings.Contains(host, ":") {
|
||||
host, _, _ = net.SplitHostPort(c.Request.Host)
|
||||
if strings.Contains(host, ":") {
|
||||
host = "[" + host + "]"
|
||||
}
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
+10
-9
@@ -2,14 +2,15 @@ package app
|
||||
|
||||
import (
|
||||
"log"
|
||||
"s-ui/config"
|
||||
"s-ui/core"
|
||||
"s-ui/cronjob"
|
||||
"s-ui/database"
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"s-ui/sub"
|
||||
"s-ui/web"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/core"
|
||||
"github.com/alireza0/s-ui/cronjob"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
"github.com/alireza0/s-ui/sub"
|
||||
"github.com/alireza0/s-ui/web"
|
||||
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
@@ -78,7 +79,7 @@ func (a *APP) Start() error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = a.configService.StartCore("")
|
||||
err = a.configService.StartCore()
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
}
|
||||
|
||||
@@ -11,4 +11,5 @@ mkdir -p web/html
|
||||
rm -fr web/html/*
|
||||
cp -R frontend/dist/* web/html/
|
||||
|
||||
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_ech,with_utls,with_reality_server,with_acme,with_gvisor" -o sui main.go
|
||||
BUILD_TAGS="with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_naive_outbound,with_musl,badlinkname,tfogo_checklinkname0,with_tailscale"
|
||||
go build -ldflags '-w -s -checklinkname=0 -extldflags "-Wl,-no_warn_duplicate_libraries"' -tags "$BUILD_TAGS" -o sui main.go
|
||||
|
||||
+4
-3
@@ -2,9 +2,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"s-ui/config"
|
||||
"s-ui/database"
|
||||
"s-ui/service"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
)
|
||||
|
||||
func resetAdmin() {
|
||||
|
||||
+14
-3
@@ -4,8 +4,10 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"s-ui/cmd/migration"
|
||||
"s-ui/config"
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/alireza0/s-ui/cmd/migration"
|
||||
"github.com/alireza0/s-ui/config"
|
||||
)
|
||||
|
||||
func ParseCmd() {
|
||||
@@ -52,7 +54,16 @@ func ParseCmd() {
|
||||
|
||||
flag.Parse()
|
||||
if showVersion {
|
||||
fmt.Println(config.GetVersion())
|
||||
fmt.Println("S-UI Panel\t", config.GetVersion())
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
for _, dep := range info.Deps {
|
||||
if dep.Path == "github.com/sagernet/sing-box" {
|
||||
fmt.Println("Sing-Box\t", dep.Version)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@ package migration
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"s-ui/database/model"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"s-ui/database/model"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package migration
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func migrate_dns(db *gorm.DB) error {
|
||||
var configStr string
|
||||
err := db.Model(model.Setting{}).Select("value").Where("key = ?", "config").First(&configStr).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if configStr == "" {
|
||||
return nil
|
||||
}
|
||||
var config map[string]interface{}
|
||||
err = json.Unmarshal([]byte(configStr), &config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dnsConfig, ok := config["dns"].(map[string]interface{}); ok {
|
||||
if dnsServers, ok := dnsConfig["servers"].([]interface{}); ok {
|
||||
for index, dnsServer := range dnsServers {
|
||||
if dnsServer, ok := dnsServer.(map[string]interface{}); ok {
|
||||
if addr, ok := dnsServer["address"].(string); ok && addr != "" {
|
||||
switch addr {
|
||||
case "local":
|
||||
delete(dnsServer, "address")
|
||||
dnsServer["type"] = "local"
|
||||
case "fakeip":
|
||||
delete(dnsServer, "address")
|
||||
dnsServer["type"] = "fakeip"
|
||||
default:
|
||||
addrParsed, err := url.Parse(addr)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
switch addrParsed.Scheme {
|
||||
case "":
|
||||
dnsServer["type"] = "udp"
|
||||
dnsServer["server"] = addr
|
||||
case "udp", "tcp", "tls", "quic", "https", "h3":
|
||||
dnsServer["type"] = addrParsed.Scheme
|
||||
dnsServer["server"] = addrParsed.Host
|
||||
case "dhcp":
|
||||
dnsServer["type"] = addrParsed.Scheme
|
||||
if addrParsed.Host != "auto" && addrParsed.Host != "" {
|
||||
dnsServer["interface"] = addrParsed.Host
|
||||
}
|
||||
case "rcode":
|
||||
dnsServer["type"] = "predefined"
|
||||
dnsServer["responses"] = []map[string]string{
|
||||
{
|
||||
"rcode": strings.ToUpper(addrParsed.Host),
|
||||
},
|
||||
}
|
||||
}
|
||||
delete(dnsServer, "address")
|
||||
if addrParsed.Port() != "" {
|
||||
port, err := strconv.Atoi(addrParsed.Port())
|
||||
if err == nil {
|
||||
dnsServer["server_port"] = port
|
||||
}
|
||||
}
|
||||
if address_resolver, ok := dnsServer["address_resolver"].(string); ok && address_resolver != "" {
|
||||
delete(dnsServer, "address_resolver")
|
||||
dnsServer["domain_resolver"] = address_resolver
|
||||
}
|
||||
delete(dnsServer, "strategy")
|
||||
}
|
||||
dnsServers[index] = dnsServer
|
||||
}
|
||||
}
|
||||
}
|
||||
dnsConfig["servers"] = dnsServers
|
||||
}
|
||||
config["dns"] = dnsConfig
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// save changes
|
||||
configs, err := json.MarshalIndent(config, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return db.Model(model.Setting{}).Where("key = ?", "config").Update("value", string(configs)).Error
|
||||
}
|
||||
|
||||
func remove_outbound_strategy(db *gorm.DB) error {
|
||||
var outbounds []model.Outbound
|
||||
err := db.Find(&outbounds).Where("json_extract(options, '$.domain_strategy') IS NOT NULL").Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, outbound := range outbounds {
|
||||
var restFields map[string]json.RawMessage
|
||||
if err := json.Unmarshal(outbound.Options, &restFields); err != nil {
|
||||
return err
|
||||
}
|
||||
delete(restFields, "domain_strategy")
|
||||
outbound.Options, _ = json.MarshalIndent(restFields, "", " ")
|
||||
db.Save(&outbound)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func anytls_user_config(db *gorm.DB) error {
|
||||
var clients []model.Client
|
||||
err := db.Model(model.Client{}).Find(&clients).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for index, client := range clients {
|
||||
var configs map[string]json.RawMessage
|
||||
if err := json.Unmarshal(client.Config, &configs); err != nil {
|
||||
return err
|
||||
}
|
||||
if configs["anytls"] != nil {
|
||||
continue
|
||||
}
|
||||
configs["anytls"] = configs["trojan"]
|
||||
configJson, err := json.MarshalIndent(configs, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clients[index].Config = configJson
|
||||
db.Save(&clients[index])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func to1_3(db *gorm.DB) error {
|
||||
err := anytls_user_config(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = migrate_dns(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = remove_outbound_strategy(db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+13
-2
@@ -4,7 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"s-ui/config"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
@@ -56,10 +57,20 @@ func MigrateDb() {
|
||||
log.Fatal("Migration to 1.2 failed: ", err)
|
||||
return
|
||||
}
|
||||
dbVersion = "1.2"
|
||||
}
|
||||
|
||||
// Before 1.3
|
||||
if dbVersion[0:3] == "1.2" {
|
||||
err = to1_3(tx)
|
||||
if err != nil {
|
||||
log.Fatal("Migration to 1.3 failed: ", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Set version
|
||||
err = tx.Raw("UPDATE settings SET value = ? WHERE key = ?", currentVersion, "version").Error
|
||||
err = tx.Exec("UPDATE settings SET value = ? WHERE key = ?", currentVersion, "version").Error
|
||||
if err != nil {
|
||||
log.Fatal("Update version failed: ", err)
|
||||
return
|
||||
|
||||
+57
-11
@@ -4,10 +4,13 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"s-ui/config"
|
||||
"s-ui/database"
|
||||
"s-ui/service"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
)
|
||||
@@ -109,6 +112,54 @@ func showSetting() {
|
||||
}
|
||||
}
|
||||
|
||||
func getPublicIP() string {
|
||||
apis := []string{
|
||||
"https://api64.ipify.org",
|
||||
"https://ip.sb",
|
||||
"https://icanhazip.com",
|
||||
"https://ipinfo.io/ip",
|
||||
"https://checkip.amazonaws.com",
|
||||
}
|
||||
type result struct {
|
||||
ip string
|
||||
err error
|
||||
}
|
||||
ch := make(chan result, len(apis))
|
||||
var wg sync.WaitGroup
|
||||
client := &http.Client{Timeout: 3 * time.Second}
|
||||
|
||||
for _, api := range apis {
|
||||
wg.Add(1)
|
||||
go func(url string) {
|
||||
defer wg.Done()
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
ch <- result{"", err}
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
ch <- result{"", err}
|
||||
return
|
||||
}
|
||||
ch <- result{string(body), nil}
|
||||
}(api)
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
for res := range ch {
|
||||
if res.err == nil && res.ip != "" {
|
||||
return strings.TrimSpace(res.ip)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getPanelURI() {
|
||||
err := database.InitDB(config.GetDBPath())
|
||||
if err != nil {
|
||||
@@ -145,7 +196,6 @@ func getPanelURI() {
|
||||
return
|
||||
}
|
||||
fmt.Println("Local address:")
|
||||
// get ip address
|
||||
netInterfaces, _ := net.Interfaces()
|
||||
for i := 0; i < len(netInterfaces); i++ {
|
||||
if len(netInterfaces[i].Flags) > 2 && netInterfaces[i].Flags[0] == "up" && netInterfaces[i].Flags[1] != "loopback" {
|
||||
@@ -160,12 +210,8 @@ func getPanelURI() {
|
||||
}
|
||||
}
|
||||
}
|
||||
resp, err := http.Get("https://api.ipify.org?format=text")
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
ip, err := io.ReadAll(resp.Body)
|
||||
if err == nil {
|
||||
fmt.Printf("\nGlobal address:\n%s%s%s%s\n", Proto, ip, PortText, BasePath)
|
||||
}
|
||||
pubIP := getPublicIP()
|
||||
if pubIP != "" {
|
||||
fmt.Printf("\nGlobal address:\n%s%s%s\n", Proto, pubIP, PortText+BasePath)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -51,9 +52,13 @@ func GetDBFolderPath() string {
|
||||
if dbFolderPath == "" {
|
||||
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
|
||||
if err != nil {
|
||||
// Cross-platform fallback path
|
||||
if runtime.GOOS == "windows" {
|
||||
return "C:\\Program Files\\s-ui\\db"
|
||||
}
|
||||
return "/usr/local/s-ui/db"
|
||||
}
|
||||
dbFolderPath = dir + "/db"
|
||||
dbFolderPath = filepath.Join(dir, "db")
|
||||
}
|
||||
return dbFolderPath
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.2.1
|
||||
1.4.1
|
||||
+264
-80
@@ -2,21 +2,26 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"s-ui/util/common"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
boxService "github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/common/certificate"
|
||||
"github.com/sagernet/sing-box/common/dialer"
|
||||
"github.com/sagernet/sing-box/common/taskmonitor"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/dns/transport/local"
|
||||
"github.com/sagernet/sing-box/experimental"
|
||||
"github.com/sagernet/sing-box/experimental/cachefile"
|
||||
"github.com/sagernet/sing-box/experimental/libbox/platform"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-box/protocol/direct"
|
||||
@@ -28,21 +33,25 @@ import (
|
||||
"github.com/sagernet/sing/service/pause"
|
||||
)
|
||||
|
||||
var _ adapter.Service = (*Box)(nil)
|
||||
var _ adapter.SimpleLifecycle = (*Box)(nil)
|
||||
|
||||
type Box struct {
|
||||
createdAt time.Time
|
||||
logFactory log.Factory
|
||||
logger log.ContextLogger
|
||||
network *route.NetworkManager
|
||||
endpoint *endpoint.Manager
|
||||
inbound *inbound.Manager
|
||||
outbound *outbound.Manager
|
||||
connection *route.ConnectionManager
|
||||
router *route.Router
|
||||
services []adapter.LifecycleService
|
||||
connTracker *ConnTracker
|
||||
done chan struct{}
|
||||
createdAt time.Time
|
||||
logFactory log.Factory
|
||||
logger log.ContextLogger
|
||||
network *route.NetworkManager
|
||||
endpoint *endpoint.Manager
|
||||
inbound *inbound.Manager
|
||||
outbound *outbound.Manager
|
||||
service *boxService.Manager
|
||||
dnsTransport *dns.TransportManager
|
||||
dnsRouter *dns.Router
|
||||
connection *route.ConnectionManager
|
||||
router *route.Router
|
||||
internalService []adapter.LifecycleService
|
||||
statsTracker *StatsTracker
|
||||
connTracker *ConnTracker
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
@@ -55,6 +64,8 @@ func Context(
|
||||
inboundRegistry adapter.InboundRegistry,
|
||||
outboundRegistry adapter.OutboundRegistry,
|
||||
endpointRegistry adapter.EndpointRegistry,
|
||||
dnsTransportRegistry adapter.DNSTransportRegistry,
|
||||
serviceRegistry adapter.ServiceRegistry,
|
||||
) context.Context {
|
||||
if service.FromContext[option.InboundOptionsRegistry](ctx) == nil ||
|
||||
service.FromContext[adapter.InboundRegistry](ctx) == nil {
|
||||
@@ -71,6 +82,14 @@ func Context(
|
||||
ctx = service.ContextWith[option.EndpointOptionsRegistry](ctx, endpointRegistry)
|
||||
ctx = service.ContextWith[adapter.EndpointRegistry](ctx, endpointRegistry)
|
||||
}
|
||||
if service.FromContext[adapter.DNSTransportRegistry](ctx) == nil {
|
||||
ctx = service.ContextWith[option.DNSTransportOptionsRegistry](ctx, dnsTransportRegistry)
|
||||
ctx = service.ContextWith[adapter.DNSTransportRegistry](ctx, dnsTransportRegistry)
|
||||
}
|
||||
if service.FromContext[adapter.ServiceRegistry](ctx) == nil {
|
||||
ctx = service.ContextWith[option.ServiceOptionsRegistry](ctx, serviceRegistry)
|
||||
ctx = service.ContextWith[adapter.ServiceRegistry](ctx, serviceRegistry)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
@@ -86,6 +105,8 @@ func NewBox(options Options) (*Box, error) {
|
||||
endpointRegistry := service.FromContext[adapter.EndpointRegistry](ctx)
|
||||
inboundRegistry := service.FromContext[adapter.InboundRegistry](ctx)
|
||||
outboundRegistry := service.FromContext[adapter.OutboundRegistry](ctx)
|
||||
dnsTransportRegistry := service.FromContext[adapter.DNSTransportRegistry](ctx)
|
||||
serviceRegistry := service.FromContext[adapter.ServiceRegistry](ctx)
|
||||
|
||||
if endpointRegistry == nil {
|
||||
return nil, common.NewError("missing endpoint registry in context")
|
||||
@@ -96,14 +117,28 @@ func NewBox(options Options) (*Box, error) {
|
||||
if outboundRegistry == nil {
|
||||
return nil, common.NewError("missing outbound registry in context")
|
||||
}
|
||||
if dnsTransportRegistry == nil {
|
||||
return nil, common.NewError("missing DNS transport registry in context")
|
||||
}
|
||||
if serviceRegistry == nil {
|
||||
return nil, common.NewError("missing service registry in context")
|
||||
}
|
||||
|
||||
ctx = pause.WithDefaultManager(ctx)
|
||||
experimentalOptions := sbCommon.PtrValueOrDefault(options.Experimental)
|
||||
var needCacheFile bool
|
||||
var needClashAPI bool
|
||||
var needV2RayAPI bool
|
||||
if experimentalOptions.CacheFile != nil && experimentalOptions.CacheFile.Enabled {
|
||||
needCacheFile = true
|
||||
}
|
||||
platformInterface := service.FromContext[platform.Interface](ctx)
|
||||
if experimentalOptions.ClashAPI != nil {
|
||||
needClashAPI = true
|
||||
}
|
||||
if experimentalOptions.V2RayAPI != nil && experimentalOptions.V2RayAPI.Listen != "" {
|
||||
needV2RayAPI = true
|
||||
}
|
||||
platformInterface := service.FromContext[adapter.PlatformInterface](ctx)
|
||||
var defaultLogWriter io.Writer
|
||||
if platformInterface != nil {
|
||||
defaultLogWriter = io.Discard
|
||||
@@ -120,25 +155,72 @@ func NewBox(options Options) (*Box, error) {
|
||||
}
|
||||
factory = logFactory
|
||||
|
||||
var internalServices []adapter.LifecycleService
|
||||
certificateOptions := sbCommon.PtrValueOrDefault(options.Certificate)
|
||||
if C.IsAndroid || certificateOptions.Store != "" && certificateOptions.Store != C.CertificateStoreSystem ||
|
||||
len(certificateOptions.Certificate) > 0 ||
|
||||
len(certificateOptions.CertificatePath) > 0 ||
|
||||
len(certificateOptions.CertificateDirectoryPath) > 0 {
|
||||
certificateStore, err := certificate.NewStore(ctx, logFactory.NewLogger("certificate"), certificateOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
service.MustRegister[adapter.CertificateStore](ctx, certificateStore)
|
||||
internalServices = append(internalServices, certificateStore)
|
||||
}
|
||||
|
||||
routeOptions := sbCommon.PtrValueOrDefault(options.Route)
|
||||
dnsOptions := sbCommon.PtrValueOrDefault(options.DNS)
|
||||
endpointManager := endpoint.NewManager(logFactory.NewLogger("endpoint"), endpointRegistry)
|
||||
inboundManager := inbound.NewManager(logFactory.NewLogger("inbound"), inboundRegistry, endpointManager)
|
||||
outboundManager := outbound.NewManager(logFactory.NewLogger("outbound"), outboundRegistry, endpointManager, routeOptions.Final)
|
||||
dnsTransportManager := dns.NewTransportManager(logFactory.NewLogger("dns/transport"), dnsTransportRegistry, outboundManager, dnsOptions.Final)
|
||||
serviceManager := boxService.NewManager(logFactory.NewLogger("service"), serviceRegistry)
|
||||
|
||||
service.MustRegister[adapter.EndpointManager](ctx, endpointManager)
|
||||
service.MustRegister[adapter.InboundManager](ctx, inboundManager)
|
||||
service.MustRegister[adapter.OutboundManager](ctx, outboundManager)
|
||||
service.MustRegister[adapter.DNSTransportManager](ctx, dnsTransportManager)
|
||||
service.MustRegister[adapter.ServiceManager](ctx, serviceManager)
|
||||
|
||||
networkManager, err := route.NewNetworkManager(ctx, logFactory.NewLogger("network"), routeOptions)
|
||||
dnsRouter := dns.NewRouter(ctx, logFactory, dnsOptions)
|
||||
service.MustRegister[adapter.DNSRouter](ctx, dnsRouter)
|
||||
|
||||
networkManager, err := route.NewNetworkManager(ctx, logFactory.NewLogger("network"), routeOptions, dnsOptions)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize network manager", err)
|
||||
}
|
||||
service.MustRegister[adapter.NetworkManager](ctx, networkManager)
|
||||
connectionManager := route.NewConnectionManager(logFactory.NewLogger("connection"))
|
||||
service.MustRegister[adapter.ConnectionManager](ctx, connectionManager)
|
||||
router, err := route.NewRouter(ctx, logFactory, routeOptions, sbCommon.PtrValueOrDefault(options.DNS))
|
||||
router := route.NewRouter(ctx, logFactory, routeOptions, dnsOptions)
|
||||
service.MustRegister[adapter.Router](ctx, router)
|
||||
err = router.Initialize(routeOptions.Rules, routeOptions.RuleSet)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize router", err)
|
||||
}
|
||||
for i, transportOptions := range dnsOptions.Servers {
|
||||
var tag string
|
||||
if transportOptions.Tag != "" {
|
||||
tag = transportOptions.Tag
|
||||
} else {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
err = dnsTransportManager.Create(
|
||||
ctx,
|
||||
logFactory.NewLogger(F.ToString("dns/", transportOptions.Type, "[", tag, "]")),
|
||||
tag,
|
||||
transportOptions.Type,
|
||||
transportOptions.Options,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize DNS server[", i, "]", err)
|
||||
}
|
||||
}
|
||||
err = dnsRouter.Initialize(dnsOptions.Rules)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize dns router", err)
|
||||
}
|
||||
for i, endpointOptions := range options.Endpoints {
|
||||
var tag string
|
||||
if endpointOptions.Tag != "" {
|
||||
@@ -146,7 +228,8 @@ func NewBox(options Options) (*Box, error) {
|
||||
} else {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
err = endpointManager.Create(ctx,
|
||||
err = endpointManager.Create(
|
||||
ctx,
|
||||
router,
|
||||
logFactory.NewLogger(F.ToString("endpoint/", endpointOptions.Type, "[", tag, "]")),
|
||||
tag,
|
||||
@@ -164,7 +247,8 @@ func NewBox(options Options) (*Box, error) {
|
||||
} else {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
err = inboundManager.Create(ctx,
|
||||
err = inboundManager.Create(
|
||||
ctx,
|
||||
router,
|
||||
logFactory.NewLogger(F.ToString("inbound/", inboundOptions.Type, "[", tag, "]")),
|
||||
tag,
|
||||
@@ -201,36 +285,82 @@ func NewBox(options Options) (*Box, error) {
|
||||
return nil, common.NewError("initialize outbound["+F.ToString(i)+"] "+tag, err)
|
||||
}
|
||||
}
|
||||
outboundManager.Initialize(sbCommon.Must1(
|
||||
direct.NewOutbound(
|
||||
for i, serviceOptions := range options.Services {
|
||||
var tag string
|
||||
if serviceOptions.Tag != "" {
|
||||
tag = serviceOptions.Tag
|
||||
} else {
|
||||
tag = F.ToString(i)
|
||||
}
|
||||
err = serviceManager.Create(
|
||||
ctx,
|
||||
logFactory.NewLogger(F.ToString("service/", serviceOptions.Type, "[", tag, "]")),
|
||||
tag,
|
||||
serviceOptions.Type,
|
||||
serviceOptions.Options,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize service["+F.ToString(i)+"]"+tag, err)
|
||||
}
|
||||
}
|
||||
outboundManager.Initialize(func() (adapter.Outbound, error) {
|
||||
return direct.NewOutbound(
|
||||
ctx,
|
||||
router,
|
||||
logFactory.NewLogger("outbound/direct"),
|
||||
"direct",
|
||||
option.DirectOutboundOptions{},
|
||||
),
|
||||
))
|
||||
)
|
||||
})
|
||||
dnsTransportManager.Initialize(func() (adapter.DNSTransport, error) {
|
||||
return local.NewTransport(
|
||||
ctx,
|
||||
logFactory.NewLogger("dns/local"),
|
||||
"local",
|
||||
option.LocalDNSServerOptions{},
|
||||
)
|
||||
})
|
||||
if platformInterface != nil {
|
||||
err = platformInterface.Initialize(networkManager)
|
||||
if err != nil {
|
||||
return nil, common.NewError("initialize platform interface", err)
|
||||
}
|
||||
}
|
||||
if connTracker == nil {
|
||||
connTracker = NewConnTracker()
|
||||
}
|
||||
router.SetTracker(connTracker)
|
||||
|
||||
var services []adapter.LifecycleService
|
||||
statsTracker := NewStatsTracker()
|
||||
connTracker := NewConnTracker()
|
||||
router.AppendTracker(statsTracker)
|
||||
router.AppendTracker(connTracker)
|
||||
|
||||
if needCacheFile {
|
||||
cacheFile := cachefile.New(ctx, sbCommon.PtrValueOrDefault(experimentalOptions.CacheFile))
|
||||
service.MustRegister[adapter.CacheFile](ctx, cacheFile)
|
||||
services = append(services, cacheFile)
|
||||
internalServices = append(internalServices, cacheFile)
|
||||
}
|
||||
if needClashAPI {
|
||||
clashAPIOptions := sbCommon.PtrValueOrDefault(experimentalOptions.ClashAPI)
|
||||
clashAPIOptions.ModeList = experimental.CalculateClashModeList(options.Options)
|
||||
clashServer, err := experimental.NewClashServer(ctx, logFactory.(log.ObservableFactory), clashAPIOptions)
|
||||
if err != nil {
|
||||
return nil, common.NewError(err, "create clash-server")
|
||||
}
|
||||
router.AppendTracker(clashServer)
|
||||
service.MustRegister[adapter.ClashServer](ctx, clashServer)
|
||||
internalServices = append(internalServices, clashServer)
|
||||
}
|
||||
if needV2RayAPI {
|
||||
v2rayServer, err := experimental.NewV2RayServer(logFactory.NewLogger("v2ray-api"), sbCommon.PtrValueOrDefault(experimentalOptions.V2RayAPI))
|
||||
if err != nil {
|
||||
return nil, common.NewError(err, "create v2ray-server")
|
||||
}
|
||||
if v2rayServer.StatsService() != nil {
|
||||
router.AppendTracker(v2rayServer.StatsService())
|
||||
internalServices = append(internalServices, v2rayServer)
|
||||
service.MustRegister[adapter.V2RayServer](ctx, v2rayServer)
|
||||
}
|
||||
}
|
||||
ntpOptions := sbCommon.PtrValueOrDefault(options.NTP)
|
||||
if ntpOptions.Enabled {
|
||||
ntpDialer, err := dialer.New(ctx, ntpOptions.DialerOptions)
|
||||
ntpDialer, err := dialer.New(ctx, ntpOptions.DialerOptions, ntpOptions.ServerIsDomain())
|
||||
if err != nil {
|
||||
return nil, common.NewError(err, "create NTP service")
|
||||
}
|
||||
@@ -243,21 +373,25 @@ func NewBox(options Options) (*Box, error) {
|
||||
WriteToSystem: ntpOptions.WriteToSystem,
|
||||
})
|
||||
service.MustRegister[ntp.TimeService](ctx, timeService)
|
||||
services = append(services, adapter.NewLifecycleService(timeService, "ntp service"))
|
||||
internalServices = append(internalServices, adapter.NewLifecycleService(timeService, "ntp service"))
|
||||
}
|
||||
return &Box{
|
||||
network: networkManager,
|
||||
endpoint: endpointManager,
|
||||
inbound: inboundManager,
|
||||
outbound: outboundManager,
|
||||
connection: connectionManager,
|
||||
router: router,
|
||||
createdAt: createdAt,
|
||||
logFactory: logFactory,
|
||||
logger: logFactory.Logger(),
|
||||
services: services,
|
||||
connTracker: connTracker,
|
||||
done: make(chan struct{}),
|
||||
network: networkManager,
|
||||
endpoint: endpointManager,
|
||||
inbound: inboundManager,
|
||||
outbound: outboundManager,
|
||||
dnsTransport: dnsTransportManager,
|
||||
service: serviceManager,
|
||||
dnsRouter: dnsRouter,
|
||||
connection: connectionManager,
|
||||
router: router,
|
||||
createdAt: createdAt,
|
||||
logFactory: logFactory,
|
||||
logger: logFactory.Logger(),
|
||||
internalService: internalServices,
|
||||
statsTracker: statsTracker,
|
||||
connTracker: connTracker,
|
||||
done: make(chan struct{}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -282,15 +416,6 @@ func (s *Box) PreStart() error {
|
||||
func (s *Box) Start() error {
|
||||
err := s.start()
|
||||
if err != nil {
|
||||
// TODO: remove catch error
|
||||
defer func() {
|
||||
v := recover()
|
||||
if v != nil {
|
||||
s.logger.Debug(err.Error())
|
||||
s.logger.Error("panic on early start: " + fmt.Sprint(v))
|
||||
}
|
||||
}()
|
||||
s.Close()
|
||||
return err
|
||||
}
|
||||
s.logger.Info("sing-box started (", F.Seconds(time.Since(s.createdAt).Seconds()), "s)")
|
||||
@@ -305,15 +430,15 @@ func (s *Box) preStart() error {
|
||||
if err != nil {
|
||||
return common.NewError(err, "start logger")
|
||||
}
|
||||
err = adapter.StartNamed(adapter.StartStateInitialize, s.services) // cache-file
|
||||
err = adapter.StartNamed(s.logger, adapter.StartStateInitialize, s.internalService) // cache-file clash-api v2ray-api
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.Start(adapter.StartStateInitialize, s.network, s.connection, s.router, s.outbound, s.inbound, s.endpoint)
|
||||
err = adapter.Start(s.logger, adapter.StartStateInitialize, s.network, s.dnsTransport, s.dnsRouter, s.connection, s.router, s.outbound, s.inbound, s.endpoint, s.service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.Start(adapter.StartStateStart, s.outbound, s.network, s.connection, s.router)
|
||||
err = adapter.Start(s.logger, adapter.StartStateStart, s.outbound, s.dnsTransport, s.dnsRouter, s.network, s.connection, s.router)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -325,31 +450,27 @@ func (s *Box) start() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.StartNamed(adapter.StartStateStart, s.services)
|
||||
err = adapter.StartNamed(s.logger, adapter.StartStateStart, s.internalService)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.inbound.Start(adapter.StartStateStart)
|
||||
err = adapter.Start(s.logger, adapter.StartStateStart, s.inbound, s.endpoint, s.service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.Start(adapter.StartStateStart, s.endpoint)
|
||||
err = adapter.Start(s.logger, adapter.StartStatePostStart, s.outbound, s.network, s.dnsTransport, s.dnsRouter, s.connection, s.router, s.inbound, s.endpoint, s.service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.Start(adapter.StartStatePostStart, s.outbound, s.network, s.connection, s.router, s.inbound, s.endpoint)
|
||||
err = adapter.StartNamed(s.logger, adapter.StartStatePostStart, s.internalService)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.StartNamed(adapter.StartStatePostStart, s.services)
|
||||
err = adapter.Start(s.logger, adapter.StartStateStarted, s.network, s.dnsTransport, s.dnsRouter, s.connection, s.router, s.outbound, s.inbound, s.endpoint, s.service)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.Start(adapter.StartStateStarted, s.network, s.connection, s.router, s.outbound, s.inbound, s.endpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = adapter.StartNamed(adapter.StartStateStarted, s.services)
|
||||
err = adapter.StartNamed(s.logger, adapter.StartStateStarted, s.internalService)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -359,28 +480,87 @@ func (s *Box) start() error {
|
||||
func (s *Box) Close() error {
|
||||
select {
|
||||
case <-s.done:
|
||||
return os.ErrClosed
|
||||
return nil
|
||||
default:
|
||||
close(s.done)
|
||||
}
|
||||
err := sbCommon.Close(
|
||||
s.endpoint, s.inbound, s.outbound, s.router, s.connection, s.network,
|
||||
)
|
||||
for _, lifecycleService := range s.services {
|
||||
err1 := lifecycleService.Close()
|
||||
if err1 != nil {
|
||||
s.logger.Debug(lifecycleService.Name(), " close error: ", err1)
|
||||
var err error
|
||||
s.logger.Info("closing sing-box")
|
||||
for _, closeItem := range []struct {
|
||||
name string
|
||||
service adapter.Lifecycle
|
||||
}{
|
||||
{"service", s.service},
|
||||
{"endpoint", s.endpoint},
|
||||
{"inbound", s.inbound},
|
||||
{"outbound", s.outbound},
|
||||
{"router", s.router},
|
||||
{"connection", s.connection},
|
||||
{"dns-router", s.dnsRouter},
|
||||
{"dns-transport", s.dnsTransport},
|
||||
{"network", s.network},
|
||||
} {
|
||||
if closeItem.service == nil {
|
||||
continue
|
||||
}
|
||||
func() {
|
||||
defer func() {
|
||||
if v := recover(); v != nil {
|
||||
err = errors.Join(err, common.NewError(fmt.Errorf("panic: %v", v), "close "+closeItem.name))
|
||||
s.logger.Error("panic closing ", closeItem.name, ": ", v)
|
||||
}
|
||||
}()
|
||||
s.logger.Trace("close ", closeItem.name)
|
||||
startTime := time.Now()
|
||||
closeErr := closeItem.service.Close()
|
||||
if closeErr != nil {
|
||||
closeErr = common.NewError(closeErr, "close "+closeItem.name)
|
||||
}
|
||||
err = errors.Join(err, closeErr)
|
||||
s.logger.Trace("close ", closeItem.name, " completed (", F.Seconds(time.Since(startTime).Seconds()), "s)")
|
||||
}()
|
||||
}
|
||||
err1 := s.logFactory.Close()
|
||||
if err1 != nil {
|
||||
s.logger.Debug("logger close error: ", err1)
|
||||
for _, lifecycleService := range s.internalService {
|
||||
if lifecycleService == nil {
|
||||
continue
|
||||
}
|
||||
func() {
|
||||
defer func() {
|
||||
if v := recover(); v != nil {
|
||||
err = errors.Join(err, common.NewError(fmt.Errorf("panic: %v", v), "close "+lifecycleService.Name()))
|
||||
s.logger.Error("panic closing ", lifecycleService.Name(), ": ", v)
|
||||
}
|
||||
}()
|
||||
s.logger.Trace("close ", lifecycleService.Name())
|
||||
startTime := time.Now()
|
||||
closeErr := lifecycleService.Close()
|
||||
if closeErr != nil {
|
||||
closeErr = common.NewError(closeErr, "close "+lifecycleService.Name())
|
||||
}
|
||||
err = errors.Join(err, closeErr)
|
||||
s.logger.Trace("close ", lifecycleService.Name(), " completed (", F.Seconds(time.Since(startTime).Seconds()), "s)")
|
||||
}()
|
||||
}
|
||||
s.logger.Trace("close logger")
|
||||
startTime := time.Now()
|
||||
closeErr := s.logFactory.Close()
|
||||
if closeErr != nil {
|
||||
closeErr = common.NewError(closeErr, "close logger")
|
||||
}
|
||||
err = errors.Join(err, closeErr)
|
||||
s.logger.Trace("close logger completed (", F.Seconds(time.Since(startTime).Seconds()), "s)")
|
||||
s.logger.Info("sing-box closed (live time: ", F.Seconds(time.Since(s.createdAt).Seconds()), "s)")
|
||||
if s.statsTracker != nil {
|
||||
s.statsTracker.Reset()
|
||||
}
|
||||
if s.connTracker != nil {
|
||||
s.connTracker.Reset()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Box) Uptime() uint32 {
|
||||
return uint32(time.Now().Sub(s.createdAt).Seconds())
|
||||
return uint32(time.Since(s.createdAt).Seconds())
|
||||
}
|
||||
|
||||
func (s *Box) Network() adapter.NetworkManager {
|
||||
@@ -403,6 +583,10 @@ func (s *Box) Endpoint() adapter.EndpointManager {
|
||||
return s.endpoint
|
||||
}
|
||||
|
||||
func (s *Box) StatsTracker() *StatsTracker {
|
||||
return s.statsTracker
|
||||
}
|
||||
|
||||
func (s *Box) ConnTracker() *ConnTracker {
|
||||
return s.connTracker
|
||||
}
|
||||
|
||||
+46
-8
@@ -1,9 +1,10 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
)
|
||||
|
||||
@@ -13,13 +14,13 @@ func (c *Core) AddInbound(config []byte) error {
|
||||
}
|
||||
var err error
|
||||
var inbound_config option.Inbound
|
||||
err = inbound_config.UnmarshalJSONContext(globalCtx, config)
|
||||
err = inbound_config.UnmarshalJSONContext(c.GetCtx(), config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = inbound_manager.Create(
|
||||
globalCtx,
|
||||
c.GetCtx(),
|
||||
router,
|
||||
factory.NewLogger("inbound/"+inbound_config.Type+"["+inbound_config.Tag+"]"),
|
||||
inbound_config.Tag,
|
||||
@@ -47,13 +48,17 @@ func (c *Core) AddOutbound(config []byte) error {
|
||||
var err error
|
||||
var outbound_config option.Outbound
|
||||
|
||||
err = outbound_config.UnmarshalJSONContext(globalCtx, config)
|
||||
err = outbound_config.UnmarshalJSONContext(c.GetCtx(), config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
outboundCtx := adapter.WithContext(c.GetCtx(), &adapter.InboundContext{
|
||||
Outbound: outbound_config.Tag,
|
||||
})
|
||||
|
||||
err = outbound_manager.Create(
|
||||
globalCtx,
|
||||
outboundCtx,
|
||||
router,
|
||||
factory.NewLogger("outbound/"+outbound_config.Type+"["+outbound_config.Tag+"]"),
|
||||
outbound_config.Tag,
|
||||
@@ -81,13 +86,13 @@ func (c *Core) AddEndpoint(config []byte) error {
|
||||
var err error
|
||||
var endpoint_config option.Endpoint
|
||||
|
||||
err = endpoint_config.UnmarshalJSONContext(globalCtx, config)
|
||||
err = endpoint_config.UnmarshalJSONContext(c.GetCtx(), config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = endpoint_manager.Create(
|
||||
globalCtx,
|
||||
c.GetCtx(),
|
||||
router,
|
||||
factory.NewLogger("endpoint/"+endpoint_config.Type+"["+endpoint_config.Tag+"]"),
|
||||
endpoint_config.Tag,
|
||||
@@ -107,3 +112,36 @@ func (c *Core) RemoveEndpoint(tag string) error {
|
||||
logger.Info("remove endpoint: ", tag)
|
||||
return endpoint_manager.Remove(tag)
|
||||
}
|
||||
|
||||
func (c *Core) AddService(config []byte) error {
|
||||
if !c.isRunning {
|
||||
return common.NewError("sing-box is not running")
|
||||
}
|
||||
var err error
|
||||
var srv_config option.Service
|
||||
|
||||
err = srv_config.UnmarshalJSONContext(c.GetCtx(), config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = service_manager.Create(
|
||||
c.GetCtx(),
|
||||
factory.NewLogger("service/"+srv_config.Type+"["+srv_config.Tag+"]"),
|
||||
srv_config.Tag,
|
||||
srv_config.Type,
|
||||
srv_config.Options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Core) RemoveService(tag string) error {
|
||||
if !c.isRunning {
|
||||
return common.NewError("sing-box is not running")
|
||||
}
|
||||
logger.Info("remove service: ", tag)
|
||||
return service_manager.Remove(tag)
|
||||
}
|
||||
|
||||
+7
-1
@@ -4,7 +4,9 @@ import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
suiLog "s-ui/logger"
|
||||
"time"
|
||||
|
||||
suiLog "github.com/alireza0/s-ui/logger"
|
||||
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing/common"
|
||||
@@ -177,6 +179,10 @@ func (l *observableLogger) Log(ctx context.Context, level log.Level, args []any)
|
||||
default:
|
||||
suiLog.Debug(l.tag, msg)
|
||||
}
|
||||
if (l.filePath != "" || l.writer != os.Stderr) && l.writer != nil {
|
||||
message := l.formatter.Format(ctx, level, l.tag, msg, time.Now())
|
||||
l.writer.Write([]byte(message))
|
||||
}
|
||||
}
|
||||
|
||||
func (l *observableLogger) Trace(args ...any) {
|
||||
|
||||
+13
-8
@@ -2,7 +2,8 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"s-ui/logger"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
|
||||
sb "github.com/sagernet/sing-box"
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
_ "github.com/sagernet/sing-box/transport/v2rayquic"
|
||||
_ "github.com/sagernet/sing-dns/quic"
|
||||
"github.com/sagernet/sing/service"
|
||||
)
|
||||
|
||||
@@ -19,9 +19,9 @@ var (
|
||||
globalCtx context.Context
|
||||
inbound_manager adapter.InboundManager
|
||||
outbound_manager adapter.OutboundManager
|
||||
service_manager adapter.ServiceManager
|
||||
endpoint_manager adapter.EndpointManager
|
||||
router adapter.Router
|
||||
connTracker *ConnTracker
|
||||
factory log.Factory
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ type Core struct {
|
||||
|
||||
func NewCore() *Core {
|
||||
globalCtx = context.Background()
|
||||
globalCtx = sb.Context(globalCtx, inboundRegistry(), outboundRegistry(), EndpointRegistry())
|
||||
globalCtx = sb.Context(globalCtx, InboundRegistry(), OutboundRegistry(), EndpointRegistry(), DNSTransportRegistry(), ServiceRegistry())
|
||||
return &Core{
|
||||
isRunning: false,
|
||||
instance: nil,
|
||||
@@ -64,12 +64,15 @@ func (c *Core) Start(sbConfig []byte) error {
|
||||
|
||||
err = c.instance.Start()
|
||||
if err != nil {
|
||||
_ = c.instance.Close()
|
||||
c.instance = nil
|
||||
return err
|
||||
}
|
||||
|
||||
globalCtx = service.ContextWith(globalCtx, c)
|
||||
inbound_manager = service.FromContext[adapter.InboundManager](globalCtx)
|
||||
outbound_manager = service.FromContext[adapter.OutboundManager](globalCtx)
|
||||
service_manager = service.FromContext[adapter.ServiceManager](globalCtx)
|
||||
endpoint_manager = service.FromContext[adapter.EndpointManager](globalCtx)
|
||||
router = service.FromContext[adapter.Router](globalCtx)
|
||||
|
||||
@@ -78,11 +81,13 @@ func (c *Core) Start(sbConfig []byte) error {
|
||||
}
|
||||
|
||||
func (c *Core) Stop() error {
|
||||
if c.isRunning {
|
||||
c.isRunning = false
|
||||
return c.instance.Close()
|
||||
c.isRunning = false
|
||||
if c.instance == nil {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
err := c.instance.Close()
|
||||
c.instance = nil
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Core) IsRunning() bool {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
urltest "github.com/sagernet/sing-box/common/urltest"
|
||||
)
|
||||
|
||||
const checkTimeout = 15 * time.Second
|
||||
|
||||
type CheckOutboundResult struct {
|
||||
OK bool
|
||||
Delay uint16
|
||||
Error string
|
||||
}
|
||||
|
||||
func CheckOutbound(ctx context.Context, tag string, link string) (result CheckOutboundResult) {
|
||||
if outbound_manager == nil {
|
||||
result.Error = "core not running"
|
||||
return result
|
||||
}
|
||||
ob, ok := outbound_manager.Outbound(tag)
|
||||
if !ok {
|
||||
result.Error = "outbound not found"
|
||||
return result
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, checkTimeout)
|
||||
defer cancel()
|
||||
|
||||
delay, err := urltest.URLTest(ctx, link, ob)
|
||||
if err != nil {
|
||||
result.Error = err.Error()
|
||||
return result
|
||||
}
|
||||
result.OK = true
|
||||
result.Delay = delay
|
||||
return result
|
||||
}
|
||||
+51
-6
@@ -4,9 +4,17 @@ import (
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/dns/transport"
|
||||
"github.com/sagernet/sing-box/dns/transport/dhcp"
|
||||
"github.com/sagernet/sing-box/dns/transport/fakeip"
|
||||
"github.com/sagernet/sing-box/dns/transport/hosts"
|
||||
"github.com/sagernet/sing-box/dns/transport/local"
|
||||
"github.com/sagernet/sing-box/dns/transport/quic"
|
||||
"github.com/sagernet/sing-box/protocol/anytls"
|
||||
"github.com/sagernet/sing-box/protocol/block"
|
||||
"github.com/sagernet/sing-box/protocol/direct"
|
||||
"github.com/sagernet/sing-box/protocol/dns"
|
||||
"github.com/sagernet/sing-box/protocol/group"
|
||||
"github.com/sagernet/sing-box/protocol/http"
|
||||
"github.com/sagernet/sing-box/protocol/hysteria"
|
||||
@@ -26,11 +34,14 @@ import (
|
||||
"github.com/sagernet/sing-box/protocol/vless"
|
||||
"github.com/sagernet/sing-box/protocol/vmess"
|
||||
"github.com/sagernet/sing-box/protocol/wireguard"
|
||||
"github.com/sagernet/sing-box/service/ccm"
|
||||
"github.com/sagernet/sing-box/service/ocm"
|
||||
"github.com/sagernet/sing-box/service/resolved"
|
||||
"github.com/sagernet/sing-box/service/ssmapi"
|
||||
_ "github.com/sagernet/sing-box/transport/v2rayquic"
|
||||
_ "github.com/sagernet/sing-dns/quic"
|
||||
)
|
||||
|
||||
func inboundRegistry() *inbound.Registry {
|
||||
func InboundRegistry() *inbound.Registry {
|
||||
registry := inbound.NewRegistry()
|
||||
|
||||
tun.RegisterInbound(registry)
|
||||
@@ -48,6 +59,7 @@ func inboundRegistry() *inbound.Registry {
|
||||
naive.RegisterInbound(registry)
|
||||
shadowtls.RegisterInbound(registry)
|
||||
vless.RegisterInbound(registry)
|
||||
anytls.RegisterInbound(registry)
|
||||
|
||||
hysteria.RegisterInbound(registry)
|
||||
tuic.RegisterInbound(registry)
|
||||
@@ -56,13 +68,12 @@ func inboundRegistry() *inbound.Registry {
|
||||
return registry
|
||||
}
|
||||
|
||||
func outboundRegistry() *outbound.Registry {
|
||||
func OutboundRegistry() *outbound.Registry {
|
||||
registry := outbound.NewRegistry()
|
||||
|
||||
direct.RegisterOutbound(registry)
|
||||
|
||||
block.RegisterOutbound(registry)
|
||||
dns.RegisterOutbound(registry)
|
||||
|
||||
group.RegisterSelector(registry)
|
||||
group.RegisterURLTest(registry)
|
||||
@@ -72,15 +83,16 @@ func outboundRegistry() *outbound.Registry {
|
||||
shadowsocks.RegisterOutbound(registry)
|
||||
vmess.RegisterOutbound(registry)
|
||||
trojan.RegisterOutbound(registry)
|
||||
registerNaiveOutbound(registry)
|
||||
tor.RegisterOutbound(registry)
|
||||
ssh.RegisterOutbound(registry)
|
||||
shadowtls.RegisterOutbound(registry)
|
||||
vless.RegisterOutbound(registry)
|
||||
anytls.RegisterOutbound(registry)
|
||||
|
||||
hysteria.RegisterOutbound(registry)
|
||||
tuic.RegisterOutbound(registry)
|
||||
hysteria2.RegisterOutbound(registry)
|
||||
wireguard.RegisterOutbound(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
@@ -89,6 +101,39 @@ func EndpointRegistry() *endpoint.Registry {
|
||||
registry := endpoint.NewRegistry()
|
||||
|
||||
wireguard.RegisterEndpoint(registry)
|
||||
registerTailscaleEndpoint(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
func DNSTransportRegistry() *dns.TransportRegistry {
|
||||
registry := dns.NewTransportRegistry()
|
||||
|
||||
transport.RegisterTCP(registry)
|
||||
transport.RegisterUDP(registry)
|
||||
transport.RegisterTLS(registry)
|
||||
transport.RegisterHTTPS(registry)
|
||||
hosts.RegisterTransport(registry)
|
||||
local.RegisterTransport(registry)
|
||||
fakeip.RegisterTransport(registry)
|
||||
|
||||
quic.RegisterTransport(registry)
|
||||
quic.RegisterHTTP3Transport(registry)
|
||||
dhcp.RegisterTransport(registry)
|
||||
registerTailscaleTransport(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
func ServiceRegistry() *service.Registry {
|
||||
registry := service.NewRegistry()
|
||||
|
||||
resolved.RegisterService(registry)
|
||||
ssmapi.RegisterService(registry)
|
||||
|
||||
registerDERPService(registry)
|
||||
ccm.RegisterService(registry)
|
||||
ocm.RegisterService(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//go:build with_naive_outbound
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
"github.com/sagernet/sing-box/protocol/naive"
|
||||
)
|
||||
|
||||
func registerNaiveOutbound(registry *outbound.Registry) {
|
||||
naive.RegisterOutbound(registry)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
//go:build !with_naive_outbound
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
)
|
||||
|
||||
func registerNaiveOutbound(registry *outbound.Registry) {
|
||||
// naive outbound is disabled when built without with_naive_outbound tag
|
||||
logger.Error("naive outbound is disabled when built without with_naive_outbound tag")
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//go:build with_tailscale
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/protocol/tailscale"
|
||||
"github.com/sagernet/sing-box/service/derp"
|
||||
)
|
||||
|
||||
func registerTailscaleEndpoint(registry *endpoint.Registry) {
|
||||
tailscale.RegisterEndpoint(registry)
|
||||
}
|
||||
|
||||
func registerTailscaleTransport(registry *dns.TransportRegistry) {
|
||||
tailscale.RegistryTransport(registry)
|
||||
}
|
||||
|
||||
func registerDERPService(registry *service.Registry) {
|
||||
derp.Register(registry)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//go:build !with_tailscale
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerTailscaleEndpoint(registry *endpoint.Registry) {
|
||||
endpoint.Register[option.TailscaleEndpointOptions](registry, C.TypeTailscale, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TailscaleEndpointOptions) (adapter.Endpoint, error) {
|
||||
return nil, E.New(`Tailscale is not included in this build, rebuild with -tags with_tailscale`)
|
||||
})
|
||||
}
|
||||
|
||||
func registerTailscaleTransport(registry *dns.TransportRegistry) {
|
||||
dns.RegisterTransport[option.TailscaleDNSServerOptions](registry, C.DNSTypeTailscale, func(ctx context.Context, logger log.ContextLogger, tag string, options option.TailscaleDNSServerOptions) (adapter.DNSTransport, error) {
|
||||
return nil, E.New(`Tailscale is not included in this build, rebuild with -tags with_tailscale`)
|
||||
})
|
||||
}
|
||||
|
||||
func registerDERPService(registry *service.Registry) {
|
||||
service.Register[option.DERPServiceOptions](registry, C.TypeDERP, func(ctx context.Context, logger log.ContextLogger, tag string, options option.DERPServiceOptions) (adapter.Service, error) {
|
||||
return nil, E.New(`DERP is not included in this build, rebuild with -tags with_tailscale`)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/gofrs/uuid/v5"
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing/common/buf"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
"github.com/sagernet/sing/common/network"
|
||||
)
|
||||
|
||||
type ConnectionInfo struct {
|
||||
ID string
|
||||
Conn net.Conn
|
||||
PacketConn network.PacketConn
|
||||
Inbound string
|
||||
Type string // "tcp" or "udp"
|
||||
}
|
||||
|
||||
type ConnTracker struct {
|
||||
access sync.Mutex
|
||||
connections map[string]*ConnectionInfo
|
||||
}
|
||||
|
||||
func NewConnTracker() *ConnTracker {
|
||||
return &ConnTracker{
|
||||
connections: make(map[string]*ConnectionInfo),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConnTracker) Reset() {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
for _, connInfo := range c.connections {
|
||||
if connInfo.Conn != nil {
|
||||
_ = connInfo.Conn.Close()
|
||||
}
|
||||
if connInfo.PacketConn != nil {
|
||||
_ = connInfo.PacketConn.Close()
|
||||
}
|
||||
}
|
||||
c.connections = make(map[string]*ConnectionInfo)
|
||||
}
|
||||
|
||||
func (c *ConnTracker) generateConnectionID() string {
|
||||
return uuid.Must(uuid.NewV4()).String()
|
||||
}
|
||||
|
||||
func (c *ConnTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
|
||||
connID := c.generateConnectionID()
|
||||
connInfo := &ConnectionInfo{
|
||||
ID: connID,
|
||||
Conn: conn,
|
||||
Inbound: metadata.Inbound,
|
||||
Type: "tcp",
|
||||
}
|
||||
|
||||
c.trackConnection(connID, connInfo)
|
||||
|
||||
return c.createWrappedConn(conn, connID)
|
||||
}
|
||||
|
||||
func (c *ConnTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
|
||||
connID := c.generateConnectionID()
|
||||
connInfo := &ConnectionInfo{
|
||||
ID: connID,
|
||||
PacketConn: conn,
|
||||
Inbound: metadata.Inbound,
|
||||
Type: "udp",
|
||||
}
|
||||
|
||||
c.trackConnection(connID, connInfo)
|
||||
|
||||
return c.createWrappedPacketConn(conn, connID)
|
||||
}
|
||||
|
||||
func (c *ConnTracker) CloseConnByInbound(inbound string) int {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
|
||||
closedCount := 0
|
||||
for connID, connInfo := range c.connections {
|
||||
if connInfo.Inbound == inbound {
|
||||
if connInfo.Conn != nil {
|
||||
connInfo.Conn.Close()
|
||||
}
|
||||
if connInfo.PacketConn != nil {
|
||||
connInfo.PacketConn.Close()
|
||||
}
|
||||
delete(c.connections, connID)
|
||||
closedCount++
|
||||
}
|
||||
}
|
||||
return closedCount
|
||||
}
|
||||
|
||||
func (c *ConnTracker) trackConnection(connID string, connInfo *ConnectionInfo) {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
c.connections[connID] = connInfo
|
||||
}
|
||||
|
||||
func (c *ConnTracker) untrackConnection(connID string) {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
delete(c.connections, connID)
|
||||
}
|
||||
|
||||
// shouldUntrackIOErr reports whether err indicates the connection is done (peer closed, reset, etc.).
|
||||
func shouldUntrackIOErr(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
if errors.Is(err, io.EOF) {
|
||||
return true
|
||||
}
|
||||
var ne net.Error
|
||||
if errors.As(err, &ne) {
|
||||
return !ne.Temporary()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *ConnTracker) createWrappedConn(conn net.Conn, connID string) *wrappedConn {
|
||||
return &wrappedConn{
|
||||
Conn: conn,
|
||||
tracker: c,
|
||||
connID: connID,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConnTracker) createWrappedPacketConn(conn network.PacketConn, connID string) *wrappedPacketConn {
|
||||
return &wrappedPacketConn{
|
||||
PacketConn: conn,
|
||||
tracker: c,
|
||||
connID: connID,
|
||||
}
|
||||
}
|
||||
|
||||
type wrappedConn struct {
|
||||
net.Conn
|
||||
tracker *ConnTracker
|
||||
connID string
|
||||
untrackOnce sync.Once
|
||||
}
|
||||
|
||||
func (w *wrappedConn) doUntrack() {
|
||||
w.untrackOnce.Do(func() {
|
||||
w.tracker.untrackConnection(w.connID)
|
||||
})
|
||||
}
|
||||
|
||||
func (w *wrappedConn) Read(b []byte) (int, error) {
|
||||
n, err := w.Conn.Read(b)
|
||||
if shouldUntrackIOErr(err) {
|
||||
w.doUntrack()
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (w *wrappedConn) Write(b []byte) (int, error) {
|
||||
n, err := w.Conn.Write(b)
|
||||
if err != nil && shouldUntrackIOErr(err) {
|
||||
w.doUntrack()
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (w *wrappedConn) Close() error {
|
||||
w.doUntrack()
|
||||
return w.Conn.Close()
|
||||
}
|
||||
|
||||
func (w *wrappedConn) Upstream() any {
|
||||
return w.Conn
|
||||
}
|
||||
|
||||
type wrappedPacketConn struct {
|
||||
network.PacketConn
|
||||
tracker *ConnTracker
|
||||
connID string
|
||||
untrackOnce sync.Once
|
||||
}
|
||||
|
||||
func (w *wrappedPacketConn) doUntrack() {
|
||||
w.untrackOnce.Do(func() {
|
||||
w.tracker.untrackConnection(w.connID)
|
||||
})
|
||||
}
|
||||
|
||||
func (w *wrappedPacketConn) ReadPacket(buffer *buf.Buffer) (destination M.Socksaddr, err error) {
|
||||
dest, err := w.PacketConn.ReadPacket(buffer)
|
||||
if shouldUntrackIOErr(err) {
|
||||
w.doUntrack()
|
||||
}
|
||||
return dest, err
|
||||
}
|
||||
|
||||
func (w *wrappedPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error {
|
||||
err := w.PacketConn.WritePacket(buffer, destination)
|
||||
if err != nil && shouldUntrackIOErr(err) {
|
||||
w.doUntrack()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *wrappedPacketConn) Close() error {
|
||||
w.doUntrack()
|
||||
return w.PacketConn.Close()
|
||||
}
|
||||
|
||||
func (w *wrappedPacketConn) Upstream() any {
|
||||
return w.PacketConn
|
||||
}
|
||||
@@ -3,10 +3,11 @@ package core
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"s-ui/database/model"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing/common/atomic"
|
||||
"github.com/sagernet/sing/common/bufio"
|
||||
@@ -18,27 +19,35 @@ type Counter struct {
|
||||
write *atomic.Int64
|
||||
}
|
||||
|
||||
type ConnTracker struct {
|
||||
type StatsTracker struct {
|
||||
access sync.Mutex
|
||||
createdAt time.Time
|
||||
inbounds map[string]Counter
|
||||
outbounds map[string]Counter
|
||||
users map[string]Counter
|
||||
}
|
||||
|
||||
func NewConnTracker() *ConnTracker {
|
||||
return &ConnTracker{
|
||||
createdAt: time.Now(),
|
||||
func NewStatsTracker() *StatsTracker {
|
||||
return &StatsTracker{
|
||||
inbounds: make(map[string]Counter),
|
||||
outbounds: make(map[string]Counter),
|
||||
users: make(map[string]Counter),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConnTracker) getReadCounters(inbound string, outbound string, user string) ([]*atomic.Int64, []*atomic.Int64) {
|
||||
func (c *StatsTracker) Reset() {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
c.inbounds = make(map[string]Counter)
|
||||
c.outbounds = make(map[string]Counter)
|
||||
c.users = make(map[string]Counter)
|
||||
}
|
||||
|
||||
func (c *StatsTracker) getReadCounters(inbound string, outbound string, user string) ([]*atomic.Int64, []*atomic.Int64) {
|
||||
var readCounter []*atomic.Int64
|
||||
var writeCounter []*atomic.Int64
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
|
||||
if inbound != "" {
|
||||
readCounter = append(readCounter, c.loadOrCreateCounter(&c.inbounds, inbound).read)
|
||||
writeCounter = append(writeCounter, c.inbounds[inbound].write)
|
||||
@@ -51,11 +60,10 @@ func (c *ConnTracker) getReadCounters(inbound string, outbound string, user stri
|
||||
readCounter = append(readCounter, c.loadOrCreateCounter(&c.users, user).read)
|
||||
writeCounter = append(writeCounter, c.users[user].write)
|
||||
}
|
||||
c.access.Unlock()
|
||||
return readCounter, writeCounter
|
||||
}
|
||||
|
||||
func (c *ConnTracker) loadOrCreateCounter(obj *map[string]Counter, name string) Counter {
|
||||
func (c *StatsTracker) loadOrCreateCounter(obj *map[string]Counter, name string) Counter {
|
||||
counter, loaded := (*obj)[name]
|
||||
if loaded {
|
||||
return counter
|
||||
@@ -65,17 +73,17 @@ func (c *ConnTracker) loadOrCreateCounter(obj *map[string]Counter, name string)
|
||||
return counter
|
||||
}
|
||||
|
||||
func (c *ConnTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
|
||||
func (c *StatsTracker) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) net.Conn {
|
||||
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
|
||||
return bufio.NewInt64CounterConn(conn, readCounter, writeCounter)
|
||||
}
|
||||
|
||||
func (c *ConnTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
|
||||
func (c *StatsTracker) RoutedPacketConnection(ctx context.Context, conn network.PacketConn, metadata adapter.InboundContext, matchedRule adapter.Rule, matchOutbound adapter.Outbound) network.PacketConn {
|
||||
readCounter, writeCounter := c.getReadCounters(metadata.Inbound, matchOutbound.Tag(), metadata.User)
|
||||
return bufio.NewInt64CounterPacketConn(conn, readCounter, writeCounter)
|
||||
return bufio.NewInt64CounterPacketConn(conn, readCounter, nil, writeCounter, nil)
|
||||
}
|
||||
|
||||
func (c *ConnTracker) GetStats() *[]model.Stats {
|
||||
func (c *StatsTracker) GetStats() *[]model.Stats {
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
)
|
||||
|
||||
type WALCheckpointJob struct{}
|
||||
|
||||
func NewWALCheckpointJob() *WALCheckpointJob {
|
||||
return &WALCheckpointJob{}
|
||||
}
|
||||
|
||||
func (s *WALCheckpointJob) Run() {
|
||||
db := database.GetDB()
|
||||
if err := db.Exec("PRAGMA wal_checkpoint(FULL)").Error; err != nil {
|
||||
logger.Error("Error checkpointing WAL: ", err.Error())
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"s-ui/service"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
)
|
||||
|
||||
type CheckCoreJob struct {
|
||||
@@ -13,5 +13,5 @@ func NewCheckCoreJob() *CheckCoreJob {
|
||||
}
|
||||
|
||||
func (s *CheckCoreJob) Run() {
|
||||
s.ConfigService.StartCore("")
|
||||
s.ConfigService.StartCore()
|
||||
}
|
||||
|
||||
+6
-2
@@ -20,13 +20,17 @@ func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
|
||||
|
||||
go func() {
|
||||
// Start stats job
|
||||
c.cron.AddJob("@every 10s", NewStatsJob())
|
||||
c.cron.AddJob("@every 10s", NewStatsJob(trafficAge > 0))
|
||||
// Start expiry job
|
||||
c.cron.AddJob("@every 1m", NewDepleteJob())
|
||||
// Start deleting old stats
|
||||
c.cron.AddJob("@daily", NewDelStatsJob(trafficAge))
|
||||
if trafficAge > 0 {
|
||||
c.cron.AddJob("@daily", NewDelStatsJob(trafficAge))
|
||||
}
|
||||
// Start core if it is not running
|
||||
c.cron.AddJob("@every 5s", NewCheckCoreJob())
|
||||
// database WAL checkpoint
|
||||
c.cron.AddJob("@every 10m", NewWALCheckpointJob())
|
||||
}()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
)
|
||||
|
||||
type DelStatsJob struct {
|
||||
|
||||
+11
-3
@@ -1,12 +1,14 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
)
|
||||
|
||||
type DepleteJob struct {
|
||||
service.ClientService
|
||||
service.InboundService
|
||||
}
|
||||
|
||||
func NewDepleteJob() *DepleteJob {
|
||||
@@ -14,9 +16,15 @@ func NewDepleteJob() *DepleteJob {
|
||||
}
|
||||
|
||||
func (s *DepleteJob) Run() {
|
||||
err := s.ClientService.DepleteClients()
|
||||
inboundIds, err := s.ClientService.DepleteClients()
|
||||
if err != nil {
|
||||
logger.Warning("Disable depleted users failed: ", err)
|
||||
return
|
||||
}
|
||||
if len(inboundIds) > 0 {
|
||||
err := s.InboundService.RestartInbounds(database.GetDB(), inboundIds)
|
||||
if err != nil {
|
||||
logger.Error("unable to restart inbounds: ", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-5
@@ -1,20 +1,23 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
)
|
||||
|
||||
type StatsJob struct {
|
||||
service.StatsService
|
||||
enableTraffic bool
|
||||
}
|
||||
|
||||
func NewStatsJob() *StatsJob {
|
||||
return &StatsJob{}
|
||||
func NewStatsJob(saveTraffic bool) *StatsJob {
|
||||
return &StatsJob{
|
||||
enableTraffic: saveTraffic,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *StatsJob) Run() {
|
||||
err := s.StatsService.SaveStats()
|
||||
err := s.StatsService.SaveStats(s.enableTraffic)
|
||||
if err != nil {
|
||||
logger.Warning("Get stats failed: ", err)
|
||||
return
|
||||
|
||||
+12
-6
@@ -7,15 +7,17 @@ import (
|
||||
"mime/multipart"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"s-ui/cmd/migration"
|
||||
"s-ui/config"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"runtime"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/cmd/migration"
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -287,7 +289,11 @@ func SendSighup() error {
|
||||
// Send SIGHUP to the current process
|
||||
go func() {
|
||||
time.Sleep(3 * time.Second)
|
||||
err := process.Signal(syscall.SIGHUP)
|
||||
if runtime.GOOS == "windows" {
|
||||
err = process.Kill()
|
||||
} else {
|
||||
err = process.Signal(syscall.SIGHUP)
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("send signal SIGHUP failed:", err)
|
||||
}
|
||||
|
||||
+24
-5
@@ -4,8 +4,11 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path"
|
||||
"s-ui/config"
|
||||
"s-ui/database/model"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
@@ -48,12 +51,28 @@ func OpenDB(dbPath string) error {
|
||||
c := &gorm.Config{
|
||||
Logger: gormLogger,
|
||||
}
|
||||
db, err = gorm.Open(sqlite.Open(dbPath), c)
|
||||
sep := "?"
|
||||
if strings.Contains(dbPath, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
dsn := dbPath + sep + "_busy_timeout=10000&_journal_mode=WAL"
|
||||
db, err = gorm.Open(sqlite.Open(dsn), c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sqlDB.SetMaxOpenConns(25)
|
||||
sqlDB.SetMaxIdleConns(5)
|
||||
sqlDB.SetConnMaxLifetime(time.Hour)
|
||||
|
||||
if config.IsDebug() {
|
||||
db = db.Debug()
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
func InitDB(dbPath string) error {
|
||||
@@ -67,7 +86,6 @@ func InitDB(dbPath string) error {
|
||||
db.Migrator().CreateTable(&model.Outbound{})
|
||||
defaultOutbound := []model.Outbound{
|
||||
{Type: "direct", Tag: "direct", Options: json.RawMessage(`{}`)},
|
||||
{Type: "dns", Tag: "dns-out", Options: json.RawMessage(`{}`)},
|
||||
}
|
||||
db.Create(&defaultOutbound)
|
||||
}
|
||||
@@ -77,6 +95,7 @@ func InitDB(dbPath string) error {
|
||||
&model.Tls{},
|
||||
&model.Inbound{},
|
||||
&model.Outbound{},
|
||||
&model.Service{},
|
||||
&model.Endpoint{},
|
||||
&model.User{},
|
||||
&model.Tokens{},
|
||||
|
||||
@@ -35,6 +35,14 @@ type Client struct {
|
||||
Up int64 `json:"up" form:"up"`
|
||||
Desc string `json:"desc" form:"desc"`
|
||||
Group string `json:"group" form:"group"`
|
||||
|
||||
// Delay start and periodic reset
|
||||
DelayStart bool `json:"delayStart" form:"delayStart" gorm:"default:false;not null"`
|
||||
AutoReset bool `json:"autoReset" form:"autoReset" gorm:"default:false;not null"`
|
||||
ResetDays int `json:"resetDays" form:"resetDays" gorm:"default:0;not null"`
|
||||
NextReset int64 `json:"nextReset" form:"nextReset" gorm:"default:0;not null"`
|
||||
TotalUp int64 `json:"totalUp" form:"totalUp" gorm:"default:0;not null"`
|
||||
TotalDown int64 `json:"totalDown" form:"totalDown" gorm:"default:0;not null"`
|
||||
}
|
||||
|
||||
type Stats struct {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
Id uint `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
|
||||
Type string `json:"type" form:"type"`
|
||||
Tag string `json:"tag" form:"tag" gorm:"unique"`
|
||||
|
||||
// Foreign key to tls table
|
||||
TlsId uint `json:"tls_id" form:"tls_id"`
|
||||
Tls *Tls `json:"tls" form:"tls" gorm:"foreignKey:TlsId;references:Id"`
|
||||
|
||||
Options json.RawMessage `json:"-" form:"-"`
|
||||
}
|
||||
|
||||
func (i *Service) UnmarshalJSON(data []byte) error {
|
||||
var err error
|
||||
var raw map[string]interface{}
|
||||
if err = json.Unmarshal(data, &raw); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Extract fixed fields and store the rest in Options
|
||||
if val, exists := raw["id"].(float64); exists {
|
||||
i.Id = uint(val)
|
||||
}
|
||||
delete(raw, "id")
|
||||
i.Type, _ = raw["type"].(string)
|
||||
delete(raw, "type")
|
||||
i.Tag, _ = raw["tag"].(string)
|
||||
delete(raw, "tag")
|
||||
|
||||
// TlsId
|
||||
if val, exists := raw["tls_id"].(float64); exists {
|
||||
i.TlsId = uint(val)
|
||||
}
|
||||
delete(raw, "tls_id")
|
||||
delete(raw, "tls")
|
||||
|
||||
// Remaining fields
|
||||
i.Options, err = json.MarshalIndent(raw, "", " ")
|
||||
return err
|
||||
}
|
||||
|
||||
// MarshalJSON customizes marshalling
|
||||
func (i Service) MarshalJSON() ([]byte, error) {
|
||||
// Combine fixed fields and dynamic fields into one map
|
||||
combined := make(map[string]interface{})
|
||||
combined["type"] = i.Type
|
||||
combined["tag"] = i.Tag
|
||||
if i.Tls != nil {
|
||||
combined["tls"] = i.Tls.Server
|
||||
}
|
||||
|
||||
if i.Options != nil {
|
||||
var restFields map[string]json.RawMessage
|
||||
if err := json.Unmarshal(i.Options, &restFields); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k, v := range restFields {
|
||||
combined[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return json.Marshal(combined)
|
||||
}
|
||||
|
||||
func (i Service) MarshalFull() (*map[string]interface{}, error) {
|
||||
combined := make(map[string]interface{})
|
||||
combined["id"] = i.Id
|
||||
combined["type"] = i.Type
|
||||
combined["tag"] = i.Tag
|
||||
combined["tls_id"] = i.TlsId
|
||||
|
||||
if i.Options != nil {
|
||||
var restFields map[string]interface{}
|
||||
if err := json.Unmarshal(i.Options, &restFields); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for k, v := range restFields {
|
||||
combined[k] = v
|
||||
}
|
||||
}
|
||||
return &combined, nil
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test Docker multi-platform build (linux/amd64, 386, arm64, arm/v7, arm/v6)
|
||||
# Requires: frontend_dist/ (run from repo root after building frontend)
|
||||
|
||||
set -e
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
echo "==> Preparing frontend_dist..."
|
||||
if [ ! -d "frontend_dist" ] || [ -z "$(ls -A frontend_dist 2>/dev/null)" ]; then
|
||||
echo "Building frontend..."
|
||||
(cd frontend && npm install --prefer-offline --no-audit && npm run build)
|
||||
rm -rf frontend_dist
|
||||
mkdir -p frontend_dist
|
||||
cp -R frontend/dist/* frontend_dist/
|
||||
echo "frontend_dist ready."
|
||||
else
|
||||
echo "frontend_dist exists, skipping frontend build."
|
||||
fi
|
||||
|
||||
PLATFORMS="linux/amd64,linux/386,linux/arm64/v8,linux/arm/v7,linux/arm/v6"
|
||||
echo "==> Testing Docker build for: $PLATFORMS"
|
||||
docker buildx build \
|
||||
--platform "$PLATFORMS" \
|
||||
-f Dockerfile.frontend-artifact \
|
||||
--build-arg CRONET_RELEASE=latest \
|
||||
--progress=plain \
|
||||
. 2>&1 | tee docker-build-test.log
|
||||
|
||||
echo "==> Done. Check docker-build-test.log for full output."
|
||||
+6
-2
@@ -1,4 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
./sui migrate
|
||||
./sui
|
||||
DB_PATH="${SUI_DB_FOLDER:-/app/db}/s-ui.db"
|
||||
if [ -f "$DB_PATH" ]; then
|
||||
./sui migrate
|
||||
fi
|
||||
|
||||
exec ./sui
|
||||
+1
-1
Submodule frontend updated: cb5b0e119b...f65f58efbd
@@ -1,125 +1,199 @@
|
||||
module s-ui
|
||||
module github.com/alireza0/s-ui
|
||||
|
||||
go 1.23.2
|
||||
go 1.25.7
|
||||
|
||||
require (
|
||||
github.com/gin-contrib/gzip v1.2.2
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/gin-contrib/gzip v1.2.5
|
||||
github.com/gin-contrib/sessions v1.0.4
|
||||
github.com/gin-gonic/gin v1.12.0
|
||||
github.com/gofrs/uuid/v5 v5.4.0
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/sagernet/sing v0.6.0
|
||||
github.com/sagernet/sing-box v1.11.1
|
||||
github.com/sagernet/sing-dns v0.4.0
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
|
||||
gorm.io/driver/sqlite v1.5.7
|
||||
gorm.io/gorm v1.25.12
|
||||
github.com/sagernet/sing v0.8.4
|
||||
github.com/sagernet/sing-box v1.13.4
|
||||
github.com/shirou/gopsutil/v4 v4.26.2
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/sqlite v1.6.0
|
||||
gorm.io/gorm v1.31.1
|
||||
)
|
||||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.2.0 // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.6 // indirect
|
||||
github.com/bytedance/sonic v1.12.7 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.2 // indirect
|
||||
github.com/caddyserver/certmagic v0.20.0 // indirect
|
||||
github.com/cloudflare/circl v1.3.7 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/akutz/memconn v0.1.0 // indirect
|
||||
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa // indirect
|
||||
github.com/andybalholm/brotli v1.1.0 // indirect
|
||||
github.com/anthropics/anthropic-sdk-go v1.26.0 // indirect
|
||||
github.com/anytls/sing-anytls v0.0.11 // indirect
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.15.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||
github.com/caddyserver/certmagic v0.25.2 // indirect
|
||||
github.com/caddyserver/zerossl v0.1.5 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/coder/websocket v1.8.14 // indirect
|
||||
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
|
||||
github.com/cretz/bine v0.2.0 // indirect
|
||||
github.com/ebitengine/purego v0.8.2 // indirect
|
||||
github.com/database64128/netx-go v0.1.1 // indirect
|
||||
github.com/database64128/tfo-go/v2 v2.3.2 // indirect
|
||||
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa // indirect
|
||||
github.com/ebitengine/purego v0.10.0 // indirect
|
||||
github.com/florianl/go-nfqueue/v2 v2.0.2 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/sessions v1.0.2
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-chi/chi/v5 v5.1.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||
github.com/gaissmai/bart v0.18.0 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-chi/chi/v5 v5.2.5 // indirect
|
||||
github.com/go-chi/render v1.0.3 // indirect
|
||||
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.24.0 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/goccy/go-json v0.10.4 // indirect
|
||||
github.com/gofrs/uuid/v5 v5.3.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/godbus/dbus/v5 v5.2.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/google/btree v1.1.3 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/context v1.1.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/gorilla/sessions v1.4.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
|
||||
github.com/insomniacslk/dhcp v0.0.0-20260220084031-5adc3eb26f91 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/jsimonetti/rtnetlink v1.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||
github.com/keybase/go-keychain v0.0.1 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/libdns/alidns v1.0.3 // indirect
|
||||
github.com/libdns/cloudflare v0.1.1 // indirect
|
||||
github.com/libdns/libdns v0.2.2 // indirect; indiresct
|
||||
github.com/libdns/acmedns v0.5.0 // indirect
|
||||
github.com/libdns/alidns v1.0.6 // indirect
|
||||
github.com/libdns/cloudflare v0.2.2 // indirect
|
||||
github.com/libdns/libdns v1.1.1 // indirect
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.24 // indirect
|
||||
github.com/mdlayher/netlink v1.7.2 // indirect
|
||||
github.com/mdlayher/socket v0.4.1 // indirect
|
||||
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa // indirect
|
||||
github.com/mholt/acmez v1.2.0 // indirect
|
||||
github.com/miekg/dns v1.1.62 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.30 // indirect
|
||||
github.com/mdlayher/netlink v1.9.0 // indirect
|
||||
github.com/mdlayher/socket v0.5.1 // indirect
|
||||
github.com/metacubex/utls v1.8.4 // indirect
|
||||
github.com/mholt/acmez/v3 v3.1.6 // indirect
|
||||
github.com/miekg/dns v1.1.72 // indirect
|
||||
github.com/mitchellh/go-ps v1.0.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/onsi/ginkgo/v2 v2.10.0 // indirect
|
||||
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/openai/openai-go/v3 v3.26.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.21 // indirect
|
||||
github.com/pires/go-proxyproto v0.8.1 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||
github.com/quic-go/qpack v0.4.0 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
|
||||
github.com/prometheus-community/pro-bing v0.4.0 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/safchain/ethtool v0.3.0 // indirect
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a // indirect
|
||||
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 // indirect
|
||||
github.com/sagernet/cors v1.2.1 // indirect
|
||||
github.com/sagernet/cronet-go v0.0.0-20260309102448-2fef65f9dba9 // indirect
|
||||
github.com/sagernet/cronet-go/all v0.0.0-20260309102448-2fef65f9dba9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/android_386 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/android_amd64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/android_arm v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/android_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/darwin_amd64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/darwin_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/ios_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_386 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_386_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_arm v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_arm_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_mips64le v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64_musl v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/tvos_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/windows_amd64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/cronet-go/lib/windows_arm64 v0.0.0-20260309101654-0cbdcfddded9 // indirect
|
||||
github.com/sagernet/fswatch v0.1.1 // indirect
|
||||
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff // indirect
|
||||
github.com/sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 // indirect
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a // indirect
|
||||
github.com/sagernet/nftables v0.3.0-beta.4 // indirect
|
||||
github.com/sagernet/quic-go v0.48.2-beta.1 // indirect
|
||||
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect
|
||||
github.com/sagernet/sing-mux v0.3.0-alpha.1 // indirect
|
||||
github.com/sagernet/sing-quic v0.4.0-beta.4 // indirect
|
||||
github.com/sagernet/sing-shadowsocks v0.2.7 // indirect
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.0 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.2.0-alpha.2 // indirect
|
||||
github.com/sagernet/sing-tun v0.6.0-beta.8 // indirect
|
||||
github.com/sagernet/sing-vmess v0.2.0-beta.2 // indirect
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 // indirect
|
||||
github.com/sagernet/utls v1.6.7 // indirect
|
||||
github.com/sagernet/wireguard-go v0.0.1-beta.5 // indirect
|
||||
github.com/sagernet/quic-go v0.59.0-sing-box-mod.4 // indirect
|
||||
github.com/sagernet/sing-mux v0.3.4 // indirect
|
||||
github.com/sagernet/sing-quic v0.6.0 // indirect
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8 // indirect
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.1 // indirect
|
||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 // indirect
|
||||
github.com/sagernet/sing-tun v0.8.6 // indirect
|
||||
github.com/sagernet/sing-vmess v0.2.8-0.20250909125414-3aed155119a1 // indirect
|
||||
github.com/sagernet/smux v1.5.50-sing-box-mod.1 // indirect
|
||||
github.com/sagernet/tailscale v1.92.4-sing-box-1.13-mod.7 // indirect
|
||||
github.com/sagernet/wireguard-go v0.0.2-beta.1.0.20260224074747-506b7631853c // indirect
|
||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 // indirect
|
||||
github.com/shirou/gopsutil/v4 v4.25.1
|
||||
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
||||
github.com/tklauser/numcpus v0.9.0 // indirect
|
||||
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e // indirect
|
||||
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 // indirect
|
||||
github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05 // indirect
|
||||
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a // indirect
|
||||
github.com/tailscale/netlink v1.1.1-0.20240822203006-4d49adab4de7 // indirect
|
||||
github.com/tailscale/peercred v0.0.0-20250107143737-35a0c7bd7edc // indirect
|
||||
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.16 // indirect
|
||||
github.com/tklauser/numcpus v0.11.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/vishvananda/netns v0.0.4 // indirect
|
||||
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
github.com/vishvananda/netns v0.0.5 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
github.com/zeebo/blake3 v0.2.3 // indirect
|
||||
github.com/zeebo/blake3 v0.2.4 // indirect
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.uber.org/zap v1.27.1 // indirect
|
||||
go.uber.org/zap/exp v0.3.0 // indirect
|
||||
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 // indirect
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
|
||||
golang.org/x/arch v0.13.0 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||
golang.org/x/mod v0.20.0 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
golang.org/x/tools v0.24.0 // indirect
|
||||
golang.org/x/arch v0.22.0 // indirect
|
||||
golang.org/x/crypto v0.48.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 // indirect
|
||||
golang.org/x/mod v0.33.0 // indirect
|
||||
golang.org/x/net v0.51.0 // indirect
|
||||
golang.org/x/oauth2 v0.34.0 // indirect
|
||||
golang.org/x/sync v0.19.0 // indirect
|
||||
golang.org/x/sys v0.41.0 // indirect
|
||||
golang.org/x/term v0.40.0 // indirect
|
||||
golang.org/x/text v0.34.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.org/x/tools v0.42.0 // indirect
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
|
||||
google.golang.org/grpc v1.67.1 // indirect
|
||||
google.golang.org/protobuf v1.36.2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
lukechampine.com/blake3 v1.3.0 // indirect
|
||||
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
|
||||
google.golang.org/grpc v1.79.3 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
lukechampine.com/blake3 v1.4.1 // indirect
|
||||
)
|
||||
|
||||
replace github.com/quic-go/quic-go => github.com/quic-go/quic-go v0.57.1
|
||||
|
||||
@@ -1,44 +1,87 @@
|
||||
code.pfad.fr/check v1.1.0 h1:GWvjdzhSEgHvEHe2uJujDcpmZoySKuHQNrZMfzfO0bE=
|
||||
code.pfad.fr/check v1.1.0/go.mod h1:NiUH13DtYsb7xp5wll0U4SXx7KhXQVCtRgdC96IPfoM=
|
||||
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
|
||||
filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/bytedance/sonic v1.12.7 h1:CQU8pxOy9HToxhndH0Kx/S1qU/CuS9GnKYrGioDcU1Q=
|
||||
github.com/bytedance/sonic v1.12.7/go.mod h1:tnbal4mxOMju17EGfknm2XyYcpyCnIROYOEYuemj13I=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.2 h1:jxAJuN9fOot/cyz5Q6dUuMJF5OqQ6+5GfA8FjjQ0R4o=
|
||||
github.com/bytedance/sonic/loader v0.2.2/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc=
|
||||
github.com/caddyserver/certmagic v0.20.0/go.mod h1:N4sXgpICQUskEWpj7zVzvWD41p3NYacrNoZYiRM2jTg=
|
||||
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
||||
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/akutz/memconn v0.1.0 h1:NawI0TORU4hcOMsMr11g7vwlCdkYeLKXBcxWu2W/P8A=
|
||||
github.com/akutz/memconn v0.1.0/go.mod h1:Jo8rI7m0NieZyLI5e2CDlRdRqRRB4S7Xp77ukDjH+Fw=
|
||||
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7VVbI0o4wBRNQIgn917usHWOd6VAffYI=
|
||||
github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
|
||||
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
||||
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
||||
github.com/anthropics/anthropic-sdk-go v1.26.0 h1:oUTzFaUpAevfuELAP1sjL6CQJ9HHAfT7CoSYSac11PY=
|
||||
github.com/anthropics/anthropic-sdk-go v1.26.0/go.mod h1:qUKmaW+uuPB64iy1l+4kOSvaLqPXnHTTBKH6RVZ7q5Q=
|
||||
github.com/anytls/sing-anytls v0.0.11 h1:w8e9Uj1oP3m4zxkyZDewPk0EcQbvVxb7Nn+rapEx4fc=
|
||||
github.com/anytls/sing-anytls v0.0.11/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/caddyserver/certmagic v0.25.2 h1:D7xcS7ggX/WEY54x0czj7ioTkmDWKIgxtIi2OcQclUc=
|
||||
github.com/caddyserver/certmagic v0.25.2/go.mod h1:llW/CvsNmza8S6hmsuggsZeiX+uS27dkqY27wDIuBWg=
|
||||
github.com/caddyserver/zerossl v0.1.5 h1:dkvOjBAEEtY6LIGAHei7sw2UgqSD6TrWweXpV7lvEvE=
|
||||
github.com/caddyserver/zerossl v0.1.5/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cilium/ebpf v0.15.0 h1:7NxJhNiBT3NG8pZJ3c+yfrVdHY8ScgKD27sScgjLMMk=
|
||||
github.com/cilium/ebpf v0.15.0/go.mod h1:DHp1WyrLeiBh19Cf/tfiSMhqheEiK8fXFZ4No0P1Hso=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
|
||||
github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
|
||||
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 h1:8h5+bWd7R6AYUslN6c6iuZWTKsKxUFDlpnmilO6R2n0=
|
||||
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFETJConOQ//Q=
|
||||
github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo=
|
||||
github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI=
|
||||
github.com/database64128/netx-go v0.1.1 h1:dT5LG7Gs7zFZBthFBbzWE6K8wAHjSNAaK7wCYZT7NzM=
|
||||
github.com/database64128/netx-go v0.1.1/go.mod h1:LNlYVipaYkQArRFDNNJ02VkNV+My9A5XR/IGS7sIBQc=
|
||||
github.com/database64128/tfo-go/v2 v2.3.2 h1:UhZMKiMq3swZGUiETkLBDzQnZBPSAeBMClpJGlnJ5Fw=
|
||||
github.com/database64128/tfo-go/v2 v2.3.2/go.mod h1:GC3uB5oa4beGpCUbRb2ZOWP73bJJFmMyAVgQSO7r724=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/ebitengine/purego v0.8.2 h1:jPPGWs2sZ1UgOSgD2bClL0MJIqu58nOmIcBuXr62z1I=
|
||||
github.com/ebitengine/purego v0.8.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa h1:h8TfIT1xc8FWbwwpmHn1J5i43Y0uZP97GqasGCzSRJk=
|
||||
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa/go.mod h1:Nx87SkVqTKd8UtT+xu7sM/l+LgXs6c0aHrlKusR+2EQ=
|
||||
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
|
||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||
github.com/ebitengine/purego v0.10.0 h1:QIw4xfpWT6GWTzaW5XEKy3HXoqrJGx1ijYHzTF0/ISU=
|
||||
github.com/ebitengine/purego v0.10.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
|
||||
github.com/florianl/go-nfqueue/v2 v2.0.2 h1:FL5lQTeetgpCvac1TRwSfgaXUn0YSO7WzGvWNIp3JPE=
|
||||
github.com/florianl/go-nfqueue/v2 v2.0.2/go.mod h1:VA09+iPOT43OMoCKNfXHyzujQUty2xmzyCRkBOlmabc=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/gzip v1.2.2 h1:iUU/EYCM8ENfkjmZaVrxbjF/ZC267Iqv5S0MMCMEliI=
|
||||
github.com/gin-contrib/gzip v1.2.2/go.mod h1:C1a5cacjlDsS20cKnHlZRCPUu57D3qH6B2pV0rl+Y/s=
|
||||
github.com/gin-contrib/sessions v1.0.2 h1:UaIjUvTH1cMeOdj3in6dl+Xb6It8RiKRF9Z1anbUyCA=
|
||||
github.com/gin-contrib/sessions v1.0.2/go.mod h1:KxKxWqWP5LJVDCInulOl4WbLzK2KSPlLesfZ66wRvMs=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
|
||||
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gaissmai/bart v0.18.0 h1:jQLBT/RduJu0pv/tLwXE+xKPgtWJejbxuXAR+wLJafo=
|
||||
github.com/gaissmai/bart v0.18.0/go.mod h1:JJzMAhNF5Rjo4SF4jWBrANuJfqY+FvsFhW7t1UZJ+XY=
|
||||
github.com/gin-contrib/gzip v1.2.5 h1:fIZs0S+l17pIu1P5XRJOo/YNqfIuPCrZZ3TWB7pjckI=
|
||||
github.com/gin-contrib/gzip v1.2.5/go.mod h1:aomRgR7ftdZV3uWY0gW/m8rChfxau0n8YVvwlOHONzw=
|
||||
github.com/gin-contrib/sessions v1.0.4 h1:ha6CNdpYiTOK/hTp05miJLbpTSNfOnFg5Jm2kbcqy8U=
|
||||
github.com/gin-contrib/sessions v1.0.4/go.mod h1:ccmkrb2z6iU2osiAHZG3x3J4suJK+OU27oqzlWOqQgs=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||
github.com/github/fakeca v0.1.0 h1:Km/MVOFvclqxPM9dZBC4+QE564nU4gz4iZ0D9pMw28I=
|
||||
github.com/github/fakeca v0.1.0/go.mod h1:+bormgoGMMuamOscx7N91aOuUST7wdaJ2rNjeohylyo=
|
||||
github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
|
||||
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
|
||||
github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
||||
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced h1:Q311OHjMh/u5E2TITc++WlTP5We0xNseRMkHDyvhW7I=
|
||||
github.com/go-json-experiment/json v0.0.0-20250813024750-ebf49471dced/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
@@ -48,29 +91,35 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
|
||||
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
|
||||
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
|
||||
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
|
||||
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
|
||||
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
|
||||
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
|
||||
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5XqmmYsTLzJp/TO9Lhy39gkverk=
|
||||
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
|
||||
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806 h1:wG8RYIyctLhdFk6Vl1yPGtSRtwGpVkWyZww1OCil2MI=
|
||||
github.com/google/nftables v0.2.1-0.20240414091927-5e242ec57806/go.mod h1:Beg6V6zZ3oEn0JuiUQ4wqwuyqqzasOltcoXPtgLbFp4=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o=
|
||||
github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM=
|
||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||
@@ -79,221 +128,358 @@ github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzq
|
||||
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
|
||||
github.com/hashicorp/yamux v0.1.2 h1:XtB8kyFOyHXYVFnwT5C3+Bdo8gArse7j2AQ0DA0Uey8=
|
||||
github.com/hashicorp/yamux v0.1.2/go.mod h1:C+zze2n6e/7wshOZep2A70/aQU6QBRWJO/G6FT1wIns=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0 h1:37ICyZqdyj0lAZ8P4D1d1id3HqbbG1N3iBb1Tb4rdcU=
|
||||
github.com/hdevalence/ed25519consensus v0.2.0/go.mod h1:w3BHWjwJbFU29IRHL1Iqkw3sus+7FctEyM4RqDxYNzo=
|
||||
github.com/insomniacslk/dhcp v0.0.0-20260220084031-5adc3eb26f91 h1:u9i04mGE3iliBh0EFuWaKsmcwrLacqGmq1G3XoaM7gY=
|
||||
github.com/insomniacslk/dhcp v0.0.0-20260220084031-5adc3eb26f91/go.mod h1:qfvBmyDNp+/liLEYWRvqny/PEz9hGe2Dz833eXILSmo=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/jsimonetti/rtnetlink v1.4.0 h1:Z1BF0fRgcETPEa0Kt0MRk3yV5+kF1FWTni6KUFKrq2I=
|
||||
github.com/jsimonetti/rtnetlink v1.4.0/go.mod h1:5W1jDvWdnthFJ7fxYX1GMK07BUpI4oskfOqvPteYS6E=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
|
||||
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=
|
||||
github.com/keybase/go-keychain v0.0.1/go.mod h1:PdEILRW3i9D8JcdM+FmY6RwkHGnhHxXwkPPMeUgOK1k=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/libdns/alidns v1.0.3 h1:LFHuGnbseq5+HCeGa1aW8awyX/4M2psB9962fdD2+yQ=
|
||||
github.com/libdns/alidns v1.0.3/go.mod h1:e18uAG6GanfRhcJj6/tps2rCMzQJaYVcGKT+ELjdjGE=
|
||||
github.com/libdns/cloudflare v0.1.1 h1:FVPfWwP8zZCqj268LZjmkDleXlHPlFU9KC4OJ3yn054=
|
||||
github.com/libdns/cloudflare v0.1.1/go.mod h1:9VK91idpOjg6v7/WbjkEW49bSCxj00ALesIFDhJ8PBU=
|
||||
github.com/libdns/libdns v0.2.0/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40=
|
||||
github.com/libdns/libdns v0.2.2 h1:O6ws7bAfRPaBsgAYt8MDe2HcNBGC29hkZ9MX2eUSX3s=
|
||||
github.com/libdns/libdns v0.2.2/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ=
|
||||
github.com/letsencrypt/challtestsrv v1.4.2 h1:0ON3ldMhZyWlfVNYYpFuWRTmZNnyfiL9Hh5YzC3JVwU=
|
||||
github.com/letsencrypt/challtestsrv v1.4.2/go.mod h1:GhqMqcSoeGpYd5zX5TgwA6er/1MbWzx/o7yuuVya+Wk=
|
||||
github.com/letsencrypt/pebble/v2 v2.10.0 h1:Wq6gYXlsY6ubqI3hhxsTzdyotvfdjFBxuwYqCLCnj/U=
|
||||
github.com/letsencrypt/pebble/v2 v2.10.0/go.mod h1:Sk8cmUIPcIdv2nINo+9PB4L+ZBhzY+F9A1a/h/xmWiQ=
|
||||
github.com/libdns/acmedns v0.5.0 h1:5pRtmUj4Lb/QkNJSl1xgOGBUJTWW7RjpNaIhjpDXjPE=
|
||||
github.com/libdns/acmedns v0.5.0/go.mod h1:X7UAFP1Ep9NpTwWpVlrZzJLR7epynAy0wrIxSPFgKjQ=
|
||||
github.com/libdns/alidns v1.0.6 h1:/Ii428ty6WHFJmE24rZxq2taq++gh7rf9jhgLfp8PmM=
|
||||
github.com/libdns/alidns v1.0.6/go.mod h1:RECwyQ88e9VqQVtSrvX76o1ux3gQUKGzMgxICi+u7Ec=
|
||||
github.com/libdns/cloudflare v0.2.2 h1:XWHv+C1dDcApqazlh08Q6pjytYLgR2a+Y3xrXFu0vsI=
|
||||
github.com/libdns/cloudflare v0.2.2/go.mod h1:w9uTmRCDlAoafAsTPnn2nJ0XHK/eaUMh86DUk8BWi60=
|
||||
github.com/libdns/libdns v1.1.1 h1:wPrHrXILoSHKWJKGd0EiAVmiJbFShguILTg9leS/P/U=
|
||||
github.com/libdns/libdns v1.1.1/go.mod h1:4Bj9+5CQiNMVGf87wjX4CY3HQJypUHRuLvlsfsZqLWQ=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
|
||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc=
|
||||
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
|
||||
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g=
|
||||
github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw=
|
||||
github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U=
|
||||
github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA=
|
||||
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa h1:9mcjV+RGZVC3reJBNDjjNPyS8PmFG97zq56X7WNaFO4=
|
||||
github.com/metacubex/tfo-go v0.0.0-20241006021335-daedaf0ca7aa/go.mod h1:4tLB5c8U0CxpkFM+AJJB77jEaVDbLH5XQvy42vAGsWw=
|
||||
github.com/mholt/acmez v1.2.0 h1:1hhLxSgY5FvH5HCnGUuwbKY2VQVo8IU7rxXKSnZ7F30=
|
||||
github.com/mholt/acmez v1.2.0/go.mod h1:VT9YwH1xgNX1kmYY89gY8xPJC84BFAisjo8Egigt4kE=
|
||||
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
|
||||
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
|
||||
github.com/mattn/go-sqlite3 v1.14.30 h1:bVreufq3EAIG1Quvws73du3/QgdeZ3myglJlrzSYYCY=
|
||||
github.com/mattn/go-sqlite3 v1.14.30/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mdlayher/netlink v1.9.0 h1:G8+GLq2x3v4D4MVIqDdNUhTUC7TKiCy/6MDkmItfKco=
|
||||
github.com/mdlayher/netlink v1.9.0/go.mod h1:YBnl5BXsCoRuwBjKKlZ+aYmEoq0r12FDA/3JC+94KDg=
|
||||
github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos=
|
||||
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
|
||||
github.com/metacubex/utls v1.8.4 h1:HmL9nUApDdWSkgUyodfwF6hSjtiwCGGdyhaSpEejKpg=
|
||||
github.com/metacubex/utls v1.8.4/go.mod h1:kncGGVhFaoGn5M3pFe3SXhZCzsbCJayNOH4UEqTKTko=
|
||||
github.com/mholt/acmez/v3 v3.1.6 h1:eGVQNObP0pBN4sxqrXeg7MYqTOWyoiYpQqITVWlrevk=
|
||||
github.com/mholt/acmez/v3 v3.1.6/go.mod h1:5nTPosTGosLxF3+LU4ygbgMRFDhbAVpqMI4+a4aHLBY=
|
||||
github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI=
|
||||
github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs=
|
||||
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
|
||||
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/onsi/ginkgo/v2 v2.10.0 h1:sfUl4qgLdvkChZrWCYndY2EAu9BRIw1YphNAzy1VNWs=
|
||||
github.com/onsi/ginkgo/v2 v2.10.0/go.mod h1:UDQOh5wbQUlMnkLfVaIUMtQ1Vus92oM+P2JX1aulgcE=
|
||||
github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
|
||||
github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
|
||||
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/openai/openai-go/v3 v3.26.0 h1:bRt6H/ozMNt/dDkN4gobnLqaEGrRGBzmbVs0xxJEnQE=
|
||||
github.com/openai/openai-go/v3 v3.26.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pires/go-proxyproto v0.8.1 h1:9KEixbdJfhrbtjpz/ZwCdWDD2Xem0NZ38qMYaASJgp0=
|
||||
github.com/pires/go-proxyproto v0.8.1/go.mod h1:ZKAAyp3cgy5Y5Mo4n9AlScrkCZwUy0g3Jf+slqQVcuU=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
|
||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
|
||||
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
|
||||
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
||||
github.com/prometheus-community/pro-bing v0.4.0 h1:YMbv+i08gQz97OZZBwLyvmmQEEzyfyrrjEaAchdy3R4=
|
||||
github.com/prometheus-community/pro-bing v0.4.0/go.mod h1:b7wRYZtCcPmt4Sz319BykUU241rWLe1VFXyiyWK/dH4=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.57.1 h1:25KAAR9QR8KZrCZRThWMKVAwGoiHIrNbT72ULHTuI10=
|
||||
github.com/quic-go/quic-go v0.57.1/go.mod h1:ly4QBAjHA2VhdnxhojRsCUOeJwKYg+taDlos92xb1+s=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/safchain/ethtool v0.3.0 h1:gimQJpsI6sc1yIqP/y8GYgiXn/NjgvpM0RNoWLVVmP0=
|
||||
github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6ocLW+CJUs=
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a h1:+NkI2670SQpQWvkkD2QgdTuzQG263YZ+2emfpeyGqW0=
|
||||
github.com/sagernet/bbolt v0.0.0-20231014093535-ea5cb2fe9f0a/go.mod h1:63s7jpZqcDAIpj8oI/1v4Izok+npJOHACFCU6+huCkM=
|
||||
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1 h1:YbmpqPQEMdlk9oFSKYWRqVuu9qzNiOayIonKmv1gCXY=
|
||||
github.com/sagernet/cloudflare-tls v0.0.0-20231208171750-a4483c1b7cd1/go.mod h1:J2yAxTFPDjrDPhuAi9aWFz2L3ox9it4qAluBBbN0H5k=
|
||||
github.com/sagernet/cors v1.2.1 h1:Cv5Z8y9YSD6Gm+qSpNrL3LO4lD3eQVvbFYJSG7JCMHQ=
|
||||
github.com/sagernet/cors v1.2.1/go.mod h1:O64VyOjjhrkLmQIjF4KGRrJO/5dVXFdpEmCW/eISRAI=
|
||||
github.com/sagernet/cronet-go v0.0.0-20260309102448-2fef65f9dba9 h1:xq5Yr10jXEppD3cnGjE3WENaB6D0YsZu6KptZ8d3054=
|
||||
github.com/sagernet/cronet-go v0.0.0-20260309102448-2fef65f9dba9/go.mod h1:hwFHBEjjthyEquDULbr4c4ucMedp8Drb6Jvm2kt/0Bw=
|
||||
github.com/sagernet/cronet-go/all v0.0.0-20260309102448-2fef65f9dba9 h1:uxQyy6Y/boOuecVA66tf79JgtoRGfeDJcfYZZLKVA5E=
|
||||
github.com/sagernet/cronet-go/all v0.0.0-20260309102448-2fef65f9dba9/go.mod h1:Xm6cCvs0/twozC1JYNq0sVlOVmcSGzV7YON1XGcD97w=
|
||||
github.com/sagernet/cronet-go/lib/android_386 v0.0.0-20260309101654-0cbdcfddded9 h1:Qi0IKBpoPP3qZqIXuOKMsT2dv+l/MLWMyBHDMLRw2EA=
|
||||
github.com/sagernet/cronet-go/lib/android_386 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:XXDwdjX/T8xftoeJxQmbBoYXZp8MAPFR2CwbFuTpEtw=
|
||||
github.com/sagernet/cronet-go/lib/android_amd64 v0.0.0-20260309101654-0cbdcfddded9 h1:p+wCMjOhj46SpSD/AJeTGgkCcbyA76FyH631XZatyU8=
|
||||
github.com/sagernet/cronet-go/lib/android_amd64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:iNiUGoLtnr8/JTuVNj7XJbmpOAp2C6+B81KDrPxwaZM=
|
||||
github.com/sagernet/cronet-go/lib/android_arm v0.0.0-20260309101654-0cbdcfddded9 h1:Y7lWrZwEhC/HX8Pb5C92CrQihuaE7hrHmWB2ykst3iQ=
|
||||
github.com/sagernet/cronet-go/lib/android_arm v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:19ILNUOGIzRdOqa2mq+iY0JoHxuieB7/lnjYeaA2vEc=
|
||||
github.com/sagernet/cronet-go/lib/android_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:3Ggy5wiyjA6t+aVVPnXlSEIVj9zkxd4ybH3NsvsNefs=
|
||||
github.com/sagernet/cronet-go/lib/android_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:JxzGyQf94Cr6sBShKqODGDyRUlESfJK/Njcz9Lz6qMQ=
|
||||
github.com/sagernet/cronet-go/lib/darwin_amd64 v0.0.0-20260309101654-0cbdcfddded9 h1:DuFTCnZloblY+7olXiZoRdueWfxi34EV5UheTFKM2rA=
|
||||
github.com/sagernet/cronet-go/lib/darwin_amd64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:KN+9T9TBycGOLzmKU4QdcHAJEj6Nlx48ifnlTvvHMvs=
|
||||
github.com/sagernet/cronet-go/lib/darwin_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:x/6T2gjpLw9yNdCVR6xBlzMUzED9fxNFNt6U6A6SOh8=
|
||||
github.com/sagernet/cronet-go/lib/darwin_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:kojvtUc29KKnk8hs2QIANynVR59921SnGWA9kXohHc0=
|
||||
github.com/sagernet/cronet-go/lib/ios_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9 h1:Lx9PExM70rg8aNxPm0JPeSr5SWC3yFiCz4wIq86ugx8=
|
||||
github.com/sagernet/cronet-go/lib/ios_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:hkQzRE5GDbaH1/ioqYh0Taho4L6i0yLRCVEZ5xHz5M0=
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:BTEpw7/vKR9BNBsHebfpiGHDCPpjVJ3vLIbHNU3VUfM=
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:tzVJFTOm66UxLxy6K0ZN5Ic2PC79e+sKKnt+V9puEa4=
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9 h1:hdEph9nQXRnKwc/lIDwo15rmzbC6znXF5jJWHPN1Fiw=
|
||||
github.com/sagernet/cronet-go/lib/ios_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:M/pN6m3j0HFU6/y83n0HU6GLYys3tYdr/xTE8hVEGMo=
|
||||
github.com/sagernet/cronet-go/lib/linux_386 v0.0.0-20260309101654-0cbdcfddded9 h1:Iq++oYV7dtRJHTpu8yclHJdn+1oj2t1e84/YpdXYWW8=
|
||||
github.com/sagernet/cronet-go/lib/linux_386 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:cGh5hO6eljCo6KMQ/Cel8Xgq4+etL0awZLRBDVG1EZQ=
|
||||
github.com/sagernet/cronet-go/lib/linux_386_musl v0.0.0-20260309101654-0cbdcfddded9 h1:Y43fuLL8cgwRHpEKwxh0O3vYp7g/SZGvbkJj3cQ6USA=
|
||||
github.com/sagernet/cronet-go/lib/linux_386_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:JFE0/cxaKkx0wqPMZU7MgaplQlU0zudv82dROJjClKU=
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64 v0.0.0-20260309101654-0cbdcfddded9 h1:bX2GJmF0VCC+tBrVAa49YEsmJ4A9dLmwoA6DJUxRtCY=
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:vU8VftFeSt7fURCa3JXD6+k6ss1YAX+idQjPvHmJ2tI=
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64_musl v0.0.0-20260309101654-0cbdcfddded9 h1:gQTR/2azUCInE0r3kmesZT9xu+x801+BmtDY0d0Tw9Y=
|
||||
github.com/sagernet/cronet-go/lib/linux_amd64_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:vCe4OUuL+XOUge9v3MyTD45BnuAXiH+DkjN9quDXJzQ=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm v0.0.0-20260309101654-0cbdcfddded9 h1:X4mP3jlYvxgrKpZLOKMmc/O8T5/zP83/23pgfQOc3tY=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:w9amBWrvjtohQzBGCKJ7LCh22LhTIJs4sE7cYaKQzM0=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:c6xj2nXr/65EDiRFddUKQIBQ/b/lAPoH8WFYlgadaPc=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:TqlsFtcYS/etTeck46kHBeT8Le0Igw1Q/AV88UnMS3s=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64_musl v0.0.0-20260309101654-0cbdcfddded9 h1:ahbl7yjOvGVVNUwk9TcQk+xejVfoYAYFRlhWnby0/YM=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm64_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:B6Qd0vys8sv9OKVRN6J9RqDzYRGE938Fb2zrYdBDyTQ=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm_musl v0.0.0-20260309101654-0cbdcfddded9 h1:JC5Zv5+J85da6g5G56VhdaK53fmo6Os2q/wWi5QlxOw=
|
||||
github.com/sagernet/cronet-go/lib/linux_arm_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:3tXMMFY7AHugOVBZ5Al7cL7JKsnFOe5bMVr0hZPk3ow=
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64 v0.0.0-20260309101654-0cbdcfddded9 h1:4bt7Go588BoM4VjNYMxx0MrvbwlFQn3DdRDCM7BmkRo=
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:Wt5uFdU3tnmm8YzobYewwdF7Mt6SucRQg6xeTNWC3Tk=
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64_musl v0.0.0-20260309101654-0cbdcfddded9 h1:E1z0BeLUh8EZfCjIyS9BrfCocZrt+0KPS0bzop3Sxf4=
|
||||
github.com/sagernet/cronet-go/lib/linux_loong64_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:lyIF6wKBLwWa5ZXaAKbAoewewl+yCHo2iYev39Mbj4E=
|
||||
github.com/sagernet/cronet-go/lib/linux_mips64le v0.0.0-20260309101654-0cbdcfddded9 h1:d8ejxRHO7Vi9JqR/6DxR7RyI/swA2JfDWATR4T7otBw=
|
||||
github.com/sagernet/cronet-go/lib/linux_mips64le v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:H46PnSTTZNcZokLLiDeMDaHiS1l14PH3tzWi0eykjD8=
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle v0.0.0-20260309101654-0cbdcfddded9 h1:iUDVEVu3RxL5ArPIY72BesbuX5zQ1la/ZFwKpQcGc5c=
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:RBhSUDAKWq7fswtV4nQUQhuaTLcX3ettR7teA7/yf2w=
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle_musl v0.0.0-20260309101654-0cbdcfddded9 h1:xB6ikOC/R3n3hjy68EJ0sbZhH4vwEhd6JM9jZ1U2SVY=
|
||||
github.com/sagernet/cronet-go/lib/linux_mipsle_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:wRzoIOGG4xbpp3Gh3triLKwMwYriScXzFtunLYhY4w0=
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64 v0.0.0-20260309101654-0cbdcfddded9 h1:mBOuLCPOOMMq8N1+dUM5FqZclqga1+u6fAbPqQcbIhc=
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:LNiZXmWil1OPwKCheqQjtakZlJuKGFz+iv2eGF76Hhs=
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64_musl v0.0.0-20260309101654-0cbdcfddded9 h1:cwPyDfj+ZNFE7kvcWbayQJyeC/KQA16HTXOxgHphL0w=
|
||||
github.com/sagernet/cronet-go/lib/linux_riscv64_musl v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:YFDGKTkpkJGc5+hnX/RYosZyTWg9h+68VB55fYRRLYc=
|
||||
github.com/sagernet/cronet-go/lib/tvos_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9 h1:Zk9zG8kt3mXAboclUXQlvvxKQuhnI8u5NdDEl8uotNY=
|
||||
github.com/sagernet/cronet-go/lib/tvos_amd64_simulator v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:aaX0YGl8nhGmfRWI8bc3BtDjY8Vzx6O0cS/e1uqxDq4=
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:Lu05srGqddQRMnl1MZtGAReln2yJljeGx9b1IadlMJ8=
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:EdzMKA96xITc42QEI+ct4SwqX8Dn3ltKK8wzdkLWpSc=
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9 h1:Tk9bDywUmOtc0iMjjCVIwMlAQNsxCy+bK+bTNA0OaBE=
|
||||
github.com/sagernet/cronet-go/lib/tvos_arm64_simulator v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:qix4kv1TTAJ5tY4lJ9vjhe9EY4mM+B7H5giOhbxDVcc=
|
||||
github.com/sagernet/cronet-go/lib/windows_amd64 v0.0.0-20260309101654-0cbdcfddded9 h1:tQqDQw3tEHdQpt7NTdAwF3UvZ3CjNIj/IJKMRFmm388=
|
||||
github.com/sagernet/cronet-go/lib/windows_amd64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:lm9w/oCCRyBiUa3G8lDQTT8x/ONUvgVR2iV9fVzUZB8=
|
||||
github.com/sagernet/cronet-go/lib/windows_arm64 v0.0.0-20260309101654-0cbdcfddded9 h1:biUIbI2YxUrcQikEfS/bwPA8NsHp/WO+VZUG4morUmE=
|
||||
github.com/sagernet/cronet-go/lib/windows_arm64 v0.0.0-20260309101654-0cbdcfddded9/go.mod h1:n34YyLgapgjWdKa0IoeczjAFCwD3/dxbsH5sucKw0bw=
|
||||
github.com/sagernet/fswatch v0.1.1 h1:YqID+93B7VRfqIH3PArW/XpJv5H4OLEVWDfProGoRQs=
|
||||
github.com/sagernet/fswatch v0.1.1/go.mod h1:nz85laH0mkQqJfaOrqPpkwtU1znMFNVTpT/5oRsVz/o=
|
||||
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff h1:mlohw3360Wg1BNGook/UHnISXhUx4Gd/3tVLs5T0nSs=
|
||||
github.com/sagernet/gvisor v0.0.0-20241123041152-536d05261cff/go.mod h1:ehZwnT2UpmOWAHFL48XdBhnd4Qu4hN2O3Ji0us3ZHMw=
|
||||
github.com/sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1 h1:AzCE2RhBjLJ4WIWc/GejpNh+z30d5H1hwaB0nD9eY3o=
|
||||
github.com/sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1/go.mod h1:NJKBtm9nVEK3iyOYWsUlrDQuoGh4zJ4KOPhSYVidvQ4=
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a h1:ObwtHN2VpqE0ZNjr6sGeT00J8uU7JF4cNUdb44/Duis=
|
||||
github.com/sagernet/netlink v0.0.0-20240612041022-b9a21c07ac6a/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM=
|
||||
github.com/sagernet/nftables v0.3.0-beta.4 h1:kbULlAwAC3jvdGAC1P5Fa3GSxVwQJibNenDW2zaXr8I=
|
||||
github.com/sagernet/nftables v0.3.0-beta.4/go.mod h1:OQXAjvjNGGFxaTgVCSTRIhYB5/llyVDeapVoENYBDS8=
|
||||
github.com/sagernet/quic-go v0.48.2-beta.1 h1:W0plrLWa1XtOWDTdX3CJwxmQuxkya12nN5BRGZ87kEg=
|
||||
github.com/sagernet/quic-go v0.48.2-beta.1/go.mod h1:1WgdDIVD1Gybp40JTWketeSfKA/+or9YMLaG5VeTk4k=
|
||||
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byLGkEnIYp6grlXfo1QYUfiYFGjewIdc=
|
||||
github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
|
||||
github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo=
|
||||
github.com/sagernet/sing v0.6.0 h1:jT55zAXrG7H3x+s/FlrC15xQy3LcmuZ2GGA9+8IJdt0=
|
||||
github.com/sagernet/sing v0.6.0/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing-box v1.11.1 h1:bs+LNhD/ikNPEtVGS69myDGkbhPArtzNMjAd8aSWO0M=
|
||||
github.com/sagernet/sing-box v1.11.1/go.mod h1:DmL1WKyrfaAEu5z88CtUeQBfELaEdUyQzLS5nzmRg8o=
|
||||
github.com/sagernet/sing-dns v0.4.0 h1:+mNoOuR3nljjouCH+qMg4zHI1+R9T2ReblGFkZPEndc=
|
||||
github.com/sagernet/sing-dns v0.4.0/go.mod h1:dweQs54ng2YGzoJfz+F9dGuDNdP5pJ3PLeggnK5VWc8=
|
||||
github.com/sagernet/sing-mux v0.3.0-alpha.1 h1:IgNX5bJBpL41gGbp05pdDOvh/b5eUQ6cv9240+Ngipg=
|
||||
github.com/sagernet/sing-mux v0.3.0-alpha.1/go.mod h1:FTcImmdfW38Lz7b+HQ+mxxOth1lz4ao8uEnz+MwIJQE=
|
||||
github.com/sagernet/sing-quic v0.4.0-beta.4 h1:kKiMLGaxvVLDCSvCMYo4PtWd1xU6FTL7xvUAQfXO09g=
|
||||
github.com/sagernet/sing-quic v0.4.0-beta.4/go.mod h1:1UNObFodd8CnS3aCT53x9cigjPSCl3P//8dfBMCwBDM=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE=
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.0 h1:wpZNs6wKnR7mh1wV9OHwOyUr21VkS3wKFHi+8XwgADg=
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.0/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
|
||||
github.com/sagernet/sing-shadowtls v0.2.0-alpha.2 h1:RPrpgAdkP5td0vLfS5ldvYosFjSsZtRPxiyLV6jyKg0=
|
||||
github.com/sagernet/sing-shadowtls v0.2.0-alpha.2/go.mod h1:0j5XlzKxaWRIEjc1uiSKmVoWb0k+L9QgZVb876+thZA=
|
||||
github.com/sagernet/sing-tun v0.6.0-beta.8 h1:GFNt/w8r1v30zC/hfCytk8C9+N/f1DfvosFXJkyJlrw=
|
||||
github.com/sagernet/sing-tun v0.6.0-beta.8/go.mod h1:fisFCbC4Vfb6HqQNcwPJi2CDK2bf0Xapyz3j3t4cnHE=
|
||||
github.com/sagernet/sing-vmess v0.2.0-beta.2 h1:obAkAL35X7ql4RnGzDg4dBYIRpGXRKqcN4LyLZpZGSs=
|
||||
github.com/sagernet/sing-vmess v0.2.0-beta.2/go.mod h1:HGhf9XUdeE2iOWrX0hQNFgXPbKyGlzpeYFyX0c/pykk=
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7 h1:DImB4lELfQhplLTxeq2z31Fpv8CQqqrUwTbrIRumZqQ=
|
||||
github.com/sagernet/smux v0.0.0-20231208180855-7041f6ea79e7/go.mod h1:FP9X2xjT/Az1EsG/orYYoC+5MojWnuI7hrffz8fGwwo=
|
||||
github.com/sagernet/utls v1.6.7 h1:Ep3+aJ8FUGGta+II2IEVNUc3EDhaRCZINWkj/LloIA8=
|
||||
github.com/sagernet/utls v1.6.7/go.mod h1:Uua1TKO/FFuAhLr9rkaVnnrTmmiItzDjv1BUb2+ERwM=
|
||||
github.com/sagernet/wireguard-go v0.0.1-beta.5 h1:aBEsxJUMEONwOZqKPIkuAcv4zJV5p6XlzEN04CF0FXc=
|
||||
github.com/sagernet/wireguard-go v0.0.1-beta.5/go.mod h1:jGXij2Gn2wbrWuYNUmmNhf1dwcZtvyAvQoe8Xd8MbUo=
|
||||
github.com/sagernet/quic-go v0.59.0-sing-box-mod.4 h1:6qvrUW79S+CrPwWz6cMePXohgjHoKxLo3c+MDhNwc3o=
|
||||
github.com/sagernet/quic-go v0.59.0-sing-box-mod.4/go.mod h1:OqILvS182CyOol5zNNo6bguvOGgXzV459+chpRaUC+4=
|
||||
github.com/sagernet/sing v0.8.4 h1:Fj+jlY3F8vhcRfz/G/P3Dwcs5wqnmyNPT7u1RVVmjFI=
|
||||
github.com/sagernet/sing v0.8.4/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak=
|
||||
github.com/sagernet/sing-box v1.13.4 h1:XfDZ4lvIFUuKS4SJDa2LjWnLxYwJfy5OF4jgI8lWUi4=
|
||||
github.com/sagernet/sing-box v1.13.4/go.mod h1:ZlRKCQgJCu9ht00xse/BtsLPWYy+901l5clVvKEfJ+Y=
|
||||
github.com/sagernet/sing-mux v0.3.4 h1:ZQplKl8MNXutjzbMVtWvWG31fohhgOfCuUZR4dVQ8+s=
|
||||
github.com/sagernet/sing-mux v0.3.4/go.mod h1:QvlKMyNBNrQoyX4x+gq028uPbLM2XeRpWtDsWBJbFSk=
|
||||
github.com/sagernet/sing-quic v0.6.0 h1:dhrFnP45wgVKEOT1EvtsToxdzRnHIDIAgj6WHV9pLyM=
|
||||
github.com/sagernet/sing-quic v0.6.0/go.mod h1:K5bWvITOm4vE10fwLfrWpw27bCoVJ+tfQ79tOWg+Ko8=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8 h1:PURj5PRoAkqeHh2ZW205RWzN9E9RtKCVCzByXruQWfE=
|
||||
github.com/sagernet/sing-shadowsocks v0.2.8/go.mod h1:lo7TWEMDcN5/h5B8S0ew+r78ZODn6SwVaFhvB6H+PTI=
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.1 h1:dWV9OXCeFPuYGHb6IRqlSptVnSzOelnqqs2gQ2/Qioo=
|
||||
github.com/sagernet/sing-shadowsocks2 v0.2.1/go.mod h1:RnXS0lExcDAovvDeniJ4IKa2IuChrdipolPYWBv9hWQ=
|
||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11 h1:tK+75l64tm9WvEFrYRE1t0YxoFdWQqw/h7Uhzj0vJ+w=
|
||||
github.com/sagernet/sing-shadowtls v0.2.1-0.20250503051639-fcd445d33c11/go.mod h1:sWqKnGlMipCHaGsw1sTTlimyUpgzP4WP3pjhCsYt9oA=
|
||||
github.com/sagernet/sing-tun v0.8.6 h1:NydXFikSXhiKqhahHKtuZ90HQPZFzlOFVRONmkr4C7I=
|
||||
github.com/sagernet/sing-tun v0.8.6/go.mod h1:pLCo4o+LacXEzz0bhwhJkKBjLlKOGPBNOAZ97ZVZWzs=
|
||||
github.com/sagernet/sing-vmess v0.2.8-0.20250909125414-3aed155119a1 h1:aSwUNYUkVyVvdmBSufR8/nRFonwJeKSIROxHcm5br9o=
|
||||
github.com/sagernet/sing-vmess v0.2.8-0.20250909125414-3aed155119a1/go.mod h1:P11scgTxMxVVQ8dlM27yNm3Cro40mD0+gHbnqrNGDuY=
|
||||
github.com/sagernet/smux v1.5.50-sing-box-mod.1 h1:XkJcivBC9V4wBjiGXIXZ229aZCU1hzcbp6kSkkyQ478=
|
||||
github.com/sagernet/smux v1.5.50-sing-box-mod.1/go.mod h1:NjhsCEWedJm7eFLyhuBgIEzwfhRmytrUoiLluxs5Sk8=
|
||||
github.com/sagernet/tailscale v1.92.4-sing-box-1.13-mod.7 h1:8zc1Aph1+ElqF9/7aSPkO0o4vTd+AfQC+CO324mLWGg=
|
||||
github.com/sagernet/tailscale v1.92.4-sing-box-1.13-mod.7/go.mod h1:m87GAn4UcesHQF3leaPFEINZETO5za1LGn1GJdNDgNc=
|
||||
github.com/sagernet/wireguard-go v0.0.2-beta.1.0.20260224074747-506b7631853c h1:f9cXNB+IOOPnR8DOLMTpr42jf7naxh5Un5Y09BBf5Cg=
|
||||
github.com/sagernet/wireguard-go v0.0.2-beta.1.0.20260224074747-506b7631853c/go.mod h1:WUxgxUDZoCF2sxVmW+STSxatP02Qn3FcafTiI2BLtE0=
|
||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854 h1:6uUiZcDRnZSAegryaUGwPC/Fj13JSHwiTftrXhMmYOc=
|
||||
github.com/sagernet/ws v0.0.0-20231204124109-acfe8907c854/go.mod h1:LtfoSK3+NG57tvnVEHgcuBW9ujgE8enPSgzgwStwCAA=
|
||||
github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs=
|
||||
github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI=
|
||||
github.com/shirou/gopsutil/v4 v4.26.2 h1:X8i6sicvUFih4BmYIGT1m2wwgw2VG9YgrDTi7cIRGUI=
|
||||
github.com/shirou/gopsutil/v4 v4.26.2/go.mod h1:LZ6ewCSkBqUpvSOf+LsTGnRinC6iaNUNMGBtDkJBaLQ=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
|
||||
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
|
||||
github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo=
|
||||
github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e h1:PtWT87weP5LWHEY//SWsYkSO3RWRZo4OSWagh3YD2vQ=
|
||||
github.com/tailscale/certstore v0.1.1-0.20231202035212-d3fa0460f47e/go.mod h1:XrBNfAFN+pwoWuksbFS9Ccxnopa15zJGgXRFN90l3K4=
|
||||
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55 h1:Gzfnfk2TWrk8Jj4P4c1a3CtQyMaTVCznlkLZI++hok4=
|
||||
github.com/tailscale/go-winio v0.0.0-20231025203758-c4f33415bf55/go.mod h1:4k4QO+dQ3R5FofL+SanAUZe+/QfeK0+OIuwDIRu2vSg=
|
||||
github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05 h1:4chzWmimtJPxRs2O36yuGRW3f9SYV+bMTTvMBI0EKio=
|
||||
github.com/tailscale/goupnp v1.0.1-0.20210804011211-c64d0f06ea05/go.mod h1:PdCqy9JzfWMJf1H5UJW2ip33/d4YkoKN0r67yKH1mG8=
|
||||
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a h1:SJy1Pu0eH1C29XwJucQo73FrleVK6t4kYz4NVhp34Yw=
|
||||
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8=
|
||||
github.com/tailscale/netlink v1.1.1-0.20240822203006-4d49adab4de7 h1:uFsXVBE9Qr4ZoF094vE6iYTLDl0qCiKzYXlL6UeWObU=
|
||||
github.com/tailscale/netlink v1.1.1-0.20240822203006-4d49adab4de7/go.mod h1:NzVQi3Mleb+qzq8VmcWpSkcSYxXIg0DkI6XDzpVkhJ0=
|
||||
github.com/tailscale/peercred v0.0.0-20250107143737-35a0c7bd7edc h1:24heQPtnFR+yfntqhI3oAu9i27nEojcQ4NuBQOo5ZFA=
|
||||
github.com/tailscale/peercred v0.0.0-20250107143737-35a0c7bd7edc/go.mod h1:f93CXfllFsO9ZQVq+Zocb1Gp4G5Fz0b0rXHLOzt/Djc=
|
||||
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 h1:UBPHPtv8+nEAy2PD8RyAhOYvau1ek0HDJqLS/Pysi14=
|
||||
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976/go.mod h1:agQPE6y6ldqCOui2gkIh7ZMztTkIQKH049tv8siLuNQ=
|
||||
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=
|
||||
github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA=
|
||||
github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI=
|
||||
github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw=
|
||||
github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
|
||||
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 h1:pyC9PaHYZFgEKFdlp3G8RaCKgVpHZnecvArXvPXcFkM=
|
||||
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701/go.mod h1:P3a5rG4X7tI17Nn3aOIAYr5HbIMukwXG0urG0WuL8OA=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
|
||||
github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/zeebo/assert v1.1.0 h1:hU1L1vLTHsnO8x8c9KAR5GmM5QscxHg5RNU5z5qbUWY=
|
||||
github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
|
||||
github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg=
|
||||
github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ=
|
||||
github.com/zeebo/blake3 v0.2.4 h1:KYQPkhpRtcqh0ssGYcKLG1JYvddkEA8QwCM/yBqhaZI=
|
||||
github.com/zeebo/blake3 v0.2.4/go.mod h1:7eeQ6d2iXWRGF6npfaxl2CU+xy2Fjo2gxeyZGCRUjcE=
|
||||
github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo=
|
||||
github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48=
|
||||
go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8=
|
||||
go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0=
|
||||
go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs=
|
||||
go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18=
|
||||
go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew=
|
||||
go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI=
|
||||
go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
|
||||
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.uber.org/zap/exp v0.3.0 h1:6JYzdifzYkGmTdRR59oYH+Ng7k49H9qVpWwNSsGJj3U=
|
||||
go.uber.org/zap/exp v0.3.0/go.mod h1:5I384qq7XGxYyByIhHm6jg5CHkGY0nsTfbDLgDDlgJQ=
|
||||
go4.org/mem v0.0.0-20240501181205-ae6ca9944745 h1:Tl++JLUCe4sxGu8cTpDzRLd3tN7US4hOxG5YpKCzkek=
|
||||
go4.org/mem v0.0.0-20240501181205-ae6ca9944745/go.mod h1:reUoABIJ9ikfM5sgtSF3Wushcza7+WeD01VB9Lirh3g=
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M=
|
||||
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
||||
golang.org/x/arch v0.13.0 h1:KCkqVVV1kGg0X87TFysjCJ8MxtZEIU4Ja/yXGeoECdA=
|
||||
golang.org/x/arch v0.13.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
|
||||
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/crypto v0.48.0 h1:/VRzVqiRSggnhY7gNRxPauEQ5Drw9haKdM0jqfcCFts=
|
||||
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
|
||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
|
||||
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
|
||||
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
|
||||
golang.org/x/image v0.27.0/go.mod h1:xbdrClrAUway1MUTEZDq9mz/UpRwYAkFFNUslZtcB+g=
|
||||
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
|
||||
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo=
|
||||
golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y=
|
||||
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
|
||||
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4=
|
||||
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
|
||||
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
|
||||
golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
|
||||
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
|
||||
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
|
||||
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
|
||||
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
||||
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||
golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k=
|
||||
golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0=
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg=
|
||||
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
|
||||
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
|
||||
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10 h1:3GDAcqdIg1ozBNLgPy4SLT84nfcBjr6rhGtXYtrkWLU=
|
||||
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20241231184526-a9ab2273dd10/go.mod h1:T97yPqesLiNrOYxkwmhMI0ZIlJDm+p0PMR8eRVeR5tQ=
|
||||
golang.zx2c4.com/wireguard/windows v0.5.3 h1:On6j2Rpn3OEMXqBq00QEDC7bWSZrPIHKIus8eIuExIE=
|
||||
golang.zx2c4.com/wireguard/windows v0.5.3/go.mod h1:9TEe8TJmtwyQebdFwAkEWOPr3prrtqm+REGFifP60hI=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 h1:gRkg/vSppuSQoDjxyiGfN4Upv/h/DQmIR10ZU8dh4Ww=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
|
||||
google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=
|
||||
google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
|
||||
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
|
||||
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
|
||||
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
|
||||
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||
lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg=
|
||||
lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo=
|
||||
software.sslmate.com/src/go-pkcs12 v0.4.0 h1:H2g08FrTvSFKUj+D309j1DPfk5APnIdAQAB8aEykJ5k=
|
||||
software.sslmate.com/src/go-pkcs12 v0.4.0/go.mod h1:Qiz0EyvDRJjjxGyUQa2cCNZn/wMyzrRJ/qcDXOQazLI=
|
||||
|
||||
+1
-61
@@ -38,66 +38,6 @@ arch() {
|
||||
|
||||
echo "arch: $(arch)"
|
||||
|
||||
os_version=""
|
||||
os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
|
||||
|
||||
if [[ "${release}" == "arch" ]]; then
|
||||
echo "Your OS is Arch Linux"
|
||||
elif [[ "${release}" == "parch" ]]; then
|
||||
echo "Your OS is Parch linux"
|
||||
elif [[ "${release}" == "manjaro" ]]; then
|
||||
echo "Your OS is Manjaro"
|
||||
elif [[ "${release}" == "armbian" ]]; then
|
||||
echo "Your OS is Armbian"
|
||||
elif [[ "${release}" == "opensuse-tumbleweed" ]]; then
|
||||
echo "Your OS is OpenSUSE Tumbleweed"
|
||||
elif [[ "${release}" == "centos" ]]; then
|
||||
if [[ ${os_version} -lt 8 ]]; then
|
||||
echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "ubuntu" ]]; then
|
||||
if [[ ${os_version} -lt 20 ]]; then
|
||||
echo -e "${red} Please use Ubuntu 20 or higher version!${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "fedora" ]]; then
|
||||
if [[ ${os_version} -lt 36 ]]; then
|
||||
echo -e "${red} Please use Fedora 36 or higher version!${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "debian" ]]; then
|
||||
if [[ ${os_version} -lt 11 ]]; then
|
||||
echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "almalinux" ]]; then
|
||||
if [[ ${os_version} -lt 9 ]]; then
|
||||
echo -e "${red} Please use AlmaLinux 9 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "rocky" ]]; then
|
||||
if [[ ${os_version} -lt 9 ]]; then
|
||||
echo -e "${red} Please use Rocky Linux 9 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "oracle" ]]; then
|
||||
if [[ ${os_version} -lt 8 ]]; then
|
||||
echo -e "${red} Please use Oracle Linux 8 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${red}Your operating system is not supported by this script.${plain}\n"
|
||||
echo "Please ensure you are using one of the following supported operating systems:"
|
||||
echo "- Ubuntu 20.04+"
|
||||
echo "- Debian 11+"
|
||||
echo "- CentOS 8+"
|
||||
echo "- Fedora 36+"
|
||||
echo "- Arch Linux"
|
||||
echo "- Parch Linux"
|
||||
echo "- Manjaro"
|
||||
echo "- Armbian"
|
||||
echo "- AlmaLinux 9+"
|
||||
echo "- Rocky Linux 9+"
|
||||
echo "- Oracle Linux 8+"
|
||||
echo "- OpenSUSE Tumbleweed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
install_base() {
|
||||
case "${release}" in
|
||||
centos | almalinux | rocky | oracle)
|
||||
@@ -245,4 +185,4 @@ install_s-ui() {
|
||||
|
||||
echo -e "${green}Executing...${plain}"
|
||||
install_base
|
||||
install_s-ui $1
|
||||
install_s-ui $1
|
||||
|
||||
+17
-6
@@ -23,15 +23,26 @@ func InitLogger(level logging.Level) {
|
||||
var backend logging.Backend
|
||||
var format logging.Formatter
|
||||
|
||||
backend, err = logging.NewSyslogBackend("")
|
||||
if err != nil {
|
||||
fmt.Println("Unable to use syslog: " + err.Error())
|
||||
backend = logging.NewLogBackend(os.Stderr, "", 0)
|
||||
_, inContainer := os.LookupEnv("container")
|
||||
if !inContainer {
|
||||
if _, statErr := os.Stat("/.dockerenv"); statErr == nil {
|
||||
inContainer = true
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if inContainer {
|
||||
backend = logging.NewLogBackend(os.Stderr, "", 0)
|
||||
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
|
||||
} else {
|
||||
format = logging.MustStringFormatter(`%{level} - %{message}`)
|
||||
backend, err = logging.NewSyslogBackend("")
|
||||
if err != nil {
|
||||
fmt.Println("Unable to use syslog: " + err.Error())
|
||||
backend = logging.NewLogBackend(os.Stderr, "", 0)
|
||||
}
|
||||
if err != nil {
|
||||
format = logging.MustStringFormatter(`%{time:2006/01/02 15:04:05} %{level} - %{message}`)
|
||||
} else {
|
||||
format = logging.MustStringFormatter(`%{level} - %{message}`)
|
||||
}
|
||||
}
|
||||
|
||||
backendFormatter := logging.NewBackendFormatter(backend, format)
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"s-ui/app"
|
||||
"s-ui/cmd"
|
||||
"syscall"
|
||||
|
||||
"github.com/alireza0/s-ui/app"
|
||||
"github.com/alireza0/s-ui/cmd"
|
||||
)
|
||||
|
||||
func runApp() {
|
||||
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "s-ui",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
red='\033[0;31m'
|
||||
@@ -6,7 +5,6 @@ green='\033[0;32m'
|
||||
yellow='\033[0;33m'
|
||||
plain='\033[0m'
|
||||
|
||||
#Add some basic function here
|
||||
function LOGD() {
|
||||
echo -e "${yellow}[DEG] $* ${plain}"
|
||||
}
|
||||
@@ -18,10 +16,9 @@ function LOGE() {
|
||||
function LOGI() {
|
||||
echo -e "${green}[INF] $* ${plain}"
|
||||
}
|
||||
# check root
|
||||
|
||||
[[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1
|
||||
|
||||
# Check OS and set release variable
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
source /etc/os-release
|
||||
release=$ID
|
||||
@@ -35,67 +32,6 @@ fi
|
||||
|
||||
echo "The OS release is: $release"
|
||||
|
||||
|
||||
os_version=""
|
||||
os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
|
||||
|
||||
if [[ "${release}" == "arch" ]]; then
|
||||
echo "Your OS is Arch Linux"
|
||||
elif [[ "${release}" == "parch" ]]; then
|
||||
echo "Your OS is Parch linux"
|
||||
elif [[ "${release}" == "manjaro" ]]; then
|
||||
echo "Your OS is Manjaro"
|
||||
elif [[ "${release}" == "armbian" ]]; then
|
||||
echo "Your OS is Armbian"
|
||||
elif [[ "${release}" == "opensuse-tumbleweed" ]]; then
|
||||
echo "Your OS is OpenSUSE Tumbleweed"
|
||||
elif [[ "${release}" == "centos" ]]; then
|
||||
if [[ ${os_version} -lt 8 ]]; then
|
||||
echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "ubuntu" ]]; then
|
||||
if [[ ${os_version} -lt 20 ]]; then
|
||||
echo -e "${red} Please use Ubuntu 20 or higher version!${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "fedora" ]]; then
|
||||
if [[ ${os_version} -lt 36 ]]; then
|
||||
echo -e "${red} Please use Fedora 36 or higher version!${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "debian" ]]; then
|
||||
if [[ ${os_version} -lt 11 ]]; then
|
||||
echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "almalinux" ]]; then
|
||||
if [[ ${os_version} -lt 9 ]]; then
|
||||
echo -e "${red} Please use AlmaLinux 9 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "rocky" ]]; then
|
||||
if [[ ${os_version} -lt 9 ]]; then
|
||||
echo -e "${red} Please use Rocky Linux 9 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
elif [[ "${release}" == "oracle" ]]; then
|
||||
if [[ ${os_version} -lt 8 ]]; then
|
||||
echo -e "${red} Please use Oracle Linux 8 or higher ${plain}\n" && exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${red}Your operating system is not supported by this script.${plain}\n"
|
||||
echo "Please ensure you are using one of the following supported operating systems:"
|
||||
echo "- Ubuntu 20.04+"
|
||||
echo "- Debian 11+"
|
||||
echo "- CentOS 8+"
|
||||
echo "- Fedora 36+"
|
||||
echo "- Arch Linux"
|
||||
echo "- Parch Linux"
|
||||
echo "- Manjaro"
|
||||
echo "- Armbian"
|
||||
echo "- AlmaLinux 9+"
|
||||
echo "- Rocky Linux 9+"
|
||||
echo "- Oracle Linux 8+"
|
||||
echo "- OpenSUSE Tumbleweed"
|
||||
exit 1
|
||||
|
||||
fi
|
||||
|
||||
confirm() {
|
||||
if [[ $# > 1 ]]; then
|
||||
echo && read -p "$1 [Default$2]: " temp
|
||||
@@ -164,7 +100,6 @@ custom_version() {
|
||||
|
||||
download_link="https://raw.githubusercontent.com/alireza0/s-ui/master/install.sh"
|
||||
|
||||
# Use the entered panel version in the download link
|
||||
install_command="bash <(curl -Ls $download_link) $panel_version"
|
||||
|
||||
echo "Downloading and installing panel version $panel_version..."
|
||||
@@ -232,13 +167,11 @@ set_setting() {
|
||||
echo -e "Enter the ${yellow}panel path${plain} (leave blank for existing/default value):"
|
||||
read config_path
|
||||
|
||||
# Sub configuration
|
||||
echo -e "Enter the ${yellow}subscription port${plain} (leave blank for existing/default value):"
|
||||
read config_subPort
|
||||
echo -e "Enter the ${yellow}subscription path${plain} (leave blank for existing/default value):"
|
||||
read config_subPath
|
||||
|
||||
# Set configs
|
||||
echo -e "${yellow}Initializing, please wait...${plain}"
|
||||
params=""
|
||||
[ -z "$config_port" ] || params="$params -port $config_port"
|
||||
@@ -373,7 +306,6 @@ update_shell() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 0: running, 1: not running, 2: not installed
|
||||
check_status() {
|
||||
if [[ ! -f "/etc/systemd/system/$1.service" ]]; then
|
||||
return 2
|
||||
@@ -487,20 +419,13 @@ bbr_menu() {
|
||||
}
|
||||
|
||||
disable_bbr() {
|
||||
|
||||
if ! grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf || ! grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then
|
||||
echo -e "${yellow}BBR is not currently enabled.${plain}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Replace BBR with CUBIC configurations
|
||||
sed -i 's/net.core.default_qdisc=fq/net.core.default_qdisc=pfifo_fast/' /etc/sysctl.conf
|
||||
sed -i 's/net.ipv4.tcp_congestion_control=bbr/net.ipv4.tcp_congestion_control=cubic/' /etc/sysctl.conf
|
||||
|
||||
# Apply changes
|
||||
sysctl -p
|
||||
|
||||
# Verify that BBR is replaced with CUBIC
|
||||
if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "cubic" ]]; then
|
||||
echo -e "${green}BBR has been replaced with CUBIC successfully.${plain}"
|
||||
else
|
||||
@@ -513,8 +438,6 @@ enable_bbr() {
|
||||
echo -e "${green}BBR is already enabled!${plain}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check the OS and install necessary packages
|
||||
case "${release}" in
|
||||
ubuntu | debian | armbian)
|
||||
apt-get update && apt-get install -yqq --no-install-recommends ca-certificates
|
||||
@@ -533,15 +456,9 @@ enable_bbr() {
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Enable BBR
|
||||
echo "net.core.default_qdisc=fq" | tee -a /etc/sysctl.conf
|
||||
echo "net.ipv4.tcp_congestion_control=bbr" | tee -a /etc/sysctl.conf
|
||||
|
||||
# Apply changes
|
||||
sysctl -p
|
||||
|
||||
# Verify that BBR is enabled
|
||||
if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "bbr" ]]; then
|
||||
echo -e "${green}BBR has been enabled successfully.${plain}"
|
||||
else
|
||||
@@ -566,6 +483,7 @@ ssl_cert_issue_main() {
|
||||
echo -e "${green}\t1.${plain} Get SSL"
|
||||
echo -e "${green}\t2.${plain} Revoke"
|
||||
echo -e "${green}\t3.${plain} Force Renew"
|
||||
echo -e "${green}\t4.${plain} Self-signed Certificate"
|
||||
read -p "Choose an option: " choice
|
||||
case "$choice" in
|
||||
1) ssl_cert_issue ;;
|
||||
@@ -579,12 +497,14 @@ ssl_cert_issue_main() {
|
||||
local domain=""
|
||||
read -p "Please enter your domain name to forcefully renew an SSL certificate: " domain
|
||||
~/.acme.sh/acme.sh --renew -d ${domain} --force ;;
|
||||
4)
|
||||
generate_self_signed_cert
|
||||
;;
|
||||
*) echo "Invalid choice" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
ssl_cert_issue() {
|
||||
# check for acme.sh first
|
||||
if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
|
||||
echo "acme.sh could not be found. we will install it"
|
||||
install_acme
|
||||
@@ -593,7 +513,6 @@ ssl_cert_issue() {
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# install socat second
|
||||
case "${release}" in
|
||||
ubuntu | debian | armbian)
|
||||
apt update && apt install socat -y
|
||||
@@ -619,11 +538,9 @@ ssl_cert_issue() {
|
||||
LOGI "install socat succeed..."
|
||||
fi
|
||||
|
||||
# get the domain here,and we need verify it
|
||||
local domain=""
|
||||
read -p "Please enter your domain name:" domain
|
||||
LOGD "your domain is:${domain},check it..."
|
||||
# here we need to judge whether there exists cert already
|
||||
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
|
||||
|
||||
if [ ${currentCert} == ${domain} ]; then
|
||||
@@ -635,7 +552,6 @@ ssl_cert_issue() {
|
||||
LOGI "your domain is ready for issuing cert now..."
|
||||
fi
|
||||
|
||||
# create a directory for install cert
|
||||
certPath="/root/cert/${domain}"
|
||||
if [ ! -d "$certPath" ]; then
|
||||
mkdir -p "$certPath"
|
||||
@@ -644,15 +560,12 @@ ssl_cert_issue() {
|
||||
mkdir -p "$certPath"
|
||||
fi
|
||||
|
||||
# get needed port here
|
||||
local WebPort=80
|
||||
read -p "please choose which port do you use,default will be 80 port:" WebPort
|
||||
if [[ ${WebPort} -gt 65535 || ${WebPort} -lt 1 ]]; then
|
||||
LOGE "your input ${WebPort} is invalid,will use default port"
|
||||
fi
|
||||
LOGI "will use port:${WebPort} to issue certs,please make sure this port is open..."
|
||||
# NOTE:This should be handled by user
|
||||
# open the port and kill the occupied progress
|
||||
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
|
||||
~/.acme.sh/acme.sh --issue -d ${domain} --standalone --httpport ${WebPort}
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -662,7 +575,6 @@ ssl_cert_issue() {
|
||||
else
|
||||
LOGE "issue certs succeed,installing certs..."
|
||||
fi
|
||||
# install cert
|
||||
~/.acme.sh/acme.sh --installcert -d ${domain} \
|
||||
--key-file /root/cert/${domain}/privkey.pem \
|
||||
--fullchain-file /root/cert/${domain}/fullchain.pem
|
||||
@@ -691,78 +603,172 @@ ssl_cert_issue() {
|
||||
ssl_cert_issue_CF() {
|
||||
echo -E ""
|
||||
LOGD "******Instructions for use******"
|
||||
LOGI "This Acme script requires the following data:"
|
||||
LOGI "1.Cloudflare Registered e-mail"
|
||||
LOGI "2.Cloudflare Global API Key"
|
||||
LOGI "3.The domain name that has been resolved dns to the current server by Cloudflare"
|
||||
LOGI "4.The script applies for a certificate. The default installation path is /root/cert "
|
||||
confirm "Confirmed?[y/n]" "y"
|
||||
if [ $? -eq 0 ]; then
|
||||
# check for acme.sh first
|
||||
if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
|
||||
echo "acme.sh could not be found. we will install it"
|
||||
install_acme
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "install acme failed, please check logs"
|
||||
exit 1
|
||||
echo "1) New certificate from Cloudflare"
|
||||
echo "2) Force renew existing Certificates"
|
||||
echo "3) Back to Menu"
|
||||
read -p "Enter your choice [1-3]: " choice
|
||||
|
||||
certPath="/root/cert-CF"
|
||||
|
||||
case $choice in
|
||||
1|2)
|
||||
force_flag=""
|
||||
if [ "$choice" -eq 2 ]; then
|
||||
force_flag="--force"
|
||||
echo "Forcing SSL certificate reissuance..."
|
||||
else
|
||||
echo "Starting SSL certificate issuance..."
|
||||
fi
|
||||
fi
|
||||
CF_Domain=""
|
||||
CF_GlobalKey=""
|
||||
CF_AccountEmail=""
|
||||
certPath=/root/cert
|
||||
if [ ! -d "$certPath" ]; then
|
||||
mkdir $certPath
|
||||
else
|
||||
rm -rf $certPath
|
||||
mkdir $certPath
|
||||
fi
|
||||
LOGD "Please set a domain name:"
|
||||
read -p "Input your domain here:" CF_Domain
|
||||
LOGD "Your domain name is set to:${CF_Domain}"
|
||||
LOGD "Please set the API key:"
|
||||
read -p "Input your key here:" CF_GlobalKey
|
||||
LOGD "Your API key is:${CF_GlobalKey}"
|
||||
LOGD "Please set up registered email:"
|
||||
read -p "Input your email here:" CF_AccountEmail
|
||||
LOGD "Your registered email address is:${CF_AccountEmail}"
|
||||
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Default CA, Lets'Encrypt fail, script exiting..."
|
||||
exit 1
|
||||
fi
|
||||
export CF_Key="${CF_GlobalKey}"
|
||||
export CF_Email=${CF_AccountEmail}
|
||||
~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Certificate issuance failed, script exiting..."
|
||||
exit 1
|
||||
else
|
||||
LOGI "Certificate issued Successfully, Installing..."
|
||||
fi
|
||||
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
|
||||
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
|
||||
--fullchain-file /root/cert/fullchain.cer
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Certificate installation failed, script exiting..."
|
||||
exit 1
|
||||
else
|
||||
LOGI "Certificate installed Successfully,Turning on automatic updates..."
|
||||
fi
|
||||
~/.acme.sh/acme.sh --upgrade --auto-upgrade
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Auto update setup Failed, script exiting..."
|
||||
ls -lah cert
|
||||
chmod 755 $certPath
|
||||
exit 1
|
||||
else
|
||||
LOGI "The certificate is installed and auto-renewal is turned on, Specific information is as follows"
|
||||
ls -lah cert
|
||||
chmod 755 $certPath
|
||||
fi
|
||||
|
||||
LOGD "******Instructions for use******"
|
||||
LOGI "This Acme script requires the following data:"
|
||||
LOGI "1.Cloudflare Registered e-mail"
|
||||
LOGI "2.Cloudflare Global API Key"
|
||||
LOGI "3.The domain name that has been resolved DNS to the current server by Cloudflare"
|
||||
LOGI "4.The script applies for a certificate. The default installation path is /root/cert "
|
||||
confirm "Confirmed?[y/n]" "y"
|
||||
if [ $? -eq 0 ]; then
|
||||
if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then
|
||||
echo "acme.sh could not be found. Installing..."
|
||||
install_acme
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Install acme failed, please check logs"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
CF_Domain=""
|
||||
if [ ! -d "$certPath" ]; then
|
||||
mkdir -p $certPath
|
||||
else
|
||||
rm -rf $certPath
|
||||
mkdir -p $certPath
|
||||
fi
|
||||
|
||||
LOGD "Please set a domain name:"
|
||||
read -p "Input your domain here: " CF_Domain
|
||||
LOGD "Your domain name is set to: ${CF_Domain}"
|
||||
|
||||
CF_GlobalKey=""
|
||||
CF_AccountEmail=""
|
||||
LOGD "Please set the API key:"
|
||||
read -p "Input your key here: " CF_GlobalKey
|
||||
LOGD "Your API key is: ${CF_GlobalKey}"
|
||||
|
||||
LOGD "Please set up registered email:"
|
||||
read -p "Input your email here: " CF_AccountEmail
|
||||
LOGD "Your registered email address is: ${CF_AccountEmail}"
|
||||
|
||||
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Default CA, Let's Encrypt failed, script exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export CF_Key="${CF_GlobalKey}"
|
||||
export CF_Email="${CF_AccountEmail}"
|
||||
|
||||
~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} $force_flag --log
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Certificate issuance failed, script exiting..."
|
||||
exit 1
|
||||
else
|
||||
LOGI "Certificate issued Successfully, Installing..."
|
||||
fi
|
||||
|
||||
mkdir -p ${certPath}/${CF_Domain}
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Failed to create directory: ${certPath}/${CF_Domain}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} \
|
||||
--fullchain-file ${certPath}/${CF_Domain}/fullchain.pem \
|
||||
--key-file ${certPath}/${CF_Domain}/privkey.pem
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Certificate installation failed, script exiting..."
|
||||
exit 1
|
||||
else
|
||||
LOGI "Certificate installed Successfully, Turning on automatic updates..."
|
||||
fi
|
||||
|
||||
~/.acme.sh/acme.sh --upgrade --auto-upgrade
|
||||
if [ $? -ne 0 ]; then
|
||||
LOGE "Auto update setup failed, script exiting..."
|
||||
exit 1
|
||||
else
|
||||
LOGI "The certificate is installed and auto-renewal is turned on."
|
||||
ls -lah ${certPath}/${CF_Domain}
|
||||
chmod 755 ${certPath}/${CF_Domain}
|
||||
fi
|
||||
fi
|
||||
show_menu
|
||||
;;
|
||||
3)
|
||||
echo "Exiting..."
|
||||
show_menu
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice, please select again."
|
||||
show_menu
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
generate_self_signed_cert() {
|
||||
cert_dir="/etc/sing-box"
|
||||
mkdir -p "$cert_dir"
|
||||
LOGI "Choose certificate type:"
|
||||
echo -e "${green}\t1.${plain} Ed25519 (*recommended*)"
|
||||
echo -e "${green}\t2.${plain} RSA 2048"
|
||||
echo -e "${green}\t3.${plain} RSA 4096"
|
||||
echo -e "${green}\t4.${plain} ECDSA prime256v1"
|
||||
echo -e "${green}\t5.${plain} ECDSA secp384r1"
|
||||
read -p "Enter your choice [1-5, default 1]: " cert_type
|
||||
cert_type=${cert_type:-1}
|
||||
|
||||
case "$cert_type" in
|
||||
1)
|
||||
algo="ed25519"
|
||||
key_opt="-newkey ed25519"
|
||||
;;
|
||||
2)
|
||||
algo="rsa"
|
||||
key_opt="-newkey rsa:2048"
|
||||
;;
|
||||
3)
|
||||
algo="rsa"
|
||||
key_opt="-newkey rsa:4096"
|
||||
;;
|
||||
4)
|
||||
algo="ecdsa"
|
||||
key_opt="-newkey ec -pkeyopt ec_paramgen_curve:prime256v1"
|
||||
;;
|
||||
5)
|
||||
algo="ecdsa"
|
||||
key_opt="-newkey ec -pkeyopt ec_paramgen_curve:secp384r1"
|
||||
;;
|
||||
*)
|
||||
algo="ed25519"
|
||||
key_opt="-newkey ed25519"
|
||||
;;
|
||||
esac
|
||||
|
||||
LOGI "Generating self-signed certificate ($algo)..."
|
||||
sudo openssl req -x509 -nodes -days 3650 $key_opt \
|
||||
-keyout "${cert_dir}/self.key" \
|
||||
-out "${cert_dir}/self.crt" \
|
||||
-subj "/CN=myserver"
|
||||
if [[ $? -eq 0 ]]; then
|
||||
sudo chmod 600 "${cert_dir}/self."*
|
||||
LOGI "Self-signed certificate generated successfully!"
|
||||
LOGI "Certificate path: ${cert_dir}/self.crt"
|
||||
LOGI "Key path: ${cert_dir}/self.key"
|
||||
else
|
||||
show_menu
|
||||
LOGE "Failed to generate self-signed certificate."
|
||||
fi
|
||||
before_show_menu
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
@@ -925,4 +931,4 @@ if [[ $# > 0 ]]; then
|
||||
esac
|
||||
else
|
||||
show_menu
|
||||
fi
|
||||
fi
|
||||
|
||||
+235
-58
@@ -1,21 +1,21 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util"
|
||||
"s-ui/util/common"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ClientService struct {
|
||||
InboundService
|
||||
}
|
||||
type ClientService struct{}
|
||||
|
||||
func (s *ClientService) Get(id string) (*[]model.Client, error) {
|
||||
if id == "" {
|
||||
@@ -38,7 +38,9 @@ func (s *ClientService) getById(id string) (*[]model.Client, error) {
|
||||
func (s *ClientService) GetAll() (*[]model.Client, error) {
|
||||
db := database.GetDB()
|
||||
var clients []model.Client
|
||||
err := db.Model(model.Client{}).Select("`id`, `enable`, `name`, `desc`, `group`, `inbounds`, `up`, `down`, `volume`, `expiry`").Scan(&clients).Error
|
||||
err := db.Model(model.Client{}).
|
||||
Select("`id`, `enable`, `name`, `desc`, `group`, `inbounds`, `up`, `down`, `volume`, `expiry`").
|
||||
Scan(&clients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -56,13 +58,21 @@ func (s *ClientService) Save(tx *gorm.DB, act string, data json.RawMessage, host
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(client.Inbounds, &inboundIds)
|
||||
err = s.updateLinksWithFixedInbounds(tx, []*model.Client{&client}, hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.updateLinksWithFixedInbounds(tx, []*model.Client{&client}, inboundIds, hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if act == "edit" {
|
||||
// Find changed inbounds
|
||||
inboundIds, err = s.findInboundsChanges(tx, &client, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err = json.Unmarshal(client.Inbounds, &inboundIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = tx.Save(&client).Error
|
||||
if err != nil {
|
||||
@@ -78,7 +88,7 @@ func (s *ClientService) Save(tx *gorm.DB, act string, data json.RawMessage, host
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.updateLinksWithFixedInbounds(tx, clients, inboundIds, hostname)
|
||||
err = s.updateLinksWithFixedInbounds(tx, clients, hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,6 +96,54 @@ func (s *ClientService) Save(tx *gorm.DB, act string, data json.RawMessage, host
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "editbulk":
|
||||
var clients []*model.Client
|
||||
err = json.Unmarshal(data, &clients)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, client := range clients {
|
||||
changedInboundIds, err := s.findInboundsChanges(tx, client, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(changedInboundIds) > 0 {
|
||||
inboundIds = common.UnionUintArray(inboundIds, changedInboundIds)
|
||||
}
|
||||
}
|
||||
if len(inboundIds) > 0 {
|
||||
err = s.updateLinksWithFixedInbounds(tx, clients, hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
err = tx.Save(clients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "delbulk":
|
||||
var ids []uint
|
||||
err = json.Unmarshal(data, &ids)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, id := range ids {
|
||||
var client model.Client
|
||||
err = tx.Where("id = ?", id).First(&client).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var clientInbounds []uint
|
||||
err = json.Unmarshal(client.Inbounds, &clientInbounds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
inboundIds = common.UnionUintArray(inboundIds, clientInbounds)
|
||||
}
|
||||
err = tx.Where("id in ?", ids).Delete(model.Client{}).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "del":
|
||||
var id uint
|
||||
err = json.Unmarshal(data, &id)
|
||||
@@ -112,13 +170,19 @@ func (s *ClientService) Save(tx *gorm.DB, act string, data json.RawMessage, host
|
||||
return inboundIds, nil
|
||||
}
|
||||
|
||||
func (s *ClientService) updateLinksWithFixedInbounds(tx *gorm.DB, clients []*model.Client, inbounIds []uint, hostname string) error {
|
||||
func (s *ClientService) updateLinksWithFixedInbounds(tx *gorm.DB, clients []*model.Client, hostname string) error {
|
||||
var err error
|
||||
var inbounds []model.Inbound
|
||||
var inboundIds []uint
|
||||
|
||||
err = json.Unmarshal(clients[0].Inbounds, &inboundIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Zero inbounds means removing local links only
|
||||
if len(inbounIds) > 0 {
|
||||
err = tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inbounIds, util.InboundTypeWithLink).Find(&inbounds).Error
|
||||
if len(inboundIds) > 0 {
|
||||
err = tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inboundIds, util.InboundTypeWithLink).Find(&inbounds).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -142,7 +206,7 @@ func (s *ClientService) updateLinksWithFixedInbounds(tx *gorm.DB, clients []*mod
|
||||
}
|
||||
}
|
||||
|
||||
// Add no local links
|
||||
// Add non local links
|
||||
for _, clientLink := range clientLinks {
|
||||
if clientLink["type"] != "local" {
|
||||
newClientLinks = append(newClientLinks, clientLink)
|
||||
@@ -208,10 +272,16 @@ func (s *ClientService) UpdateClientsOnInboundAdd(tx *gorm.DB, initIds string, i
|
||||
}
|
||||
|
||||
func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag string) error {
|
||||
var clientIds []uint
|
||||
err := tx.Raw("SELECT clients.id FROM clients, json_each(clients.inbounds) AS je WHERE je.value = ?", id).Scan(&clientIds).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(clientIds) == 0 {
|
||||
return nil
|
||||
}
|
||||
var clients []model.Client
|
||||
err := tx.Table("clients").
|
||||
Where("EXISTS (SELECT 1 FROM json_each(clients.inbounds) WHERE json_each.value = ?)", id).
|
||||
Find(&clients).Error
|
||||
err = tx.Model(model.Client{}).Where("id IN ?", clientIds).Find(&clients).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -248,17 +318,19 @@ func (s *ClientService) UpdateClientsOnInboundDelete(tx *gorm.DB, id uint, tag s
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint, hostname string) error {
|
||||
var inbounds []model.Inbound
|
||||
err := tx.Model(model.Inbound{}).Preload("Tls").Where("id in ? and type in ?", inbounIds, util.InboundTypeWithLink).Find(&inbounds).Error
|
||||
if err != nil && database.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
for _, inbound := range inbounds {
|
||||
func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounds *[]model.Inbound, hostname string, oldTag string) error {
|
||||
var err error
|
||||
for _, inbound := range *inbounds {
|
||||
var clientIds []uint
|
||||
err = tx.Raw("SELECT clients.id FROM clients, json_each(clients.inbounds) AS je WHERE je.value = ?", inbound.Id).Scan(&clientIds).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(clientIds) == 0 {
|
||||
continue
|
||||
}
|
||||
var clients []model.Client
|
||||
err = tx.Table("clients").
|
||||
Where("EXISTS (SELECT 1 FROM json_each(clients.inbounds) WHERE json_each.value = ?)", inbound.Id).
|
||||
Find(&clients).Error
|
||||
err = tx.Model(model.Client{}).Where("id IN ?", clientIds).Find(&clients).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -274,7 +346,7 @@ func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint
|
||||
})
|
||||
}
|
||||
for _, clientLink := range clientLinks {
|
||||
if clientLink["remark"] != inbound.Tag {
|
||||
if clientLink["type"] != "local" || (clientLink["remark"] != inbound.Tag && clientLink["remark"] != oldTag) {
|
||||
newClientLinks = append(newClientLinks, clientLink)
|
||||
}
|
||||
}
|
||||
@@ -292,43 +364,47 @@ func (s *ClientService) UpdateLinksByInboundChange(tx *gorm.DB, inbounIds []uint
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ClientService) DepleteClients() error {
|
||||
func (s *ClientService) DepleteClients() ([]uint, error) {
|
||||
var err error
|
||||
var clients []model.Client
|
||||
var changes []model.Changes
|
||||
var users []string
|
||||
var inboundIds []uint
|
||||
|
||||
now := time.Now().Unix()
|
||||
dt := time.Now().Unix()
|
||||
db := database.GetDB()
|
||||
|
||||
tx := db.Begin()
|
||||
defer func() {
|
||||
if err == nil {
|
||||
tx.Commit()
|
||||
if len(inboundIds) > 0 && corePtr.IsRunning() {
|
||||
err1 := s.InboundService.RestartInbounds(db, inboundIds)
|
||||
if err1 != nil {
|
||||
logger.Error("unable to restart inbounds: ", err1)
|
||||
}
|
||||
if err1 := db.Exec("PRAGMA wal_checkpoint(FULL)").Error; err1 != nil {
|
||||
logger.Error("Error checkpointing WAL: ", err1.Error())
|
||||
}
|
||||
} else {
|
||||
tx.Rollback()
|
||||
}
|
||||
}()
|
||||
|
||||
err = tx.Model(model.Client{}).Where("enable = true AND ((volume >0 AND up+down > volume) OR (expiry > 0 AND expiry < ?))", now).Scan(&clients).Error
|
||||
// Reset clients
|
||||
inboundIds, err = s.ResetClients(tx, dt)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Deplete clients
|
||||
err = tx.Model(model.Client{}).Where("enable = true AND ((volume >0 AND up+down > volume) OR (expiry > 0 AND expiry < ?))", dt).Scan(&clients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dt := time.Now().Unix()
|
||||
for _, client := range clients {
|
||||
logger.Debug("Client ", client.Name, " is going to be disabled")
|
||||
users = append(users, client.Name)
|
||||
var userInbounds []uint
|
||||
json.Unmarshal(client.Inbounds, &userInbounds)
|
||||
inboundIds = s.uniqueAppendInboundIds(inboundIds, userInbounds)
|
||||
// Find changed inbounds
|
||||
inboundIds = common.UnionUintArray(inboundIds, userInbounds)
|
||||
changes = append(changes, model.Changes{
|
||||
DateTime: dt,
|
||||
Actor: "DepleteJob",
|
||||
@@ -340,32 +416,133 @@ func (s *ClientService) DepleteClients() error {
|
||||
|
||||
// Save changes
|
||||
if len(changes) > 0 {
|
||||
err = tx.Model(model.Client{}).Where("enable = true AND ((volume >0 AND up+down > volume) OR (expiry > 0 AND expiry < ?))", now).Update("enable", false).Error
|
||||
err = tx.Model(model.Client{}).Where("enable = true AND ((volume >0 AND up+down > volume) OR (expiry > 0 AND expiry < ?))", dt).Update("enable", false).Error
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
err = tx.Model(model.Changes{}).Create(&changes).Error
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
LastUpdate = dt
|
||||
}
|
||||
|
||||
return nil
|
||||
return inboundIds, nil
|
||||
}
|
||||
|
||||
// avoid duplicate inboundIds
|
||||
func (s *ClientService) uniqueAppendInboundIds(a []uint, b []uint) []uint {
|
||||
m := make(map[uint]bool)
|
||||
for _, v := range a {
|
||||
m[v] = true
|
||||
func (s *ClientService) ResetClients(tx *gorm.DB, dt int64) ([]uint, error) {
|
||||
var err error
|
||||
var resetClients, allClients []*model.Client
|
||||
var changes []model.Changes
|
||||
var inboundIds []uint
|
||||
// Set delay start without periodic reset
|
||||
err = tx.Model(model.Client{}).
|
||||
Where("enable = true AND delay_start = true AND auto_reset = false AND (Up + Down) > 0").Find(&resetClients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, v := range b {
|
||||
m[v] = true
|
||||
for _, client := range resetClients {
|
||||
client.Expiry = dt + (int64(client.ResetDays) * 86400)
|
||||
client.DelayStart = false
|
||||
changes = append(changes, model.Changes{
|
||||
DateTime: dt,
|
||||
Actor: "ResetJob",
|
||||
Key: "clients",
|
||||
Action: "reset",
|
||||
Obj: json.RawMessage("\"" + client.Name + "\""),
|
||||
})
|
||||
}
|
||||
var res []uint
|
||||
for k := range m {
|
||||
res = append(res, k)
|
||||
allClients = append(allClients, resetClients...)
|
||||
|
||||
// Set delay start with periodic reset
|
||||
err = tx.Model(model.Client{}).
|
||||
Where("enable = true AND delay_start = true AND auto_reset = true AND (Up + Down) > 0").Find(&resetClients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return res
|
||||
for _, client := range resetClients {
|
||||
client.NextReset = dt + (int64(client.ResetDays) * 86400)
|
||||
client.DelayStart = false
|
||||
changes = append(changes, model.Changes{
|
||||
DateTime: dt,
|
||||
Actor: "ResetJob",
|
||||
Key: "clients",
|
||||
Action: "reset",
|
||||
Obj: json.RawMessage("\"" + client.Name + "\""),
|
||||
})
|
||||
}
|
||||
allClients = append(allClients, resetClients...)
|
||||
|
||||
// Set periodic reset
|
||||
err = tx.Model(model.Client{}).
|
||||
Where("delay_start = false AND auto_reset = true AND next_reset < ?", dt).Find(&resetClients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, client := range resetClients {
|
||||
client.NextReset = dt + (int64(client.ResetDays) * 86400)
|
||||
client.TotalUp += client.Up
|
||||
client.TotalDown += client.Down
|
||||
client.Up = 0
|
||||
client.Down = 0
|
||||
if !client.Enable {
|
||||
client.Enable = true
|
||||
var clientInboundIds []uint
|
||||
json.Unmarshal(client.Inbounds, &clientInboundIds)
|
||||
inboundIds = common.UnionUintArray(inboundIds, clientInboundIds)
|
||||
}
|
||||
}
|
||||
allClients = append(allClients, resetClients...)
|
||||
|
||||
// Save clients
|
||||
if len(allClients) > 0 {
|
||||
err = tx.Save(allClients).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Save changes
|
||||
if len(changes) > 0 {
|
||||
err = tx.Model(model.Changes{}).Create(&changes).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
LastUpdate = dt
|
||||
}
|
||||
return inboundIds, nil
|
||||
}
|
||||
|
||||
func (s *ClientService) findInboundsChanges(tx *gorm.DB, client *model.Client, fillOmitted bool) ([]uint, error) {
|
||||
var err error
|
||||
var oldClient model.Client
|
||||
var oldInboundIds, newInboundIds []uint
|
||||
err = tx.Model(model.Client{}).Where("id = ?", client.Id).First(&oldClient).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if fillOmitted {
|
||||
client.Links = oldClient.Links
|
||||
client.Config = oldClient.Config
|
||||
}
|
||||
err = json.Unmarshal(oldClient.Inbounds, &oldInboundIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = json.Unmarshal(client.Inbounds, &newInboundIds)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Check client.Config changes
|
||||
if !bytes.Equal(oldClient.Config, client.Config) ||
|
||||
oldClient.Name != client.Name ||
|
||||
oldClient.Enable != client.Enable {
|
||||
return common.UnionUintArray(oldInboundIds, newInboundIds), nil
|
||||
}
|
||||
|
||||
// Check client.Inbounds changes
|
||||
diffInbounds := common.DiffUintArray(oldInboundIds, newInboundIds)
|
||||
|
||||
return diffInbounds, nil
|
||||
}
|
||||
|
||||
+107
-74
@@ -2,18 +2,24 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/core"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/core"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
)
|
||||
|
||||
var (
|
||||
LastUpdate int64
|
||||
corePtr *core.Core
|
||||
LastUpdate int64
|
||||
corePtr *core.Core
|
||||
startCoreMu sync.Mutex
|
||||
startCoreInProgress bool
|
||||
lastStartFailTime time.Time
|
||||
startCooldown = 15 * time.Second
|
||||
)
|
||||
|
||||
type ConfigService struct {
|
||||
@@ -22,6 +28,7 @@ type ConfigService struct {
|
||||
SettingService
|
||||
InboundService
|
||||
OutboundService
|
||||
ServicesService
|
||||
EndpointService
|
||||
}
|
||||
|
||||
@@ -31,6 +38,7 @@ type SingBoxConfig struct {
|
||||
Ntp json.RawMessage `json:"ntp"`
|
||||
Inbounds []json.RawMessage `json:"inbounds"`
|
||||
Outbounds []json.RawMessage `json:"outbounds"`
|
||||
Services []json.RawMessage `json:"services"`
|
||||
Endpoints []json.RawMessage `json:"endpoints"`
|
||||
Route json.RawMessage `json:"route"`
|
||||
Experimental json.RawMessage `json:"experimental"`
|
||||
@@ -41,7 +49,7 @@ func NewConfigService(core *core.Core) *ConfigService {
|
||||
return &ConfigService{}
|
||||
}
|
||||
|
||||
func (s *ConfigService) GetConfig(data string) (*SingBoxConfig, error) {
|
||||
func (s *ConfigService) GetConfig(data string) (*[]byte, error) {
|
||||
var err error
|
||||
if len(data) == 0 {
|
||||
data, err = s.SettingService.GetConfig()
|
||||
@@ -63,27 +71,53 @@ func (s *ConfigService) GetConfig(data string) (*SingBoxConfig, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
singboxConfig.Services, err = s.ServicesService.GetAllConfig(database.GetDB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
singboxConfig.Endpoints, err = s.EndpointService.GetAllConfig(database.GetDB())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &singboxConfig, nil
|
||||
rawConfig, err := json.MarshalIndent(singboxConfig, "", " ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rawConfig, nil
|
||||
}
|
||||
|
||||
func (s *ConfigService) StartCore(defaultConfig string) error {
|
||||
func (s *ConfigService) StartCore() error {
|
||||
if corePtr.IsRunning() {
|
||||
return nil
|
||||
}
|
||||
singboxConfig, err := s.GetConfig(defaultConfig)
|
||||
startCoreMu.Lock()
|
||||
if startCoreInProgress {
|
||||
startCoreMu.Unlock()
|
||||
return nil
|
||||
}
|
||||
if time.Since(lastStartFailTime) < startCooldown {
|
||||
logger.Info("start core cooldown ", startCooldown/time.Second, " seconds")
|
||||
startCoreMu.Unlock()
|
||||
return nil
|
||||
}
|
||||
startCoreInProgress = true
|
||||
startCoreMu.Unlock()
|
||||
defer func() {
|
||||
startCoreMu.Lock()
|
||||
startCoreInProgress = false
|
||||
startCoreMu.Unlock()
|
||||
}()
|
||||
|
||||
logger.Info("starting core")
|
||||
rawConfig, err := s.GetConfig("")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rawConfig, err := json.MarshalIndent(singboxConfig, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = corePtr.Start(rawConfig)
|
||||
err = corePtr.Start(*rawConfig)
|
||||
if err != nil {
|
||||
startCoreMu.Lock()
|
||||
lastStartFailTime = time.Now()
|
||||
startCoreMu.Unlock()
|
||||
logger.Error("start sing-box err:", err.Error())
|
||||
return err
|
||||
}
|
||||
@@ -96,15 +130,40 @@ func (s *ConfigService) RestartCore() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.StartCore("")
|
||||
return s.StartCore()
|
||||
}
|
||||
|
||||
func (s *ConfigService) restartCoreWithConfig(config json.RawMessage) error {
|
||||
err := s.StopCore()
|
||||
startCoreMu.Lock()
|
||||
if startCoreInProgress {
|
||||
startCoreMu.Unlock()
|
||||
return nil
|
||||
}
|
||||
startCoreInProgress = true
|
||||
startCoreMu.Unlock()
|
||||
defer func() {
|
||||
startCoreMu.Lock()
|
||||
startCoreInProgress = false
|
||||
startCoreMu.Unlock()
|
||||
}()
|
||||
|
||||
if corePtr.IsRunning() {
|
||||
if err := corePtr.Stop(); err != nil {
|
||||
logger.Error("restart sing-box err (stop):", err.Error())
|
||||
return err
|
||||
}
|
||||
}
|
||||
rawConfig, err := s.GetConfig(string(config))
|
||||
if err != nil {
|
||||
logger.Error("restart sing-box err (get config):", err.Error())
|
||||
return err
|
||||
}
|
||||
return s.StartCore(string(config))
|
||||
if err := corePtr.Start(*rawConfig); err != nil {
|
||||
logger.Error("restart sing-box err (start):", err.Error())
|
||||
return err
|
||||
}
|
||||
logger.Info("sing-box restarted with new config")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ConfigService) StopCore() error {
|
||||
@@ -116,10 +175,18 @@ func (s *ConfigService) StopCore() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ConfigService) CheckOutbound(tag string, link string) core.CheckOutboundResult {
|
||||
if tag == "" {
|
||||
return core.CheckOutboundResult{Error: "missing query parameter: tag"}
|
||||
}
|
||||
if corePtr == nil || !corePtr.IsRunning() {
|
||||
return core.CheckOutboundResult{Error: "core not running"}
|
||||
}
|
||||
return core.CheckOutbound(corePtr.GetCtx(), tag, link)
|
||||
}
|
||||
|
||||
func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initUsers string, loginUser string, hostname string) ([]string, error) {
|
||||
var err error
|
||||
var inboundIds []uint
|
||||
var inboundId uint
|
||||
var objs []string = []string{obj}
|
||||
|
||||
db := database.GetDB()
|
||||
@@ -127,15 +194,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
defer func() {
|
||||
if err == nil {
|
||||
tx.Commit()
|
||||
if len(inboundIds) > 0 && corePtr.IsRunning() {
|
||||
err1 := s.InboundService.RestartInbounds(db, inboundIds)
|
||||
if err1 != nil {
|
||||
logger.Error("unable to restart inbounds: ", err1)
|
||||
}
|
||||
}
|
||||
// Try to start core if it is not running
|
||||
if !corePtr.IsRunning() {
|
||||
s.StartCore("")
|
||||
s.StartCore()
|
||||
}
|
||||
} else {
|
||||
tx.Rollback()
|
||||
@@ -144,14 +205,25 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
|
||||
switch obj {
|
||||
case "clients":
|
||||
var inboundIds []uint
|
||||
inboundIds, err = s.ClientService.Save(tx, act, data, hostname)
|
||||
objs = append(objs, "inbounds")
|
||||
if err == nil && len(inboundIds) > 0 {
|
||||
objs = append(objs, "inbounds")
|
||||
err = s.InboundService.RestartInbounds(tx, inboundIds)
|
||||
if err != nil {
|
||||
return nil, common.NewErrorf("failed to update users for inbounds: %v", err)
|
||||
}
|
||||
}
|
||||
case "tls":
|
||||
inboundIds, err = s.TlsService.Save(tx, act, data)
|
||||
err = s.TlsService.Save(tx, act, data, hostname)
|
||||
objs = append(objs, "clients", "inbounds")
|
||||
case "inbounds":
|
||||
inboundId, err = s.InboundService.Save(tx, act, data, initUsers, hostname)
|
||||
err = s.InboundService.Save(tx, act, data, initUsers, hostname)
|
||||
objs = append(objs, "clients")
|
||||
case "outbounds":
|
||||
err = s.OutboundService.Save(tx, act, data)
|
||||
case "services":
|
||||
err = s.ServicesService.Save(tx, act, data)
|
||||
case "endpoints":
|
||||
err = s.EndpointService.Save(tx, act, data)
|
||||
case "config":
|
||||
@@ -159,7 +231,9 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.restartCoreWithConfig(data)
|
||||
configData := make(json.RawMessage, len(data))
|
||||
copy(configData, data)
|
||||
go func() { _ = s.restartCoreWithConfig(configData) }()
|
||||
case "settings":
|
||||
err = s.SettingService.Save(tx, data)
|
||||
default:
|
||||
@@ -180,49 +254,8 @@ func (s *ConfigService) Save(obj string, act string, data json.RawMessage, initU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Commit changes so far
|
||||
tx.Commit()
|
||||
|
||||
LastUpdate = time.Now().Unix()
|
||||
tx = db.Begin()
|
||||
|
||||
// Update side changes
|
||||
|
||||
// Update client links
|
||||
if obj == "tls" && len(inboundIds) > 0 {
|
||||
err = s.ClientService.UpdateLinksByInboundChange(tx, inboundIds, hostname)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objs = append(objs, "clients")
|
||||
}
|
||||
if obj == "inbounds" {
|
||||
switch act {
|
||||
case "new":
|
||||
err = s.ClientService.UpdateClientsOnInboundAdd(tx, initUsers, inboundId, hostname)
|
||||
case "edit":
|
||||
err = s.ClientService.UpdateLinksByInboundChange(tx, []uint{inboundId}, hostname)
|
||||
case "del":
|
||||
var tag string
|
||||
err = json.Unmarshal(data, &tag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.ClientService.UpdateClientsOnInboundDelete(tx, inboundId, tag)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
objs = append(objs, "clients")
|
||||
}
|
||||
|
||||
// Update out_json of inbounds when tls is changed
|
||||
if obj == "tls" && len(inboundIds) > 0 {
|
||||
err = s.InboundService.UpdateOutJsons(tx, inboundIds, hostname)
|
||||
if err != nil {
|
||||
return nil, common.NewError("unable to update out_json of inbounds: ", err.Error())
|
||||
}
|
||||
objs = append(objs, "inbounds")
|
||||
}
|
||||
|
||||
return objs, nil
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package service
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/util/common"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
+115
-101
@@ -2,17 +2,21 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/util"
|
||||
"s-ui/util/common"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type InboundService struct{}
|
||||
type InboundService struct {
|
||||
ClientService
|
||||
}
|
||||
|
||||
func (s *InboundService) Get(ids string) (*[]map[string]interface{}, error) {
|
||||
if ids == "" {
|
||||
@@ -49,6 +53,7 @@ func (s *InboundService) GetAll() (*[]map[string]interface{}, error) {
|
||||
var data []map[string]interface{}
|
||||
for _, inbound := range inbounds {
|
||||
var shadowtls_version uint
|
||||
ss_managed := false
|
||||
inbData := map[string]interface{}{
|
||||
"id": inbound.Id,
|
||||
"type": inbound.Type,
|
||||
@@ -65,20 +70,19 @@ func (s *InboundService) GetAll() (*[]map[string]interface{}, error) {
|
||||
if inbound.Type == "shadowtls" {
|
||||
json.Unmarshal(restFields["version"], &shadowtls_version)
|
||||
}
|
||||
}
|
||||
switch inbound.Type {
|
||||
case "mixed", "socks", "http", "shadowsocks", "vmess", "trojan", "naive", "hysteria", "shadowtls", "tuic", "hysteria2", "vless":
|
||||
if inbound.Type == "shadowtls" && shadowtls_version < 3 {
|
||||
break
|
||||
if inbound.Type == "shadowsocks" {
|
||||
json.Unmarshal(restFields["managed"], &ss_managed)
|
||||
}
|
||||
}
|
||||
if s.hasUser(inbound.Type) &&
|
||||
!(inbound.Type == "shadowtls" && shadowtls_version < 3) &&
|
||||
!(inbound.Type == "shadowsocks" && ss_managed) {
|
||||
users := []string{}
|
||||
err = db.Raw("SELECT clients.name FROM clients, json_each(clients.inbounds) as je WHERE je.value = ?", inbound.Id).Scan(&users).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(users) > 0 || inbound.Type != "shadowsocks" {
|
||||
inbData["users"] = users
|
||||
}
|
||||
inbData["users"] = users
|
||||
}
|
||||
|
||||
data = append(data, inbData)
|
||||
@@ -96,51 +100,41 @@ func (s *InboundService) FromIds(ids []uint) ([]*model.Inbound, error) {
|
||||
return inbounds, nil
|
||||
}
|
||||
|
||||
func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUserIds string, hostname string) (uint, error) {
|
||||
func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, initUserIds string, hostname string) error {
|
||||
var err error
|
||||
var id uint
|
||||
|
||||
switch act {
|
||||
case "new", "edit":
|
||||
var inbound model.Inbound
|
||||
err = inbound.UnmarshalJSON(data)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
if inbound.TlsId > 0 {
|
||||
err = tx.Model(model.Tls{}).Where("id = ?", inbound.TlsId).Find(&inbound.Tls).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
var oldTag string
|
||||
if act == "edit" {
|
||||
err = tx.Model(model.Inbound{}).Select("tag").Where("id = ?", inbound.Id).Find(&oldTag).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = util.FillOutJson(&inbound, hostname)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
err = tx.Save(&inbound).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
id = inbound.Id
|
||||
|
||||
if corePtr.IsRunning() {
|
||||
if act == "edit" {
|
||||
var oldTag string
|
||||
err = tx.Model(model.Inbound{}).Select("tag").Where("id = ?", inbound.Id).Find(&oldTag).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
err = corePtr.RemoveInbound(oldTag)
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
inboundConfig, err := inbound.MarshalJSON()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
|
||||
if act == "edit" {
|
||||
@@ -149,38 +143,62 @@ func (s *InboundService) Save(tx *gorm.DB, act string, data json.RawMessage, ini
|
||||
inboundConfig, err = s.initUsers(tx, inboundConfig, initUserIds, inbound.Type)
|
||||
}
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
|
||||
err = corePtr.AddInbound(inboundConfig)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = util.FillOutJson(&inbound, hostname)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Save(&inbound).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch act {
|
||||
case "new":
|
||||
err = s.ClientService.UpdateClientsOnInboundAdd(tx, initUserIds, inbound.Id, hostname)
|
||||
case "edit":
|
||||
err = s.ClientService.UpdateLinksByInboundChange(tx, &[]model.Inbound{inbound}, hostname, oldTag)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "del":
|
||||
var tag string
|
||||
err = json.Unmarshal(data, &tag)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
if corePtr.IsRunning() {
|
||||
err = corePtr.RemoveInbound(tag)
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
var id uint
|
||||
err = tx.Model(model.Inbound{}).Select("id").Where("tag = ?", tag).Scan(&id).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
err = s.ClientService.UpdateClientsOnInboundDelete(tx, id, tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = tx.Where("tag = ?", tag).Delete(model.Inbound{}).Error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return 0, common.NewErrorf("unknown action: %s", act)
|
||||
return common.NewErrorf("unknown action: %s", act)
|
||||
}
|
||||
return id, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *InboundService) UpdateOutJsons(tx *gorm.DB, inboundIds []uint, hostname string) error {
|
||||
@@ -224,11 +242,49 @@ func (s *InboundService) GetAllConfig(db *gorm.DB) ([]json.RawMessage, error) {
|
||||
return inboundsJson, nil
|
||||
}
|
||||
|
||||
func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uint, inboundType string) ([]byte, error) {
|
||||
func (s *InboundService) hasUser(inboundType string) bool {
|
||||
switch inboundType {
|
||||
case "mixed", "socks", "http", "shadowsocks", "vmess", "trojan", "naive", "hysteria", "shadowtls", "tuic", "hysteria2", "vless":
|
||||
break
|
||||
default:
|
||||
case "mixed", "socks", "http", "shadowsocks", "vmess", "trojan", "naive", "hysteria", "shadowtls", "tuic", "hysteria2", "vless", "anytls":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *InboundService) fetchUsers(db *gorm.DB, inboundType string, condition string, inbound map[string]interface{}) ([]json.RawMessage, error) {
|
||||
if inboundType == "shadowtls" {
|
||||
version, _ := inbound["version"].(float64)
|
||||
if int(version) < 3 {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
if inboundType == "shadowsocks" {
|
||||
method, _ := inbound["method"].(string)
|
||||
if method == "2022-blake3-aes-128-gcm" {
|
||||
inboundType = "shadowsocks16"
|
||||
}
|
||||
}
|
||||
|
||||
var users []string
|
||||
|
||||
err := db.Raw(
|
||||
fmt.Sprintf(`SELECT json_extract(clients.config, "$.%s")
|
||||
FROM clients WHERE enable = true AND %s`,
|
||||
inboundType, condition)).Scan(&users).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var usersJson []json.RawMessage
|
||||
for _, user := range users {
|
||||
if inboundType == "vless" && inbound["tls"] == nil {
|
||||
user = strings.Replace(user, "xtls-rprx-vision", "", -1)
|
||||
}
|
||||
usersJson = append(usersJson, json.RawMessage(user))
|
||||
}
|
||||
return usersJson, nil
|
||||
}
|
||||
|
||||
func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uint, inboundType string) ([]byte, error) {
|
||||
if !s.hasUser(inboundType) {
|
||||
return inboundJson, nil
|
||||
}
|
||||
|
||||
@@ -238,34 +294,11 @@ func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if inboundType == "shadowtls" {
|
||||
version, _ := inbound["version"].(float64)
|
||||
if int(version) < 3 {
|
||||
return inboundJson, nil
|
||||
}
|
||||
}
|
||||
if inboundType == "shadowsocks" {
|
||||
method, _ := inbound["method"].(string)
|
||||
if method == "2022-blake3-aes-128-gcm" {
|
||||
inboundType = "shadowsocks16"
|
||||
}
|
||||
}
|
||||
var users []string
|
||||
err = db.Raw(`SELECT json_extract(clients.config, ?)
|
||||
FROM clients, json_each(clients.inbounds) as je
|
||||
WHERE clients.enable = true AND je.value = ?;`,
|
||||
"$."+inboundType, inboundId).Scan(&users).Error
|
||||
condition := fmt.Sprintf("%d IN (SELECT json_each.value FROM json_each(clients.inbounds))", inboundId)
|
||||
inbound["users"], err = s.fetchUsers(db, inboundType, condition, inbound)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var usersJson []json.RawMessage
|
||||
for _, user := range users {
|
||||
usersJson = append(usersJson, json.RawMessage(user))
|
||||
}
|
||||
|
||||
if len(usersJson) > 0 || inboundType != "shadowsocks" {
|
||||
inbound["users"] = usersJson
|
||||
}
|
||||
|
||||
return json.Marshal(inbound)
|
||||
}
|
||||
@@ -275,10 +308,8 @@ func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds st
|
||||
if len(ClientIds) == 0 {
|
||||
return inboundJson, nil
|
||||
}
|
||||
switch inboundType {
|
||||
case "mixed", "socks", "http", "shadowsocks", "vmess", "trojan", "naive", "hysteria", "shadowtls", "tuic", "hysteria2", "vless":
|
||||
break
|
||||
default:
|
||||
|
||||
if !s.hasUser(inboundType) {
|
||||
return inboundJson, nil
|
||||
}
|
||||
|
||||
@@ -288,39 +319,19 @@ func (s *InboundService) initUsers(db *gorm.DB, inboundJson []byte, clientIds st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if inboundType == "shadowtls" {
|
||||
version, _ := inbound["version"].(float64)
|
||||
if int(version) < 3 {
|
||||
return inboundJson, nil
|
||||
}
|
||||
}
|
||||
if inboundType == "shadowsocks" {
|
||||
method, _ := inbound["method"].(string)
|
||||
if method == "2022-blake3-aes-128-gcm" {
|
||||
inboundType = "shadowsocks16"
|
||||
}
|
||||
}
|
||||
var users []string
|
||||
err = db.Raw(`SELECT json_extract(clients.config, ?)
|
||||
FROM clients
|
||||
WHERE enable = true AND id in ?`,
|
||||
"$."+inboundType, ClientIds).Scan(&users).Error
|
||||
condition := fmt.Sprintf("id IN (%s)", strings.Join(ClientIds, ","))
|
||||
inbound["users"], err = s.fetchUsers(db, inboundType, condition, inbound)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var usersJson []json.RawMessage
|
||||
for _, user := range users {
|
||||
usersJson = append(usersJson, json.RawMessage(user))
|
||||
}
|
||||
|
||||
if len(usersJson) > 0 || inboundType != "shadowsocks" {
|
||||
inbound["users"] = usersJson
|
||||
}
|
||||
|
||||
return json.Marshal(inbound)
|
||||
}
|
||||
|
||||
func (s *InboundService) RestartInbounds(tx *gorm.DB, ids []uint) error {
|
||||
if !corePtr.IsRunning() {
|
||||
return nil
|
||||
}
|
||||
var inbounds []*model.Inbound
|
||||
err := tx.Model(model.Inbound{}).Preload("Tls").Where("id in ?", ids).Find(&inbounds).Error
|
||||
if err != nil {
|
||||
@@ -331,6 +342,9 @@ func (s *InboundService) RestartInbounds(tx *gorm.DB, ids []uint) error {
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return err
|
||||
}
|
||||
// Close all existing connections
|
||||
corePtr.GetInstance().ConnTracker().CloseConnByInbound(inbound.Tag)
|
||||
|
||||
inboundConfig, err := inbound.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -3,9 +3,10 @@ package service
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/util/common"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
+8
-2
@@ -2,9 +2,11 @@ package service
|
||||
|
||||
import (
|
||||
"os"
|
||||
"s-ui/logger"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
)
|
||||
|
||||
type PanelService struct {
|
||||
@@ -17,7 +19,11 @@ func (s *PanelService) RestartPanel(delay time.Duration) error {
|
||||
}
|
||||
go func() {
|
||||
time.Sleep(delay)
|
||||
err := p.Signal(syscall.SIGHUP)
|
||||
if runtime.GOOS == "windows" {
|
||||
err = p.Kill()
|
||||
} else {
|
||||
err = p.Signal(syscall.SIGHUP)
|
||||
}
|
||||
if err != nil {
|
||||
logger.Error("send signal SIGHUP failed:", err)
|
||||
}
|
||||
|
||||
+88
-19
@@ -4,14 +4,18 @@ import (
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"runtime"
|
||||
"s-ui/config"
|
||||
"s-ui/logger"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
|
||||
"github.com/sagernet/sing-box/common/tls"
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
"github.com/shirou/gopsutil/v4/disk"
|
||||
"github.com/shirou/gopsutil/v4/host"
|
||||
"github.com/shirou/gopsutil/v4/mem"
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
@@ -29,13 +33,20 @@ func (s *ServerService) GetStatus(request string) *map[string]interface{} {
|
||||
status["cpu"] = s.GetCpuPercent()
|
||||
case "mem":
|
||||
status["mem"] = s.GetMemInfo()
|
||||
case "dsk":
|
||||
status["dsk"] = s.GetDiskInfo()
|
||||
case "dio":
|
||||
status["dio"] = s.GetDiskIO()
|
||||
case "swp":
|
||||
status["swp"] = s.GetSwapInfo()
|
||||
case "net":
|
||||
status["net"] = s.GetNetInfo()
|
||||
case "sys":
|
||||
status["uptime"] = s.GetUptime()
|
||||
status["sys"] = s.GetSystemInfo()
|
||||
case "sbd":
|
||||
status["sbd"] = s.GetSingboxInfo()
|
||||
case "db":
|
||||
status["db"] = s.GetDatabaseInfo()
|
||||
}
|
||||
}
|
||||
return &status
|
||||
@@ -51,16 +62,6 @@ func (s *ServerService) GetCpuPercent() float64 {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetUptime() uint64 {
|
||||
upTime, err := host.Uptime()
|
||||
if err != nil {
|
||||
logger.Warning("get uptime failed:", err)
|
||||
return 0
|
||||
} else {
|
||||
return upTime
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetMemInfo() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
memInfo, err := mem.VirtualMemory()
|
||||
@@ -73,6 +74,49 @@ func (s *ServerService) GetMemInfo() map[string]interface{} {
|
||||
return info
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDiskInfo() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
diskInfo, err := disk.Usage("/")
|
||||
if err != nil {
|
||||
logger.Warning("get disk usage failed:", err)
|
||||
} else {
|
||||
info["current"] = diskInfo.Used
|
||||
info["total"] = diskInfo.Total
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDiskIO() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
ioStats, err := disk.IOCounters()
|
||||
if err != nil {
|
||||
logger.Warning("get disk io counters failed:", err)
|
||||
} else if len(ioStats) > 0 {
|
||||
infoR, infoW := uint64(0), uint64(0)
|
||||
for _, ioStat := range ioStats {
|
||||
infoR += ioStat.ReadBytes
|
||||
infoW += ioStat.WriteBytes
|
||||
}
|
||||
info["read"] = infoR
|
||||
info["write"] = infoW
|
||||
} else {
|
||||
logger.Warning("can not find disk io counters")
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (s *ServerService) GetSwapInfo() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
swapInfo, err := mem.SwapMemory()
|
||||
if err != nil {
|
||||
logger.Warning("get swap memory failed:", err)
|
||||
} else {
|
||||
info["current"] = swapInfo.Used
|
||||
info["total"] = swapInfo.Total
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (s *ServerService) GetNetInfo() map[string]interface{} {
|
||||
info := make(map[string]interface{}, 0)
|
||||
ioStats, err := net.IOCounters(false)
|
||||
@@ -141,6 +185,7 @@ func (s *ServerService) GetSystemInfo() map[string]interface{} {
|
||||
}
|
||||
info["ipv4"] = ipv4
|
||||
info["ipv6"] = ipv6
|
||||
info["bootTime"], _ = host.BootTime()
|
||||
|
||||
return info
|
||||
}
|
||||
@@ -172,12 +217,8 @@ func (s *ServerService) GenKeypair(keyType string, options string) []string {
|
||||
return []string{"Failed to generate keypair"}
|
||||
}
|
||||
|
||||
func (s *ServerService) generateECHKeyPair(options string) []string {
|
||||
parts := strings.Split(options, ",")
|
||||
if len(parts) != 2 {
|
||||
return []string{"Failed to generate ECH keypair: ", "invalid options"}
|
||||
}
|
||||
configPem, keyPem, err := tls.ECHKeygenDefault(parts[0], parts[1] == "true")
|
||||
func (s *ServerService) generateECHKeyPair(serverName string) []string {
|
||||
configPem, keyPem, err := tls.ECHKeygenDefault(serverName)
|
||||
if err != nil {
|
||||
return []string{"Failed to generate ECH keypair: ", err.Error()}
|
||||
}
|
||||
@@ -212,3 +253,31 @@ func (s *ServerService) generateWireGuardKey(pk string) []string {
|
||||
}
|
||||
return []string{"PrivateKey: " + wgKeys.String(), "PublicKey: " + wgKeys.PublicKey().String()}
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDatabaseInfo() map[string]int64 {
|
||||
info := make(map[string]int64, 0)
|
||||
db := database.GetDB()
|
||||
if db == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var clientsCount, inboundsCount, outboundsCount, servicesCount, endpointsCount, clientUp, clientDown int64
|
||||
|
||||
db.Model(&model.Client{}).Count(&clientsCount)
|
||||
db.Model(&model.Inbound{}).Count(&inboundsCount)
|
||||
db.Model(&model.Outbound{}).Count(&outboundsCount)
|
||||
db.Model(&model.Service{}).Count(&servicesCount)
|
||||
db.Model(&model.Endpoint{}).Count(&endpointsCount)
|
||||
db.Model(&model.Client{}).Select("COALESCE(SUM(up+total_up),0)").Scan(&clientUp)
|
||||
db.Model(&model.Client{}).Select("COALESCE(SUM(down+total_down),0)").Scan(&clientDown)
|
||||
|
||||
info["clients"] = clientsCount
|
||||
info["inbounds"] = inboundsCount
|
||||
info["outbounds"] = outboundsCount
|
||||
info["services"] = servicesCount
|
||||
info["endpoints"] = endpointsCount
|
||||
info["clientUp"] = clientUp
|
||||
info["clientDown"] = clientDown
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ServicesService struct{}
|
||||
|
||||
func (s *ServicesService) GetAll() (*[]map[string]interface{}, error) {
|
||||
db := database.GetDB()
|
||||
services := []model.Service{}
|
||||
err := db.Model(model.Service{}).Scan(&services).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var data []map[string]interface{}
|
||||
for _, srv := range services {
|
||||
srvData := map[string]interface{}{
|
||||
"id": srv.Id,
|
||||
"type": srv.Type,
|
||||
"tag": srv.Tag,
|
||||
"tls_id": srv.TlsId,
|
||||
}
|
||||
if srv.Options != nil {
|
||||
var restFields map[string]json.RawMessage
|
||||
if err := json.Unmarshal(srv.Options, &restFields); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for k, v := range restFields {
|
||||
srvData[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
data = append(data, srvData)
|
||||
}
|
||||
return &data, nil
|
||||
}
|
||||
|
||||
func (s *ServicesService) GetAllConfig(db *gorm.DB) ([]json.RawMessage, error) {
|
||||
var servicesJson []json.RawMessage
|
||||
var services []*model.Service
|
||||
err := db.Model(model.Service{}).Preload("Tls").Find(&services).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, srv := range services {
|
||||
srvJson, err := srv.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
servicesJson = append(servicesJson, srvJson)
|
||||
}
|
||||
return servicesJson, nil
|
||||
}
|
||||
|
||||
func (s *ServicesService) Save(tx *gorm.DB, act string, data json.RawMessage) error {
|
||||
var err error
|
||||
|
||||
switch act {
|
||||
case "new", "edit":
|
||||
var srv model.Service
|
||||
err = srv.UnmarshalJSON(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if srv.TlsId > 0 {
|
||||
err = tx.Model(model.Tls{}).Where("id = ?", srv.TlsId).Find(&srv.Tls).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if corePtr.IsRunning() {
|
||||
configData, err := srv.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if act == "edit" {
|
||||
var oldTag string
|
||||
err = tx.Model(model.Service{}).Select("tag").Where("id = ?", srv.Id).Find(&oldTag).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = corePtr.RemoveService(oldTag)
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = corePtr.AddService(configData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = tx.Save(&srv).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "del":
|
||||
var tag string
|
||||
err = json.Unmarshal(data, &tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if corePtr.IsRunning() {
|
||||
err = corePtr.RemoveService(tag)
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = tx.Where("tag = ?", tag).Delete(model.Service{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return common.NewErrorf("unknown action: %s", act)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *ServicesService) RestartServices(tx *gorm.DB, ids []uint) error {
|
||||
if !corePtr.IsRunning() {
|
||||
return nil
|
||||
}
|
||||
var services []*model.Service
|
||||
err := tx.Model(model.Service{}).Preload("Tls").Where("id in ?", ids).Find(&services).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, srv := range services {
|
||||
err = corePtr.RemoveService(srv.Tag)
|
||||
if err != nil && err != os.ErrInvalid {
|
||||
return err
|
||||
}
|
||||
srvConfig, err := srv.MarshalJSON()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = corePtr.AddService(srvConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+29
-6
@@ -3,15 +3,17 @@ package service
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"s-ui/config"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -19,9 +21,15 @@ var defaultConfig = `{
|
||||
"log": {
|
||||
"level": "info"
|
||||
},
|
||||
"dns": {},
|
||||
"dns": {
|
||||
"servers": [],
|
||||
"rules": []
|
||||
},
|
||||
"route": {
|
||||
"rules": [
|
||||
{
|
||||
"action": "sniff"
|
||||
},
|
||||
{
|
||||
"protocol": [
|
||||
"dns"
|
||||
@@ -56,6 +64,7 @@ var defaultValueMap = map[string]string{
|
||||
"subShowInfo": "false",
|
||||
"subURI": "",
|
||||
"subJsonExt": "",
|
||||
"subClashExt": "",
|
||||
"config": defaultConfig,
|
||||
"version": config.GetVersion(),
|
||||
}
|
||||
@@ -238,6 +247,9 @@ func (s *SettingService) GetTimeLocation() (*time.Location, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
l = "Local"
|
||||
}
|
||||
location, err := time.LoadLocation(l)
|
||||
if err != nil {
|
||||
defaultLocation := defaultValueMap["timeLocation"]
|
||||
@@ -380,6 +392,13 @@ func (s *SettingService) Save(tx *gorm.DB, data json.RawMessage) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete all stats if it is set to 0
|
||||
if key == "trafficAge" && obj == "0" {
|
||||
err = tx.Where("id > 0").Delete(model.Stats{}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = tx.Model(model.Setting{}).Where("key = ?", key).Update("value", obj).Error
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -392,6 +411,10 @@ func (s *SettingService) GetSubJsonExt() (string, error) {
|
||||
return s.getString("subJsonExt")
|
||||
}
|
||||
|
||||
func (s *SettingService) GetSubClashExt() (string, error) {
|
||||
return s.getString("subClashExt")
|
||||
}
|
||||
|
||||
func (s *SettingService) fileExists(path string) error {
|
||||
_, err := os.Stat(path)
|
||||
return err
|
||||
|
||||
+66
-7
@@ -1,10 +1,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -19,11 +21,19 @@ var onlineResources = &onlines{}
|
||||
type StatsService struct {
|
||||
}
|
||||
|
||||
func (s *StatsService) SaveStats() error {
|
||||
if !corePtr.IsRunning() {
|
||||
func (s *StatsService) SaveStats(enableTraffic bool) error {
|
||||
if corePtr == nil || !corePtr.IsRunning() {
|
||||
return nil
|
||||
}
|
||||
stats := corePtr.GetInstance().ConnTracker().GetStats()
|
||||
box := corePtr.GetInstance()
|
||||
if box == nil {
|
||||
return nil
|
||||
}
|
||||
st := box.StatsTracker()
|
||||
if st == nil {
|
||||
return nil
|
||||
}
|
||||
stats := st.GetStats()
|
||||
|
||||
// Reset onlines
|
||||
onlineResources.Inbound = nil
|
||||
@@ -70,8 +80,10 @@ func (s *StatsService) SaveStats() error {
|
||||
}
|
||||
}
|
||||
|
||||
err = tx.Create(&stats).Error
|
||||
return err
|
||||
if !enableTraffic {
|
||||
return nil
|
||||
}
|
||||
return tx.Create(&stats).Error
|
||||
}
|
||||
|
||||
func (s *StatsService) GetStats(resource string, tag string, limit int) ([]model.Stats, error) {
|
||||
@@ -90,9 +102,56 @@ func (s *StatsService) GetStats(resource string, tag string, limit int) ([]model
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = s.downsampleStats(result, 60) // 60 rows for 30 buckets
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// downsampleStats reduces stats to maxRows rows.
|
||||
// Each bucket outputs two rows (direction false and true) with average Traffic.
|
||||
func (s *StatsService) downsampleStats(stats []model.Stats, maxRows int) []model.Stats {
|
||||
if len(stats) <= maxRows {
|
||||
return stats
|
||||
}
|
||||
numBuckets := int(maxRows / 2)
|
||||
sort.Slice(stats, func(i, j int) bool { return stats[i].DateTime < stats[j].DateTime })
|
||||
timeMin, timeMax := stats[0].DateTime, stats[len(stats)-1].DateTime
|
||||
bucketSpan := (timeMax - timeMin) / int64(numBuckets)
|
||||
if bucketSpan == 0 {
|
||||
bucketSpan = 1
|
||||
}
|
||||
downsampled := make([]model.Stats, 0, maxRows)
|
||||
for i := 0; i < numBuckets; i++ {
|
||||
bucketStart := timeMin + int64(i)*bucketSpan
|
||||
bucketEnd := timeMin + int64(i+1)*bucketSpan
|
||||
if i == numBuckets-1 {
|
||||
bucketEnd = timeMax + 1
|
||||
}
|
||||
for _, dir := range []bool{false, true} {
|
||||
var sum int64
|
||||
var count int
|
||||
for _, r := range stats {
|
||||
if r.DateTime >= bucketStart && r.DateTime < bucketEnd && r.Direction == dir {
|
||||
sum += r.Traffic
|
||||
count++
|
||||
}
|
||||
}
|
||||
avg := int64(0)
|
||||
if count > 0 {
|
||||
avg = sum / int64(count)
|
||||
}
|
||||
downsampled = append(downsampled, model.Stats{
|
||||
DateTime: bucketStart,
|
||||
Resource: stats[0].Resource,
|
||||
Tag: stats[0].Tag,
|
||||
Direction: dir,
|
||||
Traffic: avg,
|
||||
})
|
||||
}
|
||||
}
|
||||
return downsampled
|
||||
}
|
||||
|
||||
func (s *StatsService) GetOnlines() (onlines, error) {
|
||||
return *onlineResources, nil
|
||||
}
|
||||
|
||||
+54
-17
@@ -2,15 +2,17 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/util/common"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TlsService struct {
|
||||
InboundService
|
||||
ServicesService
|
||||
}
|
||||
|
||||
func (s *TlsService) GetAll() ([]model.Tls, error) {
|
||||
@@ -24,45 +26,80 @@ func (s *TlsService) GetAll() ([]model.Tls, error) {
|
||||
return tlsConfig, nil
|
||||
}
|
||||
|
||||
func (s *TlsService) Save(tx *gorm.DB, action string, data json.RawMessage) ([]uint, error) {
|
||||
func (s *TlsService) Save(tx *gorm.DB, action string, data json.RawMessage, hostname string) error {
|
||||
var err error
|
||||
var inboundIds []uint
|
||||
|
||||
switch action {
|
||||
case "new", "edit":
|
||||
var tls model.Tls
|
||||
err = json.Unmarshal(data, &tls)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
err = tx.Save(&tls).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
err = tx.Model(model.Inbound{}).Select("id").Where("tls_id = ?", tls.Id).Scan(&inboundIds).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if action == "edit" {
|
||||
var inbounds []model.Inbound
|
||||
err = tx.Model(model.Inbound{}).Preload("Tls").Where("tls_id = ?", tls.Id).Find(&inbounds).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(inbounds) > 0 {
|
||||
err = s.ClientService.UpdateLinksByInboundChange(tx, &inbounds, hostname, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var inboundIds []uint
|
||||
for _, inbound := range inbounds {
|
||||
inboundIds = append(inboundIds, inbound.Id)
|
||||
}
|
||||
err = s.InboundService.UpdateOutJsons(tx, inboundIds, hostname)
|
||||
if err != nil {
|
||||
return common.NewError("unable to update out_json of inbounds: ", err.Error())
|
||||
}
|
||||
err = s.InboundService.RestartInbounds(tx, inboundIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var serviceIds []uint
|
||||
err = tx.Model(model.Service{}).Where("tls_id = ?", tls.Id).Scan(&serviceIds).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(serviceIds) > 0 {
|
||||
err = s.ServicesService.RestartServices(tx, serviceIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return inboundIds, nil
|
||||
case "del":
|
||||
var id uint
|
||||
err = json.Unmarshal(data, &id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
var inboundCount int64
|
||||
err = tx.Model(model.Inbound{}).Where("tls_id = ?", id).Count(&inboundCount).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if inboundCount > 0 {
|
||||
return nil, common.NewError("tls in use")
|
||||
var serviceCount int64
|
||||
err = tx.Model(model.Service{}).Where("tls_id = ?", id).Count(&serviceCount).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inboundCount > 0 || serviceCount > 0 {
|
||||
return common.NewError("tls in use")
|
||||
}
|
||||
err = tx.Where("id = ?", id).Delete(model.Tls{}).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
+5
-4
@@ -2,11 +2,12 @@ package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
)
|
||||
|
||||
type UserService struct {
|
||||
|
||||
+21
-26
@@ -8,35 +8,30 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"s-ui/database/model"
|
||||
"s-ui/logger"
|
||||
"s-ui/util/common"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
)
|
||||
|
||||
type WarpService struct{}
|
||||
|
||||
func (s *WarpService) getWarpInfo(ep *model.Endpoint) ([]byte, error) {
|
||||
var warpData map[string]string
|
||||
err := json.Unmarshal(ep.Ext, &warpData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("https://api.cloudflareclient.com/v0a2158/reg/%s", warpData["device_id"])
|
||||
func (s *WarpService) getWarpInfo(deviceId string, accessToken string) ([]byte, error) {
|
||||
url := fmt.Sprintf("https://api.cloudflareclient.com/v0a2158/reg/%s", deviceId)
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+warpData["access_token"])
|
||||
req.Header.Set("Authorization", "Bearer "+accessToken)
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
if err != nil || resp.StatusCode != 200 {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
@@ -69,7 +64,7 @@ func (s *WarpService) RegisterWarp(ep *model.Endpoint) error {
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
if err != nil || resp.StatusCode != 200 {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
@@ -94,18 +89,7 @@ func (s *WarpService) RegisterWarp(ep *model.Endpoint) error {
|
||||
return err
|
||||
}
|
||||
|
||||
warpData := map[string]string{
|
||||
"access_token": token,
|
||||
"device_id": deviceId,
|
||||
"license_key": license,
|
||||
}
|
||||
|
||||
ep.Ext, err = json.MarshalIndent(warpData, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
warpInfo, err := s.getWarpInfo(ep)
|
||||
warpInfo, err := s.getWarpInfo(deviceId, token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -142,6 +126,17 @@ func (s *WarpService) RegisterWarp(ep *model.Endpoint) error {
|
||||
},
|
||||
}
|
||||
|
||||
warpData := map[string]interface{}{
|
||||
"access_token": token,
|
||||
"device_id": deviceId,
|
||||
"license_key": license,
|
||||
}
|
||||
|
||||
ep.Ext, err = json.MarshalIndent(warpData, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var epOptions map[string]interface{}
|
||||
err = json.Unmarshal(ep.Options, &epOptions)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
package sub
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type ClashService struct {
|
||||
service.SettingService
|
||||
JsonService
|
||||
LinkService
|
||||
}
|
||||
|
||||
const basicClashConfig = `mixed-port: 7890
|
||||
allow-lan: false
|
||||
mode: rule
|
||||
log-level: info
|
||||
external-controller: 127.0.0.1:9090
|
||||
tun:
|
||||
enable: true
|
||||
stack: system
|
||||
auto-route: true
|
||||
auto-detect-interface: true
|
||||
dns-hijack:
|
||||
- any:53
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
enhanced-mode: fake-ip
|
||||
fake-ip-range: 198.18.0.1/16
|
||||
default-nameserver:
|
||||
- 8.8.8.8
|
||||
- 1.1.1.1
|
||||
nameserver:
|
||||
- https://doh.pub/dns-query
|
||||
- https://1.0.0.1/dns-query
|
||||
fallback:
|
||||
- tcp://9.9.9.9:53
|
||||
fake-ip-filter:
|
||||
- "*.lan"
|
||||
- localhost
|
||||
- "*.local"
|
||||
rules:
|
||||
- GEOIP,Private,DIRECT
|
||||
- MATCH,Proxy
|
||||
`
|
||||
|
||||
const ProxyGroups = `- name: Proxy
|
||||
type: select
|
||||
proxies: []
|
||||
- name: Auto
|
||||
type: url-test
|
||||
proxies: []
|
||||
url: http://www.gstatic.com/generate_204
|
||||
interval: 300
|
||||
tolerance: 50
|
||||
`
|
||||
|
||||
func (s *ClashService) GetClash(subId string) (*string, []string, error) {
|
||||
|
||||
client, inDatas, err := s.getData(subId)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
outbounds, outTags, err := s.getOutbounds(client.Config, inDatas)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
links := s.LinkService.GetLinks(&client.Links, "external", "")
|
||||
tagNumEnable := 0
|
||||
if len(links) > 1 {
|
||||
tagNumEnable = 1
|
||||
}
|
||||
for index, link := range links {
|
||||
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
|
||||
if err == nil && len(tag) > 0 {
|
||||
*outbounds = append(*outbounds, *json)
|
||||
*outTags = append(*outTags, tag)
|
||||
}
|
||||
}
|
||||
|
||||
basicConfig, err := s.getClashConfig()
|
||||
if err != nil || len(basicConfig) == 0 {
|
||||
basicConfig = basicClashConfig
|
||||
}
|
||||
|
||||
resultStr, err := s.ConvertToClashMeta(outbounds, basicConfig)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
updateInterval, _ := s.SettingService.GetSubUpdates()
|
||||
headers := util.GetHeaders(client, updateInterval)
|
||||
|
||||
return &resultStr, headers, nil
|
||||
}
|
||||
|
||||
func (s *ClashService) getClashConfig() (string, error) {
|
||||
subClashExt, err := s.SettingService.GetSubClashExt()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return subClashExt, nil
|
||||
}
|
||||
|
||||
func (s *ClashService) ConvertToClashMeta(outbounds *[]map[string]interface{}, basicConfig string) (string, error) {
|
||||
var proxies []interface{}
|
||||
proxyTags := make([]string, 0)
|
||||
for _, obMap := range *outbounds {
|
||||
|
||||
t, _ := obMap["type"].(string)
|
||||
if t == "selector" || t == "urltest" || t == "direct" {
|
||||
continue
|
||||
}
|
||||
|
||||
proxy := make(map[string]interface{})
|
||||
proxy["name"] = obMap["tag"]
|
||||
proxy["type"] = t
|
||||
|
||||
server, _ := obMap["server"].(string)
|
||||
if len(server) > 0 && strings.Contains(server, ":") && !strings.Contains(server, ".") && !(strings.HasPrefix(server, "[") && strings.HasSuffix(server, "]")) {
|
||||
server = "'[" + server + "]'"
|
||||
}
|
||||
proxy["server"] = server
|
||||
|
||||
proxy["port"] = obMap["server_port"]
|
||||
|
||||
switch t {
|
||||
case "vmess", "vless", "tuic":
|
||||
proxy["uuid"] = obMap["uuid"]
|
||||
if t == "vmess" {
|
||||
if alterId, ok := obMap["alter_id"].(float64); ok {
|
||||
proxy["alterId"] = int(alterId)
|
||||
} else {
|
||||
proxy["alterId"] = 0
|
||||
}
|
||||
proxy["cipher"] = "auto"
|
||||
}
|
||||
if t == "vless" {
|
||||
if flow, ok := obMap["flow"].(string); ok {
|
||||
proxy["flow"] = flow
|
||||
}
|
||||
}
|
||||
if t == "tuic" {
|
||||
proxy["password"] = obMap["password"]
|
||||
if congestion_control, ok := obMap["congestion_control"].(string); ok {
|
||||
proxy["congestion-controller"] = congestion_control
|
||||
}
|
||||
}
|
||||
case "trojan":
|
||||
proxy["password"] = obMap["password"]
|
||||
case "socks", "http":
|
||||
if t == "socks" {
|
||||
proxy["type"] = "socks5"
|
||||
}
|
||||
proxy["username"] = obMap["username"]
|
||||
proxy["password"] = obMap["password"]
|
||||
case "hysteria", "hysteria2":
|
||||
if _, ok := obMap["up_mbps"].(float64); ok {
|
||||
proxy["up"] = obMap["up_mbps"]
|
||||
}
|
||||
if _, ok := obMap["down_mbps"].(float64); ok {
|
||||
proxy["down"] = obMap["down_mbps"]
|
||||
}
|
||||
if t == "hysteria" {
|
||||
proxy["auth-str"] = obMap["auth_str"]
|
||||
if obfs, ok := obMap["obfs"].(string); ok {
|
||||
proxy["obfs"] = obfs
|
||||
}
|
||||
} else {
|
||||
proxy["password"] = obMap["password"]
|
||||
if obfs, ok := obMap["obfs"].(map[string]interface{}); ok {
|
||||
proxy["obfs"] = obfs["type"]
|
||||
proxy["obfs-password"] = obfs["password"]
|
||||
}
|
||||
}
|
||||
|
||||
if portLists, ok := obMap["server_ports"].([]interface{}); ok {
|
||||
var ports []string
|
||||
for _, portList := range portLists {
|
||||
portRange, _ := portList.(string)
|
||||
ports = append(ports, strings.ReplaceAll(portRange, ":", "-"))
|
||||
}
|
||||
proxy["ports"] = strings.Join(ports, ",")
|
||||
}
|
||||
case "anytls":
|
||||
proxy["password"] = obMap["password"]
|
||||
if tls, ok := obMap["tls"].(map[string]interface{}); ok {
|
||||
proxy["sni"] = tls["server_name"]
|
||||
proxy["skip-cert-verify"] = tls["insecure"]
|
||||
}
|
||||
case "shadowsocks":
|
||||
proxy["type"] = "ss"
|
||||
proxy["cipher"] = obMap["method"]
|
||||
proxy["password"] = obMap["password"]
|
||||
if network, ok := obMap["network"].(string); ok && network != "tcp" {
|
||||
proxy["udp"] = true
|
||||
}
|
||||
if uot, ok := obMap["udp_over_tcp"].(bool); ok && uot {
|
||||
proxy["udp-over-tcp"] = true
|
||||
}
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
// TLS params
|
||||
tls, isTls := obMap["tls"].(map[string]interface{})
|
||||
if isTls {
|
||||
tlsEnabled, ok := tls["enabled"].(bool)
|
||||
if ok && !tlsEnabled {
|
||||
isTls = false
|
||||
}
|
||||
}
|
||||
if isTls {
|
||||
proxy["tls"] = tls["enabled"]
|
||||
|
||||
// ALPN if exists
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
proxy["alpn"] = alpn
|
||||
}
|
||||
|
||||
// Add reality if exists
|
||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
||||
reality_opts := make(map[string]interface{})
|
||||
if pbk, ok := reality["public_key"].(string); ok {
|
||||
reality_opts["public-key"] = pbk
|
||||
}
|
||||
if sid, ok := reality["short_id"].(string); ok {
|
||||
reality_opts["short-id"] = sid
|
||||
}
|
||||
proxy["reality-opts"] = reality_opts
|
||||
}
|
||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||
if enabled, ok := utls["enabled"].(bool); ok && enabled {
|
||||
if fp, ok := utls["fingerprint"].(string); ok {
|
||||
proxy["client-fingerprint"] = fp
|
||||
}
|
||||
}
|
||||
}
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
if t == "vless" || t == "vmess" {
|
||||
proxy["servername"] = sni
|
||||
} else {
|
||||
proxy["sni"] = sni
|
||||
}
|
||||
}
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
proxy["skip-cert-verify"] = insecure
|
||||
}
|
||||
// ech outbounds
|
||||
if ech, ok := tls["ech"].(map[string]interface{}); ok && ech["enabled"].(bool) {
|
||||
ech_config, _ := ech["config"].([]interface{})
|
||||
ech_string := ""
|
||||
for i := 1; i < len(ech_config)-1; i++ {
|
||||
ech_string += ech_config[i].(string)
|
||||
}
|
||||
proxy["ech-opts"] = map[string]interface{}{
|
||||
"enable": true,
|
||||
"config": ech_string,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Transport if exist
|
||||
if transport, ok := obMap["transport"].(map[string]interface{}); ok {
|
||||
tt, _ := transport["type"].(string)
|
||||
switch tt {
|
||||
case "http":
|
||||
httpOpts := make(map[string]interface{})
|
||||
if path, ok := transport["path"].([]interface{}); ok {
|
||||
httpOpts["path"] = path[0]
|
||||
} else if path, ok := transport["path"].(string); ok {
|
||||
httpOpts["path"] = path
|
||||
}
|
||||
if host, ok := transport["host"].([]interface{}); ok {
|
||||
httpOpts["host"] = host[0]
|
||||
}
|
||||
if isTls {
|
||||
proxy["network"] = "h2"
|
||||
proxy["h2-opts"] = httpOpts
|
||||
} else {
|
||||
proxy["network"] = "http"
|
||||
proxy["http-opts"] = map[string]interface{}{"path": []interface{}{httpOpts["path"]}, "host": httpOpts["host"]}
|
||||
}
|
||||
case "ws", "httpupgrade":
|
||||
proxy["network"] = "ws"
|
||||
wsOpts := make(map[string]interface{})
|
||||
if path, ok := transport["path"].(string); ok {
|
||||
wsOpts["path"] = path
|
||||
}
|
||||
if headers, ok := transport["headers"].([]interface{}); ok {
|
||||
wsOpts["headers"] = headers
|
||||
}
|
||||
if ed, ok := transport["early_data_header_name"].(string); ok {
|
||||
wsOpts["early-data-header-name"] = ed
|
||||
}
|
||||
if tt == "httpupgrade" {
|
||||
wsOpts["v2ray-http-upgrade"] = true
|
||||
}
|
||||
proxy["ws-opts"] = wsOpts
|
||||
case "grpc":
|
||||
proxy["network"] = "grpc"
|
||||
grpcOpts := make(map[string]interface{})
|
||||
if service_name, ok := transport["service_name"].(string); ok {
|
||||
grpcOpts["grpc-service-name"] = service_name
|
||||
}
|
||||
proxy["grpc-opts"] = grpcOpts
|
||||
}
|
||||
}
|
||||
|
||||
// Multiplex
|
||||
if mux, ok := obMap["multiplex"].(map[string]interface{}); ok {
|
||||
if enabled, ok := mux["enabled"].(bool); ok && enabled {
|
||||
smux := make(map[string]interface{})
|
||||
smux["enabled"] = true
|
||||
if protocol, ok := mux["protocol"].(string); ok {
|
||||
smux["protocol"] = protocol
|
||||
}
|
||||
if _, ok := mux["max_connections"].(float64); ok {
|
||||
smux["max-connections"] = mux["max_connections"]
|
||||
}
|
||||
if _, ok := mux["min_streams"].(float64); ok {
|
||||
smux["min-streams"] = mux["min_streams"]
|
||||
}
|
||||
if _, ok := mux["max_streams"].(float64); ok {
|
||||
smux["max-streams"] = mux["max_streams"]
|
||||
}
|
||||
if _, ok := mux["padding"].(bool); ok {
|
||||
smux["padding"] = mux["padding"]
|
||||
}
|
||||
if brutal, ok := mux["brutal"].(map[string]interface{}); ok {
|
||||
if enabled, ok := brutal["enabled"].(bool); ok && enabled {
|
||||
brutalOpts := make(map[string]interface{})
|
||||
brutalOpts["enabled"] = true
|
||||
if _, ok := brutal["up_mbps"].(float64); ok {
|
||||
brutalOpts["up"] = brutal["up_mbps"]
|
||||
}
|
||||
if _, ok := brutal["down_mbps"].(float64); ok {
|
||||
brutalOpts["down"] = brutal["down_mbps"]
|
||||
}
|
||||
smux["brutal-opts"] = brutalOpts
|
||||
}
|
||||
}
|
||||
proxy["smux"] = smux
|
||||
}
|
||||
}
|
||||
|
||||
proxies = append(proxies, proxy)
|
||||
proxyTags = append(proxyTags, obMap["tag"].(string))
|
||||
}
|
||||
|
||||
var proxyGroups []map[string]interface{}
|
||||
err := yaml.Unmarshal([]byte(ProxyGroups), &proxyGroups)
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
}
|
||||
|
||||
proxyGroups[1]["proxies"] = proxyTags
|
||||
proxyGroups[0]["proxies"] = append([]string{proxyGroups[1]["name"].(string)}, proxyTags...)
|
||||
|
||||
// Merge proxies and proxy groups if exist
|
||||
var output map[string]interface{}
|
||||
err = yaml.Unmarshal([]byte(basicConfig), &output)
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
}
|
||||
|
||||
if p, ok := output["proxies"].([]interface{}); ok {
|
||||
output["proxies"] = append(p, proxies...)
|
||||
} else {
|
||||
output["proxies"] = proxies
|
||||
}
|
||||
|
||||
if pg, ok := output["proxy-groups"].([]interface{}); ok {
|
||||
output["proxy-groups"] = append(pg, proxyGroups[0], proxyGroups[1])
|
||||
} else {
|
||||
output["proxy-groups"] = proxyGroups
|
||||
}
|
||||
|
||||
result, err := yaml.Marshal(output)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(result), nil
|
||||
}
|
||||
+64
-18
@@ -3,10 +3,12 @@ package sub
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/service"
|
||||
"s-ui/util"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
)
|
||||
|
||||
const defaultJson = `
|
||||
@@ -46,22 +48,26 @@ type JsonService struct {
|
||||
LinkService
|
||||
}
|
||||
|
||||
func (j *JsonService) GetJson(subId string, format string) (*string, error) {
|
||||
func (j *JsonService) GetJson(subId string, format string) (*string, []string, error) {
|
||||
var jsonConfig map[string]interface{}
|
||||
|
||||
client, inDatas, err := j.getData(subId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
outbounds, outTags, err := j.getOutbounds(client.Config, inDatas)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
links := j.LinkService.GetLinks(&client.Links, "external", "")
|
||||
tagNumEnable := 0
|
||||
if len(links) > 1 {
|
||||
tagNumEnable = 1
|
||||
}
|
||||
for index, link := range links {
|
||||
json, tag, err := util.GetOutbound(link, index)
|
||||
json, tag, err := util.GetOutbound(link, (index+1)*tagNumEnable)
|
||||
if err == nil && len(tag) > 0 {
|
||||
*outbounds = append(*outbounds, *json)
|
||||
*outTags = append(*outTags, tag)
|
||||
@@ -72,7 +78,7 @@ func (j *JsonService) GetJson(subId string, format string) (*string, error) {
|
||||
|
||||
err = json.Unmarshal([]byte(defaultJson), &jsonConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
jsonConfig["outbounds"] = outbounds
|
||||
@@ -82,7 +88,11 @@ func (j *JsonService) GetJson(subId string, format string) (*string, error) {
|
||||
|
||||
result, _ := json.MarshalIndent(jsonConfig, "", " ")
|
||||
resultStr := string(result)
|
||||
return &resultStr, nil
|
||||
|
||||
updateInterval, _ := j.SettingService.GetSubUpdates()
|
||||
headers := util.GetHeaders(client, updateInterval)
|
||||
|
||||
return &resultStr, headers, nil
|
||||
}
|
||||
|
||||
func (j *JsonService) getData(subId string) (*model.Client, []*model.Inbound, error) {
|
||||
@@ -124,9 +134,34 @@ func (j *JsonService) getOutbounds(clientConfig json.RawMessage, inbounds []*mod
|
||||
return nil, nil, err
|
||||
}
|
||||
protocol, _ := outbound["type"].(string)
|
||||
config, _ := configs[protocol].(map[string]interface{})
|
||||
for key, value := range config {
|
||||
if key != "alterId" && key != "name" {
|
||||
|
||||
// Shadowsocks
|
||||
if protocol == "shadowsocks" {
|
||||
var userPass []string
|
||||
var inbOptions map[string]interface{}
|
||||
err = json.Unmarshal(inData.Options, &inbOptions)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
method, _ := inbOptions["method"].(string)
|
||||
if strings.HasPrefix(method, "2022") {
|
||||
inbPass, _ := inbOptions["password"].(string)
|
||||
userPass = append(userPass, inbPass)
|
||||
}
|
||||
var pass string
|
||||
if method == "2022-blake3-aes-128-gcm" {
|
||||
pass, _ = configs["shadowsocks16"].(map[string]interface{})["password"].(string)
|
||||
} else {
|
||||
pass, _ = configs["shadowsocks"].(map[string]interface{})["password"].(string)
|
||||
}
|
||||
userPass = append(userPass, pass)
|
||||
outbound["password"] = strings.Join(userPass, ":")
|
||||
} else { // Other protocols
|
||||
config, _ := configs[protocol].(map[string]interface{})
|
||||
for key, value := range config {
|
||||
if key == "name" || key == "alterId" || (key == "flow" && inData.TlsId == 0) {
|
||||
continue
|
||||
}
|
||||
outbound[key] = value
|
||||
}
|
||||
}
|
||||
@@ -210,20 +245,27 @@ func (j *JsonService) addDefaultOutbounds(outbounds *[]map[string]interface{}, o
|
||||
}
|
||||
|
||||
func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
||||
rules := []interface{}{
|
||||
rules_start := []interface{}{
|
||||
map[string]interface{}{
|
||||
"clash_mode": "Direct",
|
||||
"outbound": "direct",
|
||||
"action": "sniff",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"clash_mode": "Direct",
|
||||
"action": "route",
|
||||
"outbound": "direct",
|
||||
},
|
||||
}
|
||||
rules_end := []interface{}{
|
||||
map[string]interface{}{
|
||||
"clash_mode": "Global",
|
||||
"action": "route",
|
||||
"outbound": "proxy",
|
||||
},
|
||||
}
|
||||
route := map[string]interface{}{
|
||||
"auto_detect_interface": true,
|
||||
"final": "proxy",
|
||||
"rules": rules,
|
||||
"rules": rules_start,
|
||||
}
|
||||
|
||||
othersStr, err := j.SettingService.GetSubJsonExt()
|
||||
@@ -255,7 +297,11 @@ func (j *JsonService) addOthers(jsonConfig *map[string]interface{}) error {
|
||||
route["rule_set"] = othersJson["rule_set"]
|
||||
}
|
||||
if settingRules, ok := othersJson["rules"].([]interface{}); ok {
|
||||
route["rules"] = append(rules, settingRules...)
|
||||
rules := append(rules_start, settingRules...)
|
||||
route["rules"] = append(rules, rules_end...)
|
||||
}
|
||||
if defaultDomainResolver, ok := othersJson["default_domain_resolver"].(string); ok {
|
||||
route["default_domain_resolver"] = defaultDomainResolver
|
||||
}
|
||||
(*jsonConfig)["route"] = route
|
||||
|
||||
|
||||
+5
-34
@@ -1,13 +1,11 @@
|
||||
package sub
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"s-ui/logger"
|
||||
"s-ui/util"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
@@ -31,7 +29,8 @@ func (s *LinkService) GetLinks(linkJson *json.RawMessage, types string, clientIn
|
||||
case "external":
|
||||
result = append(result, link.Uri)
|
||||
case "sub":
|
||||
result = append(result, s.getExternalSub(link.Uri)...)
|
||||
subLinks := util.GetExternalLink(link.Uri)
|
||||
result = append(result, strings.Split(subLinks, "\n")...)
|
||||
case "local":
|
||||
if types == "all" {
|
||||
result = append(result, s.addClientInfo(link.Uri, clientInfo))
|
||||
@@ -73,31 +72,3 @@ func (s *LinkService) addClientInfo(uri string, clientInfo string) string {
|
||||
return uri + clientInfo
|
||||
}
|
||||
}
|
||||
|
||||
func (s *LinkService) getExternalSub(url string) []string {
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
// Make the HTTP request
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
logger.Warning("sub: Error making HTTP request:", err)
|
||||
return nil
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
// Read the response body
|
||||
body, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
logger.Warning("sub: Error reading response body:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert if the content is Base64 encoded
|
||||
links := util.StrOrBase64Encoded(string(body))
|
||||
return strings.Split(links, "\n")
|
||||
|
||||
}
|
||||
|
||||
+17
-9
@@ -6,12 +6,14 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"s-ui/config"
|
||||
"s-ui/logger"
|
||||
"s-ui/middleware"
|
||||
"s-ui/network"
|
||||
"s-ui/service"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/middleware"
|
||||
"github.com/alireza0/s-ui/network"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -132,20 +134,26 @@ func (s *Server) Start() (err error) {
|
||||
}
|
||||
|
||||
func (s *Server) Stop() error {
|
||||
s.cancel()
|
||||
var err error
|
||||
if s.httpServer != nil {
|
||||
err = s.httpServer.Shutdown(s.ctx)
|
||||
shutdownCtx, cancelShutdown := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
err = s.httpServer.Shutdown(shutdownCtx)
|
||||
cancelShutdown()
|
||||
if err != nil {
|
||||
s.cancel()
|
||||
if s.listener != nil {
|
||||
_ = s.listener.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
if s.listener != nil {
|
||||
} else if s.listener != nil {
|
||||
err = s.listener.Close()
|
||||
if err != nil {
|
||||
s.cancel()
|
||||
return err
|
||||
}
|
||||
}
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+41
-14
@@ -1,8 +1,8 @@
|
||||
package sub
|
||||
|
||||
import (
|
||||
"s-ui/logger"
|
||||
"s-ui/service"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -11,6 +11,7 @@ type SubHandler struct {
|
||||
service.SettingService
|
||||
SubService
|
||||
JsonService
|
||||
ClashService
|
||||
}
|
||||
|
||||
func NewSubHandler(g *gin.RouterGroup) {
|
||||
@@ -20,32 +21,58 @@ func NewSubHandler(g *gin.RouterGroup) {
|
||||
|
||||
func (s *SubHandler) initRouter(g *gin.RouterGroup) {
|
||||
g.GET("/:subid", s.subs)
|
||||
g.HEAD("/:subid", s.subHeaders)
|
||||
}
|
||||
|
||||
func (s *SubHandler) subs(c *gin.Context) {
|
||||
var headers []string
|
||||
var result *string
|
||||
var err error
|
||||
subId := c.Param("subid")
|
||||
format, isFormat := c.GetQuery("format")
|
||||
if isFormat {
|
||||
result, err := s.JsonService.GetJson(subId, format)
|
||||
switch format {
|
||||
case "json":
|
||||
result, headers, err = s.JsonService.GetJson(subId, format)
|
||||
case "clash":
|
||||
result, headers, err = s.ClashService.GetClash(subId)
|
||||
}
|
||||
if err != nil || result == nil {
|
||||
logger.Error(err)
|
||||
c.String(400, "Error!")
|
||||
} else {
|
||||
c.String(200, *result)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
result, headers, err := s.SubService.GetSubs(subId)
|
||||
result, headers, err = s.SubService.GetSubs(subId)
|
||||
if err != nil || result == nil {
|
||||
logger.Error(err)
|
||||
c.String(400, "Error!")
|
||||
} else {
|
||||
|
||||
// Add headers
|
||||
c.Writer.Header().Set("Subscription-Userinfo", headers[0])
|
||||
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
|
||||
c.Writer.Header().Set("Profile-Title", headers[2])
|
||||
|
||||
c.String(200, *result)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
s.addHeaders(c, headers)
|
||||
|
||||
c.String(200, *result)
|
||||
}
|
||||
|
||||
func (s *SubHandler) subHeaders(c *gin.Context) {
|
||||
subId := c.Param("subid")
|
||||
client, err := s.SubService.getClientBySubId(subId)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
c.String(400, "Error!")
|
||||
return
|
||||
}
|
||||
|
||||
headers := s.SubService.getClientHeaders(client)
|
||||
s.addHeaders(c, headers)
|
||||
|
||||
c.Status(200)
|
||||
}
|
||||
|
||||
func (s *SubHandler) addHeaders(c *gin.Context, headers []string) {
|
||||
c.Writer.Header().Set("Subscription-Userinfo", headers[0])
|
||||
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
|
||||
c.Writer.Header().Set("Profile-Title", headers[2])
|
||||
}
|
||||
|
||||
+22
-11
@@ -3,11 +3,13 @@ package sub
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"s-ui/database"
|
||||
"s-ui/database/model"
|
||||
"s-ui/service"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/database"
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
"github.com/alireza0/s-ui/util"
|
||||
)
|
||||
|
||||
type SubService struct {
|
||||
@@ -18,9 +20,7 @@ type SubService struct {
|
||||
func (s *SubService) GetSubs(subId string) (*string, []string, error) {
|
||||
var err error
|
||||
|
||||
db := database.GetDB()
|
||||
client := &model.Client{}
|
||||
err = db.Model(model.Client{}).Where("enable = true and name = ?", subId).First(client).Error
|
||||
client, err := s.getClientBySubId(subId)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -34,11 +34,7 @@ func (s *SubService) GetSubs(subId string) (*string, []string, error) {
|
||||
linksArray := s.LinkService.GetLinks(&client.Links, "all", clientInfo)
|
||||
result := strings.Join(linksArray, "\n")
|
||||
|
||||
var headers []string
|
||||
updateInterval, _ := s.SettingService.GetSubUpdates()
|
||||
headers = append(headers, fmt.Sprintf("upload=%d; download=%d; total=%d; expire=%d", client.Up, client.Down, client.Volume, client.Expiry))
|
||||
headers = append(headers, fmt.Sprintf("%d", updateInterval))
|
||||
headers = append(headers, subId)
|
||||
headers := s.getClientHeaders(client)
|
||||
|
||||
subEncode, _ := s.SettingService.GetSubEncode()
|
||||
if subEncode {
|
||||
@@ -48,6 +44,21 @@ func (s *SubService) GetSubs(subId string) (*string, []string, error) {
|
||||
return &result, headers, nil
|
||||
}
|
||||
|
||||
func (j *SubService) getClientBySubId(subId string) (*model.Client, error) {
|
||||
db := database.GetDB()
|
||||
client := &model.Client{}
|
||||
err := db.Model(model.Client{}).Where("enable = true and name = ?", subId).First(client).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (s *SubService) getClientHeaders(client *model.Client) []string {
|
||||
updateInterval, _ := s.SettingService.GetSubUpdates()
|
||||
return util.GetHeaders(client, updateInterval)
|
||||
}
|
||||
|
||||
func (s *SubService) getClientInfo(c *model.Client) string {
|
||||
now := time.Now().Unix()
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package common
|
||||
|
||||
// UnionUintArray returns a new unique slice that contains all elements from both input slices
|
||||
func UnionUintArray(a []uint, b []uint) []uint {
|
||||
m := make(map[uint]bool)
|
||||
for _, v := range a {
|
||||
m[v] = true
|
||||
}
|
||||
for _, v := range b {
|
||||
m[v] = true
|
||||
}
|
||||
var res []uint
|
||||
for k := range m {
|
||||
res = append(res, k)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// Find different elements in two slices
|
||||
// Returns elements in 'a' that are not in 'b' and elements in 'b' that are not in 'a'
|
||||
func DiffUintArray(a []uint, b []uint) []uint {
|
||||
different := []uint{}
|
||||
set := make(map[uint]bool)
|
||||
|
||||
for _, item := range a {
|
||||
set[item] = true
|
||||
}
|
||||
for _, item := range b {
|
||||
if !set[item] {
|
||||
different = append(different, item)
|
||||
}
|
||||
}
|
||||
|
||||
set = make(map[uint]bool)
|
||||
for _, item := range b {
|
||||
set[item] = true
|
||||
}
|
||||
for _, item := range a {
|
||||
if !set[item] {
|
||||
different = append(different, item)
|
||||
}
|
||||
}
|
||||
|
||||
return different
|
||||
}
|
||||
+2
-1
@@ -3,7 +3,8 @@ package common
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"s-ui/logger"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
)
|
||||
|
||||
func NewErrorf(format string, a ...interface{}) error {
|
||||
|
||||
+40
-15
@@ -1,30 +1,55 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
crand "crypto/rand"
|
||||
"math/big"
|
||||
mrand "math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
allSeq []rune
|
||||
rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
allSeq []rune = []rune{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
}
|
||||
|
||||
fallbackRand = mrand.New(mrand.NewSource(time.Now().UnixNano()))
|
||||
fallbackMu = sync.Mutex{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
chars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
for _, char := range chars {
|
||||
allSeq = append(allSeq, char)
|
||||
}
|
||||
}
|
||||
|
||||
func Random(n int) string {
|
||||
runes := make([]rune, n)
|
||||
for i := 0; i < n; i++ {
|
||||
runes[i] = allSeq[rnd.Intn(len(allSeq))]
|
||||
if n <= 0 || len(allSeq) == 0 {
|
||||
return ""
|
||||
}
|
||||
return string(runes)
|
||||
result := make([]rune, n)
|
||||
maxBig := big.NewInt(int64(len(allSeq)))
|
||||
for i := 0; i < n; i++ {
|
||||
num, err := crand.Int(crand.Reader, maxBig)
|
||||
if err != nil {
|
||||
// fallback
|
||||
fallbackMu.Lock()
|
||||
result[i] = allSeq[fallbackRand.Intn(len(allSeq))]
|
||||
fallbackMu.Unlock()
|
||||
continue
|
||||
}
|
||||
result[i] = allSeq[int(num.Int64())]
|
||||
}
|
||||
return string(result)
|
||||
}
|
||||
|
||||
func RandomInt(n int) int {
|
||||
return rnd.Intn(n)
|
||||
if n <= 0 {
|
||||
return 0
|
||||
}
|
||||
max := big.NewInt(int64(n))
|
||||
result, err := crand.Int(crand.Reader, max)
|
||||
if err != nil {
|
||||
// fallback
|
||||
fallbackMu.Lock()
|
||||
defer fallbackMu.Unlock()
|
||||
return fallbackRand.Intn(n)
|
||||
}
|
||||
return int(result.Int64())
|
||||
}
|
||||
|
||||
+259
-205
@@ -5,12 +5,18 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"s-ui/database/model"
|
||||
"s-ui/util/common"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
)
|
||||
|
||||
var InboundTypeWithLink = []string{"shadowsocks", "naive", "hysteria", "hysteria2", "tuic", "vless", "trojan", "vmess"}
|
||||
var InboundTypeWithLink = []string{"socks", "http", "mixed", "shadowsocks", "naive", "hysteria", "hysteria2", "anytls", "tuic", "vless", "trojan", "vmess"}
|
||||
|
||||
type LinkParam struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname string) []string {
|
||||
inbound, err := i.MarshalFull()
|
||||
@@ -29,7 +35,9 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
|
||||
}
|
||||
|
||||
var Addrs []map[string]interface{}
|
||||
json.Unmarshal(i.Addrs, &Addrs)
|
||||
if err := json.Unmarshal(i.Addrs, &Addrs); err != nil {
|
||||
return []string{}
|
||||
}
|
||||
if len(Addrs) == 0 {
|
||||
Addrs = append(Addrs, map[string]interface{}{
|
||||
"server": hostname,
|
||||
@@ -61,6 +69,15 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
|
||||
}
|
||||
|
||||
switch i.Type {
|
||||
case "socks":
|
||||
return socksLink(userConfig["socks"], Addrs)
|
||||
case "http":
|
||||
return httpLink(userConfig["http"], Addrs)
|
||||
case "mixed":
|
||||
return append(
|
||||
socksLink(userConfig["socks"], Addrs),
|
||||
httpLink(userConfig["http"], Addrs)...,
|
||||
)
|
||||
case "shadowsocks":
|
||||
return shadowsocksLink(userConfig, *inbound, Addrs)
|
||||
case "naive":
|
||||
@@ -73,6 +90,8 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
|
||||
return tuicLink(userConfig["tuic"], *inbound, Addrs)
|
||||
case "vless":
|
||||
return vlessLink(userConfig["vless"], *inbound, Addrs)
|
||||
case "anytls":
|
||||
return anytlsLink(userConfig["anytls"], Addrs)
|
||||
case "trojan":
|
||||
return trojanLink(userConfig["trojan"], *inbound, Addrs)
|
||||
case "vmess":
|
||||
@@ -84,8 +103,12 @@ func LinkGenerator(clientConfig json.RawMessage, i *model.Inbound, hostname stri
|
||||
|
||||
func prepareTls(t *model.Tls) map[string]interface{} {
|
||||
var iTls, oTls map[string]interface{}
|
||||
json.Unmarshal(t.Client, &oTls)
|
||||
json.Unmarshal(t.Server, &iTls)
|
||||
if err := json.Unmarshal(t.Client, &oTls); err != nil {
|
||||
return nil
|
||||
}
|
||||
if err := json.Unmarshal(t.Server, &iTls); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for k, v := range iTls {
|
||||
switch k {
|
||||
@@ -95,8 +118,8 @@ func prepareTls(t *model.Tls) map[string]interface{} {
|
||||
reality := v.(map[string]interface{})
|
||||
clientReality := oTls["reality"].(map[string]interface{})
|
||||
clientReality["enabled"] = reality["enabled"]
|
||||
if short_ids, hasSIds := reality["short_ids"].([]interface{}); hasSIds && len(short_ids) > 0 {
|
||||
clientReality["short_id"] = short_ids[common.RandomInt(len(short_ids))]
|
||||
if shortIDs, hasSIds := reality["short_id"].([]interface{}); hasSIds && len(shortIDs) > 0 {
|
||||
clientReality["short_id"] = shortIDs[common.RandomInt(len(shortIDs))]
|
||||
}
|
||||
oTls["reality"] = clientReality
|
||||
}
|
||||
@@ -104,6 +127,26 @@ func prepareTls(t *model.Tls) map[string]interface{} {
|
||||
return oTls
|
||||
}
|
||||
|
||||
func socksLink(userConfig map[string]interface{}, addrs []map[string]interface{}) []string {
|
||||
var links []string
|
||||
for _, addr := range addrs {
|
||||
links = append(links, fmt.Sprintf("socks5://%s:%s@%s:%d", userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64))))
|
||||
}
|
||||
return links
|
||||
}
|
||||
|
||||
func httpLink(userConfig map[string]interface{}, addrs []map[string]interface{}) []string {
|
||||
var links []string
|
||||
protocol := "http"
|
||||
for _, addr := range addrs {
|
||||
if addr["tls"] != nil {
|
||||
protocol = "https"
|
||||
}
|
||||
links = append(links, fmt.Sprintf("%s://%s:%s@%s:%d", protocol, userConfig["username"], userConfig["password"], addr["server"].(string), uint(addr["server_port"].(float64))))
|
||||
}
|
||||
return links
|
||||
}
|
||||
|
||||
func shadowsocksLink(
|
||||
userConfig map[string]map[string]interface{},
|
||||
inbound map[string]interface{},
|
||||
@@ -128,7 +171,7 @@ func shadowsocksLink(
|
||||
var links []string
|
||||
for _, addr := range addrs {
|
||||
port, _ := addr["server_port"].(float64)
|
||||
links = append(links, fmt.Sprintf("%s@%s:%d", uriBase, addr["server"].(string), uint(port)))
|
||||
links = append(links, fmt.Sprintf("%s@%s:%.0f#%s", uriBase, addr["server"].(string), port, addr["remark"].(string)))
|
||||
}
|
||||
return links
|
||||
}
|
||||
@@ -145,31 +188,31 @@ func naiveLink(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := map[string]string{}
|
||||
params["padding"] = "1"
|
||||
var params []LinkParam
|
||||
params = append(params, LinkParam{"padding", "1"})
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["peer"] = sni
|
||||
params = append(params, LinkParam{"peer", sni})
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
params = append(params, LinkParam{"alpn", strings.Join(alpnList, ",")})
|
||||
}
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["insecure"] = "1"
|
||||
params = append(params, LinkParam{"insecure", "1"})
|
||||
}
|
||||
}
|
||||
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
|
||||
params["tfo"] = "1"
|
||||
params = append(params, LinkParam{"tfo", "1"})
|
||||
} else {
|
||||
params["tfo"] = "0"
|
||||
params = append(params, LinkParam{"tfo", "0"})
|
||||
}
|
||||
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%d", username, password, addr["server"].(string), uint(port))))
|
||||
uri := baseUri + toBase64([]byte(fmt.Sprintf("%s:%s@%s:%.0f", username, password, addr["server"].(string), port)))
|
||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||
}
|
||||
return links
|
||||
@@ -184,42 +227,41 @@ func hysteriaLink(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := map[string]string{}
|
||||
if upmbps, ok := inbound["up_mbps"].(string); ok {
|
||||
params["up_mbps"] = upmbps
|
||||
var params []LinkParam
|
||||
if upmbps, ok := inbound["up_mbps"].(float64); ok {
|
||||
params = append(params, LinkParam{"downmbps", fmt.Sprintf("%.0f", upmbps)})
|
||||
}
|
||||
if downmbps, ok := inbound["down_mbps"].(string); ok {
|
||||
params["down_mbps"] = downmbps
|
||||
if downmbps, ok := inbound["down_mbps"].(float64); ok {
|
||||
params = append(params, LinkParam{"upmbps", fmt.Sprintf("%.0f", downmbps)})
|
||||
}
|
||||
if auth, ok := userConfig["auth_str"].(string); ok {
|
||||
params["auth"] = auth
|
||||
params = append(params, LinkParam{"auth", auth})
|
||||
}
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["peer"] = sni
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
}
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["insecure"] = "1"
|
||||
}
|
||||
getTlsParams(¶ms, tls, "insecure")
|
||||
}
|
||||
if obfs, ok := inbound["obfs"].(string); ok {
|
||||
params["obfs"] = obfs
|
||||
params = append(params, LinkParam{"obfs", obfs})
|
||||
}
|
||||
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
|
||||
params["fastopen"] = "1"
|
||||
params = append(params, LinkParam{"fastopen", "1"})
|
||||
} else {
|
||||
params["fastopen"] = "0"
|
||||
params = append(params, LinkParam{"fastopen", "0"})
|
||||
}
|
||||
var outJson map[string]interface{}
|
||||
if err := json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson); err != nil {
|
||||
return []string{} // Handle error
|
||||
}
|
||||
if mport, ok := outJson["server_ports"].([]interface{}); ok {
|
||||
mportList := make([]string, len(mport))
|
||||
for i, v := range mport {
|
||||
mportList[i] = v.(string)
|
||||
}
|
||||
params = append(params, LinkParam{"mport", strings.Join(mportList, ",")})
|
||||
}
|
||||
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
||||
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||
}
|
||||
|
||||
@@ -236,44 +278,65 @@ func hysteria2Link(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := map[string]string{}
|
||||
if upmbps, ok := inbound["up_mbps"].(string); ok {
|
||||
params["up_mbps"] = upmbps
|
||||
var params []LinkParam
|
||||
if upmbps, ok := inbound["up_mbps"].(float64); ok {
|
||||
params = append(params, LinkParam{"downmbps", fmt.Sprintf("%.0f", upmbps)})
|
||||
}
|
||||
if downmbps, ok := inbound["down_mbps"].(string); ok {
|
||||
params["down_mbps"] = downmbps
|
||||
if downmbps, ok := inbound["down_mbps"].(float64); ok {
|
||||
params = append(params, LinkParam{"upmbps", fmt.Sprintf("%.0f", downmbps)})
|
||||
}
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["sni"] = sni
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
}
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["insecure"] = "1"
|
||||
}
|
||||
getTlsParams(¶ms, tls, "insecure")
|
||||
}
|
||||
if obfs, ok := inbound["obfs"].(map[string]interface{}); ok {
|
||||
if obfsType, ok := obfs["type"].(string); ok {
|
||||
params["obfs"] = obfsType
|
||||
params = append(params, LinkParam{"obfs", obfsType})
|
||||
}
|
||||
if obfsPassword, ok := obfs["password"].(string); ok {
|
||||
params["obfs-password"] = obfsPassword
|
||||
params = append(params, LinkParam{"obfs-password", obfsPassword})
|
||||
}
|
||||
}
|
||||
if tfo, ok := inbound["tcp_fast_open"].(bool); ok && tfo {
|
||||
params["fastopen"] = "1"
|
||||
params = append(params, LinkParam{"fastopen", "1"})
|
||||
} else {
|
||||
params["fastopen"] = "0"
|
||||
params = append(params, LinkParam{"fastopen", "0"})
|
||||
}
|
||||
var outJson map[string]interface{}
|
||||
if err := json.Unmarshal(inbound["out_json"].(json.RawMessage), &outJson); err != nil {
|
||||
return []string{} // Handle error
|
||||
}
|
||||
if mport, ok := outJson["server_ports"].([]interface{}); ok {
|
||||
mportList := make([]string, len(mport))
|
||||
for i, v := range mport {
|
||||
mportList[i] = v.(string)
|
||||
}
|
||||
params = append(params, LinkParam{"mport", strings.Join(mportList, ",")})
|
||||
}
|
||||
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
||||
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||
}
|
||||
|
||||
return links
|
||||
}
|
||||
|
||||
func anytlsLink(
|
||||
userConfig map[string]interface{},
|
||||
addrs []map[string]interface{}) []string {
|
||||
|
||||
password, _ := userConfig["password"].(string)
|
||||
baseUri := fmt.Sprintf("%s%s@", "anytls://", password)
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
var params []LinkParam
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||
getTlsParams(¶ms, tls, "insecure")
|
||||
}
|
||||
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||
}
|
||||
|
||||
@@ -291,31 +354,16 @@ func tuicLink(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := map[string]string{}
|
||||
var params []LinkParam
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok {
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["sni"] = sni
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
}
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["insecure"] = "1"
|
||||
}
|
||||
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
|
||||
params["disable_sni"] = "1"
|
||||
}
|
||||
getTlsParams(¶ms, tls, "insecure")
|
||||
}
|
||||
if congestionControl, ok := inbound["congestion_control"].(string); ok {
|
||||
params["congestion_control"] = congestionControl
|
||||
params = append(params, LinkParam{"congestion_control", congestionControl})
|
||||
}
|
||||
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("%s%s:%d", baseUri, addr["server"].(string), uint(port))
|
||||
uri := fmt.Sprintf("%s%s:%.0f", baseUri, addr["server"].(string), port)
|
||||
links = append(links, addParams(uri, params, addr["remark"].(string)))
|
||||
}
|
||||
|
||||
@@ -332,41 +380,16 @@ func vlessLink(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := baseParams
|
||||
params := make([]LinkParam, len(baseParams))
|
||||
copy(params, baseParams)
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
||||
params["security"] = "reality"
|
||||
if pbk, ok := reality["public_key"].(string); ok {
|
||||
params["pbk"] = pbk
|
||||
}
|
||||
if sid, ok := reality["short_id"].(string); ok {
|
||||
params["sid"] = sid
|
||||
}
|
||||
} else {
|
||||
params["security"] = "tls"
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["allowInsecure"] = "1"
|
||||
}
|
||||
}
|
||||
getTlsParams(¶ms, tls, "allowInsecure")
|
||||
if flow, ok := userConfig["flow"].(string); ok {
|
||||
params["flow"] = flow
|
||||
}
|
||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||
params["fingerprint"], _ = utls["fingerprint"].(string)
|
||||
}
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["sni"] = sni
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
params = append(params, LinkParam{"flow", flow})
|
||||
}
|
||||
}
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("vless://%s@%s:%d", uuid, addr["server"].(string), uint(port))
|
||||
uri := fmt.Sprintf("vless://%s@%s:%.0f", uuid, addr["server"].(string), port)
|
||||
uri = addParams(uri, params, addr["remark"].(string))
|
||||
links = append(links, uri)
|
||||
}
|
||||
@@ -383,38 +406,13 @@ func trojanLink(
|
||||
var links []string
|
||||
|
||||
for _, addr := range addrs {
|
||||
params := baseParams
|
||||
params := make([]LinkParam, len(baseParams))
|
||||
copy(params, baseParams)
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
||||
params["security"] = "reality"
|
||||
if pbk, ok := reality["public_key"].(string); ok {
|
||||
params["pbk"] = pbk
|
||||
}
|
||||
if sid, ok := reality["short_id"].(string); ok {
|
||||
params["sid"] = sid
|
||||
}
|
||||
} else {
|
||||
params["security"] = "tls"
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["allowInsecure"] = "1"
|
||||
}
|
||||
}
|
||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||
params["fingerprint"], _ = utls["fingerprint"].(string)
|
||||
}
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["sni"] = sni
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
}
|
||||
getTlsParams(¶ms, tls, "allowInsecure")
|
||||
}
|
||||
port, _ := addr["server_port"].(float64)
|
||||
uri := fmt.Sprintf("trojan://%s@%s:%d", password, addr["server"].(string), uint(port))
|
||||
uri := fmt.Sprintf("trojan://%s@%s:%.0f", password, addr["server"].(string), port)
|
||||
uri = addParams(uri, params, addr["remark"].(string))
|
||||
links = append(links, uri)
|
||||
}
|
||||
@@ -428,51 +426,58 @@ func vmessLink(
|
||||
addrs []map[string]interface{}) []string {
|
||||
|
||||
uuid, _ := userConfig["uuid"].(string)
|
||||
trasportParams := getTransportParams(inbound["transport"])
|
||||
transportParams := getTransportParams(inbound["transport"])
|
||||
var links []string
|
||||
|
||||
baseParams := map[string]interface{}{
|
||||
"v": 2,
|
||||
"v": "2",
|
||||
"id": uuid,
|
||||
"aid": 0,
|
||||
}
|
||||
if trasportParams["type"] == "http" || trasportParams["type"] == "tcp" {
|
||||
|
||||
var net, typ, host, path string
|
||||
for _, p := range transportParams {
|
||||
switch p.Key {
|
||||
case "type":
|
||||
net = p.Value
|
||||
case "host":
|
||||
host = p.Value
|
||||
case "path":
|
||||
path = p.Value
|
||||
}
|
||||
}
|
||||
|
||||
if net == "http" || net == "tcp" {
|
||||
baseParams["net"] = "tcp"
|
||||
if trasportParams["type"] == "http" {
|
||||
baseParams["type"] = "http"
|
||||
if net == "http" {
|
||||
typ = "http"
|
||||
}
|
||||
} else {
|
||||
baseParams["net"] = trasportParams["type"]
|
||||
baseParams["net"] = net
|
||||
}
|
||||
|
||||
for _, addr := range addrs {
|
||||
obj := baseParams
|
||||
obj["add"], _ = addr["server"].(string)
|
||||
port, _ := addr["server_port"].(float64)
|
||||
obj["port"] = uint(port)
|
||||
obj["ps"], _ = addr["remark"].(string)
|
||||
if trasportParams["host"] != "" {
|
||||
obj["host"] = trasportParams["host"]
|
||||
}
|
||||
if trasportParams["path"] != "" {
|
||||
obj["path"] = trasportParams["path"]
|
||||
}
|
||||
if tls, ok := addr["tls"].(map[string]interface{}); ok && tls["enabled"].(bool) {
|
||||
obj["tls"] = "tls"
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
obj["allowInsecure"] = 1
|
||||
}
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
obj["sni"] = sni
|
||||
}
|
||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||
obj["fp"], _ = utls["fingerprint"].(string)
|
||||
}
|
||||
} else {
|
||||
obj["tls"] = "none"
|
||||
obj := make(map[string]interface{})
|
||||
for k, v := range baseParams {
|
||||
obj[k] = v
|
||||
}
|
||||
|
||||
jsonStr, _ := json.MarshalIndent(obj, "", " ")
|
||||
obj["add"], _ = addr["server"].(string)
|
||||
port, _ := addr["server_port"].(float64)
|
||||
obj["port"] = fmt.Sprintf("%.0f", port)
|
||||
obj["ps"], _ = addr["remark"].(string)
|
||||
if typ != "" {
|
||||
obj["type"] = typ
|
||||
}
|
||||
if host != "" {
|
||||
obj["host"] = host
|
||||
}
|
||||
if path != "" {
|
||||
obj["path"] = path
|
||||
}
|
||||
populateVmessTlsParams(obj, addr["tls"])
|
||||
|
||||
jsonStr, _ := json.Marshal(obj)
|
||||
|
||||
uri := fmt.Sprintf("vmess://%s", toBase64(jsonStr))
|
||||
links = append(links, uri)
|
||||
@@ -480,82 +485,131 @@ func vmessLink(
|
||||
return links
|
||||
}
|
||||
|
||||
func toBase64(d []byte) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(d))
|
||||
func populateVmessTlsParams(obj map[string]interface{}, tlsConfig interface{}) {
|
||||
if tlsMap, ok := tlsConfig.(map[string]interface{}); ok && tlsMap["enabled"].(bool) {
|
||||
obj["tls"] = "tls"
|
||||
var tlsParams []LinkParam
|
||||
getTlsParams(&tlsParams, tlsMap, "allowInsecure")
|
||||
for _, p := range tlsParams {
|
||||
switch p.Key {
|
||||
case "security":
|
||||
// ignore, as "tls" is already set
|
||||
case "allowInsecure":
|
||||
obj["allowInsecure"] = 1
|
||||
case "sni":
|
||||
obj["sni"] = p.Value
|
||||
case "fp":
|
||||
obj["fp"] = p.Value
|
||||
case "alpn":
|
||||
obj["alpn"] = p.Value
|
||||
}
|
||||
}
|
||||
} else {
|
||||
obj["tls"] = "none"
|
||||
}
|
||||
}
|
||||
|
||||
func addParams(uri string, params map[string]string, remark string) string {
|
||||
func toBase64(d []byte) string {
|
||||
return base64.StdEncoding.EncodeToString(d)
|
||||
}
|
||||
|
||||
func addParams(uri string, params []LinkParam, remark string) string {
|
||||
URL, _ := url.Parse(uri)
|
||||
q := URL.Query()
|
||||
for k, v := range params {
|
||||
q.Add(k, v)
|
||||
var q []string
|
||||
for _, p := range params {
|
||||
switch p.Key {
|
||||
case "mport", "alpn":
|
||||
q = append(q, fmt.Sprintf("%s=%s", p.Key, p.Value))
|
||||
default:
|
||||
q = append(q, fmt.Sprintf("%s=%s", p.Key, url.QueryEscape(p.Value)))
|
||||
}
|
||||
}
|
||||
URL.RawQuery = q.Encode()
|
||||
URL.RawQuery = strings.Join(q, "&")
|
||||
URL.Fragment = remark
|
||||
return URL.String()
|
||||
}
|
||||
|
||||
func getTransportParams(t interface{}) map[string]string {
|
||||
params := map[string]string{}
|
||||
func getTransportParams(t interface{}) []LinkParam {
|
||||
var params []LinkParam
|
||||
trasport, _ := t.(map[string]interface{})
|
||||
if transportType, ok := trasport["type"].(string); ok {
|
||||
params["type"] = transportType
|
||||
var transportType string
|
||||
if tt, ok := trasport["type"].(string); ok {
|
||||
transportType = tt
|
||||
} else {
|
||||
params["type"] = "tcp"
|
||||
transportType = "tcp"
|
||||
}
|
||||
params = append(params, LinkParam{"type", transportType})
|
||||
if transportType == "tcp" {
|
||||
return params
|
||||
}
|
||||
switch params["type"] {
|
||||
|
||||
switch transportType {
|
||||
case "http":
|
||||
if host, ok := trasport["host"].([]interface{}); ok {
|
||||
var hosts []string
|
||||
for _, v := range host {
|
||||
hosts = append(hosts, v.(string))
|
||||
}
|
||||
params["host"] = strings.Join(hosts, ",")
|
||||
params = append(params, LinkParam{"host", strings.Join(hosts, ",")})
|
||||
}
|
||||
if path, ok := trasport["path"].(string); ok {
|
||||
params["path"] = path
|
||||
params = append(params, LinkParam{"path", path})
|
||||
}
|
||||
case "ws":
|
||||
if path, ok := trasport["path"].(string); ok {
|
||||
params["path"] = path
|
||||
params = append(params, LinkParam{"path", path})
|
||||
}
|
||||
if headers, ok := trasport["headers"].(map[string]interface{}); ok {
|
||||
if host, ok := headers["Host"].(string); ok {
|
||||
params["peer"] = host
|
||||
params = append(params, LinkParam{"host", host})
|
||||
}
|
||||
}
|
||||
case "grpc":
|
||||
if serviceName, ok := trasport["service_name"].(string); ok {
|
||||
params["serviceName"] = serviceName
|
||||
params = append(params, LinkParam{"serviceName", serviceName})
|
||||
}
|
||||
case "httpupgrade":
|
||||
if host, ok := trasport["host"].(string); ok {
|
||||
params["peer"] = host
|
||||
params = append(params, LinkParam{"host", host})
|
||||
}
|
||||
if path, ok := trasport["path"].(string); ok {
|
||||
params["path"] = path
|
||||
params = append(params, LinkParam{"path", path})
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func getTlsParams(t interface{}) map[string]string {
|
||||
params := map[string]string{}
|
||||
if tls, hasTls := t.(map[string]interface{}); hasTls {
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
params["sni"] = sni
|
||||
func getTlsParams(params *[]LinkParam, tls map[string]interface{}, insecureKey string) {
|
||||
if reality, ok := tls["reality"].(map[string]interface{}); ok && reality["enabled"].(bool) {
|
||||
*params = append(*params, LinkParam{"security", "reality"})
|
||||
if pbk, ok := reality["public_key"].(string); ok {
|
||||
*params = append(*params, LinkParam{"pbk", pbk})
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
params["alpn"] = strings.Join(alpnList, ",")
|
||||
if sid, ok := reality["short_id"].(string); ok {
|
||||
*params = append(*params, LinkParam{"sid", sid})
|
||||
}
|
||||
} else {
|
||||
*params = append(*params, LinkParam{"security", "tls"})
|
||||
if insecure, ok := tls["insecure"].(bool); ok && insecure {
|
||||
params["insecure"] = "1"
|
||||
*params = append(*params, LinkParam{insecureKey, "1"})
|
||||
}
|
||||
if disableSni, ok := tls["disable_sni"].(bool); ok && disableSni {
|
||||
*params = append(*params, LinkParam{"disable_sni", "1"})
|
||||
}
|
||||
}
|
||||
return params
|
||||
if utls, ok := tls["utls"].(map[string]interface{}); ok {
|
||||
if fingerprint, ok := utls["fingerprint"].(string); ok {
|
||||
*params = append(*params, LinkParam{"fp", fingerprint})
|
||||
}
|
||||
}
|
||||
if sni, ok := tls["server_name"].(string); ok {
|
||||
*params = append(*params, LinkParam{"sni", sni})
|
||||
}
|
||||
if alpn, ok := tls["alpn"].([]interface{}); ok {
|
||||
alpnList := make([]string, len(alpn))
|
||||
for i, v := range alpn {
|
||||
alpnList[i] = v.(string)
|
||||
}
|
||||
*params = append(*params, LinkParam{"alpn", strings.Join(alpnList, ",")})
|
||||
}
|
||||
}
|
||||
|
||||
+158
-50
@@ -5,9 +5,10 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"s-ui/util/common"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
)
|
||||
|
||||
func GetOutbound(uri string, i int) (*map[string]interface{}, string, error) {
|
||||
@@ -24,10 +25,14 @@ func GetOutbound(uri string, i int) (*map[string]interface{}, string, error) {
|
||||
return hy(u, i)
|
||||
case "hy2", "hysteria2":
|
||||
return hy2(u, i)
|
||||
case "anytls":
|
||||
return anytls(u, i)
|
||||
case "tuic":
|
||||
return tuic(u, i)
|
||||
case "ss", "shadowsocks":
|
||||
return ss(u, i)
|
||||
case "naive+https", "naive+quic", "http2":
|
||||
return parseNaiveLink(u, i)
|
||||
}
|
||||
}
|
||||
return nil, "", common.NewError("Unsupported link format")
|
||||
@@ -112,9 +117,9 @@ func vmess(data string, i int) (*map[string]interface{}, string, error) {
|
||||
if i > 0 {
|
||||
tag = fmt.Sprintf("%d.%s", i, tag)
|
||||
}
|
||||
alter_id, ok := dataJson["aid"].(int)
|
||||
if !ok {
|
||||
alter_id = 0
|
||||
alter_id := 0
|
||||
if aid, ok := dataJson["aid"].(float64); ok {
|
||||
alter_id = int(aid)
|
||||
}
|
||||
vmess := map[string]interface{}{
|
||||
"type": "vmess",
|
||||
@@ -197,17 +202,9 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
}
|
||||
|
||||
tls := map[string]interface{}{
|
||||
"enabled": true,
|
||||
"server_name": query.Get("peer"),
|
||||
}
|
||||
alpn := query.Get("alpn")
|
||||
insecure := query.Get("insecure")
|
||||
if len(alpn) > 0 {
|
||||
tls["alpn"] = strings.Split(alpn, ",")
|
||||
}
|
||||
if insecure == "1" || insecure == "true" {
|
||||
tls["insecure"] = true
|
||||
security := query.Get("security")
|
||||
if len(security) == 0 {
|
||||
security = "tls"
|
||||
}
|
||||
|
||||
tag := u.Fragment
|
||||
@@ -221,7 +218,7 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
"server_port": port,
|
||||
"obfs": query.Get("obfsParam"),
|
||||
"auth_str": query.Get("auth"),
|
||||
"tls": tls,
|
||||
"tls": getTls(security, &query),
|
||||
}
|
||||
down, _ := strconv.Atoi(query.Get("downmbps"))
|
||||
up, _ := strconv.Atoi(query.Get("upmbps"))
|
||||
@@ -250,17 +247,9 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
}
|
||||
|
||||
tls := map[string]interface{}{
|
||||
"enabled": true,
|
||||
"server_name": query.Get("sni"),
|
||||
}
|
||||
alpn := query.Get("alpn")
|
||||
insecure := query.Get("insecure")
|
||||
if len(alpn) > 0 {
|
||||
tls["alpn"] = strings.Split(alpn, ",")
|
||||
}
|
||||
if insecure == "1" || insecure == "true" {
|
||||
tls["insecure"] = true
|
||||
security := query.Get("security")
|
||||
if len(security) == 0 {
|
||||
security = "tls"
|
||||
}
|
||||
|
||||
tag := u.Fragment
|
||||
@@ -273,11 +262,13 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
"server": host,
|
||||
"server_port": port,
|
||||
"password": u.User.Username(),
|
||||
"tls": tls,
|
||||
"tls": getTls(security, &query),
|
||||
}
|
||||
down, _ := strconv.Atoi(query.Get("downmbps"))
|
||||
up, _ := strconv.Atoi(query.Get("upmbps"))
|
||||
obfs := query.Get("obfs")
|
||||
mport := strings.ReplaceAll(query.Get("mport"), "-", ":")
|
||||
fastopen := query.Get("fastopen")
|
||||
if down > 0 {
|
||||
hy2["down_mbps"] = down
|
||||
}
|
||||
@@ -290,9 +281,43 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
"password": query.Get("obfs-password"),
|
||||
}
|
||||
}
|
||||
if len(mport) > 0 {
|
||||
hy2["server_ports"] = strings.Split(mport, ",")
|
||||
}
|
||||
if fastopen == "1" || fastopen == "true" {
|
||||
hy2["fastopen"] = true
|
||||
}
|
||||
return &hy2, tag, nil
|
||||
}
|
||||
|
||||
func anytls(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
query, _ := url.ParseQuery(u.RawQuery)
|
||||
host, portStr, _ := net.SplitHostPort(u.Host)
|
||||
port := 443
|
||||
if len(portStr) > 0 {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
}
|
||||
|
||||
security := query.Get("security")
|
||||
if len(security) == 0 {
|
||||
security = "tls"
|
||||
}
|
||||
|
||||
tag := u.Fragment
|
||||
if i > 0 {
|
||||
tag = fmt.Sprintf("%d.%s", i, u.Fragment)
|
||||
}
|
||||
anytls := map[string]interface{}{
|
||||
"type": "anytls",
|
||||
"tag": tag,
|
||||
"server": host,
|
||||
"server_port": port,
|
||||
"password": u.User.Username(),
|
||||
"tls": getTls(security, &query),
|
||||
}
|
||||
return &anytls, tag, nil
|
||||
}
|
||||
|
||||
func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
query, _ := url.ParseQuery(u.RawQuery)
|
||||
host, portStr, _ := net.SplitHostPort(u.Host)
|
||||
@@ -301,21 +326,9 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
}
|
||||
|
||||
tls := map[string]interface{}{
|
||||
"enabled": true,
|
||||
"server_name": query.Get("sni"),
|
||||
}
|
||||
alpn := query.Get("alpn")
|
||||
insecure := query.Get("allow_insecure")
|
||||
disable_sni := query.Get("disable_sni")
|
||||
if len(alpn) > 0 {
|
||||
tls["alpn"] = strings.Split(alpn, ",")
|
||||
}
|
||||
if insecure == "1" || insecure == "true" {
|
||||
tls["insecure"] = true
|
||||
}
|
||||
if disable_sni == "1" || disable_sni == "true" {
|
||||
tls["disable_sni"] = true
|
||||
security := query.Get("security")
|
||||
if len(security) == 0 {
|
||||
security = "tls"
|
||||
}
|
||||
|
||||
tag := u.Fragment
|
||||
@@ -332,7 +345,7 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
"password": password,
|
||||
"congestion_control": query.Get("congestion_control"),
|
||||
"udp_relay_mode": query.Get("udp_relay_mode"),
|
||||
"tls": tls,
|
||||
"tls": getTls(security, &query),
|
||||
}
|
||||
return &tuic, tag, nil
|
||||
}
|
||||
@@ -397,7 +410,88 @@ func ss(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
return &ss, tag, nil
|
||||
}
|
||||
|
||||
func getTransport(tp_type string, q *url.Values) *map[string]interface{} {
|
||||
func parseNaiveLink(u *url.URL, i int) (*map[string]interface{}, string, error) {
|
||||
var host, portStr, username, password string
|
||||
var port int
|
||||
|
||||
switch u.Scheme {
|
||||
case "http2":
|
||||
decoded := StrOrBase64Encoded(u.Hostname())
|
||||
if idx := strings.Index(decoded, "@"); idx != -1 {
|
||||
userInfo := decoded[:idx]
|
||||
hostPort := decoded[idx+1:]
|
||||
if idx2 := strings.Index(userInfo, ":"); idx2 != -1 {
|
||||
username = userInfo[:idx2]
|
||||
password = userInfo[idx2+1:]
|
||||
} else {
|
||||
username = userInfo
|
||||
}
|
||||
host, portStr, _ = net.SplitHostPort(hostPort)
|
||||
if portStr != "" {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
} else {
|
||||
port = 443
|
||||
}
|
||||
} else {
|
||||
return nil, "", common.NewError("Invalid naive link (http2)")
|
||||
}
|
||||
case "naive+https", "naive+quic":
|
||||
host, portStr, _ = net.SplitHostPort(u.Host)
|
||||
if portStr != "" {
|
||||
port, _ = strconv.Atoi(portStr)
|
||||
} else {
|
||||
port = 443
|
||||
}
|
||||
if u.User != nil {
|
||||
username = u.User.Username()
|
||||
password, _ = u.User.Password()
|
||||
}
|
||||
default:
|
||||
return nil, "", common.NewError("Unsupported naive scheme")
|
||||
}
|
||||
|
||||
tag := u.Fragment
|
||||
if i > 0 {
|
||||
tag = fmt.Sprintf("%d.%s", i, u.Fragment)
|
||||
}
|
||||
if tag == "" {
|
||||
tag = fmt.Sprintf("naive-%d", i)
|
||||
}
|
||||
|
||||
naive := map[string]interface{}{
|
||||
"type": "naive",
|
||||
"tag": tag,
|
||||
"server": host,
|
||||
"server_port": port,
|
||||
"username": username,
|
||||
"password": password,
|
||||
"tls": map[string]interface{}{"enabled": true},
|
||||
}
|
||||
|
||||
query := u.Query()
|
||||
if peer := query.Get("peer"); peer != "" {
|
||||
if tls, ok := naive["tls"].(map[string]interface{}); ok {
|
||||
tls["server_name"] = peer
|
||||
}
|
||||
}
|
||||
if insecure := query.Get("insecure"); insecure == "1" || insecure == "true" {
|
||||
if tls, ok := naive["tls"].(map[string]interface{}); ok {
|
||||
tls["insecure"] = true
|
||||
}
|
||||
}
|
||||
if alpn := query.Get("alpn"); alpn != "" {
|
||||
if tls, ok := naive["tls"].(map[string]interface{}); ok {
|
||||
tls["alpn"] = strings.Split(alpn, ",")
|
||||
}
|
||||
}
|
||||
if u.Scheme == "naive+quic" {
|
||||
naive["quic"] = true
|
||||
}
|
||||
|
||||
return &naive, tag, nil
|
||||
}
|
||||
|
||||
func getTransport(tp_type string, q *url.Values) map[string]interface{} {
|
||||
transport := map[string]interface{}{}
|
||||
tp_host := q.Get("host")
|
||||
tp_path := q.Get("path")
|
||||
@@ -434,15 +528,18 @@ func getTransport(tp_type string, q *url.Values) *map[string]interface{} {
|
||||
transport["path"] = tp_path
|
||||
transport["host"] = tp_host
|
||||
}
|
||||
return &transport
|
||||
return transport
|
||||
}
|
||||
|
||||
func getTls(security string, q *url.Values) *map[string]interface{} {
|
||||
func getTls(security string, q *url.Values) map[string]interface{} {
|
||||
tls := map[string]interface{}{}
|
||||
tls_fp := q.Get("fp")
|
||||
tls_sni := q.Get("sni")
|
||||
tls_insecure := q.Get("allowInsecure")
|
||||
tls_allow_insecure := q.Get("allowInsecure")
|
||||
tls_insecure := q.Get("insecure")
|
||||
tls_alpn := q.Get("alpn")
|
||||
tls_ech := q.Get("ech")
|
||||
disable_sni := q.Get("disable_sni")
|
||||
switch security {
|
||||
case "tls":
|
||||
tls["enabled"] = true
|
||||
@@ -460,7 +557,7 @@ func getTls(security string, q *url.Values) *map[string]interface{} {
|
||||
if len(tls_alpn) > 0 {
|
||||
tls["alpn"] = strings.Split(tls_alpn, ",")
|
||||
}
|
||||
if tls_insecure == "1" || tls_insecure == "true" {
|
||||
if tls_insecure == "1" || tls_insecure == "true" || tls_allow_insecure == "1" || tls_allow_insecure == "true" {
|
||||
tls["insecure"] = true
|
||||
}
|
||||
if len(tls_fp) > 0 {
|
||||
@@ -469,5 +566,16 @@ func getTls(security string, q *url.Values) *map[string]interface{} {
|
||||
"fingerprint": tls_fp,
|
||||
}
|
||||
}
|
||||
return &tls
|
||||
if len(tls_ech) > 0 {
|
||||
tls["ech"] = map[string]interface{}{
|
||||
"enabled": true,
|
||||
"config": []string{
|
||||
tls_ech,
|
||||
},
|
||||
}
|
||||
}
|
||||
if disable_sni == "1" || disable_sni == "true" {
|
||||
tls["disable_sni"] = true
|
||||
}
|
||||
return tls
|
||||
}
|
||||
|
||||
+42
-6
@@ -2,8 +2,10 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"s-ui/database/model"
|
||||
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
)
|
||||
|
||||
// Fill Inbound's out_json
|
||||
@@ -39,10 +41,11 @@ func FillOutJson(i *model.Inbound, hostname string) error {
|
||||
outJson["server_port"] = (*inbound)["listen_port"]
|
||||
|
||||
switch i.Type {
|
||||
case "http", "socks", "mixed":
|
||||
case "http", "socks", "mixed", "anytls":
|
||||
case "naive":
|
||||
naiveOut(&outJson, *inbound)
|
||||
case "shadowsocks":
|
||||
shadowsocksOut(&outJson, *inbound)
|
||||
return nil
|
||||
case "shadowtls":
|
||||
shadowTlsOut(&outJson, *inbound)
|
||||
case "hysteria":
|
||||
@@ -98,6 +101,9 @@ func addTls(out *map[string]interface{}, tls *model.Tls) {
|
||||
if maxVersion, ok := tlsServer["max_version"]; ok {
|
||||
tlsConfig["max_version"] = maxVersion
|
||||
}
|
||||
if certificate, ok := tlsServer["certificate"]; ok {
|
||||
tlsConfig["certificate"] = certificate
|
||||
}
|
||||
if cipherSuites, ok := tlsServer["cipher_suites"]; ok {
|
||||
tlsConfig["cipher_suites"] = cipherSuites
|
||||
}
|
||||
@@ -105,7 +111,7 @@ func addTls(out *map[string]interface{}, tls *model.Tls) {
|
||||
realityConfig := tlsConfig["reality"].(map[string]interface{})
|
||||
realityConfig["enabled"] = true
|
||||
if shortIDs, ok := reality["short_id"].([]interface{}); ok && len(shortIDs) > 0 {
|
||||
realityConfig["short_id"] = shortIDs[rand.Intn(len(shortIDs))]
|
||||
realityConfig["short_id"] = shortIDs[common.RandomInt(len(shortIDs))]
|
||||
}
|
||||
tlsConfig["reality"] = realityConfig
|
||||
}
|
||||
@@ -120,7 +126,21 @@ func addTls(out *map[string]interface{}, tls *model.Tls) {
|
||||
(*out)["tls"] = tlsConfig
|
||||
}
|
||||
|
||||
// Protocol-specific functions
|
||||
func naiveOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
if quic_congestion_control, ok := inbound["quic_congestion_control"].(string); ok {
|
||||
(*out)["quic"] = true
|
||||
switch quic_congestion_control {
|
||||
case "bbr_standard":
|
||||
(*out)["quic_congestion_control"] = "bbr"
|
||||
case "bbr2_variant":
|
||||
(*out)["quic_congestion_control"] = "bbr2"
|
||||
default:
|
||||
(*out)["quic_congestion_control"] = quic_congestion_control
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func shadowsocksOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
if method, ok := inbound["method"].(string); ok {
|
||||
(*out)["method"] = method
|
||||
@@ -139,6 +159,12 @@ func shadowTlsOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
}
|
||||
|
||||
func hysteriaOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
delete(*out, "down_mbps")
|
||||
delete(*out, "up_mbps")
|
||||
delete(*out, "obfs")
|
||||
delete(*out, "recv_window_conn")
|
||||
delete(*out, "disable_mtu_discovery")
|
||||
|
||||
if upMbps, ok := inbound["down_mbps"]; ok {
|
||||
(*out)["up_mbps"] = upMbps
|
||||
}
|
||||
@@ -157,6 +183,10 @@ func hysteriaOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
}
|
||||
|
||||
func hysteria2Out(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
delete(*out, "down_mbps")
|
||||
delete(*out, "up_mbps")
|
||||
delete(*out, "obfs")
|
||||
|
||||
if upMbps, ok := inbound["down_mbps"]; ok {
|
||||
(*out)["up_mbps"] = upMbps
|
||||
}
|
||||
@@ -169,6 +199,8 @@ func hysteria2Out(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
}
|
||||
|
||||
func tuicOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
delete(*out, "zero_rtt_handshake")
|
||||
delete(*out, "heartbeat")
|
||||
if congestionControl, ok := inbound["congestion_control"].(string); ok {
|
||||
(*out)["congestion_control"] = congestionControl
|
||||
} else {
|
||||
@@ -183,18 +215,22 @@ func tuicOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
}
|
||||
|
||||
func vlessOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
delete(*out, "transport")
|
||||
if transport, ok := inbound["transport"]; ok {
|
||||
(*out)["transport"] = transport
|
||||
}
|
||||
}
|
||||
|
||||
func trojanOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
delete(*out, "transport")
|
||||
if transport, ok := inbound["transport"]; ok {
|
||||
(*out)["transport"] = transport
|
||||
}
|
||||
}
|
||||
|
||||
func vmessOut(out *map[string]interface{}, inbound map[string]interface{}) {
|
||||
(*out)["alter_id"] = 0
|
||||
delete(*out, "transport")
|
||||
if transport, ok := inbound["transport"]; ok {
|
||||
(*out)["transport"] = transport
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/alireza0/s-ui/database/model"
|
||||
)
|
||||
|
||||
func GetHeaders(client *model.Client, updateInterval int) []string {
|
||||
var headers []string
|
||||
headers = append(headers, fmt.Sprintf("upload=%d; download=%d; total=%d; expire=%d", client.Up, client.Down, client.Volume, client.Expiry))
|
||||
headers = append(headers, fmt.Sprintf("%d", updateInterval))
|
||||
headers = append(headers, client.Name)
|
||||
return headers
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/util/common"
|
||||
)
|
||||
|
||||
func GetExternalLink(url string) string {
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
logger.Warning("sub: Error making HTTP request:", err)
|
||||
return ""
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
body, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
logger.Warning("sub: Error reading response body:", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
data := StrOrBase64Encoded(string(body))
|
||||
return data
|
||||
}
|
||||
|
||||
func GetExternalSub(url string) ([]map[string]interface{}, error) {
|
||||
var err error
|
||||
var result []map[string]interface{}
|
||||
|
||||
if len(url) == 0 {
|
||||
return nil, common.NewError("no url")
|
||||
}
|
||||
|
||||
data := GetExternalLink(url)
|
||||
if len(data) == 0 {
|
||||
return nil, common.NewError("no result")
|
||||
}
|
||||
|
||||
// if the data is a JSON object
|
||||
if strings.HasPrefix(data, "{") && strings.HasSuffix(data, "}") {
|
||||
var jsonData map[string]interface{}
|
||||
err = json.Unmarshal([]byte(data), &jsonData)
|
||||
if err != nil {
|
||||
logger.Warning("sub: Error unmarshalling JSON:", err)
|
||||
return nil, err
|
||||
}
|
||||
outbounds, ok := jsonData["outbounds"].([]any)
|
||||
if !ok {
|
||||
logger.Warning("sub: Error getting outbounds:", err)
|
||||
return nil, err
|
||||
}
|
||||
for _, outbound := range outbounds {
|
||||
outboundMap, ok := outbound.(map[string]interface{})
|
||||
if ok && len(outboundMap) > 0 {
|
||||
oType, _ := outboundMap["type"].(string)
|
||||
switch oType {
|
||||
case "urltest":
|
||||
case "direct":
|
||||
case "selector":
|
||||
case "block":
|
||||
continue
|
||||
default:
|
||||
result = append(result, outboundMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(result) == 0 {
|
||||
return nil, common.NewError("no result")
|
||||
}
|
||||
return result, nil
|
||||
} else {
|
||||
// if data is a text
|
||||
links := strings.Split(data, "\n")
|
||||
for _, link := range links {
|
||||
linkToJson, _, err := GetOutbound(link, 0)
|
||||
if err == nil {
|
||||
result = append(result, *linkToJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(result) == 0 {
|
||||
return nil, common.NewError("no result")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
+18
-10
@@ -9,14 +9,16 @@ import (
|
||||
"io/fs"
|
||||
"net"
|
||||
"net/http"
|
||||
"s-ui/api"
|
||||
"s-ui/config"
|
||||
"s-ui/logger"
|
||||
"s-ui/middleware"
|
||||
"s-ui/network"
|
||||
"s-ui/service"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alireza0/s-ui/api"
|
||||
"github.com/alireza0/s-ui/config"
|
||||
"github.com/alireza0/s-ui/logger"
|
||||
"github.com/alireza0/s-ui/middleware"
|
||||
"github.com/alireza0/s-ui/network"
|
||||
"github.com/alireza0/s-ui/service"
|
||||
|
||||
"github.com/gin-contrib/gzip"
|
||||
"github.com/gin-contrib/sessions"
|
||||
@@ -199,20 +201,26 @@ func (s *Server) Start() (err error) {
|
||||
}
|
||||
|
||||
func (s *Server) Stop() error {
|
||||
s.cancel()
|
||||
var err error
|
||||
if s.httpServer != nil {
|
||||
err = s.httpServer.Shutdown(s.ctx)
|
||||
shutdownCtx, cancelShutdown := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
err = s.httpServer.Shutdown(shutdownCtx)
|
||||
cancelShutdown()
|
||||
if err != nil {
|
||||
s.cancel()
|
||||
if s.listener != nil {
|
||||
_ = s.listener.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
if s.listener != nil {
|
||||
} else if s.listener != nil {
|
||||
err = s.listener.Close()
|
||||
if err != nil {
|
||||
s.cancel()
|
||||
return err
|
||||
}
|
||||
}
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Windows Files
|
||||
|
||||
This directory contains all Windows-specific files for S-UI.
|
||||
|
||||
## Available Files:
|
||||
|
||||
- **s-ui-windows.xml**: Windows Service configuration
|
||||
- **install-windows.bat**: Installation script
|
||||
- **s-ui-windows.bat**: Control panel
|
||||
- **uninstall-windows.bat**: Uninstallation script
|
||||
- **build-windows.bat**: Simple build script for CMD
|
||||
- **build-windows.ps1**: Advanced build script for PowerShell
|
||||
|
||||
## Usage:
|
||||
|
||||
To install S-UI on Windows:
|
||||
1. Run `install-windows.bat` as Administrator
|
||||
2. Follow the installation wizard
|
||||
3. Use `s-ui-windows.bat` for management
|
||||
|
||||
To build from source:
|
||||
- With CMD: `build-windows.bat`
|
||||
- With PowerShell: `.\build-windows.ps1`
|
||||
@@ -0,0 +1,73 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo Building S-UI for Windows...
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
REM Check if Go is installed
|
||||
go version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo Error: Go is not installed or not in PATH
|
||||
echo Please install Go from https://golang.org/dl/
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Check if Node.js is installed
|
||||
node --version >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo Error: Node.js is not installed or not in PATH
|
||||
echo Please install Node.js from https://nodejs.org/
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Building frontend...
|
||||
cd frontend
|
||||
call npm install
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to install frontend dependencies
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call npm run build
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to build frontend
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
cd ..
|
||||
|
||||
echo Creating web/html directory...
|
||||
if not exist "web\html" mkdir "web\html"
|
||||
|
||||
echo Copying frontend build files...
|
||||
xcopy "frontend\dist\*" "web\html\" /E /Y /Q
|
||||
|
||||
echo Building backend...
|
||||
set CGO_ENABLED=1
|
||||
set GOOS=windows
|
||||
set GOARCH=amd64
|
||||
|
||||
REM Try to build with CGO first
|
||||
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_tailscale" -o sui.exe main.go
|
||||
if errorlevel 1 (
|
||||
echo Warning: CGO build failed, trying without CGO...
|
||||
set CGO_ENABLED=0
|
||||
go build -ldflags "-w -s" -tags "with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_tailscale" -o sui.exe main.go
|
||||
if errorlevel 1 (
|
||||
echo Error: Failed to build backend
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo Built without CGO (some features may be limited)
|
||||
) else (
|
||||
echo Built with CGO
|
||||
)
|
||||
|
||||
echo Build completed successfully!
|
||||
echo Output: sui.exe
|
||||
pause
|
||||
@@ -0,0 +1,138 @@
|
||||
# PowerShell script for building S-UI on Windows
|
||||
param(
|
||||
[string]$Architecture = "amd64",
|
||||
[switch]$NoCGO,
|
||||
[switch]$Help
|
||||
)
|
||||
|
||||
if ($Help) {
|
||||
Write-Host "Usage: .\build-windows.ps1 [-Architecture <arch>] [-NoCGO] [-Help]"
|
||||
Write-Host "Architectures: amd64, 386, arm64"
|
||||
Write-Host "Examples:"
|
||||
Write-Host " .\build-windows.ps1 # Build for amd64 with CGO"
|
||||
Write-Host " .\build-windows.ps1 -Architecture 386 # Build for 32-bit Windows"
|
||||
Write-Host " .\build-windows.ps1 -NoCGO # Build without CGO"
|
||||
exit 0
|
||||
}
|
||||
|
||||
Write-Host "Building S-UI for Windows ($Architecture)..." -ForegroundColor Green
|
||||
|
||||
# Check if Go is installed
|
||||
try {
|
||||
$goVersion = go version 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Go not found"
|
||||
}
|
||||
Write-Host "Go version: $goVersion" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Error: Go is not installed or not in PATH" -ForegroundColor Red
|
||||
Write-Host "Please install Go from https://golang.org/dl/" -ForegroundColor Yellow
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if Node.js is installed
|
||||
try {
|
||||
$nodeVersion = node --version 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Node.js not found"
|
||||
}
|
||||
Write-Host "Node.js version: $nodeVersion" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Error: Node.js is not installed or not in PATH" -ForegroundColor Red
|
||||
Write-Host "Please install Node.js from https://nodejs.org/" -ForegroundColor Yellow
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Build frontend
|
||||
Write-Host "Building frontend..." -ForegroundColor Yellow
|
||||
Push-Location frontend
|
||||
|
||||
try {
|
||||
Write-Host "Installing dependencies..." -ForegroundColor Cyan
|
||||
npm install
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to install frontend dependencies"
|
||||
}
|
||||
|
||||
Write-Host "Building frontend..." -ForegroundColor Cyan
|
||||
npm run build
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to build frontend"
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Error: $_" -ForegroundColor Red
|
||||
Pop-Location
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
|
||||
# Create web/html directory
|
||||
Write-Host "Creating web/html directory..." -ForegroundColor Yellow
|
||||
if (!(Test-Path "web\html")) {
|
||||
New-Item -ItemType Directory -Path "web\html" -Force | Out-Null
|
||||
}
|
||||
|
||||
# Copy frontend build files
|
||||
Write-Host "Copying frontend build files..." -ForegroundColor Yellow
|
||||
Copy-Item "frontend\dist\*" "web\html\" -Recurse -Force
|
||||
|
||||
# Build backend
|
||||
Write-Host "Building backend..." -ForegroundColor Yellow
|
||||
|
||||
# Set environment variables
|
||||
$env:GOOS = "windows"
|
||||
$env:GOARCH = $Architecture
|
||||
|
||||
if ($NoCGO) {
|
||||
$env:CGO_ENABLED = "0"
|
||||
Write-Host "Building without CGO..." -ForegroundColor Yellow
|
||||
} else {
|
||||
$env:CGO_ENABLED = "1"
|
||||
Write-Host "Building with CGO..." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Build command
|
||||
$buildCmd = "go build -ldflags `"-w -s`" -tags `"with_quic,with_grpc,with_utls,with_acme,with_gvisor,with_tailscale`" -o sui.exe main.go"
|
||||
|
||||
try {
|
||||
Invoke-Expression $buildCmd
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if (!$NoCGO) {
|
||||
Write-Host "CGO build failed, trying without CGO..." -ForegroundColor Yellow
|
||||
$env:CGO_ENABLED = "0"
|
||||
Invoke-Expression $buildCmd
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Failed to build backend even without CGO"
|
||||
}
|
||||
Write-Host "Built without CGO (some features may be limited)" -ForegroundColor Yellow
|
||||
} else {
|
||||
throw "Failed to build backend"
|
||||
}
|
||||
} else {
|
||||
if ($env:CGO_ENABLED -eq "1") {
|
||||
Write-Host "Built successfully with CGO" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Built successfully without CGO" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Host "Error: $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Build completed successfully!" -ForegroundColor Green
|
||||
Write-Host "Output: sui.exe" -ForegroundColor Green
|
||||
|
||||
# Show file info
|
||||
if (Test-Path "sui.exe") {
|
||||
$fileInfo = Get-Item "sui.exe"
|
||||
Write-Host "File size: $([math]::Round($fileInfo.Length / 1MB, 2)) MB" -ForegroundColor Cyan
|
||||
Write-Host "Created: $($fileInfo.CreationTime)" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
Read-Host "Press Enter to exit"
|
||||
@@ -0,0 +1,195 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ========================================
|
||||
echo S-UI Windows Installer
|
||||
echo ========================================
|
||||
|
||||
REM Check if running as Administrator
|
||||
net session >nul 2>&1
|
||||
if %errorLevel% neq 0 (
|
||||
echo Error: This script must be run as Administrator
|
||||
echo Right-click on this file and select "Run as administrator"
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
cd /d "%~dp0"
|
||||
REM Set installation directory
|
||||
set "INSTALL_DIR=C:\Program Files\s-ui"
|
||||
set "SERVICE_NAME=s-ui"
|
||||
|
||||
echo Installing S-UI to: %INSTALL_DIR%
|
||||
|
||||
REM Create installation directory
|
||||
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
|
||||
if not exist "%INSTALL_DIR%\db" mkdir "%INSTALL_DIR%\db"
|
||||
if not exist "%INSTALL_DIR%\logs" mkdir "%INSTALL_DIR%\logs"
|
||||
if not exist "%INSTALL_DIR%\cert" mkdir "%INSTALL_DIR%\cert"
|
||||
|
||||
REM Copy files
|
||||
echo Copying files...
|
||||
copy "sui.exe" "%INSTALL_DIR%\" >nul
|
||||
copy "s-ui-windows.xml" "%INSTALL_DIR%\" >nul
|
||||
copy "s-ui-windows.bat" "%INSTALL_DIR%\" >nul
|
||||
|
||||
REM Check if WinSW is available
|
||||
set "WINSW_PATH=%INSTALL_DIR%\winsw.exe"
|
||||
if not exist "%WINSW_PATH%" (
|
||||
echo Downloading WinSW...
|
||||
powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe' -OutFile '%WINSW_PATH%'}"
|
||||
if exist "%WINSW_PATH%" (
|
||||
echo WinSW downloaded successfully
|
||||
) else (
|
||||
echo Warning: Failed to download WinSW. Service installation will be skipped.
|
||||
echo You can manually download WinSW from: https://github.com/winsw/winsw/releases
|
||||
)
|
||||
)
|
||||
|
||||
REM Install Windows Service
|
||||
if exist "%WINSW_PATH%" (
|
||||
echo Installing Windows Service...
|
||||
cd /d "%INSTALL_DIR%"
|
||||
copy "winsw.exe" "s-ui-service.exe" >nul
|
||||
copy "s-ui-windows.xml" "s-ui-service.xml" >nul
|
||||
|
||||
REM Install service
|
||||
s-ui-service.exe install
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service installed successfully
|
||||
) else (
|
||||
echo Warning: Failed to install service. You can install it manually later.
|
||||
)
|
||||
)
|
||||
|
||||
REM Run migration
|
||||
echo Running database migration...
|
||||
cd /d "%INSTALL_DIR%"
|
||||
sui.exe migrate
|
||||
if %errorLevel% equ 0 (
|
||||
echo Migration completed successfully
|
||||
) else (
|
||||
echo Warning: Migration failed or database is new
|
||||
)
|
||||
|
||||
REM Get network configuration
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Network Configuration
|
||||
echo ========================================
|
||||
|
||||
REM Get local IP addresses
|
||||
echo Available IP addresses:
|
||||
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
|
||||
echo %%i
|
||||
)
|
||||
|
||||
REM Get panel configuration
|
||||
echo.
|
||||
set /p panel_port="Enter panel port (default: 2095): "
|
||||
if "%panel_port%"=="" set "panel_port=2095"
|
||||
|
||||
set /p panel_path="Enter panel path (default: /app/): "
|
||||
if "%panel_path%"=="" set "panel_path=/app/"
|
||||
|
||||
set /p sub_port="Enter subscription port (default: 2096): "
|
||||
if "%sub_port%"=="" set "sub_port=2096"
|
||||
|
||||
set /p sub_path="Enter subscription path (default: /sub/): "
|
||||
if "%sub_path%"=="" set "sub_path=/sub/"
|
||||
|
||||
REM Apply settings
|
||||
echo.
|
||||
echo Applying settings...
|
||||
cd /d "%INSTALL_DIR%"
|
||||
sui.exe setting -port %panel_port% -path "%panel_path%" -subPort %sub_port% -subPath "%sub_path%"
|
||||
|
||||
REM Get admin credentials
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Admin Configuration
|
||||
echo ========================================
|
||||
|
||||
set /p admin_username="Enter admin username (default: admin): "
|
||||
if "%admin_username%"=="" set "admin_username=admin"
|
||||
|
||||
set /p admin_password="Enter admin password: "
|
||||
if "%admin_password%"=="" (
|
||||
echo Error: Password cannot be empty
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Set admin credentials
|
||||
echo Setting admin credentials...
|
||||
sui.exe admin -username "%admin_username%" -password "%admin_password%"
|
||||
|
||||
REM Start service
|
||||
echo Starting S-UI service...
|
||||
net start %SERVICE_NAME%
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service started successfully
|
||||
) else (
|
||||
echo Warning: Failed to start service. You can start it manually later.
|
||||
)
|
||||
|
||||
REM Create desktop shortcut
|
||||
echo Creating desktop shortcut...
|
||||
set "DESKTOP=%USERPROFILE%\Desktop"
|
||||
if exist "%DESKTOP%" (
|
||||
powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%DESKTOP%\S-UI.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}"
|
||||
echo Desktop shortcut created
|
||||
)
|
||||
|
||||
REM Create Start Menu shortcut
|
||||
echo Creating Start Menu shortcut...
|
||||
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs"
|
||||
if exist "%START_MENU%" (
|
||||
if not exist "%START_MENU%\S-UI" mkdir "%START_MENU%\S-UI"
|
||||
powershell -Command "& {$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%START_MENU%\S-UI\S-UI Control Panel.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\s-ui-windows.bat'; $Shortcut.WorkingDirectory = '%INSTALL_DIR%'; $Shortcut.Description = 'S-UI Control Panel'; $Shortcut.Save()}"
|
||||
echo Start Menu shortcut created
|
||||
)
|
||||
|
||||
REM Set permissions
|
||||
echo Setting permissions...
|
||||
icacls "%INSTALL_DIR%" /grant "Users:(OI)(CI)RX" /T >nul
|
||||
icacls "%INSTALL_DIR%\db" /grant "Users:(OI)(CI)F" /T >nul
|
||||
icacls "%INSTALL_DIR%\logs" /grant "Users:(OI)(CI)F" /T >nul
|
||||
|
||||
REM Create environment variable
|
||||
echo Setting environment variable...
|
||||
setx SUI_HOME "%INSTALL_DIR%" /M >nul
|
||||
|
||||
REM Show final configuration
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Installation completed successfully!
|
||||
echo ========================================
|
||||
echo.
|
||||
echo S-UI has been installed to: %INSTALL_DIR%
|
||||
echo.
|
||||
echo Configuration:
|
||||
echo Panel Port: %panel_port%
|
||||
echo Panel Path: %panel_path%
|
||||
echo Subscription Port: %sub_port%
|
||||
echo Subscription Path: %sub_path%
|
||||
echo Admin Username: %admin_username%
|
||||
echo.
|
||||
echo Access URLs:
|
||||
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
|
||||
set "ip=%%i"
|
||||
set "ip=!ip: =!"
|
||||
echo Panel: http://!ip!:%panel_port%%panel_path%
|
||||
echo Subscription: http://!ip!:%sub_port%%sub_path%
|
||||
)
|
||||
echo.
|
||||
echo Service name: %SERVICE_NAME%
|
||||
echo.
|
||||
echo Useful commands:
|
||||
echo net start %SERVICE_NAME% - Start the service
|
||||
echo net stop %SERVICE_NAME% - Stop the service
|
||||
echo sc query %SERVICE_NAME% - Check service status
|
||||
echo.
|
||||
echo You can also use the desktop shortcut or Start Menu item.
|
||||
echo.
|
||||
pause
|
||||
@@ -0,0 +1,237 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM S-UI Windows Control Script
|
||||
REM This script provides a menu-driven interface for managing S-UI on Windows
|
||||
|
||||
cd /d "%~dp0"
|
||||
set "SERVICE_NAME=s-ui"
|
||||
set "INSTALL_DIR=%SUI_HOME%"
|
||||
if "%INSTALL_DIR%"=="" set "INSTALL_DIR=C:\Program Files\s-ui"
|
||||
|
||||
:menu
|
||||
cls
|
||||
echo ========================================
|
||||
echo S-UI Windows Control Panel
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Current directory: %INSTALL_DIR%
|
||||
echo.
|
||||
echo 1. Start S-UI Service
|
||||
echo 2. Stop S-UI Service
|
||||
echo 3. Restart S-UI Service
|
||||
echo 4. Check Service Status
|
||||
echo 5. View Service Logs
|
||||
echo 6. Open Panel in Browser
|
||||
echo 7. Run S-UI Manually
|
||||
echo 8. Install/Uninstall Service
|
||||
echo 9. Open Installation Directory
|
||||
echo 10. Show Configuration
|
||||
echo 11. Show Access URLs
|
||||
echo 0. Exit
|
||||
echo.
|
||||
echo ========================================
|
||||
|
||||
set /p choice="Please select an option [0-11]: "
|
||||
|
||||
if "%choice%"=="1" goto start_service
|
||||
if "%choice%"=="2" goto stop_service
|
||||
if "%choice%"=="3" goto restart_service
|
||||
if "%choice%"=="4" goto check_status
|
||||
if "%choice%"=="5" goto view_logs
|
||||
if "%choice%"=="6" goto open_panel
|
||||
if "%choice%"=="7" goto run_manual
|
||||
if "%choice%"=="8" goto service_management
|
||||
if "%choice%"=="9" goto open_directory
|
||||
if "%choice%"=="10" goto show_config
|
||||
if "%choice%"=="11" goto show_urls
|
||||
if "%choice%"=="0" goto exit
|
||||
goto invalid_choice
|
||||
|
||||
:start_service
|
||||
echo Starting S-UI service...
|
||||
net start %SERVICE_NAME%
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service started successfully!
|
||||
) else (
|
||||
echo Failed to start service. Error code: %errorLevel%
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:stop_service
|
||||
echo Stopping S-UI service...
|
||||
net stop %SERVICE_NAME%
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service stopped successfully!
|
||||
) else (
|
||||
echo Failed to stop service. Error code: %errorLevel%
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:restart_service
|
||||
echo Restarting S-UI service...
|
||||
net stop %SERVICE_NAME% >nul 2>&1
|
||||
timeout /t 2 /nobreak >nul
|
||||
net start %SERVICE_NAME%
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service restarted successfully!
|
||||
) else (
|
||||
echo Failed to restart service. Error code: %errorLevel%
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:check_status
|
||||
echo Checking S-UI service status...
|
||||
sc query %SERVICE_NAME%
|
||||
echo.
|
||||
echo Service status details:
|
||||
for /f "tokens=3 delims=: " %%i in ('sc query %SERVICE_NAME% ^| find "STATE"') do (
|
||||
echo Current state: %%i
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:view_logs
|
||||
echo Opening S-UI logs...
|
||||
if exist "%INSTALL_DIR%\logs" (
|
||||
start "" "%INSTALL_DIR%\logs"
|
||||
) else (
|
||||
echo Logs directory not found: %INSTALL_DIR%\logs
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:open_panel
|
||||
echo Opening S-UI panel in browser...
|
||||
start http://localhost:2095
|
||||
echo Panel opened in default browser.
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:run_manual
|
||||
echo Running S-UI manually...
|
||||
if exist "%INSTALL_DIR%\sui.exe" (
|
||||
cd /d "%INSTALL_DIR%"
|
||||
echo Starting S-UI in current window...
|
||||
echo Press Ctrl+C to stop
|
||||
echo.
|
||||
sui.exe
|
||||
) else (
|
||||
echo S-UI executable not found: %INSTALL_DIR%\sui.exe
|
||||
echo Please run the installer first.
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:service_management
|
||||
cls
|
||||
echo ========================================
|
||||
echo Service Management
|
||||
echo ========================================
|
||||
echo.
|
||||
echo 1. Install Windows Service
|
||||
echo 2. Uninstall Windows Service
|
||||
echo 3. Back to Main Menu
|
||||
echo.
|
||||
set /p service_choice="Select option [1-3]: "
|
||||
|
||||
if "%service_choice%"=="1" goto install_service
|
||||
if "%service_choice%"=="2" goto uninstall_service
|
||||
if "%service_choice%"=="3" goto menu
|
||||
goto invalid_choice
|
||||
|
||||
:install_service
|
||||
echo Installing Windows Service...
|
||||
if exist "%INSTALL_DIR%\s-ui-service.exe" (
|
||||
cd /d "%INSTALL_DIR%"
|
||||
s-ui-service.exe install
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service installed successfully!
|
||||
echo Starting service...
|
||||
net start %SERVICE_NAME%
|
||||
) else (
|
||||
echo Failed to install service. Error code: %errorLevel%
|
||||
)
|
||||
) else (
|
||||
echo Service wrapper not found. Please run the installer first.
|
||||
)
|
||||
pause
|
||||
goto service_management
|
||||
|
||||
:uninstall_service
|
||||
echo Uninstalling Windows Service...
|
||||
if exist "%INSTALL_DIR%\s-ui-service.exe" (
|
||||
cd /d "%INSTALL_DIR%"
|
||||
net stop %SERVICE_NAME% >nul 2>&1
|
||||
s-ui-service.exe uninstall
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service uninstalled successfully!
|
||||
) else (
|
||||
echo Failed to uninstall service. Error code: %errorLevel%
|
||||
)
|
||||
) else (
|
||||
echo Service wrapper not found.
|
||||
)
|
||||
pause
|
||||
goto service_management
|
||||
|
||||
:open_directory
|
||||
echo Opening installation directory...
|
||||
if exist "%INSTALL_DIR%" (
|
||||
start "" "%INSTALL_DIR%"
|
||||
) else (
|
||||
echo Installation directory not found: %INSTALL_DIR%
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:show_config
|
||||
echo.
|
||||
echo ========================================
|
||||
echo S-UI Configuration
|
||||
echo ========================================
|
||||
if exist "%INSTALL_DIR%\sui.exe" (
|
||||
cd /d "%INSTALL_DIR%"
|
||||
echo Current settings:
|
||||
sui.exe setting -show
|
||||
echo.
|
||||
echo Admin credentials:
|
||||
sui.exe admin -show
|
||||
) else (
|
||||
echo S-UI executable not found. Please run the installer first.
|
||||
)
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:show_urls
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Access URLs
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Local access:
|
||||
echo Panel: http://localhost:2095
|
||||
echo Subscription: http://localhost:2096
|
||||
echo.
|
||||
echo Network access:
|
||||
for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr /i "IPv4"') do (
|
||||
set "ip=%%i"
|
||||
set "ip=!ip: =!"
|
||||
echo Panel: http://!ip!:2095
|
||||
echo Subscription: http://!ip!:2096
|
||||
)
|
||||
echo.
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:invalid_choice
|
||||
echo Invalid choice. Please select a valid option.
|
||||
pause
|
||||
goto menu
|
||||
|
||||
:exit
|
||||
echo Thank you for using S-UI Windows Control Panel!
|
||||
exit /b 0
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<service>
|
||||
<id>s-ui</id>
|
||||
<name>S-UI Proxy Panel</name>
|
||||
<description>S-UI is a proxy panel for managing proxy services</description>
|
||||
<executable>%BASE%\sui.exe</executable>
|
||||
<arguments></arguments>
|
||||
<logmode>rotate</logmode>
|
||||
<logpath>%BASE%\logs</logpath>
|
||||
<log size="10 m" />
|
||||
<log keep="10" />
|
||||
<workingdirectory>%BASE%</workingdirectory>
|
||||
<env name="SUI_DB_FOLDER" value="db" />
|
||||
<env name="SUI_DEBUG" value="false" />
|
||||
<onfailure action="restart" delay="10 sec" />
|
||||
<onfailure action="restart" delay="20 sec" />
|
||||
<onfailure action="none" />
|
||||
<resetfailure>1 hour</resetfailure>
|
||||
<startmode>Automatic</startmode>
|
||||
<depend>tcpip</depend>
|
||||
<depend>netman</depend>
|
||||
</service>
|
||||
@@ -0,0 +1,102 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ========================================
|
||||
echo S-UI Windows Uninstaller
|
||||
echo ========================================
|
||||
|
||||
REM Check if running as Administrator
|
||||
net session >nul 2>&1
|
||||
if %errorLevel% neq 0 (
|
||||
echo Error: This script must be run as Administrator
|
||||
echo Right-click on this file and select "Run as administrator"
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM Set installation directory
|
||||
set "INSTALL_DIR=C:\Program Files\s-ui"
|
||||
set "SERVICE_NAME=s-ui"
|
||||
|
||||
echo Uninstalling S-UI from: %INSTALL_DIR%
|
||||
|
||||
REM Stop and remove Windows Service
|
||||
if exist "%INSTALL_DIR%\s-ui-service.exe" (
|
||||
echo Stopping and removing Windows Service...
|
||||
net stop %SERVICE_NAME% >nul 2>&1
|
||||
cd /d "%INSTALL_DIR%"
|
||||
s-ui-service.exe uninstall >nul 2>&1
|
||||
if %errorLevel% equ 0 (
|
||||
echo Service removed successfully
|
||||
) else (
|
||||
echo Warning: Failed to remove service or service was not installed
|
||||
)
|
||||
)
|
||||
|
||||
REM Remove desktop shortcut
|
||||
echo Removing desktop shortcut...
|
||||
set "DESKTOP=%USERPROFILE%\Desktop"
|
||||
if exist "%DESKTOP%\S-UI.lnk" (
|
||||
del "%DESKTOP%\S-UI.lnk" >nul 2>&1
|
||||
echo Desktop shortcut removed
|
||||
)
|
||||
|
||||
REM Remove Start Menu shortcut
|
||||
echo Removing Start Menu shortcut...
|
||||
set "START_MENU=%APPDATA%\Microsoft\Windows\Start Menu\Programs\S-UI"
|
||||
if exist "%START_MENU%" (
|
||||
rmdir /s /q "%START_MENU%" >nul 2>&1
|
||||
echo Start Menu shortcut removed
|
||||
)
|
||||
|
||||
REM Remove environment variable
|
||||
echo Removing environment variable...
|
||||
reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v SUI_HOME /f >nul 2>&1
|
||||
|
||||
REM Ask user if they want to keep data
|
||||
echo.
|
||||
set /p keep_data="Do you want to keep your data (database, logs, certificates)? [y/n]: "
|
||||
if /i "%keep_data%"=="y" (
|
||||
echo Keeping data files...
|
||||
REM Remove only executable and service files
|
||||
if exist "%INSTALL_DIR%\sui.exe" del "%INSTALL_DIR%\sui.exe" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\s-ui-service.exe" del "%INSTALL_DIR%\s-ui-service.exe" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\s-ui-service.xml" del "%INSTALL_DIR%\s-ui-service.xml" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\winsw.exe" del "%INSTALL_DIR%\winsw.exe" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\*.bat" del "%INSTALL_DIR%\*.bat" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\*.xml" del "%INSTALL_DIR%\*.xml" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%\*.md" del "%INSTALL_DIR%\*.md" >nul 2>&1
|
||||
echo Data files preserved in: %INSTALL_DIR%
|
||||
) else (
|
||||
echo Removing all files...
|
||||
REM Remove entire installation directory
|
||||
if exist "%INSTALL_DIR%" (
|
||||
rmdir /s /q "%INSTALL_DIR%" >nul 2>&1
|
||||
if exist "%INSTALL_DIR%" (
|
||||
echo Warning: Some files could not be removed. Please manually delete: %INSTALL_DIR%
|
||||
) else (
|
||||
echo All files removed successfully
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM Remove firewall rules
|
||||
echo Removing firewall rules...
|
||||
netsh advfirewall firewall delete rule name="S-UI Panel" >nul 2>&1
|
||||
netsh advfirewall firewall delete rule name="S-UI Subscription" >nul 2>&1
|
||||
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Uninstallation completed!
|
||||
echo ========================================
|
||||
echo.
|
||||
echo S-UI has been uninstalled from your system.
|
||||
echo.
|
||||
if /i "%keep_data%"=="y" (
|
||||
echo Your data has been preserved in: %INSTALL_DIR%
|
||||
echo You can safely delete this directory if you no longer need the data.
|
||||
)
|
||||
echo.
|
||||
echo Thank you for using S-UI!
|
||||
echo.
|
||||
pause
|
||||
Reference in New Issue
Block a user