Skip to content

Commit aa56f53

Browse files
committed
feat: bundle NaïveProxy client (no external plugin required)
Extract the official klzgrad/naiveproxy client binary from the upstream plugin APKs and bundle it as app/executableSo/<abi>/libnaive.so for all 4 ABIs, so NaïveProxy profiles work without installing the separate moe.matsuri.exe.naive plugin. - buildScript/lib/naive.sh: download the naiveproxy plugin APKs (v149.0.7827.114-1) and extract libnaive.so per ABI (./run lib naive). - PluginManager.initNativeInternal: resolve naive-plugin -> libnaive.so from nativeLibraryDir, mirroring the bundled Mieru/Hysteria mechanism, falling back to the external APK plugin when the bundled binary is absent. - CI: build + cache the naive binary and verify it across the 4 workflows. - libnaive.so is already in Executable.EXECUTABLES, and BoxInstance already launches naive-plugin as a sidecar, so no launch changes are needed. There is no native sing-box Naïve outbound (sing-box only implements a Naïve inbound), and the real client is Cronet/C++; bundling the official binary is the native-without-plugin path, consistent with the other bundled sidecars.
1 parent 49f7e6c commit aa56f53

7 files changed

Lines changed: 85 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
MIERU_VERSION: v3.34.0
1111
HYSTERIA_VERSION: v2.9.2
12+
NAIVE_VERSION: v149.0.7827.114-1
1213
permissions:
1314
contents: read
1415
jobs:
@@ -44,14 +45,14 @@ jobs:
4445
- name: Checkout
4546
uses: actions/checkout@v5
4647
- name: Sidecars Status
47-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
48+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
4849
- name: Sidecars Cache
4950
id: cache
5051
uses: actions/cache@v5
5152
with:
5253
path: |
5354
app/executableSo
54-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
55+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
5556
- name: Install Golang
5657
if: steps.cache.outputs.cache-hit != 'true'
5758
uses: actions/setup-go@v6
@@ -63,6 +64,9 @@ jobs:
6364
- name: Hysteria2 Download
6465
if: steps.cache.outputs.cache-hit != 'true'
6566
run: ./run lib hysteria2
67+
- name: Naive Download
68+
if: steps.cache.outputs.cache-hit != 'true'
69+
run: ./run lib naive
6670
build:
6771
name: Build OSS APK
6872
runs-on: ubuntu-latest
@@ -83,18 +87,18 @@ jobs:
8387
app/libs/libcore.aar
8488
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
8589
- name: Sidecars Status
86-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
90+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
8791
- name: Sidecars Cache
8892
id: sidecars-cache
8993
uses: actions/cache@v5
9094
with:
9195
path: |
9296
app/executableSo
93-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
97+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
9498
- name: Verify Sidecar Artifacts
9599
run: |
96100
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
97-
for so in libmieru.so libhysteria2.so; do
101+
for so in libmieru.so libhysteria2.so libnaive.so; do
98102
if [ ! -f "app/executableSo/$abi/$so" ]; then
99103
echo "Error: missing app/executableSo/$abi/$so (sidecar cache miss)" >&2
100104
exit 1

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
env:
1010
MIERU_VERSION: v3.34.0
1111
HYSTERIA_VERSION: v2.9.2
12+
NAIVE_VERSION: v149.0.7827.114-1
1213
permissions:
1314
contents: read
1415
jobs:
@@ -49,14 +50,14 @@ jobs:
4950
- name: Checkout
5051
uses: actions/checkout@v5
5152
- name: Sidecars Status
52-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
53+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
5354
- name: Sidecars Cache
5455
id: cache
5556
uses: actions/cache@v5
5657
with:
5758
path: |
5859
app/executableSo
59-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars-ci
60+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars-ci
6061
- name: Install Golang
6162
if: steps.cache.outputs.cache-hit != 'true'
6263
uses: actions/setup-go@v6
@@ -68,6 +69,9 @@ jobs:
6869
- name: Hysteria2 Download
6970
if: steps.cache.outputs.cache-hit != 'true'
7071
run: ./run lib hysteria2
72+
- name: Naive Download
73+
if: steps.cache.outputs.cache-hit != 'true'
74+
run: ./run lib naive
7175
build:
7276
name: Build OSS APK
7377
runs-on: ubuntu-latest
@@ -93,18 +97,18 @@ jobs:
9397
app/libs/libcore.aar
9498
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}-ci
9599
- name: Sidecars Status
96-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
100+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
97101
- name: Sidecars Cache
98102
id: sidecars-cache
99103
uses: actions/cache@v5
100104
with:
101105
path: |
102106
app/executableSo
103-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars-ci
107+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars-ci
104108
- name: Verify Sidecar Artifacts
105109
run: |
106110
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
107-
for so in libmieru.so libhysteria2.so; do
111+
for so in libmieru.so libhysteria2.so libnaive.so; do
108112
if [ ! -f "app/executableSo/$abi/$so" ]; then
109113
echo "Error: missing app/executableSo/$abi/$so (sidecar cache miss)" >&2
110114
exit 1

