mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-28 20:32:42 +00:00
Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33f32deb32 | ||
|
|
258a64ed4f | ||
|
|
7e16236595 | ||
|
|
4e6e25c710 | ||
|
|
7dec83d529 | ||
|
|
c4aa8c5b5e | ||
|
|
e22f043213 | ||
|
|
e9c39481df | ||
|
|
6854ea4923 | ||
|
|
dc5c13c76c | ||
|
|
5f644b0b08 | ||
|
|
73352ecb43 | ||
|
|
34adb36029 | ||
|
|
311c696c1d | ||
|
|
33660d7f1b | ||
|
|
0844ebcae7 | ||
|
|
27e82ca60c | ||
|
|
bd06896454 | ||
|
|
72ea8a098f | ||
|
|
456fc328d5 | ||
|
|
19fcccf7f8 | ||
|
|
e3101cfa5e | ||
|
|
198fe253d1 | ||
|
|
3589cfd615 | ||
|
|
c204199477 | ||
|
|
dbba931701 | ||
|
|
ee9b239e21 | ||
|
|
c56685fd40 | ||
|
|
3b2a2632d9 | ||
|
|
c359424242 | ||
|
|
4d0ed9a105 | ||
|
|
63eee92062 | ||
|
|
b9b864cf51 | ||
|
|
bdd6bbf67a | ||
|
|
8a18d3564b | ||
|
|
2ee7c3aa04 | ||
|
|
598f6ac414 | ||
|
|
6c296bfbf2 | ||
|
|
43fc751a2d | ||
|
|
99c1ef8b1a | ||
|
|
53b561bce7 | ||
|
|
469feaf0f5 | ||
|
|
0895a16876 | ||
|
|
a8292b1fc6 | ||
|
|
1ff018c47b | ||
|
|
6227eb4e7d | ||
|
|
54c8e65c70 | ||
|
|
b90e63b506 | ||
|
|
185e3893bf | ||
|
|
5a4049af89 | ||
|
|
c842defea8 | ||
|
|
e26eaf0bf5 | ||
|
|
766bdcd6e1 | ||
|
|
897dc5ed43 | ||
|
|
7bd6670448 | ||
|
|
7af3bf1794 | ||
|
|
359d9794a8 | ||
|
|
089f782177 | ||
|
|
75023b028e | ||
|
|
322924f24a | ||
|
|
04a2c24904 | ||
|
|
e80ce5833c | ||
|
|
31ba5373f0 | ||
|
|
d3801b7951 | ||
|
|
31775a91a8 | ||
|
|
af4dd857a8 | ||
|
|
686f6b3517 | ||
|
|
ebad0e96f7 | ||
|
|
927c828a27 | ||
|
|
13a372511b | ||
|
|
119df56f35 | ||
|
|
0672bd11cd | ||
|
|
f4de5097a6 | ||
|
|
cb36b431ce | ||
|
|
d5b3f920b8 | ||
|
|
69e35d6657 | ||
|
|
936ff011e9 | ||
|
|
0cda1641d3 | ||
|
|
5b85906be1 | ||
|
|
03b6f02573 | ||
|
|
92db1f1f58 | ||
|
|
d68a2217fe | ||
|
|
ca6042bb8c | ||
|
|
3b7b519584 | ||
|
|
26f8f51eb5 | ||
|
|
9f8067ab11 | ||
|
|
3938ebfce9 |
327
.github/workflows/build.yml
vendored
327
.github/workflows/build.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: GitHub CI
|
||||
on:
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
tags:
|
||||
@@ -7,215 +7,144 @@ on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
linux32_build:
|
||||
name: Linux x86 Build
|
||||
runs-on: ubuntu-latest
|
||||
linux_build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86
|
||||
artifact: subconverter_linux32
|
||||
os: ubuntu-latest
|
||||
- arch: amd64
|
||||
artifact: subconverter_linux64
|
||||
os: ubuntu-latest
|
||||
- arch: armv7
|
||||
artifact: subconverter_armv7
|
||||
os: ubuntu-latest
|
||||
- arch: aarch64
|
||||
artifact: subconverter_aarch64
|
||||
os: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: Linux ${{ matrix.arch }} Build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:x86-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_linux32
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf subconverter_linux32.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_linux32.tar.gz
|
||||
draft: true
|
||||
|
||||
linux64_build:
|
||||
name: Linux x86_64 Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:amd64-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_linux64
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf subconverter_linux64.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_linux64.tar.gz
|
||||
draft: true
|
||||
|
||||
armv7_build:
|
||||
name: Linux armv7 Build
|
||||
runs-on: [self-hosted, linux, ARM]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:armv7-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_armv7
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf subconverter_armv7.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_armv7.tar.gz
|
||||
draft: true
|
||||
|
||||
aarch64_build:
|
||||
name: Linux aarch64 Build
|
||||
runs-on: [self-hosted, linux, ARM64]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:aarch64-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_aarch64
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf subconverter_aarch64.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_aarch64.tar.gz
|
||||
draft: true
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: docker run --rm -v $GITHUB_WORKSPACE:/root/workdir multiarch/alpine:${{ matrix.arch }}-latest-stable /bin/sh -c "apk add bash git nodejs npm && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ${{ matrix.artifact }}.tar.gz
|
||||
draft: true
|
||||
|
||||
macos_build:
|
||||
name: macOS Build
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86
|
||||
artifact: subconverter_darwin64
|
||||
os: macos-13
|
||||
- arch: arm
|
||||
artifact: subconverter_darwinarm
|
||||
os: macos-14
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: macOS ${{ matrix.arch }} Build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: bash scripts/build.macos.release.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_darwin64
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf subconverter_darwin64.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_darwin64.tar.gz
|
||||
draft: true
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i -e 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: bash scripts/build.macos.release.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: tar czf ${{ matrix.artifact }}.tar.gz subconverter
|
||||
- name: Draft Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ${{ matrix.artifact }}.tar.gz
|
||||
draft: true
|
||||
|
||||
windows64_build:
|
||||
name: Windows x86_64 Build
|
||||
windows_build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86
|
||||
artifact: subconverter_win32
|
||||
env: i686
|
||||
msystem: MINGW32
|
||||
- arch: amd64
|
||||
artifact: subconverter_win64
|
||||
env: x86_64
|
||||
msystem: MINGW64
|
||||
runs-on: windows-latest
|
||||
name: Windows ${{ matrix.arch }} Build
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
install: base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-pcre2 patch
|
||||
msystem: MINGW64
|
||||
path-type: inherit
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: bash scripts/build.windows.release.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_win64
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: 7z a subconverter_win64.7z subconverter/
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_win64.7z
|
||||
draft: true
|
||||
|
||||
windows32_build:
|
||||
name: Windows x86 Build
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
install: base-devel git mingw-w64-i686-gcc mingw-w64-i686-cmake mingw-w64-i686-pcre2 patch
|
||||
msystem: MINGW32
|
||||
path-type: inherit
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: bash scripts/build.windows.release.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: subconverter_win32
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: 7z a subconverter_win32.7z subconverter/
|
||||
- name: Draft Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
with:
|
||||
files: subconverter_win32.7z
|
||||
draft: true
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Setup MSYS2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
update: true
|
||||
install: base-devel git mingw-w64-${{ matrix.env }}-gcc mingw-w64-${{ matrix.env }}-cmake mingw-w64-${{ matrix.env }}-pcre2 patch
|
||||
msystem: ${{ matrix.msystem }}
|
||||
path-type: inherit
|
||||
- name: Add commit id into version
|
||||
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
||||
run: SHA=$(git rev-parse --short HEAD) && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h
|
||||
- name: Build
|
||||
run: bash scripts/build.windows.release.sh
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: subconverter/
|
||||
- name: Package Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
run: 7z a ${{ matrix.artifact }}.7z subconverter/
|
||||
- name: Draft Release
|
||||
if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') }}
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
files: ${{ matrix.artifact }}.7z
|
||||
draft: true
|
||||
409
.github/workflows/docker.yml
vendored
409
.github/workflows/docker.yml
vendored
@@ -1,335 +1,130 @@
|
||||
name: Publish Docker Image
|
||||
on:
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
tags:
|
||||
- '**'
|
||||
|
||||
concurrency:
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: asdlokj1qpi23/subconverter
|
||||
|
||||
jobs:
|
||||
amd64_build:
|
||||
name: Build AMD64 Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:latest
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v6
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Build release and export
|
||||
id: build_rel
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:${{steps.version.outputs.result}}
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Save digest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Save release digest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: digest_amd64
|
||||
path: /tmp/digest.txt
|
||||
|
||||
x86_build:
|
||||
name: Build x86 Image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/386
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:latest-x86
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v6
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Build release and export
|
||||
id: build_rel
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/386
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:${{steps.version.outputs.result}}-x86
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Save digest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Save release digest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: digest_386
|
||||
path: /tmp/digest.txt
|
||||
|
||||
armv7_build:
|
||||
name: Build ARMv7 Image
|
||||
runs-on: [self-hosted, linux, ARM]
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/arm/v7
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:latest-armv7
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
THREADS=4
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v6
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Build release and export
|
||||
id: build_rel
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/arm/v7
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:${{steps.version.outputs.result}}-armv7
|
||||
build-args: |
|
||||
THREADS=4
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Save digest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Save release digest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: digest_armv7
|
||||
path: /tmp/digest.txt
|
||||
|
||||
arm64_build:
|
||||
name: Build ARM64 Image
|
||||
runs-on: [self-hosted, linux, ARM64]
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/arm64
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:latest-arm64
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
THREADS=4
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v6
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Build release and export
|
||||
id: build_rel
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
platforms: linux/arm64
|
||||
context: scripts/
|
||||
tags: asdlokj1qpi23/subconverter:${{steps.version.outputs.result}}-arm64
|
||||
build-args: |
|
||||
THREADS=4
|
||||
outputs: type=image,push=true
|
||||
|
||||
- name: Save digest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Save release digest
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: digest_arm64
|
||||
path: /tmp/digest.txt
|
||||
|
||||
build:
|
||||
name: Build
|
||||
needs: [amd64_build, x86_build, armv7_build, arm64_build]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
- platform: linux/386
|
||||
os: ubuntu-latest
|
||||
- platform: linux/arm/v7
|
||||
os: ubuntu-latest
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: Build ${{ matrix.platform }} Image
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/docker/setup-qemu-action
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
# https://github.com/docker/setup-buildx-action
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
config-inline: |
|
||||
[worker.oci]
|
||||
max-parallelism = 1
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v3
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
path: /tmp/images/
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Replace tag without `v`
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: actions/github-script@v6
|
||||
id: version
|
||||
with:
|
||||
script: |
|
||||
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
|
||||
result-encoding: string
|
||||
|
||||
- name: Merge and push manifest on master branch
|
||||
- name: Get commit SHA
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: python scripts/merge_manifest.py
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Merge and push manifest on release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: python scripts/merge_manifest.py ${{steps.version.outputs.result}}
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: scripts/
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
rm -rf /tmp/digests
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
name: Merge
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digest-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
# subconverter-docker
|
||||
|
||||
This is a minimized image to run https://github.com/tindy2013/subconverter.
|
||||
|
||||
For running this docker, simply use the following commands:
|
||||
```bash
|
||||
# run the container detached, forward internal port 25500 to host port 25500
|
||||
docker run -d --restart=always -p 25500:25500 tindy2013/subconverter:latest
|
||||
docker run -d --restart=always -p 25500:25500 asdlokj1qpi23/subconverter:latest
|
||||
# then check its status
|
||||
curl http://localhost:25500/version
|
||||
# if you see `subconverter vx.x.x backend` then the container is up and running
|
||||
@@ -16,7 +14,7 @@ Or run in docker-compose:
|
||||
version: '3'
|
||||
services:
|
||||
subconverter:
|
||||
image: tindy2013/subconverter:latest
|
||||
image: asdlokj1qpi23/subconverter:latest
|
||||
container_name: subconverter
|
||||
ports:
|
||||
- "15051:25500"
|
||||
|
||||
46
README.md
46
README.md
@@ -2,23 +2,48 @@
|
||||
|
||||
Utility to convert between various proxy subscription formats.
|
||||
|
||||
[](https://github.com/tindy2013/subconverter/actions)
|
||||
[](https://github.com/tindy2013/subconverter/tags)
|
||||
[](https://github.com/tindy2013/subconverter/releases)
|
||||
[](https://github.com/tindy2013/subconverter/blob/master/LICENSE)
|
||||
original git: https://github.com/asdlokj1qpi23/subconverter
|
||||
|
||||
[Docker README](https://github.com/tindy2013/subconverter/blob/master/README-docker.md)
|
||||
[](https://github.com/asdlokj1qpi233/subconverter/actions)
|
||||
[](https://github.com/asdlokj1qpi23/subconverter/tags)
|
||||
[](https://github.com/asdlokj1qpi23/subconverter/releases)
|
||||
[](https://github.com/tindy2013/subconverter/blob/master/LICENSE)
|
||||
|
||||
[中文文档](https://github.com/tindy2013/subconverter/blob/master/README-cn.md)
|
||||
[Docker README](https://github.com/asdlokj1qpi23/subconverter/blob/master/README-docker.md)
|
||||
|
||||
[中文文档](https://github.com/asdlokj1qpi23/subconverter/blob/master/README-cn.md)
|
||||
|
||||
- [subconverter](#subconverter)
|
||||
- [Docker](#docker)
|
||||
- [Supported Types](#supported-types)
|
||||
- [Quick Usage](#quick-usage)
|
||||
- [Access Interface](#access-interface)
|
||||
- [Description](#description)
|
||||
- [Advanced Usage](#advanced-usage)
|
||||
- [Auto Upload](#auto-upload)
|
||||
|
||||
## Docker
|
||||
|
||||
For running this docker, simply use the following commands:
|
||||
```bash
|
||||
# run the container detached, forward internal port 25500 to host port 25500
|
||||
docker run -d --restart=always -p 25500:25500 asdlokj1qpi23/subconverter:latest
|
||||
# then check its status
|
||||
curl http://localhost:25500/version
|
||||
# if you see `subconverter vx.x.x backend` then the container is up and running
|
||||
```
|
||||
Or run in docker-compose:
|
||||
```yaml
|
||||
---
|
||||
version: '3'
|
||||
services:
|
||||
subconverter:
|
||||
image: asdlokj1qpi23/subconverter:latest
|
||||
container_name: subconverter
|
||||
ports:
|
||||
- "15051:25500"
|
||||
restart: always
|
||||
```
|
||||
## Supported Types
|
||||
|
||||
| Type | As Source | As Target | Target Name |
|
||||
@@ -36,9 +61,11 @@ Utility to convert between various proxy subscription formats.
|
||||
| Surge 2 | ✓ | ✓ | surge&ver=2 |
|
||||
| Surge 3 | ✓ | ✓ | surge&ver=3 |
|
||||
| Surge 4 | ✓ | ✓ | surge&ver=4 |
|
||||
| Surge 5 | ✓ | ✓ | surge&ver=5 |
|
||||
| V2Ray | ✓ | ✓ | v2ray |
|
||||
| Telegram-liked HTTP/Socks 5 links | ✓ | × | Only as source |
|
||||
| Singbox | × | ✓ | singbox |
|
||||
| Singbox | ✓ | ✓ | singbox |
|
||||
|
||||
Notice:
|
||||
|
||||
1. Shadowrocket users should use `ss`, `ssr` or `v2ray` as target.
|
||||
@@ -95,7 +122,7 @@ Finally subscribe this link in Clash and you are done!
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
Please refer to [中文文档](https://github.com/tindy2013/subconverter/blob/master/README-cn.md#%E8%BF%9B%E9%98%B6%E7%94%A8%E6%B3%95).
|
||||
Please refer to [中文文档](https://github.com/asdlokj1qpi23/subconverter/blob/master/README-cn.md#%E8%BF%9B%E9%98%B6%E7%94%A8%E6%B3%95).
|
||||
|
||||
## Auto Upload
|
||||
|
||||
@@ -110,3 +137,6 @@ Example:
|
||||
;uncomment the following line and enter your token to enable upload function
|
||||
token = xxxxxxxxxxxxxxxxxxxxxxxx(Your Personal Access Token)
|
||||
```
|
||||
## Thanks
|
||||
[tindy2013](https://github.com/tindy2013)
|
||||
[https://github.com/tindy2013/subconverter](https://github.com/tindy2013/subconverter)
|
||||
@@ -117,10 +117,10 @@ match = '^Smart Access expire: (\d+)/(\d+)/(\d+)$'
|
||||
replace = '$1:$2:$3:0:0:0'
|
||||
|
||||
[node_pref]
|
||||
udp_flag = true
|
||||
tcp_fast_open_flag = false
|
||||
skip_cert_verify_flag = true
|
||||
tls13_flag = false
|
||||
#udp_flag = true
|
||||
#tcp_fast_open_flag = false
|
||||
#skip_cert_verify_flag = true
|
||||
#tls13_flag = false
|
||||
|
||||
sort_flag = false
|
||||
# Script used for sorting nodes. A "compare" function with 2 arguments which are the 2 nodes to be compared should be defined in the script. Supports inline script and script path.
|
||||
|
||||
@@ -35,7 +35,7 @@ RUN set -xe && \
|
||||
cmake -DCMAKE_CXX_STANDARD=11 . && \
|
||||
make install -j $THREADS && \
|
||||
cd .. && \
|
||||
git clone https://github.com/asdlokj1qpi23/subconverter --depth=1 && \
|
||||
git clone https://github.com/asdlokj1qpi233/subconverter --depth=1 && \
|
||||
cd subconverter && \
|
||||
[ -n "$SHA" ] && sed -i 's/\(v[0-9]\.[0-9]\.[0-9]\)/\1-'"$SHA"'/' src/version.h;\
|
||||
python3 -m ensurepip && \
|
||||
|
||||
@@ -14,49 +14,47 @@ brew reinstall rapidjson zlib pcre2 pkgconfig
|
||||
git clone https://github.com/jbeder/yaml-cpp --depth=1
|
||||
cd yaml-cpp
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF . > /dev/null
|
||||
make install -j8 > /dev/null
|
||||
make -j6 > /dev/null
|
||||
sudo make install > /dev/null
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ftk/quickjspp --depth=1
|
||||
cd quickjspp
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make quickjs -j8
|
||||
install -d /usr/local/lib/quickjs/
|
||||
install -m644 quickjs/libquickjs.a /usr/local/lib/quickjs/
|
||||
install -d /usr/local/include/quickjs/
|
||||
install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/local/include/quickjs/
|
||||
install -m644 quickjspp.hpp /usr/local/include/
|
||||
make quickjs -j6 > /dev/null
|
||||
sudo install -d /usr/local/lib/quickjs/
|
||||
sudo install -m644 quickjs/libquickjs.a /usr/local/lib/quickjs/
|
||||
sudo install -d /usr/local/include/quickjs/
|
||||
sudo install -m644 quickjs/quickjs.h quickjs/quickjs-libc.h /usr/local/include/quickjs/
|
||||
sudo install -m644 quickjspp.hpp /usr/local/include/
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/PerMalmberg/libcron --depth=1
|
||||
cd libcron
|
||||
git submodule update --init
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make libcron install -j8
|
||||
install -m644 libcron/out/Release/liblibcron.a /usr/local/lib/
|
||||
install -d /usr/local/include/libcron/
|
||||
install -m644 libcron/include/libcron/* /usr/local/include/libcron/
|
||||
install -d /usr/local/include/date/
|
||||
install -m644 libcron/externals/date/include/date/* /usr/local/include/date/
|
||||
make libcron -j6
|
||||
sudo install -m644 libcron/out/Release/liblibcron.a /usr/local/lib/
|
||||
sudo install -d /usr/local/include/libcron/
|
||||
sudo install -m644 libcron/include/libcron/* /usr/local/include/libcron/
|
||||
sudo install -d /usr/local/include/date/
|
||||
sudo install -m644 libcron/externals/date/include/date/* /usr/local/include/date/
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ToruNiina/toml11 --depth=1
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||
cd toml11
|
||||
cmake -DCMAKE_CXX_STANDARD=11 .
|
||||
make install -j4
|
||||
sudo make install -j6 > /dev/null
|
||||
cd ..
|
||||
|
||||
cp /usr/local/opt/zlib/lib/libz.a .
|
||||
cp /usr/local/lib/libpcre2-8.a .
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j8
|
||||
make -j6
|
||||
rm subconverter
|
||||
# shellcheck disable=SC2046
|
||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter -framework CoreFoundation -framework Security $(find CMakeFiles/subconverter.dir/src/ -name "*.o") $(find . -name "*.a") -lcurl -O3
|
||||
c++ -Xlinker -unexported_symbol -Xlinker "*" -o base/subconverter -framework CoreFoundation -framework Security $(find CMakeFiles/subconverter.dir/src/ -name "*.o") "$(brew --prefix zlib)/lib/libz.a" "$(brew --prefix pcre2)/lib/libpcre2-8.a" $(find . -name "*.a") -lcurl -O3
|
||||
|
||||
python -m ensurepip
|
||||
python -m pip install gitpython
|
||||
sudo python -m pip install gitpython
|
||||
python scripts/update_rules.py -c scripts/rules_config.conf
|
||||
|
||||
cd base
|
||||
@@ -65,4 +63,4 @@ chmod +r ./*
|
||||
cd ..
|
||||
mv base subconverter
|
||||
|
||||
set +xe
|
||||
set +xe
|
||||
@@ -1,9 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -xe
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_4_0
|
||||
# 获取系统架构
|
||||
ARCH=$(uname -m)
|
||||
|
||||
if [ "$ARCH" == "x86_64" ]; then
|
||||
TOOLCHAIN="mingw-w64-x86_64"
|
||||
else
|
||||
TOOLCHAIN="mingw-w64-i686"
|
||||
fi
|
||||
|
||||
pacman -S --needed --noconfirm base-devel ${TOOLCHAIN}-toolchain ${TOOLCHAIN}-cmake ${TOOLCHAIN}-nghttp2 ${TOOLCHAIN}-openssl
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_8_0
|
||||
cd curl
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCURL_USE_LIBSSH2=OFF -DHTTP_ONLY=ON -DCURL_USE_SCHANNEL=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DHAVE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF .
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCURL_USE_LIBSSH2=OFF \
|
||||
-DHTTP_ONLY=ON \
|
||||
-DCURL_USE_SCHANNEL=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_CURL_EXE=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" \
|
||||
-G "Unix Makefiles" \
|
||||
-DHAVE_LIBIDN2=OFF \
|
||||
-DCURL_USE_LIBPSL=OFF \
|
||||
-DCURL_STATICLIB=ON \
|
||||
-DCURL_DISABLE_SOCKETPAIR=ON \
|
||||
-DCURL_DISABLE_NONBLOCKING=ON .
|
||||
|
||||
make install -j4
|
||||
cd ..
|
||||
|
||||
@@ -38,7 +62,7 @@ cmake -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD
|
||||
make install -j4
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ToruNiina/toml11 --depth=1
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||
cd toml11
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=11 .
|
||||
make install -j4
|
||||
|
||||
@@ -13,8 +13,8 @@ dest=base/config/
|
||||
keep_tree=false
|
||||
|
||||
[DivineEngine]
|
||||
url=https://github.com/DivineEngine/Profiles
|
||||
checkout=f4d75f7d48a3f42129e030bef751d4d22bca02da
|
||||
url=https://github.com/asdlokj1qpi233/Profiles.git
|
||||
checkout=f6302d855192bd8d0be08319dff3e58ae7c2bd4e
|
||||
match=Surge/Ruleset/**
|
||||
|
||||
[NobyDa]
|
||||
|
||||
23
scripts/rules_config_bak.conf
Normal file
23
scripts/rules_config_bak.conf
Normal file
@@ -0,0 +1,23 @@
|
||||
[ACL4SSR]
|
||||
name=ACL4SSR
|
||||
url=https://github.com/ACL4SSR/ACL4SSR
|
||||
checkout=1dc5c92b0c8ceaaecbc66530c309961f53e52c8c
|
||||
match=Clash/*.list|Clash/Ruleset/**
|
||||
|
||||
[ACL4SSR_config]
|
||||
name=ACL4SSR
|
||||
url=https://github.com/ACL4SSR/ACL4SSR
|
||||
checkout=1dc5c92b0c8ceaaecbc66530c309961f53e52c8c
|
||||
match=Clash/config/**
|
||||
dest=base/config/
|
||||
keep_tree=false
|
||||
|
||||
[DivineEngine]
|
||||
url=https://github.com/DivineEngine/Profiles
|
||||
checkout=f4d75f7d48a3f42129e030bef751d4d22bca02da
|
||||
match=Surge/Ruleset/**
|
||||
|
||||
[NobyDa]
|
||||
url=https://github.com/NobyDa/Script
|
||||
checkout=ae4c12f23de8078e02c373c9969b19af28257fcb
|
||||
match=Surge/*.list
|
||||
@@ -238,7 +238,6 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
xudp.define(x.XUDP);
|
||||
scv.define(x.AllowInsecure);
|
||||
tfo.define(x.TCPFastOpen);
|
||||
|
||||
singleproxy["name"] = x.Remark;
|
||||
singleproxy["server"] = x.Hostname;
|
||||
singleproxy["port"] = x.Port;
|
||||
@@ -278,6 +277,12 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
singleproxy["alterId"] = x.AlterId;
|
||||
singleproxy["cipher"] = x.EncryptMethod;
|
||||
singleproxy["tls"] = x.TLSSecure;
|
||||
if (!x.AlpnList.empty()) {
|
||||
for (auto &item: x.AlpnList) {
|
||||
singleproxy["alpn"].push_back(item);
|
||||
}
|
||||
} else if (!x.Alpn.empty())
|
||||
singleproxy["alpn"].push_back(x.Alpn);
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
if (!x.ServerName.empty())
|
||||
@@ -382,10 +387,20 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
case ProxyType::Trojan:
|
||||
singleproxy["type"] = "trojan";
|
||||
singleproxy["password"] = x.Password;
|
||||
if (!x.Host.empty())
|
||||
if (!x.ServerName.empty())
|
||||
singleproxy["sni"] = x.ServerName;
|
||||
else if (!x.Host.empty()) {
|
||||
singleproxy["sni"] = x.Host;
|
||||
if (std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty())
|
||||
}
|
||||
if (!x.AlpnList.empty()) {
|
||||
for (auto &item: x.AlpnList) {
|
||||
singleproxy["alpn"].push_back(item);
|
||||
}
|
||||
} else if (!x.Alpn.empty())
|
||||
singleproxy["alpn"].push_back(x.Alpn);
|
||||
if (std::all_of(x.Password.begin(), x.Password.end(), ::isdigit) && !x.Password.empty()) {
|
||||
singleproxy["password"].SetTag("str");
|
||||
}
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
switch (hash_(x.TransferProtocol)) {
|
||||
@@ -436,14 +451,19 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
case ProxyType::Hysteria:
|
||||
singleproxy["type"] = "hysteria";
|
||||
singleproxy["auth_str"] = x.Auth;
|
||||
singleproxy["auth-str"] = x.Auth;
|
||||
singleproxy["up"] = x.UpMbps;
|
||||
singleproxy["down"] = x.DownMbps;
|
||||
if (!tfo.is_undef())
|
||||
if (!x.Ports.empty()) {
|
||||
singleproxy["ports"] = x.Ports;
|
||||
}
|
||||
if (!tfo.is_undef()) {
|
||||
singleproxy["fast-open"] = tfo.get();
|
||||
}
|
||||
if (!x.FakeType.empty())
|
||||
singleproxy["protocol"] = x.FakeType;
|
||||
if (!x.Host.empty())
|
||||
singleproxy["sni"] = x.Host;
|
||||
if (!x.ServerName.empty())
|
||||
singleproxy["sni"] = x.ServerName;
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
if (x.Insecure == "1")
|
||||
@@ -457,12 +477,16 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
singleproxy["type"] = "hysteria2";
|
||||
singleproxy["password"] = x.Password;
|
||||
singleproxy["auth"] = x.Password;
|
||||
if (!x.PublicKey.empty()) {
|
||||
singleproxy["ca-str"] = x.PublicKey;
|
||||
}
|
||||
if (!x.ServerName.empty()) {
|
||||
singleproxy["sni"] = x.ServerName;
|
||||
}
|
||||
if (!x.UpMbps.empty())
|
||||
singleproxy["up"] = x.UpMbps;
|
||||
if (!x.DownMbps.empty())
|
||||
singleproxy["down"] = x.DownMbps;
|
||||
if (!x.Host.empty())
|
||||
singleproxy["sni"] = x.Host;
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
if (!x.Alpn.empty())
|
||||
@@ -471,17 +495,55 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
singleproxy["obfs"] = x.OBFSParam;
|
||||
if (!x.OBFSPassword.empty())
|
||||
singleproxy["obfs-password"] = x.OBFSPassword;
|
||||
if (!x.Ports.empty())
|
||||
singleproxy["ports"] = x.Ports;
|
||||
break;
|
||||
case ProxyType::TUIC:
|
||||
singleproxy["type"] = "tuic";
|
||||
if (!x.Password.empty()) {
|
||||
singleproxy["password"] = x.Password;
|
||||
}
|
||||
if (!x.UserId.empty()) {
|
||||
singleproxy["uuid"] = x.UserId;
|
||||
}
|
||||
if (!x.token.empty()) {
|
||||
singleproxy["token"] = x.token;
|
||||
}
|
||||
if (!x.ServerName.empty()) {
|
||||
singleproxy["sni"] = x.ServerName;
|
||||
}
|
||||
if (!scv.is_undef())
|
||||
singleproxy["skip-cert-verify"] = scv.get();
|
||||
if (!x.Alpn.empty())
|
||||
singleproxy["alpn"].push_back(x.Alpn);
|
||||
singleproxy["disable-sni"] = x.DisableSni.get();
|
||||
singleproxy["reduce-rtt"] = x.ReduceRtt.get();
|
||||
singleproxy["request-timeout"] = x.RequestTimeout;
|
||||
if (!x.UdpRelayMode.empty()) {
|
||||
if (x.UdpRelayMode == "native" || x.UdpRelayMode == "quic") {
|
||||
singleproxy["udp-relay-mode"] = x.UdpRelayMode;
|
||||
}
|
||||
}
|
||||
if (!x.CongestionControl.empty()) {
|
||||
singleproxy["congestion-controller"] = x.CongestionControl;
|
||||
}
|
||||
break;
|
||||
case ProxyType::VLESS:
|
||||
singleproxy["type"] = "vless";
|
||||
singleproxy["uuid"] = x.UserId;
|
||||
singleproxy["tls"] = x.TLSSecure;
|
||||
if (!x.AlpnList.empty()) {
|
||||
for (auto &item: x.AlpnList) {
|
||||
singleproxy["alpn"].push_back(item);
|
||||
}
|
||||
}
|
||||
if (!tfo.is_undef())
|
||||
singleproxy["tfo"] = tfo.get();
|
||||
if (xudp && udp)
|
||||
singleproxy["xudp"] = true;
|
||||
if (!x.Host.empty())
|
||||
singleproxy["servername"] = x.Host;
|
||||
if(!x.PacketEncoding.empty()){
|
||||
singleproxy["packet-encoding"] = x.PacketEncoding;
|
||||
}
|
||||
if (!x.Flow.empty())
|
||||
singleproxy["flow"] = x.Flow;
|
||||
if (!scv.is_undef())
|
||||
@@ -489,11 +551,20 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
if (!x.PublicKey.empty()) {
|
||||
singleproxy["reality-opts"]["public-key"] = x.PublicKey;
|
||||
}
|
||||
if (!x.ServerName.empty())
|
||||
singleproxy["servername"] = x.ServerName;
|
||||
if (!x.ShortId.empty()) {
|
||||
singleproxy["reality-opts"]["short-id"] = x.ShortId;
|
||||
singleproxy["reality-opts"]["short-id"] = "" + x.ShortId;
|
||||
}
|
||||
if (!x.PublicKey.empty() || x.Flow == "xtls-rprx-vision") {
|
||||
singleproxy["client-fingerprint"] = "chrome";
|
||||
}
|
||||
if (!x.Fingerprint.empty()) {
|
||||
singleproxy["client-fingerprint"] = x.Fingerprint;
|
||||
}
|
||||
switch (hash_(x.TransferProtocol)) {
|
||||
case "tcp"_hash:
|
||||
singleproxy["network"] = x.TransferProtocol;
|
||||
break;
|
||||
case "ws"_hash:
|
||||
singleproxy["network"] = x.TransferProtocol;
|
||||
@@ -541,7 +612,7 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
|
||||
// UDP is not supported yet in clash using snell
|
||||
// sees in https://dreamacro.github.io/clash/configuration/outbound.html#snell
|
||||
if (udp && x.Type != ProxyType::Snell)
|
||||
if (udp && x.Type != ProxyType::Snell && x.Type != ProxyType::TUIC)
|
||||
singleproxy["udp"] = true;
|
||||
if (block)
|
||||
singleproxy.SetStyle(YAML::EmitterStyle::Block);
|
||||
@@ -630,6 +701,34 @@ proxyToClash(std::vector<Proxy> &nodes, YAML::Node &yamlnode, const ProxyGroupCo
|
||||
yamlnode["Proxy Group"] = original_groups;
|
||||
}
|
||||
|
||||
void formatterShortId(std::string &input) {
|
||||
std::string target = "short-id:";
|
||||
size_t startPos = input.find(target);
|
||||
|
||||
while (startPos != std::string::npos) {
|
||||
// 查找对应实例的结束位置
|
||||
size_t endPos = input.find("}", startPos);
|
||||
|
||||
if (endPos != std::string::npos) {
|
||||
// 提取原始id
|
||||
std::string originalId = input.substr(startPos + target.length(), endPos - startPos - target.length());
|
||||
|
||||
// 去除原始id中的空格
|
||||
originalId.erase(remove_if(originalId.begin(), originalId.end(), ::isspace), originalId.end());
|
||||
|
||||
// 添加引号
|
||||
std::string modifiedId = " \"" + originalId + "\" ";
|
||||
|
||||
// 替换原始id为修改后的id
|
||||
input.replace(startPos + target.length(), endPos - startPos - target.length(), modifiedId);
|
||||
}
|
||||
|
||||
// 继续查找下一个实例
|
||||
startPos = input.find(target, startPos + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf,
|
||||
std::vector<RulesetContent> &ruleset_content_array, const ProxyGroupConfigs &extra_proxy_group,
|
||||
bool clashR, extra_settings &ext) {
|
||||
@@ -677,6 +776,7 @@ std::string proxyToClash(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
//rulesetToClash(yamlnode, ruleset_content_array, ext.overwrite_original_rules, ext.clash_new_field_name);
|
||||
//std::string output_content = YAML::Dump(yamlnode);
|
||||
replaceAll(output_content, "!<str> ", "");
|
||||
formatterShortId(output_content);
|
||||
return output_content;
|
||||
}
|
||||
|
||||
@@ -740,7 +840,7 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
|
||||
processRemark(x.Remark, remarks_list);
|
||||
|
||||
std::string &hostname = x.Hostname, &username = x.Username, &password = x.Password, &method = x.EncryptMethod, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &edge = x.Edge, &path = x.Path, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &plugin = x.Plugin, &pluginopts = x.PluginOption;
|
||||
std::string &hostname = x.Hostname, &sni = x.ServerName, &username = x.Username, &password = x.Password, &method = x.EncryptMethod, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &edge = x.Edge, &path = x.Path, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &plugin = x.Plugin, &pluginopts = x.PluginOption;
|
||||
std::string port = std::to_string(x.Port);
|
||||
bool &tlssecure = x.TLSSecure;
|
||||
|
||||
@@ -856,8 +956,11 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
proxy = "trojan, " + hostname + ", " + port + ", password=" + password;
|
||||
if (x.SnellVersion != 0)
|
||||
proxy += ", version=" + std::to_string(x.SnellVersion);
|
||||
if (!host.empty())
|
||||
if (!sni.empty()) {
|
||||
proxy += ", sni=" + sni;
|
||||
} else if (!host.empty()) {
|
||||
proxy += ", sni=" + host;
|
||||
}
|
||||
if (!scv.is_undef())
|
||||
proxy += ", skip-cert-verify=" + scv.get_str();
|
||||
break;
|
||||
@@ -871,6 +974,13 @@ std::string proxyToSurge(std::vector<Proxy> &nodes, const std::string &base_conf
|
||||
if (x.SnellVersion != 0)
|
||||
proxy += ", version=" + std::to_string(x.SnellVersion);
|
||||
break;
|
||||
case ProxyType::Hysteria2:
|
||||
if (surge_ver < 4 && surge_ver != -3)
|
||||
continue;
|
||||
proxy = "hysteria2, " + hostname + ", " + port + ", password=" + password;
|
||||
if (!scv.is_undef())
|
||||
proxy += ", skip-cert-verify=" + scv.get_str();
|
||||
break;
|
||||
case ProxyType::WireGuard:
|
||||
if (surge_ver < 4 && surge_ver != -3)
|
||||
continue;
|
||||
@@ -986,7 +1096,7 @@ std::string proxyToSingle(std::vector<Proxy> &nodes, int types, extra_settings &
|
||||
|
||||
for (Proxy &x: nodes) {
|
||||
std::string remark = x.Remark;
|
||||
std::string &hostname = x.Hostname, &password = x.Password, &method = x.EncryptMethod, &plugin = x.Plugin, &pluginopts = x.PluginOption, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &path = x.Path, &faketype = x.FakeType;
|
||||
std::string &hostname = x.Hostname, &sni = x.ServerName, &password = x.Password, &method = x.EncryptMethod, &plugin = x.Plugin, &pluginopts = x.PluginOption, &protocol = x.Protocol, &protoparam = x.ProtocolParam, &obfs = x.OBFS, &obfsparam = x.OBFSParam, &id = x.UserId, &transproto = x.TransferProtocol, &host = x.Host, &path = x.Path, &faketype = x.FakeType;
|
||||
bool &tlssecure = x.TLSSecure;
|
||||
std::string port = std::to_string(x.Port);
|
||||
std::string aid = std::to_string(x.AlterId);
|
||||
@@ -1036,8 +1146,11 @@ std::string proxyToSingle(std::vector<Proxy> &nodes, int types, extra_settings &
|
||||
continue;
|
||||
proxyStr = "trojan://" + password + "@" + hostname + ":" + port + "?allowInsecure=" +
|
||||
(x.AllowInsecure.get() ? "1" : "0");
|
||||
if (!host.empty())
|
||||
if (!sni.empty()) {
|
||||
proxyStr += "&sni=" + sni;
|
||||
} else if (!host.empty()) {
|
||||
proxyStr += "&sni=" + host;
|
||||
}
|
||||
if (transproto == "ws") {
|
||||
proxyStr += "&ws=1";
|
||||
if (!path.empty())
|
||||
@@ -1403,6 +1516,25 @@ void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<Ruleset
|
||||
} else if (tlssecure)
|
||||
proxyStr += ", obfs=over-tls, obfs-host=" + host;
|
||||
break;
|
||||
case ProxyType::VLESS:
|
||||
if (method == "auto")
|
||||
method = "none";
|
||||
else
|
||||
method = "none";
|
||||
proxyStr = "vless = " + hostname + ":" + port + ", method=" + method + ", password=" + id;
|
||||
if (x.AlterId != 0)
|
||||
proxyStr += ", aead=false";
|
||||
if (tlssecure && !tls13.is_undef())
|
||||
proxyStr += ", tls13=" + std::string(tls13 ? "true" : "false");
|
||||
if (transproto == "ws") {
|
||||
if (tlssecure)
|
||||
proxyStr += ", obfs=wss";
|
||||
else
|
||||
proxyStr += ", obfs=ws";
|
||||
proxyStr += ", obfs-host=" + host + ", obfs-uri=" + path;
|
||||
} else if (tlssecure)
|
||||
proxyStr += ", obfs=over-tls, obfs-host=" + host;
|
||||
break;
|
||||
case ProxyType::Shadowsocks:
|
||||
proxyStr = "shadowsocks = " + hostname + ":" + port + ", method=" + method + ", password=" + password;
|
||||
if (!plugin.empty()) {
|
||||
@@ -1486,7 +1618,8 @@ void proxyToQuanX(std::vector<Proxy> &nodes, INIReader &ini, std::vector<Ruleset
|
||||
proxyStr += ", fast-open=" + tfo.get_str();
|
||||
if (!udp.is_undef())
|
||||
proxyStr += ", udp-relay=" + udp.get_str();
|
||||
if (tlssecure && !scv.is_undef() && (x.Type != ProxyType::Shadowsocks && x.Type != ProxyType::ShadowsocksR))
|
||||
if (tlssecure && !scv.is_undef() &&
|
||||
(x.Type != ProxyType::Shadowsocks && x.Type != ProxyType::ShadowsocksR && x.Type != ProxyType::VLESS))
|
||||
proxyStr += ", tls-verification=" + scv.reverse().get_str();
|
||||
proxyStr += ", tag=" + x.Remark;
|
||||
|
||||
@@ -1934,14 +2067,48 @@ proxyToLoon(std::vector<Proxy> &nodes, const std::string &base_conf, std::vector
|
||||
proxy += ", keepalive=" + std::to_string(x.KeepAlive);
|
||||
proxy += ", peers=[{" + generatePeer(x, true) + "}]";
|
||||
break;
|
||||
case ProxyType::Hysteria2:
|
||||
proxy = "Hysteria2," + hostname + "," + port + ",\"" + password + "\"";
|
||||
if (!x.ServerName.empty()) {
|
||||
proxy += ",sni=" + x.ServerName;
|
||||
}
|
||||
if (!x.UpMbps.empty()) {
|
||||
std::string search = " Mbps";
|
||||
size_t pos = x.UpMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.UpMbps.replace(pos, search.length(), "");
|
||||
} else {
|
||||
search = "Mbps";
|
||||
pos = x.UpMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.UpMbps.replace(pos, search.length(), "");
|
||||
}
|
||||
}
|
||||
proxy += ",download-bandwidth=" + x.UpMbps;
|
||||
} else {
|
||||
proxy += ",download-bandwidth=100";
|
||||
}
|
||||
if (!scv.is_undef())
|
||||
proxy += ",skip-cert-verify=" + std::string(scv.get() ? "true" : "false");
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ext.tfo)
|
||||
if (ext.tfo) {
|
||||
proxy += ",fast-open=true";
|
||||
if (ext.udp)
|
||||
} else {
|
||||
if (x.Type == ProxyType::Hysteria2) {
|
||||
proxy += ",fast-open=false";
|
||||
}
|
||||
}
|
||||
if (ext.udp) {
|
||||
proxy += ",udp=true";
|
||||
} else {
|
||||
if (x.Type == ProxyType::Hysteria2) {
|
||||
proxy += ",udp=true";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ext.nodelist)
|
||||
@@ -2109,6 +2276,23 @@ static rapidjson::Value stringArrayToJsonArray(const std::string &array, const s
|
||||
return result;
|
||||
}
|
||||
|
||||
static rapidjson::Value
|
||||
vectorToJsonArray(const std::vector<std::string> &array, rapidjson::MemoryPoolAllocator<> &allocator) {
|
||||
rapidjson::Value result(rapidjson::kArrayType);
|
||||
for (const auto &x: array)
|
||||
result.PushBack(rapidjson::Value(trim(x).c_str(), allocator), allocator);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isNumeric(const std::string &str) {
|
||||
for (char c: str) {
|
||||
if (!std::isdigit(static_cast<unsigned char>(c))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector<RulesetContent> &ruleset_content_array,
|
||||
const ProxyGroupConfigs &extra_proxy_group, extra_settings &ext) {
|
||||
@@ -2117,6 +2301,7 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
rapidjson::Value outbounds(rapidjson::kArrayType), route(rapidjson::kArrayType);
|
||||
std::vector<Proxy> nodelist;
|
||||
string_array remarks_list;
|
||||
std::string search = " Mbps";
|
||||
|
||||
if (!ext.nodelist) {
|
||||
auto direct = buildObject(allocator, "type", "direct", "tag", "DIRECT");
|
||||
@@ -2149,21 +2334,24 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
if (!x.Plugin.empty() && !x.PluginOption.empty()) {
|
||||
if (x.Plugin == "simple-obfs")
|
||||
x.Plugin = "obfs-local";
|
||||
if (x.Plugin != "obfs-local" && x.Plugin != "v2ray-plugin") {
|
||||
continue;
|
||||
}
|
||||
proxy.AddMember("plugin", rapidjson::StringRef(x.Plugin.c_str()), allocator);
|
||||
proxy.AddMember("plugin_opts", rapidjson::StringRef(x.PluginOption.c_str()), allocator);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProxyType::ShadowsocksR: {
|
||||
addSingBoxCommonMembers(proxy, x, "shadowsocksr", allocator);
|
||||
proxy.AddMember("method", rapidjson::StringRef(x.EncryptMethod.c_str()), allocator);
|
||||
proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||
proxy.AddMember("protocol", rapidjson::StringRef(x.Protocol.c_str()), allocator);
|
||||
proxy.AddMember("protocol_param", rapidjson::StringRef(x.ProtocolParam.c_str()), allocator);
|
||||
proxy.AddMember("obfs", rapidjson::StringRef(x.OBFS.c_str()), allocator);
|
||||
proxy.AddMember("obfs_param", rapidjson::StringRef(x.OBFSParam.c_str()), allocator);
|
||||
break;
|
||||
}
|
||||
// case ProxyType::ShadowsocksR: {
|
||||
// addSingBoxCommonMembers(proxy, x, "shadowsocksr", allocator);
|
||||
// proxy.AddMember("method", rapidjson::StringRef(x.EncryptMethod.c_str()), allocator);
|
||||
// proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||
// proxy.AddMember("protocol", rapidjson::StringRef(x.Protocol.c_str()), allocator);
|
||||
// proxy.AddMember("protocol_param", rapidjson::StringRef(x.ProtocolParam.c_str()), allocator);
|
||||
// proxy.AddMember("obfs", rapidjson::StringRef(x.OBFS.c_str()), allocator);
|
||||
// proxy.AddMember("obfs_param", rapidjson::StringRef(x.OBFSParam.c_str()), allocator);
|
||||
// break;
|
||||
// }
|
||||
case ProxyType::VMess: {
|
||||
addSingBoxCommonMembers(proxy, x, "vmess", allocator);
|
||||
proxy.AddMember("uuid", rapidjson::StringRef(x.UserId.c_str()), allocator);
|
||||
@@ -2175,49 +2363,53 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
proxy.AddMember("transport", transport, allocator);
|
||||
break;
|
||||
}
|
||||
// TODO VLESS后续支持
|
||||
case ProxyType::VLESS: {
|
||||
addSingBoxCommonMembers(proxy, x, "vmess", allocator);
|
||||
addSingBoxCommonMembers(proxy, x, "vless", allocator);
|
||||
proxy.AddMember("uuid", rapidjson::StringRef(x.UserId.c_str()), allocator);
|
||||
if (xudp && udp)
|
||||
proxy.AddMember("packet_encoding", rapidjson::StringRef("xudp"), allocator);
|
||||
if (!x.Host.empty())
|
||||
proxy.AddMember("server", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
if (!x.Flow.empty())
|
||||
proxy.AddMember("flow", rapidjson::StringRef(x.Flow.c_str()), allocator);
|
||||
rapidjson::Value transport(rapidjson::kObjectType);
|
||||
if(!x.PacketEncoding.empty()){
|
||||
proxy.AddMember("packet_encoding", rapidjson::StringRef(x.PacketEncoding.c_str()), allocator);
|
||||
}
|
||||
rapidjson::Value vlesstransport(rapidjson::kObjectType);
|
||||
rapidjson::Value vlessheaders(rapidjson::kObjectType);
|
||||
switch (hash_(x.TransferProtocol)) {
|
||||
case "tcp"_hash:
|
||||
proxy.AddMember("network", rapidjson::StringRef("ws"), allocator);
|
||||
break;
|
||||
case "ws"_hash:
|
||||
transport.AddMember("type", rapidjson::StringRef("ws"), allocator);
|
||||
transport.AddMember("host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
transport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
addHeaders(transport, x, allocator);
|
||||
proxy.AddMember("transport", transport, allocator);
|
||||
if (x.Path.empty())
|
||||
vlesstransport.AddMember("path", "/", allocator);
|
||||
else
|
||||
vlesstransport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
if (!x.Host.empty())
|
||||
vlessheaders.AddMember("Host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
if (!x.Edge.empty())
|
||||
vlessheaders.AddMember("Edge", rapidjson::StringRef(x.Edge.c_str()), allocator);
|
||||
vlesstransport.AddMember("type", rapidjson::StringRef("ws"), allocator);
|
||||
addHeaders(vlesstransport, x, allocator);
|
||||
proxy.AddMember("transport", vlesstransport, allocator);
|
||||
break;
|
||||
case "http"_hash:
|
||||
transport.AddMember("type", rapidjson::StringRef("http"), allocator);
|
||||
transport.AddMember("host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
transport.AddMember("method", rapidjson::StringRef("GET"), allocator);
|
||||
transport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
addHeaders(transport, x, allocator);
|
||||
proxy.AddMember("transport", transport, allocator);
|
||||
vlesstransport.AddMember("type", rapidjson::StringRef("http"), allocator);
|
||||
vlesstransport.AddMember("host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
vlesstransport.AddMember("method", rapidjson::StringRef("GET"), allocator);
|
||||
vlesstransport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
addHeaders(vlesstransport, x, allocator);
|
||||
proxy.AddMember("transport", vlesstransport, allocator);
|
||||
break;
|
||||
case "h2"_hash:
|
||||
transport.AddMember("type", rapidjson::StringRef("httpupgrade"), allocator);
|
||||
transport.AddMember("host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
transport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
proxy.AddMember("transport", transport, allocator);
|
||||
vlesstransport.AddMember("type", rapidjson::StringRef("httpupgrade"), allocator);
|
||||
vlesstransport.AddMember("host", rapidjson::StringRef(x.Host.c_str()), allocator);
|
||||
vlesstransport.AddMember("path", rapidjson::StringRef(x.Path.c_str()), allocator);
|
||||
proxy.AddMember("transport", vlesstransport, allocator);
|
||||
break;
|
||||
case "grpc"_hash:
|
||||
transport.AddMember("type", rapidjson::StringRef("grpc"), allocator);
|
||||
transport.AddMember("service_name", rapidjson::StringRef(x.GRPCServiceName.c_str()), allocator);
|
||||
if (!x.GRPCMode.empty()) {
|
||||
transport.AddMember("permit_without_stream", rapidjson::StringRef("true"), allocator);
|
||||
}
|
||||
proxy.AddMember("transport", transport, allocator);
|
||||
vlesstransport.AddMember("type", rapidjson::StringRef("grpc"), allocator);
|
||||
vlesstransport.AddMember("service_name", rapidjson::StringRef(x.GRPCServiceName.c_str()),
|
||||
allocator);
|
||||
proxy.AddMember("transport", vlesstransport, allocator);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
@@ -2236,13 +2428,15 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
case ProxyType::WireGuard: {
|
||||
proxy.AddMember("type", "wireguard", allocator);
|
||||
proxy.AddMember("tag", rapidjson::StringRef(x.Remark.c_str()), allocator);
|
||||
proxy.AddMember("inet4_bind_address", rapidjson::StringRef(x.SelfIP.c_str()), allocator);
|
||||
rapidjson::Value addresses(rapidjson::kArrayType);
|
||||
addresses.PushBack(rapidjson::StringRef(x.SelfIP.c_str()), allocator);
|
||||
if (!x.SelfIPv6.empty())
|
||||
addresses.PushBack(rapidjson::StringRef(x.SelfIPv6.c_str()), allocator);
|
||||
addresses.PushBack(rapidjson::StringRef(x.SelfIP.append("/32").c_str()), allocator);
|
||||
// if (!x.SelfIPv6.empty())
|
||||
// addresses.PushBack(rapidjson::StringRef(x.SelfIPv6.c_str()), allocator);
|
||||
proxy.AddMember("local_address", addresses, allocator);
|
||||
if (!x.SelfIPv6.empty())
|
||||
proxy.AddMember("inet6_bind_address", rapidjson::StringRef(x.SelfIPv6.c_str()), allocator);
|
||||
proxy.AddMember("private_key", rapidjson::StringRef(x.PrivateKey.c_str()), allocator);
|
||||
|
||||
rapidjson::Value peer(rapidjson::kObjectType);
|
||||
peer.AddMember("server", rapidjson::StringRef(x.Hostname.c_str()), allocator);
|
||||
peer.AddMember("server_port", x.Port, allocator);
|
||||
@@ -2259,7 +2453,9 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
auto reserved = stringArrayToJsonArray(x.ClientId, ",", allocator);
|
||||
peer.AddMember("reserved", reserved, allocator);
|
||||
}
|
||||
|
||||
if (!x.Password.empty()) {
|
||||
proxy.AddMember("pre_shared_key", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||
}
|
||||
rapidjson::Value peers(rapidjson::kArrayType);
|
||||
peers.PushBack(peer, allocator);
|
||||
proxy.AddMember("peers", peers, allocator);
|
||||
@@ -2283,19 +2479,39 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
case ProxyType::Hysteria: {
|
||||
addSingBoxCommonMembers(proxy, x, "hysteria", allocator);
|
||||
proxy.AddMember("auth_str", rapidjson::StringRef(x.Auth.c_str()), allocator);
|
||||
proxy.AddMember("up", rapidjson::StringRef(x.UpMbps.c_str()), allocator);
|
||||
proxy.AddMember("down", rapidjson::StringRef(x.DownMbps.c_str()), allocator);
|
||||
rapidjson::Value tls(rapidjson::kObjectType);
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
proxy.AddMember("tls", tls, allocator);
|
||||
if (!tfo.is_undef())
|
||||
proxy.AddMember("tcp_fast_open",
|
||||
rapidjson::StringRef(std::string(tfo.get() ? "true" : "false").c_str()), allocator);
|
||||
if (isNumeric(x.UpMbps)) {
|
||||
proxy.AddMember("up_mbps", std::stoi(x.UpMbps), allocator);
|
||||
} else {
|
||||
size_t pos = x.UpMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.UpMbps.replace(pos, search.length(), "");
|
||||
}
|
||||
proxy.AddMember("up_mbps", std::stoi(x.UpMbps), allocator);
|
||||
}
|
||||
if (isNumeric(x.DownMbps)) {
|
||||
proxy.AddMember("down_mbps", std::stoi(x.DownMbps), allocator);
|
||||
} else {
|
||||
size_t pos = x.DownMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.DownMbps.replace(pos, search.length(), "");
|
||||
}
|
||||
proxy.AddMember("down_mbps", std::stoi(x.DownMbps), allocator);
|
||||
}
|
||||
if (!x.TLSSecure) {
|
||||
rapidjson::Value tls(rapidjson::kObjectType);
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
if (!x.Alpn.empty()) {
|
||||
auto alpns = stringArrayToJsonArray(x.Alpn, ",", allocator);
|
||||
tls.AddMember("alpn", alpns, allocator);
|
||||
}
|
||||
if (!x.ServerName.empty()) {
|
||||
tls.AddMember("server_name", rapidjson::StringRef(x.ServerName.c_str()), allocator);
|
||||
}
|
||||
tls.AddMember("insecure", buildBooleanValue(scv), allocator);
|
||||
proxy.AddMember("tls", tls, allocator);
|
||||
}
|
||||
if (!x.FakeType.empty())
|
||||
proxy.AddMember("network", rapidjson::StringRef(x.FakeType.c_str()), allocator);
|
||||
if (!x.Alpn.empty())
|
||||
proxy.AddMember("tls", rapidjson::StringRef(
|
||||
std::string(R"({ "enabled": true,"alpn": [)" + x.Alpn + "],}").c_str()), allocator);
|
||||
if (!x.OBFSParam.empty())
|
||||
proxy.AddMember("obfs", rapidjson::StringRef(x.OBFSParam.c_str()), allocator);
|
||||
break;
|
||||
@@ -2303,26 +2519,80 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
case ProxyType::Hysteria2: {
|
||||
addSingBoxCommonMembers(proxy, x, "hysteria2", allocator);
|
||||
proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||
rapidjson::Value tls(rapidjson::kObjectType);
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
proxy.AddMember("tls", tls, allocator);
|
||||
if (!x.UpMbps.empty())
|
||||
proxy.AddMember("up_mbps", rapidjson::StringRef(x.UpMbps.c_str()), allocator);
|
||||
if (!x.DownMbps.empty())
|
||||
proxy.AddMember("down_mbps", rapidjson::StringRef(x.DownMbps.c_str()), allocator);
|
||||
if (!x.Alpn.empty())
|
||||
proxy.AddMember("tls", rapidjson::StringRef(
|
||||
std::string(R"({ "enabled": true,"alpn": [)" + x.Alpn + "],}").c_str()), allocator);
|
||||
if (!x.OBFSParam.empty()) {
|
||||
if (!x.OBFSPassword.empty()) {
|
||||
proxy.AddMember("obfs", rapidjson::StringRef(std::string(
|
||||
R"({ "type": )" + x.OBFSParam + ",password: \"" + x.OBFSPassword + "\"}").c_str()),
|
||||
allocator);
|
||||
} else {
|
||||
proxy.AddMember("obfs",
|
||||
rapidjson::StringRef(std::string(R"({ "type": )" + x.OBFSParam + "}").c_str()),
|
||||
allocator);
|
||||
if (!x.TLSSecure) {
|
||||
|
||||
rapidjson::Value tls(rapidjson::kObjectType);
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
if (!x.ServerName.empty())
|
||||
tls.AddMember("server_name", rapidjson::StringRef(x.ServerName.c_str()), allocator);
|
||||
if (!x.Alpn.empty()) {
|
||||
auto alpns = stringArrayToJsonArray(x.Alpn, ",", allocator);
|
||||
tls.AddMember("alpn", alpns, allocator);
|
||||
}
|
||||
if (!x.PublicKey.empty()) {
|
||||
tls.AddMember("certificate", rapidjson::StringRef(x.PublicKey.c_str()), allocator);
|
||||
}
|
||||
tls.AddMember("insecure", buildBooleanValue(scv), allocator);
|
||||
proxy.AddMember("tls", tls, allocator);
|
||||
}
|
||||
if (!x.UpMbps.empty()) {
|
||||
if (!isNumeric(x.UpMbps)) {
|
||||
size_t pos = x.UpMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.UpMbps.replace(pos, search.length(), "");
|
||||
}
|
||||
}
|
||||
proxy.AddMember("up_mbps", std::stoi(x.UpMbps), allocator);
|
||||
}
|
||||
if (!x.DownMbps.empty()) {
|
||||
if (!isNumeric(x.DownMbps)) {
|
||||
size_t pos = x.DownMbps.find(search);
|
||||
if (pos != std::string::npos) {
|
||||
x.DownMbps.replace(pos, search.length(), "");
|
||||
}
|
||||
}
|
||||
proxy.AddMember("down_mbps", std::stoi(x.DownMbps), allocator);
|
||||
}
|
||||
if (!x.OBFSParam.empty()) {
|
||||
rapidjson::Value obfs(rapidjson::kObjectType);
|
||||
obfs.AddMember("type", rapidjson::StringRef(x.OBFSParam.c_str()), allocator);
|
||||
if (!x.OBFSPassword.empty()) {
|
||||
obfs.AddMember("password", rapidjson::StringRef(x.OBFSPassword.c_str()), allocator);
|
||||
}
|
||||
proxy.AddMember("obfs", obfs, allocator);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ProxyType::TUIC: {
|
||||
addSingBoxCommonMembers(proxy, x, "tuic", allocator);
|
||||
proxy.AddMember("password", rapidjson::StringRef(x.Password.c_str()), allocator);
|
||||
proxy.AddMember("uuid", rapidjson::StringRef(x.UserId.c_str()), allocator);
|
||||
if (!x.TLSSecure && !x.Alpn.empty()) {
|
||||
rapidjson::Value tls(rapidjson::kObjectType);
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
if (!scv.is_undef()) {
|
||||
tls.AddMember("insecure", buildBooleanValue(scv), allocator);
|
||||
}
|
||||
if (!x.ServerName.empty())
|
||||
tls.AddMember("server_name", rapidjson::StringRef(x.ServerName.c_str()), allocator);
|
||||
if (!x.Alpn.empty()) {
|
||||
auto alpns = stringArrayToJsonArray(x.Alpn, ",", allocator);
|
||||
tls.AddMember("alpn", alpns, allocator);
|
||||
}
|
||||
if (!x.DisableSni.is_undef()) {
|
||||
tls.AddMember("disable_sni", buildBooleanValue(x.DisableSni), allocator);
|
||||
}
|
||||
proxy.AddMember("tls", tls, allocator);
|
||||
}
|
||||
if (!x.CongestionControl.empty()) {
|
||||
proxy.AddMember("congestion_control", rapidjson::StringRef(x.CongestionControl.c_str()), allocator);
|
||||
}
|
||||
if (!x.UdpRelayMode.empty()) {
|
||||
proxy.AddMember("udp_relay_mode", rapidjson::StringRef(x.UdpRelayMode.c_str()), allocator);
|
||||
}
|
||||
if (!x.ReduceRtt.is_undef()) {
|
||||
proxy.AddMember("zero_rtt_handshake", buildBooleanValue(x.ReduceRtt), allocator);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2334,18 +2604,30 @@ proxyToSingBox(std::vector<Proxy> &nodes, rapidjson::Document &json, std::vector
|
||||
tls.AddMember("enabled", true, allocator);
|
||||
if (!x.ServerName.empty())
|
||||
tls.AddMember("server_name", rapidjson::StringRef(x.ServerName.c_str()), allocator);
|
||||
if (!x.Alpn.empty())
|
||||
tls.AddMember("alpn", rapidjson::StringRef(("[" + x.Alpn + "]").c_str()), allocator);
|
||||
if (!x.AlpnList.empty()) {
|
||||
auto alpns = vectorToJsonArray(x.AlpnList, allocator);
|
||||
tls.AddMember("alpn", alpns, allocator);
|
||||
} else if (!x.Alpn.empty()) {
|
||||
auto alpns = stringArrayToJsonArray(x.Alpn, ",", allocator);
|
||||
tls.AddMember("alpn", alpns, allocator);
|
||||
}
|
||||
tls.AddMember("insecure", buildBooleanValue(scv), allocator);
|
||||
if (x.Type == ProxyType::VLESS) {
|
||||
rapidjson::Value reality(rapidjson::kObjectType);
|
||||
if (!x.PublicKey.empty() || !x.ShortId.empty()) {
|
||||
reality.AddMember("enabled", rapidjson::StringRef("false"), allocator);
|
||||
rapidjson::Value utls(rapidjson::kObjectType);
|
||||
utls.AddMember("enabled", true, allocator);
|
||||
utls.AddMember("fingerprint", rapidjson::StringRef("chrome"), allocator);
|
||||
tls.AddMember("utls", utls, allocator);
|
||||
reality.AddMember("enabled", true, allocator);
|
||||
if (!x.PublicKey.empty()) {
|
||||
reality.AddMember("public_key", rapidjson::StringRef("false"), allocator);
|
||||
reality.AddMember("public_key", rapidjson::StringRef(x.PublicKey.c_str()), allocator);
|
||||
}
|
||||
// auto shortIds = stringArrayToJsonArray(x.ShortId, ",", allocator);
|
||||
if (!x.ShortId.empty()) {
|
||||
reality.AddMember("short_id", rapidjson::StringRef(("[" + x.ShortId + "]").c_str()), allocator);
|
||||
reality.AddMember("short_id", rapidjson::StringRef(x.ShortId.c_str()), allocator);
|
||||
} else {
|
||||
reality.AddMember("short_id", rapidjson::StringRef(""), allocator);
|
||||
}
|
||||
tls.AddMember("reality", reality, allocator);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
#include <toml.hpp>
|
||||
|
||||
#include "config/binding.h"
|
||||
#include "handler/webget.h"
|
||||
@@ -565,12 +564,12 @@ void readYAMLConf(YAML::Node &node)
|
||||
writeLog(0, "Load preference settings in YAML format completed.", LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
template <class T, class... U>
|
||||
void find_if_exist(const toml::value &v, const toml::key &k, T& target, U&&... args)
|
||||
{
|
||||
if(v.contains(k)) target = toml::find<T>(v, k);
|
||||
if constexpr (sizeof...(args) > 0) find_if_exist(v, std::forward<U>(args)...);
|
||||
}
|
||||
//template <class T, class... U>
|
||||
//void find_if_exist(const toml::value &v, const toml::key &k, T& target, U&&... args)
|
||||
//{
|
||||
// if(v.contains(k)) target = toml::find<T>(v, k);
|
||||
// if constexpr (sizeof...(args) > 0) find_if_exist(v, std::forward<U>(args)...);
|
||||
//}
|
||||
|
||||
void operate_toml_kv_table(const std::vector<toml::table> &arr, const toml::key &key_name, const toml::key &value_name, std::function<void (const toml::value&, const toml::value&)> binary_op)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "utils/string.h"
|
||||
#include "utils/stl_extra.h"
|
||||
#include "utils/tribool.h"
|
||||
#include <toml.hpp>
|
||||
|
||||
struct Settings
|
||||
{
|
||||
@@ -100,7 +101,12 @@ extern Settings global;
|
||||
|
||||
int importItems(string_array &target, bool scope_limit = true);
|
||||
int loadExternalConfig(std::string &path, ExternalConfig &ext);
|
||||
|
||||
template <class T, class... U>
|
||||
void find_if_exist(const toml::value &v, const toml::key &k, T& target, U&&... args)
|
||||
{
|
||||
if(v.contains(k)) target = toml::find<T>(v, k);
|
||||
if constexpr (sizeof...(args) > 0) find_if_exist(v, std::forward<U>(args)...);
|
||||
}
|
||||
template <class... Args>
|
||||
void parseGroupTimes(const std::string &src, Args... args)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,8 @@ enum class ProxyType {
|
||||
WireGuard,
|
||||
VLESS,
|
||||
Hysteria,
|
||||
Hysteria2
|
||||
Hysteria2,
|
||||
TUIC
|
||||
};
|
||||
|
||||
inline String getProxyTypeName(ProxyType type) {
|
||||
@@ -51,6 +52,8 @@ inline String getProxyTypeName(ProxyType type) {
|
||||
return "Hysteria";
|
||||
case ProxyType::Hysteria2:
|
||||
return "Hysteria2";
|
||||
case ProxyType::TUIC:
|
||||
return "Tuic";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@@ -64,7 +67,7 @@ struct Proxy {
|
||||
String Remark;
|
||||
String Hostname;
|
||||
uint16_t Port = 0;
|
||||
|
||||
String CongestionControl;
|
||||
String Username;
|
||||
String Password;
|
||||
String EncryptMethod;
|
||||
@@ -78,6 +81,8 @@ struct Proxy {
|
||||
uint16_t AlterId = 0;
|
||||
String TransferProtocol;
|
||||
String FakeType;
|
||||
String AuthStr;
|
||||
|
||||
bool TLSSecure = false;
|
||||
|
||||
String Host;
|
||||
@@ -107,7 +112,7 @@ struct Proxy {
|
||||
uint16_t KeepAlive = 0;
|
||||
String TestUrl;
|
||||
String ClientId;
|
||||
|
||||
String Ports;
|
||||
String Auth;
|
||||
String Alpn;
|
||||
String UpMbps;
|
||||
@@ -120,6 +125,13 @@ struct Proxy {
|
||||
String ShortId;
|
||||
String Flow;
|
||||
bool FlowShow = false;
|
||||
tribool DisableSni;
|
||||
tribool ReduceRtt;
|
||||
String UdpRelayMode = "native";
|
||||
uint16_t RequestTimeout = 15000;
|
||||
String token;
|
||||
std::vector<String> AlpnList;
|
||||
String PacketEncoding;
|
||||
};
|
||||
|
||||
#define SS_DEFAULT_GROUP "SSProvider"
|
||||
@@ -133,5 +145,6 @@ struct Proxy {
|
||||
#define XRAY_DEFAULT_GROUP "XRayProvider"
|
||||
#define HYSTERIA_DEFAULT_GROUP "HysteriaProvider"
|
||||
#define HYSTERIA2_DEFAULT_GROUP "Hysteria2Provider"
|
||||
#define TUIC_DEFAULT_GROUP "TuicProvider"
|
||||
|
||||
#endif // PROXY_H_INCLUDED
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,7 @@
|
||||
|
||||
#include "config/proxy.h"
|
||||
|
||||
enum class ConfType
|
||||
{
|
||||
enum class ConfType {
|
||||
Unknow,
|
||||
SS,
|
||||
SSR,
|
||||
@@ -19,36 +18,116 @@ enum class ConfType
|
||||
SUB,
|
||||
Local
|
||||
};
|
||||
void hysteriaConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &auth, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &insecure ,tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void hysteria2Construct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &password, const std::string &host, const std::string &up, const std::string &down, const std::string &alpn, const std::string &obfsParam, const std::string &obfsPassword, const std::string &insecure ,tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &flow, const std::string &mode, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls,const std::string &pkd, const std::string &sid, const std::string &fp, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void vmessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add, const std::string &port, const std::string &type, const std::string &id, const std::string &aid, const std::string &net, const std::string &cipher, const std::string &path, const std::string &host, const std::string &edge, const std::string &tls, const std::string &sni, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void ssrConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &protocol, const std::string &method, const std::string &obfs, const std::string &password, const std::string &obfsparam, const std::string &protoparam, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
void ssConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &method, const std::string &plugin, const std::string &pluginopts, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void socksConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
void httpConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &username, const std::string &password, bool tls, tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void trojanConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &network, const std::string &host, const std::string &path, bool tlssecure, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
void snellConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server, const std::string &port, const std::string &password, const std::string &obfs, const std::string &host, uint16_t version = 0, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
|
||||
void hysteriaConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||
const std::string &port, const std::string &type, const std::string &auth,
|
||||
const std::string &auth_str, const std::string &host, const std::string &up,
|
||||
const std::string &down, const std::string &alpn, const std::string &obfsParam,
|
||||
const std::string &insecure, const std::string &ports, const std::string &sni,
|
||||
tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(),
|
||||
tribool tls13 = tribool());
|
||||
|
||||
void hysteria2Construct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||
const std::string &port, const std::string &password, const std::string &host,
|
||||
const std::string &up, const std::string &down, const std::string &alpn,
|
||||
const std::string &obfsParam, const std::string &obfsPassword, const std::string &sni,
|
||||
const std::string &publicKey, const std::string &ports,
|
||||
tribool udp, tribool tfo,
|
||||
tribool scv);
|
||||
|
||||
void vlessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||
const std::string &port, const std::string &type, const std::string &id, const std::string &aid,
|
||||
const std::string &net, const std::string &cipher, const std::string &flow, const std::string &mode,
|
||||
const std::string &path, const std::string &host, const std::string &edge, const std::string &tls,
|
||||
const std::string &pkd, const std::string &sid, const std::string &fp, const std::string &sni,
|
||||
const std::vector<std::string> &alpnList,const std::string &packet_encoding,
|
||||
tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(),
|
||||
tribool tls13 = tribool());
|
||||
|
||||
void vmessConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||
const std::string &port, const std::string &type, const std::string &id, const std::string &aid,
|
||||
const std::string &net, const std::string &cipher, const std::string &path, const std::string &host,
|
||||
const std::string &edge, const std::string &tls, const std::string &sni,
|
||||
const std::vector<std::string> &alpnList, tribool udp = tribool(),
|
||||
tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
|
||||
void ssrConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &protocol, const std::string &method,
|
||||
const std::string &obfs, const std::string &password, const std::string &obfsparam,
|
||||
const std::string &protoparam, tribool udp = tribool(), tribool tfo = tribool(),
|
||||
tribool scv = tribool());
|
||||
|
||||
void ssConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &password, const std::string &method,
|
||||
const std::string &plugin, const std::string &pluginopts, tribool udp = tribool(),
|
||||
tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
|
||||
void socksConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &username, const std::string &password,
|
||||
tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool());
|
||||
|
||||
void httpConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &username, const std::string &password, bool tls,
|
||||
tribool tfo = tribool(), tribool scv = tribool(), tribool tls13 = tribool());
|
||||
|
||||
void trojanConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &password, const std::string &network,
|
||||
const std::string &host, const std::string &path, const std::string &fp, const std::string &sni,
|
||||
const std::vector<std::string> &alpnList,
|
||||
bool tlssecure, tribool udp = tribool(), tribool tfo = tribool(), tribool scv = tribool(),
|
||||
tribool tls13 = tribool());
|
||||
|
||||
void snellConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &server,
|
||||
const std::string &port, const std::string &password, const std::string &obfs,
|
||||
const std::string &host, uint16_t version = 0, tribool udp = tribool(), tribool tfo = tribool(),
|
||||
tribool scv = tribool());
|
||||
|
||||
void tuicConstruct(Proxy &node, const std::string &group, const std::string &remarks, const std::string &add,
|
||||
const std::string &port, const std::string &password, const std::string &congestion_control,
|
||||
const std::string &alpn,
|
||||
const std::string &sni, const std::string &uuid, const std::string &udpRelayMode,
|
||||
const std::string &token,
|
||||
tribool udp = tribool(), tribool tfo = tribool(),
|
||||
tribool scv = tribool(), tribool reduceRtt = tribool(), tribool disableSni = tribool(),
|
||||
uint16_t request_timeout = 15000);
|
||||
|
||||
void explodeVmess(std::string vmess, Proxy &node);
|
||||
|
||||
void explodeSSR(std::string ssr, Proxy &node);
|
||||
|
||||
void explodeSS(std::string ss, Proxy &node);
|
||||
|
||||
void explodeTrojan(std::string trojan, Proxy &node);
|
||||
|
||||
void explodeQuan(const std::string &quan, Proxy &node);
|
||||
|
||||
void explodeStdVMess(std::string vmess, Proxy &node);
|
||||
|
||||
void explodeStdVless(std::string vless, Proxy &node);
|
||||
|
||||
void explodeStdHysteria(std::string hysteria, Proxy &node);
|
||||
|
||||
void explodeStdHysteria2(std::string hysteria2, Proxy &node);
|
||||
|
||||
void explodeShadowrocket(std::string kit, Proxy &node);
|
||||
|
||||
void explodeKitsunebi(std::string kit, Proxy &node);
|
||||
|
||||
void explodeVless(std::string vless, Proxy &node);
|
||||
|
||||
void explodeHysteria(std::string hysteria, Proxy &node);
|
||||
|
||||
void explodeHysteria2(std::string hysteria2, Proxy &node);
|
||||
|
||||
/// Parse a link
|
||||
void explode(const std::string &link, Proxy &node);
|
||||
|
||||
void explodeSSD(std::string link, std::vector<Proxy> &nodes);
|
||||
|
||||
void explodeSub(std::string sub, std::vector<Proxy> &nodes);
|
||||
|
||||
int explodeConf(const std::string &filepath, std::vector<Proxy> &nodes);
|
||||
|
||||
int explodeConfContent(const std::string &content, std::vector<Proxy> &nodes);
|
||||
|
||||
#endif // SUBPARSER_H_INCLUDED
|
||||
|
||||
@@ -5,11 +5,9 @@
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
|
||||
struct strICaseComp
|
||||
{
|
||||
bool operator() (const std::string &lhs, const std::string &rhs) const
|
||||
{
|
||||
return strcasecmp(lhs.c_str(), rhs.c_str());
|
||||
struct strICaseComp {
|
||||
bool operator()(const std::string &lhs, const std::string &rhs) const {
|
||||
return strcasecmp(lhs.c_str(), rhs.c_str()) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifndef VERSION_H_INCLUDED
|
||||
#define VERSION_H_INCLUDED
|
||||
|
||||
#define VERSION "v0.8.2"
|
||||
#define VERSION "v0.9.7"
|
||||
|
||||
#endif // VERSION_H_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user