Skip to content

Commit a2b415a

Browse files
committed
feat: add CLI script aliases for singbox2proxy; update README with chaining examples
1 parent 423ab07 commit a2b415a

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ keywords = [
3636
]
3737
dependencies = ["psutil", "pysocks"]
3838

39+
[project.scripts]
40+
singbox2proxy = "singbox2proxy.__main__:main"
41+
sb2p = "singbox2proxy.__main__:main"
42+
3943
[project.urls]
4044
"Homepage" = "https://github.com/nichind/singbox2proxy"
4145
"Issues" = "https://github.com/nichind/singbox2proxy/issues"

readme.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,85 +85,88 @@ async def main():
8585
print(response.status, await response.text()) # 200, {"ip":"..."}
8686
```
8787

88-
### CLI
88+
#### Chaining
89+
90+
Chained proxies allow you to route your traffic through multiple proxy servers if you'll ever need more privacy or easy restriction bypass. You can chain multiple proxies together by specifying a `chain_proxy` with a gate `SingBoxProxy` instance when creating a new `SingBoxProxy`.
8991

90-
Start a proxy server from the command line:
92+
> [!NOTE]
93+
> See what protocols can be used as middleman proxies at [supported protocols](#supported-protocols)
9194
92-
```shell
93-
singbox2proxy "vless://..."
95+
```python
96+
from singbox2proxy import SingBoxProxy
97+
98+
proxy1 = SingBoxProxy("vmess://...")
99+
proxy2 = SingBoxProxy("vless://...", chain_proxy=proxy1)
100+
101+
response = proxy2.request("GET", "https://api.ipify.org?format=json")
102+
print(response.status_code, response.text) # 200, {"ip": "<proxy2's IP>"}
103+
# Here, requests made through `proxy2` will first go through `proxy1`, then proxy1 will forward the request to proxy2, and finally proxy2 will send the request to the target server.
94104
```
95105

106+
### CLI
107+
108+
> [!NOTE]
109+
> If the `singbox2proxy` or `sb2p` command isn't working in your terminal, use `python -m singbox2proxy <command>`, `uv run -m singbox2proxy <command>`, etc. instead.
110+
96111
#### Basic Commands
97112

98113
Start a single proxy:
99114

100115
```shell
101-
singbox2proxy "vmess://eyJ2IjoiMiIsInBzIjoidGVzdCIsImFkZCI6IjEuMS4xLjEiLCJwb3J0IjoiNDQzIiwiaWQiOiI3YzI4ZmYzNC1mYTcxLTQ4ZjYtYWFjMS0xOGE4ODgzYWE2YzAiLCJhaWQiOiIwIiwibmV0IjoidGNwIiwidHlwZSI6Im5vbmUiLCJob3N0IjoiIiwicGF0aCI6IiIsInRscyI6InRscyJ9"
116+
sb2p "vmess://eyJ2IjoiMiIsInBzIj..."
102117
```
103118

104119
Specify custom ports:
105120

106121
```shell
107-
singbox2proxy "ss://..." --http-port 8080 --socks-port 1080
122+
sb2p "ss://..." --http-port 8080 --socks-port False # Socks disabled
108123
```
109124

110125
Test the proxy connection:
111126

112127
```shell
113-
singbox2proxy "trojan://..." --test
128+
sb2p "trojan://..." --test
114129
```
115130

116131
#### Proxy Chaining
117132

118133
Chain multiple proxies (traffic flows: you -> proxy1 -> proxy2 -> target):
119134

120135
```shell
121-
singbox2proxy "vmess://..." "vless://..." "hy2://..." --chain
136+
sb2p "vmess://..." "vless://..." "hy2://..." --chain
122137
```
123138

139+
> [!NOTE]
140+
> See what protocols can be used as middleman proxies at [supported protocols](#supported-protocols)
141+
124142
The first URL becomes the entry point, and the last URL connects to the target server.
125143

126144
#### Configuration Management
127145

128146
Generate configuration without starting:
129147

130148
```shell
131-
singbox2proxy "vless://..." --config-only
149+
sb2p "vless://..." --config-only
132150
```
133151

134152
Save configuration to file:
135153

136154
```shell
137-
singbox2proxy "vmess://..." --output-config config.json
155+
sb2p "vmess://..." --output-config config.json
138156
```
139157

140158
#### Logging Options
141159

142160
Enable verbose logging:
143161

144162
```shell
145-
singbox2proxy "ss://..." --verbose
163+
sb2p "ss://..." --verbose
146164
```
147165

148166
Disable all logging:
149167

150168
```shell
151-
singbox2proxy "hy2://..." --quiet
152-
```
153-
154-
### Chaining
155-
156-
Chained proxies allow you to route your traffic through multiple proxy servers if you'll ever need more privacy or easy restriction bypass. You can chain multiple proxies together by specifying a `chain_proxy` with a gate `SingBoxProxy` instance when creating a new `SingBoxProxy`.
157-
158-
```python
159-
from singbox2proxy import SingBoxProxy
160-
161-
proxy1 = SingBoxProxy("vmess://...")
162-
proxy2 = SingBoxProxy("vless://...", chain_proxy=proxy1)
163-
164-
response = proxy2.request("GET", "https://api.ipify.org?format=json")
165-
print(response.status_code, response.text) # 200, {"ip": "<proxy2's IP>"}
166-
# Here, requests made through `proxy2` will first go through `proxy1`, then proxy1 will forward the request to proxy2, and finally proxy2 will send the request to the target server.
169+
sb2p "hy2://..." --quiet
167170
```
168171

169172
### Discaimer

0 commit comments

Comments
 (0)