Skip to content

Commit 4a71f93

Browse files
committed
feat: add mieru protocol
1 parent 7fd21f8 commit 4a71f93

18 files changed

Lines changed: 1003 additions & 44 deletions

File tree

.github/workflows/build.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
description: "Build type"
1212
required: true
1313
type: choice
14-
default: "All"
14+
default: "Binary"
1515
options:
1616
- All
1717
- Binary
@@ -345,13 +345,13 @@ jobs:
345345
-p "dist/sing-box_${{ needs.calculate_version.outputs.version }}_${{ matrix.os }}_${{ matrix.debian }}.deb" \
346346
--architecture ${{ matrix.debian }} \
347347
dist/sing-box=/usr/bin/sing-box
348-
curl -Lo '/tmp/debsigs.diff' 'https://gitlab.com/debsigs/debsigs/-/commit/160138f5de1ec110376d3c807b60a37388bc7c90.diff'
349-
sudo patch /usr/bin/debsigs < '/tmp/debsigs.diff'
350-
rm -rf $HOME/.gnupg
351-
gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
352-
${{ secrets.GPG_KEY }}
353-
EOF
354-
debsigs --sign=origin -k ${{ secrets.GPG_KEY_ID }} --gpgopts '--pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}"' dist/*.deb
348+
# curl -Lo '/tmp/debsigs.diff' 'https://gitlab.com/debsigs/debsigs/-/commit/160138f5de1ec110376d3c807b60a37388bc7c90.diff'
349+
# sudo patch /usr/bin/debsigs < '/tmp/debsigs.diff'
350+
# rm -rf $HOME/.gnupg
351+
# gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
352+
# ${{ secrets.GPG_KEY }}
353+
# EOF
354+
# debsigs --sign=origin -k ${{ secrets.GPG_KEY_ID }} --gpgopts '--pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}"' dist/*.deb
355355
- name: Package RPM
356356
if: matrix.rpm != ''
357357
run: |-
@@ -363,14 +363,14 @@ jobs:
363363
-p "dist/sing-box_${{ needs.calculate_version.outputs.version }}_${{ matrix.os }}_${{ matrix.rpm }}.rpm" \
364364
--architecture ${{ matrix.rpm }} \
365365
dist/sing-box=/usr/bin/sing-box
366-
cat > $HOME/.rpmmacros <<EOF
367-
%_gpg_name ${{ secrets.GPG_KEY_ID }}
368-
%_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSPHRASE }}
369-
EOF
370-
gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
371-
${{ secrets.GPG_KEY }}
372-
EOF
373-
rpmsign --addsign dist/*.rpm
366+
# cat > $HOME/.rpmmacros <<EOF
367+
# %_gpg_name ${{ secrets.GPG_KEY_ID }}
368+
# %_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSPHRASE }}
369+
# EOF
370+
# gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
371+
# ${{ secrets.GPG_KEY }}
372+
# EOF
373+
# rpmsign --addsign dist/*.rpm
374374
- name: Package Pacman
375375
if: matrix.pacman != ''
376376
run: |-

.github/workflows/linux.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ jobs:
194194
-p "dist/${NAME}_${{ needs.calculate_version.outputs.version }}_linux_${{ matrix.debian }}.deb" \
195195
--architecture ${{ matrix.debian }} \
196196
dist/sing-box=/usr/bin/sing-box
197-
curl -Lo '/tmp/debsigs.diff' 'https://gitlab.com/debsigs/debsigs/-/commit/160138f5de1ec110376d3c807b60a37388bc7c90.diff'
198-
sudo patch /usr/bin/debsigs < '/tmp/debsigs.diff'
199-
rm -rf $HOME/.gnupg
200-
gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
201-
${{ secrets.GPG_KEY }}
202-
EOF
203-
debsigs --sign=origin -k ${{ secrets.GPG_KEY_ID }} --gpgopts '--pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}"' dist/*.deb
197+
# curl -Lo '/tmp/debsigs.diff' 'https://gitlab.com/debsigs/debsigs/-/commit/160138f5de1ec110376d3c807b60a37388bc7c90.diff'
198+
# sudo patch /usr/bin/debsigs < '/tmp/debsigs.diff'
199+
# rm -rf $HOME/.gnupg
200+
# gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
201+
# ${{ secrets.GPG_KEY }}
202+
# EOF
203+
# debsigs --sign=origin -k ${{ secrets.GPG_KEY_ID }} --gpgopts '--pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}"' dist/*.deb
204204
- name: Package RPM
205205
if: matrix.rpm != ''
206206
run: |-
@@ -213,14 +213,14 @@ jobs:
213213
-p "dist/${NAME}_${{ needs.calculate_version.outputs.version }}_linux_${{ matrix.rpm }}.rpm" \
214214
--architecture ${{ matrix.rpm }} \
215215
dist/sing-box=/usr/bin/sing-box
216-
cat > $HOME/.rpmmacros <<EOF
217-
%_gpg_name ${{ secrets.GPG_KEY_ID }}
218-
%_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSPHRASE }}
219-
EOF
220-
gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
221-
${{ secrets.GPG_KEY }}
222-
EOF
223-
rpmsign --addsign dist/*.rpm
216+
# cat > $HOME/.rpmmacros <<EOF
217+
# %_gpg_name ${{ secrets.GPG_KEY_ID }}
218+
# %_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase ${{ secrets.GPG_PASSPHRASE }}
219+
# EOF
220+
# gpg --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import <<EOF
221+
# ${{ secrets.GPG_KEY }}
222+
# EOF
223+
# rpmsign --addsign dist/*.rpm
224224
- name: Cleanup
225225
run: rm dist/sing-box
226226
- name: Upload artifact

README.md

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,88 @@
1-
> Sponsored by [Warp](https://go.warp.dev/sing-box), built for coding with multiple AI agents
1+
# mbox
22

3-
<a href="https://go.warp.dev/sing-box">
4-
<img alt="Warp sponsorship" width="400" src="https://github.com/warpdotdev/brand-assets/raw/refs/heads/main/Github/Sponsor/Warp-Github-LG-02.png">
5-
</a>
3+
A reference implementation of [mieru](https://github.com/enfein/mieru) protocol
4+
in sing-box.
65

7-
---
6+
We don't guarantee all sing-box features are working. We recommend you maintain
7+
your own fork.
88

9-
# sing-box
9+
## Example Configuration with mieru Outbound (Proxy Client)
1010

11-
The universal proxy platform.
11+
```js
12+
{
13+
"inbounds": [
14+
{
15+
"type": "mixed",
16+
"tag": "mixed-in",
17+
"listen": "0.0.0.0",
18+
"listen_port": 1080
19+
}
20+
],
21+
"outbounds": [
22+
{
23+
"type": "mieru",
24+
"tag": "mieru-out",
25+
"server": "127.0.0.1",
26+
"server_port": 8964,
27+
"transport": "TCP",
28+
"username": "baozi",
29+
"password": "manlianpenfen",
30+
"traffic_pattern": "GgQIARAK"
31+
}
32+
],
33+
"route": {
34+
"rules": [
35+
{
36+
"inbound": ["mixed-in"],
37+
"action": "route",
38+
"outbound": "mieru-out"
39+
}
40+
]
41+
},
42+
"log": {
43+
"level": "warn"
44+
}
45+
}
46+
```
47+
48+
You can also use `server_ports` to set a list of port ranges.
1249

13-
[![Packaging status](https://repology.org/badge/vertical-allrepos/sing-box.svg)](https://repology.org/project/sing-box/versions)
50+
## Example Configuration with mieru Inbound (Proxy Server)
51+
52+
```js
53+
{
54+
"inbounds": [
55+
{
56+
"type": "mieru",
57+
"tag": "mieru-tcp",
58+
"listen": "0.0.0.0",
59+
"listen_port": 8964,
60+
"transport": "TCP",
61+
"users": [
62+
{
63+
"name": "baozi",
64+
"password": "manlianpenfen"
65+
}
66+
],
67+
"traffic_pattern": "GgQIARAK"
68+
}
69+
],
70+
"outbounds": [],
71+
"route": {},
72+
"log": {
73+
"level": "warn"
74+
}
75+
}
76+
```
1477

15-
## Documentation
78+
## Branches
1679

17-
https://sing-box.sagernet.org
80+
- `mieru` branch has the latest code based on recent upstream releases. It may not be stable.
81+
- `release-*` branches record the references where binaries are published. Those branches don't change after creation.
82+
83+
## Limitations
84+
85+
- UDP outbound can't use domain name as server address.
1886

1987
## License
2088

@@ -36,4 +104,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36104
37105
In addition, no derivative work may use the name or imply association
38106
with this application without prior consent.
39-
```
107+
```

constant/proxy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
TypeSSH = "ssh"
2121
TypeShadowTLS = "shadowtls"
2222
TypeAnyTLS = "anytls"
23+
TypeMieru = "mieru"
2324
TypeShadowsocksR = "shadowsocksr"
2425
TypeVLESS = "vless"
2526
TypeTUIC = "tuic"
@@ -88,6 +89,8 @@ func ProxyDisplayName(proxyType string) string {
8889
return "AnyTLS"
8990
case TypeTailscale:
9091
return "Tailscale"
92+
case TypeMieru:
93+
return "Mieru"
9194
case TypeSelector:
9295
return "Selector"
9396
case TypeURLTest:

docs/configuration/inbound/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
| `hysteria2` | [Hysteria2](./hysteria2/) | :material-close: |
3232
| `vless` | [VLESS](./vless/) | TCP |
3333
| `anytls` | [AnyTLS](./anytls/) | TCP |
34+
| `mieru` | [Mieru](./mieru/) | :material-close: |
3435
| `tun` | [Tun](./tun/) | :material-close: |
3536
| `redirect` | [Redirect](./redirect/) | :material-close: |
3637
| `tproxy` | [TProxy](./tproxy/) | :material-close: |
3738

3839
#### tag
3940

40-
The tag of the inbound.
41+
The tag of the inbound.

docs/configuration/inbound/index.zh.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
| `hysteria2` | [Hysteria2](./hysteria2/) | :material-close: |
3232
| `vless` | [VLESS](./vless/) | TCP |
3333
| `anytls` | [AnyTLS](./anytls/) | TCP |
34+
| `mieru` | [Mieru](./mieru/) | :material-close: |
3435
| `tun` | [Tun](./tun/) | :material-close: |
3536
| `redirect` | [Redirect](./redirect/) | :material-close: |
3637
| `tproxy` | [TProxy](./tproxy/) | :material-close: |
3738

3839
#### tag
3940

40-
入站的标签。
41+
入站的标签。
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
icon: material/new-box
3+
---
4+
5+
### Structure
6+
7+
```json
8+
{
9+
"type": "mieru",
10+
"tag": "mieru-in",
11+
12+
... // Listen Fields
13+
14+
"transport": "TCP",
15+
"users": [
16+
{
17+
"name": "asdf",
18+
"password": "hjkl"
19+
}
20+
],
21+
"traffic_pattern": "GgQIARAK",
22+
}
23+
```
24+
25+
### Listen Fields
26+
27+
See [Listen Fields](/configuration/shared/listen/) for details.
28+
29+
### Fields
30+
31+
#### transport
32+
33+
==Required==
34+
35+
Transmission protocol. Allowed values are `TCP` and `UDP`.
36+
37+
#### users
38+
39+
==Required==
40+
41+
A list of mieru user name and password.
42+
43+
#### traffic_pattern
44+
45+
A base64 string to fine tune network behavior.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
icon: material/new-box
3+
---
4+
5+
### 结构
6+
7+
```json
8+
{
9+
"type": "mieru",
10+
"tag": "mieru-in",
11+
12+
... // 监听字段
13+
14+
"transport": "TCP",
15+
"users": [
16+
{
17+
"name": "asdf",
18+
"password": "hjkl"
19+
}
20+
],
21+
"traffic_pattern": "GgQIARAK",
22+
}
23+
```
24+
25+
### 监听字段
26+
27+
参阅 [监听字段](/zh/configuration/shared/listen/)
28+
29+
### 字段
30+
31+
#### transport
32+
33+
==必填==
34+
35+
通信协议。可设为 `TCP``UDP`
36+
37+
#### users
38+
39+
==必填==
40+
41+
一组 mieru 用户名和密码。
42+
43+
#### traffic_pattern
44+
45+
一个 base64 字符串用于微调网络行为。

docs/configuration/outbound/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `tuic` | [TUIC](./tuic/) |
3232
| `hysteria2` | [Hysteria2](./hysteria2/) |
3333
| `anytls` | [AnyTLS](./anytls/) |
34+
| `mieru` | [Mieru](./mieru/) |
3435
| `tor` | [Tor](./tor/) |
3536
| `ssh` | [SSH](./ssh/) |
3637
| `dns` | [DNS](./dns/) |

docs/configuration/outbound/index.zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| `tuic` | [TUIC](./tuic/) |
3232
| `hysteria2` | [Hysteria2](./hysteria2/) |
3333
| `anytls` | [AnyTLS](./anytls/) |
34+
| `mieru` | [Mieru](./mieru/) |
3435
| `tor` | [Tor](./tor/) |
3536
| `ssh` | [SSH](./ssh/) |
3637
| `dns` | [DNS](./dns/) |

0 commit comments

Comments
 (0)