.github/workflows/preview.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
env:
66
MIERU_VERSION: v3.34.0
77
HYSTERIA_VERSION: v2.9.2
8+
NAIVE_VERSION: v149.0.7827.114-1
89
permissions:
910
contents: read
1011
jobs:
@@ -40,14 +41,14 @@ jobs:
4041
- name: Checkout
4142
uses: actions/checkout@v5
4243
- name: Sidecars Status
43-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
44+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
4445
- name: Sidecars Cache
4546
id: cache
4647
uses: actions/cache@v5
4748
with:
4849
path: |
4950
app/executableSo
50-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
51+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
5152
- name: Install Golang
5253
if: steps.cache.outputs.cache-hit != 'true'
5354
uses: actions/setup-go@v6
@@ -59,6 +60,9 @@ jobs:
5960
- name: Hysteria2 Download
6061
if: steps.cache.outputs.cache-hit != 'true'
6162
run: ./run lib hysteria2
63+
- name: Naive Download
64+
if: steps.cache.outputs.cache-hit != 'true'
65+
run: ./run lib naive
6266
build:
6367
name: Build OSS APK
6468
runs-on: ubuntu-latest
@@ -79,18 +83,18 @@ jobs:
7983
app/libs/libcore.aar
8084
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
8185
- name: Sidecars Status
82-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
86+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
8387
- name: Sidecars Cache
8488
id: sidecars-cache
8589
uses: actions/cache@v5
8690
with:
8791
path: |
8892
app/executableSo
89-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
93+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
9094
- name: Verify Sidecar Artifacts
9195
run: |
9296
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
93-
for so in libmieru.so libhysteria2.so; do
97+
for so in libmieru.so libhysteria2.so libnaive.so; do
9498
if [ ! -f "app/executableSo/$abi/$so" ]; then
9599
echo "Error: missing app/executableSo/$abi/$so (sidecar cache miss)" >&2
96100
exit 1

.github/workflows/release.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
env:
1212
MIERU_VERSION: v3.34.0
1313
HYSTERIA_VERSION: v2.9.2
14+
NAIVE_VERSION: v149.0.7827.114-1
1415
permissions:
1516
contents: write
1617
jobs:
@@ -46,14 +47,14 @@ jobs:
4647
- name: Checkout
4748
uses: actions/checkout@v5
4849
- name: Sidecars Status
49-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
50+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
5051
- name: Sidecars Cache
5152
id: cache
5253
uses: actions/cache@v5
5354
with:
5455
path: |
5556
app/executableSo
56-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
57+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
5758
- name: Install Golang
5859
if: steps.cache.outputs.cache-hit != 'true'
5960
uses: actions/setup-go@v6
@@ -65,6 +66,9 @@ jobs:
6566
- name: Hysteria2 Download
6667
if: steps.cache.outputs.cache-hit != 'true'
6768
run: ./run lib hysteria2
69+
- name: Naive Download
70+
if: steps.cache.outputs.cache-hit != 'true'
71+
run: ./run lib naive
6872
build:
6973
name: Build OSS APK
7074
runs-on: ubuntu-latest
@@ -85,18 +89,18 @@ jobs:
8589
app/libs/libcore.aar
8690
key: ${{ hashFiles('.github/workflows/*', 'golang_status', 'libcore_status') }}
8791
- name: Sidecars Status
88-
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
92+
run: cat buildScript/lib/mieru.sh buildScript/lib/hysteria2.sh buildScript/lib/naive.sh buildScript/init/env.sh buildScript/init/env_ndk.sh | sha1sum > sidecars_status
8993
- name: Sidecars Cache
9094
id: sidecars-cache
9195
uses: actions/cache@v5
9296
with:
9397
path: |
9498
app/executableSo
95-
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-sidecars
99+
key: ${{ hashFiles('.github/workflows/*', 'sidecars_status') }}-${{ env.MIERU_VERSION }}-${{ env.HYSTERIA_VERSION }}-${{ env.NAIVE_VERSION }}-sidecars
96100
- name: Verify Sidecar Artifacts
97101
run: |
98102
for abi in arm64-v8a armeabi-v7a x86 x86_64; do
99-
for so in libmieru.so libhysteria2.so; do
103+
for so in libmieru.so libhysteria2.so libnaive.so; do
100104
if [ ! -f "app/executableSo/$abi/$so" ]; then
101105
echo "Error: missing app/executableSo/$abi/$so (sidecar cache miss)" >&2
102106
exit 1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ source version. Please do not download it.**
3232
* MasterDnsVPN (DNS-tunnel, bundled)
3333
* Mieru (bundled)
3434
* Trojan-Go (trojan-go-plugin)
35-
* NaïveProxy (naive-plugin)
35+
* NaïveProxy (bundled)
3636

