From e444a5323940cbc69e9da314357c0f4beb434984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 22 May 2021 09:46:39 +0800 Subject: [PATCH] Import brook --- .github/workflows/debug.yml | 32 +++- .github/workflows/release_brook.yml | 162 ++++++++++++++++++ .github/workflows/release_naive.yml | 7 +- .github/workflows/release_pingtunnel.yml | 10 +- .github/workflows/release_relaybaton.yml | 8 +- .github/workflows/release_trojan_go.yml | 6 +- .github/workflows/release_xtls.yml | 8 +- .gitmodules | 3 + .idea/gradle.xml | 1 + README.md | 8 +- bin/plugin/brook.sh | 8 + bin/plugin/brook/arm64-v8a.sh | 9 + bin/plugin/brook/armeabi-v7a.sh | 9 + bin/plugin/brook/build.sh | 15 ++ bin/plugin/brook/end.sh | 5 + bin/plugin/brook/init.sh | 13 ++ bin/plugin/brook/x86.sh | 9 + bin/plugin/brook/x86_64.sh | 9 + plugin/brook/build.gradle.kts | 5 + plugin/brook/src/main/AndroidManifest.xml | 39 +++++ plugin/brook/src/main/go/brook | 1 + .../brook/src/main/ic_launcher-playstore.png | Bin 0 -> 14168 bytes .../sagernet/plugin/brook/BinaryProvider.kt | 63 +++++++ .../res/drawable/ic_launcher_foreground.xml | 25 +++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 1690 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 3670 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 1161 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2275 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 2388 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 5335 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 3752 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 8313 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 5206 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 12165 bytes .../res/values/ic_launcher_background.xml | 4 + .../pingtunnel/src/main/AndroidManifest.xml | 2 +- plugin/trojan-go/src/main/AndroidManifest.xml | 2 +- sager.properties | 22 +-- settings.gradle.kts | 1 + 41 files changed, 453 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/release_brook.yml create mode 100755 bin/plugin/brook.sh create mode 100755 bin/plugin/brook/arm64-v8a.sh create mode 100755 bin/plugin/brook/armeabi-v7a.sh create mode 100755 bin/plugin/brook/build.sh create mode 100755 bin/plugin/brook/end.sh create mode 100755 bin/plugin/brook/init.sh create mode 100755 bin/plugin/brook/x86.sh create mode 100755 bin/plugin/brook/x86_64.sh create mode 100644 plugin/brook/build.gradle.kts create mode 100644 plugin/brook/src/main/AndroidManifest.xml create mode 160000 plugin/brook/src/main/go/brook create mode 100644 plugin/brook/src/main/ic_launcher-playstore.png create mode 100644 plugin/brook/src/main/java/io/nekohasekai/sagernet/plugin/brook/BinaryProvider.kt create mode 100644 plugin/brook/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 plugin/brook/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 plugin/brook/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 plugin/brook/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 plugin/brook/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 plugin/brook/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 plugin/brook/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 plugin/brook/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 plugin/brook/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 plugin/brook/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 plugin/brook/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 plugin/brook/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 plugin/brook/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 plugin/brook/src/main/res/values/ic_launcher_background.xml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 658dd1b4..bf61b74a 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -77,7 +77,7 @@ jobs: with: path: | plugin/xtls/src/main/jniLibs - key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} + key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -100,7 +100,7 @@ jobs: with: path: | plugin/trojan-go/src/main/jniLibs - key: ${{ hashFiles('bin/lib/trojan_go.sh', 'trojan_go_status') }} + key: ${{ hashFiles('bin/lib/trojan_go/*', 'trojan_go_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -132,6 +132,7 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: | ./run init action naive + ./run plugin naive init ./run plugin naive ${{ matrix.arch }} pingtunnel: name: Native Build (PingTunnel) @@ -147,7 +148,7 @@ jobs: with: path: | plugin/pingtunnel/src/main/jniLibs - key: ${{ hashFiles('bin/lib/pingtunnel.sh', 'pt_status') }} + key: ${{ hashFiles('bin/lib/pingtunnel/*', 'pt_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -170,7 +171,7 @@ jobs: with: path: | plugin/relaybaton/src/main/jniLibs - key: ${{ hashFiles('bin/lib/relaybaton.sh', 'rb_status') }} + key: ${{ hashFiles('bin/lib/relaybaton/*', 'rb_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -179,6 +180,29 @@ jobs: - name: Native Build if: steps.cache.outputs.cache-hit != 'true' run: ./run plugin relaybaton + brook: + name: Native Build (Brook) + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/brook/*' > brook_status + - name: Brook Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/brook/src/main/jniLibs + key: ${{ hashFiles('bin/lib/brook/*', 'brook_status') }} + - name: Install Golang + uses: actions/setup-go@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + go-version: 1.16 + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin brook shadowsocks: name: Native Build (Shadowsocks) runs-on: ubuntu-latest diff --git a/.github/workflows/release_brook.yml b/.github/workflows/release_brook.yml new file mode 100644 index 00000000..19bfe55b --- /dev/null +++ b/.github/workflows/release_brook.yml @@ -0,0 +1,162 @@ +name: Brook Plugin Release Build +on: + workflow_dispatch: + inputs: + tag: + description: 'Release Tag' + required: true + upload: + description: 'Upload: If want ignore' + required: false +# publish: +# description: 'Publish: If want ignore' +# required: false +jobs: + check: + name: Check Access + runs-on: ubuntu-latest + steps: + - name: "Check access" + uses: "lannonbr/repo-permission-check-action@2.0.0" + with: + permission: "write" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + native: + name: Native Build + runs-on: ubuntu-latest + needs: + - check + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/brook/*' > brook_status + - name: Brook Cache + id: cache + uses: actions/cache@v2 + with: + path: | + plugin/brook/src/main/jniLibs + key: ${{ hashFiles('bin/lib/brook/*', 'brook_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle') }} + - name: Install Golang + uses: actions/setup-go@v2 + if: steps.cache.outputs.cache-hit != 'true' + with: + go-version: 1.16 + - name: Native Build + if: steps.cache.outputs.cache-hit != 'true' + run: ./run plugin brook + build: + name: Gradle Build + runs-on: ubuntu-latest + needs: + - native + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Fetch Status + run: git submodule status 'plugin/brook/*' > brook_status + - name: brook Cache + uses: actions/cache@v2 + with: + path: | + plugin/brook/src/main/jniLibs + key: ${{ hashFiles('bin/lib/brook/*', 'brook_status') }} + - name: Gradle cache + uses: actions/cache@v2 + with: + path: ~/.gradle + key: gradle-${{ hashFiles('**/*.gradle') }} + - name: Release Build + run: | + echo "sdk.dir=${ANDROID_HOME}" > local.properties + echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties + export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" + ./gradlew :plugin:brook:assembleOssRelease + APK=$(find plugin/brook/build/outputs/apk -name '*arm64-v8a*.apk') + APK=$(dirname $APK) + echo "APK=$APK" >> $GITHUB_ENV + - uses: actions/upload-artifact@v2 + with: + name: brook + path: ${{ env.APK }} + publish: + name: Publish Release + if: github.event.inputs.publish != 'y' + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Donwload Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Release + run: | + wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz + tar -xvf ghr.tar.gz + mv ghr*linux_amd64/ghr . + mkdir apks + find artifacts -name "*.apk" -exec cp {} apks \; + ./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks + upload: + name: Upload Release + if: github.event.inputs.upload != 'y' + runs-on: ubuntu-latest + needs: build + steps: + - name: Donwload Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + - name: Release + run: | + mkdir apks + find artifacts -name "*.apk" -exec cp {} apks \; + function upload() { + for apk in $@; do + echo ">> Uploading $apk" + curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendDocument \ + -X POST \ + -F chat_id="${{ secrets.TELEGRAM_CHANNEL }}" \ + -F document="@$apk" \ + --silent --show-error --fail >/dev/null & + done + for job in $(jobs -p); do + wait $job || exit 1 + done + } + upload apks/*.apk +# play: +# name: Publish to Play Store +# if: github.event.inputs.upload != 'y' +# runs-on: ubuntu-latest +# needs: +# - native +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# - name: Fetch Status +# run: git submodule status 'plugin/brook/*' > brook_status +# - name: brook Cache +# uses: actions/cache@v2 +# with: +# path: | +# plugin/brook/src/main/jniLibs +# key: ${{ hashFiles('bin/lib/brook/*', 'brook_status') }} +# - name: Release Build +# run: | +# echo "sdk.dir=${ANDROID_HOME}" > local.properties +# echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties +# export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" +# cat > service_account_credentials.json << EOF +# ${{ secrets.ANDROID_PUBLISHER_CREDENTIALS }}" +# EOF +# ./gradlew brook-plugin:publishRelease \ No newline at end of file diff --git a/.github/workflows/release_naive.yml b/.github/workflows/release_naive.yml index 9d45c10e..abbccbcc 100644 --- a/.github/workflows/release_naive.yml +++ b/.github/workflows/release_naive.yml @@ -54,6 +54,7 @@ jobs: echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties ./run init action naive + ./run plugin naive init ./run plugin naive ${{ matrix.arch }} naive: needs: naive_libs @@ -94,11 +95,13 @@ jobs: path: ~/.gradle key: native-${{ hashFiles('**/*.gradle') }} - name: Native Build + env: + SKIP_BUILD: on run: | echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew naive-plugin:assembleRelease + ./gradlew :plugin:naive:assembleOssRelease APK=$(find plugin/naive/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV @@ -170,7 +173,7 @@ jobs: # with: # path: | # plugin/xtls/src/main/jniLibs -# key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} +# key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} # - name: Release Build # run: | # echo "sdk.dir=${ANDROID_HOME}" > local.properties diff --git a/.github/workflows/release_pingtunnel.yml b/.github/workflows/release_pingtunnel.yml index f880e3ad..11e30065 100644 --- a/.github/workflows/release_pingtunnel.yml +++ b/.github/workflows/release_pingtunnel.yml @@ -38,7 +38,7 @@ jobs: with: path: | plugin/pingtunnel/src/main/jniLibs - key: ${{ hashFiles('bin/lib/pingtunnel.sh', 'pt_status') }} + key: ${{ hashFiles('bin/lib/pingtunnel/*', 'pt_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -62,18 +62,20 @@ jobs: with: path: | plugin/pingtunnel/src/main/jniLibs - key: ${{ hashFiles('bin/lib/pingtunnel.sh', 'pt_status') }} + key: ${{ hashFiles('bin/lib/pingtunnel/*', 'pt_status') }} - name: Gradle cache uses: actions/cache@v2 with: path: ~/.gradle key: gradle-${{ hashFiles('**/*.gradle') }} - name: Release Build + env: + SKIP_BUILD: on run: | echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew pt-plugin:assembleRelease + ./gradlew :plugin:pingtunnel:assembleOssRelease APK=$(find plugin/pingtunnel/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV @@ -145,7 +147,7 @@ jobs: # with: # path: | # plugin/xtls/src/main/jniLibs -# key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} +# key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} # - name: Release Build # run: | # echo "sdk.dir=${ANDROID_HOME}" > local.properties diff --git a/.github/workflows/release_relaybaton.yml b/.github/workflows/release_relaybaton.yml index add5ad92..422b2302 100644 --- a/.github/workflows/release_relaybaton.yml +++ b/.github/workflows/release_relaybaton.yml @@ -38,7 +38,7 @@ jobs: with: path: | plugin/relaybaton/src/main/jniLibs - key: ${{ hashFiles('bin/lib/relaybaton.sh', 'rb_status') }} + key: ${{ hashFiles('bin/lib/relaybaton/*', 'rb_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -62,7 +62,7 @@ jobs: with: path: | plugin/relaybaton/src/main/jniLibs - key: ${{ hashFiles('bin/lib/relaybaton.sh', 'rb_status') }} + key: ${{ hashFiles('bin/lib/relaybaton/*', 'rb_status') }} - name: Gradle cache uses: actions/cache@v2 with: @@ -73,7 +73,7 @@ jobs: echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew rb-plugin:assembleRelease + ./gradlew :plugin:relaybaton:assembleOssRelease APK=$(find plugin/relaybaton/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV @@ -145,7 +145,7 @@ jobs: # with: # path: | # plugin/xtls/src/main/jniLibs -# key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} +# key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} # - name: Release Build # run: | # echo "sdk.dir=${ANDROID_HOME}" > local.properties diff --git a/.github/workflows/release_trojan_go.yml b/.github/workflows/release_trojan_go.yml index 36a6d26a..d3fa7703 100644 --- a/.github/workflows/release_trojan_go.yml +++ b/.github/workflows/release_trojan_go.yml @@ -38,7 +38,7 @@ jobs: with: path: | plugin/trojan-go/src/main/jniLibs - key: ${{ hashFiles('bin/lib/trojan_go.sh', 'trojan_go_status') }} + key: ${{ hashFiles('bin/lib/trojan_go/*', 'trojan_go_status') }} - name: Install Golang uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' @@ -62,7 +62,7 @@ jobs: with: path: | plugin/trojan-go/src/main/jniLibs - key: ${{ hashFiles('bin/lib/trojan_go.sh', 'trojan_go_status') }} + key: ${{ hashFiles('bin/lib/trojan_go/*', 'trojan_go_status') }} - name: Gradle cache uses: actions/cache@v2 with: @@ -73,7 +73,7 @@ jobs: echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew trojan-go-plugin:assembleRelease + ./gradlew :plugin:trojan-go:assembleOssRelease APK=$(find plugin/trojan-go/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV diff --git a/.github/workflows/release_xtls.yml b/.github/workflows/release_xtls.yml index 733c5b5c..30ff1d5c 100644 --- a/.github/workflows/release_xtls.yml +++ b/.github/workflows/release_xtls.yml @@ -38,7 +38,7 @@ jobs: with: path: | plugin/xtls/src/main/jniLibs - key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} + key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} - name: Gradle cache uses: actions/cache@v2 with: @@ -67,7 +67,7 @@ jobs: with: path: | plugin/xtls/src/main/jniLibs - key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} + key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} - name: Gradle cache uses: actions/cache@v2 with: @@ -78,7 +78,7 @@ jobs: echo "sdk.dir=${ANDROID_HOME}" > local.properties echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew xtls-plugin:assembleRelease + ./gradlew :plugin:xtls:assembleOssRelease APK=$(find plugin/xtls/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV @@ -150,7 +150,7 @@ jobs: # with: # path: | # plugin/xtls/src/main/jniLibs -# key: ${{ hashFiles('bin/lib/xtls.sh', 'xtls_status') }} +# key: ${{ hashFiles('bin/lib/xtls/*', 'xtls_status') }} # - name: Release Build # run: | # echo "sdk.dir=${ANDROID_HOME}" > local.properties diff --git a/.gitmodules b/.gitmodules index ecf1283b..70472c0c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -46,3 +46,6 @@ [submodule "plugin/relaybaton/src/main/go/relaybaton"] path = plugin/relaybaton/src/main/go/relaybaton url = https://github.com/iyouport-org/relaybaton +[submodule "plugin/brook/src/main/go/brook"] + path = plugin/brook/src/main/go/brook + url = https://github.com/txthinking/brook diff --git a/.idea/gradle.xml b/.idea/gradle.xml index a33621db..75724f9c 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -28,6 +28,7 @@