3737
<details>
3838
<summary>XHTTP Extra TLS configuration example</summary>
@@ -188,7 +188,7 @@ source version. Please do not download it.**
188188
</code></pre>
189189
</details>
190190

191-
Trojan-Go and NaïveProxy require their external plugins for full proxy support.
191+
Trojan-Go requires its external plugin for full proxy support.
192192

193193
## Supported Subscription Format
194194

app/src/main/java/io/nekohasekai/sagernet/plugin/PluginManager.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ object PluginManager {
7474
"hysteria-plugin" -> soIfExist("libhysteria.so")
7575
"hysteria2-plugin" -> soIfExist("libhysteria2.so")
7676
"mieru-plugin" -> soIfExist("libmieru.so")
77+
"naive-plugin" -> soIfExist("libnaive.so")
7778
else -> null
7879
}
7980
}

buildScript/lib/naive.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
# Extract the official naiveproxy client binary from klzgrad/naiveproxy plugin
3+
# APKs and install it as a bundled native executable
4+
# (app/executableSo/<abi>/libnaive.so).
5+
#
6+
# This lets NekoBox run NaïveProxy profiles without installing the separate
7+
# external plugin (moe.matsuri.exe.naive). PluginManager.initNativeInternal
8+
# resolves "naive-plugin" -> libnaive.so from nativeLibraryDir, mirroring the
9+
# bundled Mieru / Hysteria mechanism, and falls back to the external APK plugin
10+
# when the bundled binary is absent.
11+
#
12+
# Usage: ./run lib naive
13+
set -e
14+
set -o pipefail
15+
16+
# Pinned naiveproxy release.
17+
NAIVE_VERSION="${NAIVE_VERSION:-v149.0.7827.114-1}"
18+
BASE="https://github.com/klzgrad/naiveproxy/releases/download/${NAIVE_VERSION}"
19+
20+
OUT="$(pwd)/app/executableSo"
21+
WORK="$(pwd)/.naive-build"
22+
mkdir -p "$WORK"
23+
24+
# Map Android ABI -> naiveproxy plugin APK ABI tag (identical here).
25+
extract_abi() {
26+
local abi="$1"
27+
local apk="naiveproxy-plugin-${NAIVE_VERSION}-${abi}.apk"
28+
echo ">> fetching libnaive.so for $abi ($apk)"
29+
curl -fL --retry 3 --retry-delay 2 --max-time 300 "$BASE/$apk" -o "$WORK/$apk"
30+
mkdir -p "$OUT/$abi"
31+
# The plugin APK ships the client as lib/<abi>/libnaive.so.
32+
unzip -o -j "$WORK/$apk" "lib/$abi/libnaive.so" -d "$OUT/$abi" >/dev/null
33+
if [ ! -f "$OUT/$abi/libnaive.so" ]; then
34+
echo "Error: libnaive.so not found in $apk" >&2
35+
exit 1
36+
fi
37+
chmod +x "$OUT/$abi/libnaive.so"
38+
}
39+
40+
extract_abi "arm64-v8a"
41+
extract_abi "armeabi-v7a"
42+
extract_abi "x86"
43+
extract_abi "x86_64"
44+
45+
echo ">> installed naive binaries:"
46+
ls -la "$OUT"/*/libnaive.so

0 commit comments

Comments
 (0)