Skip to content

Commit 9f510be

Browse files
authored
Update README.rst
1 parent d7c935b commit 9f510be

1 file changed

Lines changed: 78 additions & 43 deletions

File tree

‎README.rst‎

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ HTTP/Socks/Shadowsocks/ShadowsocksR/Redirect asynchronous tunnel proxy implement
1919
QuickStart
2020
----------
2121

22-
| $ pip3 install pproxy
23-
| $ pproxy
24-
| Serving on :8080 by http,socks
25-
|
22+
.. code:: rst
2623
24+
$ pip3 install pproxy
25+
$ pproxy
26+
Serving on :8080 by http,socks
27+
2728
Features
2829
--------
2930

@@ -58,13 +59,17 @@ From **proxy** 1.3.0, the minimal Python requirement is **3.6**, since **Python
5859
Installation
5960
------------
6061

61-
| $ pip3 install pproxy
62+
.. code:: rst
63+
64+
$ pip3 install pproxy
6265
6366
PyPy3
6467
-----
6568

66-
| $ pypy3 -m ensurepip
67-
| $ pypy3 -m pip install asyncio pproxy
69+
.. code:: rst
70+
71+
$ pypy3 -m ensurepip
72+
$ pypy3 -m pip install asyncio pproxy
6873
6974
Requirement
7075
-----------
@@ -73,24 +78,28 @@ pycryptodome_ is an optional library to enable faster (C version) cipher encrypt
7378

7479
These are some performance comparisons between Python ciphers and C ciphers (process 8MB data totally):
7580

76-
| $ python3 speed.py chacha20
77-
| chacha20 0.6451280117034912
78-
| $ pypy3 speed.py chacha20-py
79-
| chacha20-py 1.3277630805969238
80-
| $ python3 speed.py chacha20-py
81-
| chacha20-py 48.85661292076111
81+
.. code:: rst
82+
83+
$ python3 speed.py chacha20
84+
chacha20 0.6451280117034912
85+
$ pypy3 speed.py chacha20-py
86+
chacha20-py 1.3277630805969238
87+
$ python3 speed.py chacha20-py
88+
chacha20-py 48.85661292076111
8289
8390
.. _pycryptodome: https://pycryptodome.readthedocs.io/en/latest/src/introduction.html
8491
.. _PyPy: http://pypy.org
8592

8693
Usage
8794
-----
8895

96+
.. code:: rst
97+
8998
$ pproxy -h
9099
usage: pproxy [-h] [-i LISTEN] [-r RSERVER] [-b BLOCK] [-v] [--ssl SSLFILE] [--pac PAC] [--get GETS] [--version]
91100
92101
Proxy server that can tunnel among remote servers by regex rules. Supported
93-
protocols: http,socks,shadowsocks,redirect
102+
protocols: http,socks,shadowsocks,shadowsocksr,redirect
94103
95104
optional arguments:
96105
-h, --help show this help message and exit
@@ -113,13 +122,21 @@ URI Syntax
113122
- scheme
114123
- Currently supported scheme: http, socks, ss, ssl, secure. You can use + to link multiple protocols together.
115124

116-
:http: http protocol
117-
:socks: socks5 protocol
118-
:ss: shadowsocks protocol
119-
:ssr: shadowsocksR protocol
120-
:redir: redirect protocol (iptables nat)
121-
:ssl: communicate in (unsecured) ssl
122-
:secure: comnunicate in (secured) ssl
125+
+--------+-----------------------------+
126+
| http | http protocol |
127+
+--------+-----------------------------+
128+
| socks | socks5 protocol |
129+
+--------+-----------------------------+
130+
| ss | shadowsocks protocol |
131+
+--------+-----------------------------+
132+
| ssr | shadowsocksr (SSR) protocol |
133+
+--------+-----------------------------+
134+
| redir | redirect (iptables nat) |
135+
+--------+-----------------------------+
136+
| ssl | unsecured ssl (no cert) |
137+
+--------+-----------------------------+
138+
| secure | secured ssl (required cert) |
139+
+--------+-----------------------------+
123140

124141
- Valid schemes: http://, http+socks://, http+ssl://, ss+secure://, http+socks+ss://
125142
- Invalid schemes: ssl://, secure://
@@ -218,66 +235,84 @@ Examples
218235

219236
We can define file "rules" as follow:
220237

221-
| #google domains
222-
| (?:.+\.)?google.*\.com
223-
| (?:.+\.)?gstatic\.com
224-
| (?:.+\.)?gmail\.com
225-
| (?:.+\.)?ntp\.org
226-
| (?:.+\.)?glpals\.com
227-
| (?:.+\.)?akamai.*\.net
228-
| (?:.+\.)?ggpht\.com
229-
| (?:.+\.)?android\.com
230-
| (?:.+\.)?gvt1\.com
231-
| (?:.+\.)?youtube.*\.com
232-
| (?:.+\.)?ytimg\.com
233-
| (?:.+\.)?goo\.gl
234-
| (?:.+\.)?youtu\.be
235-
| (?:.+\.)?google\..+
238+
.. code:: rst
239+
240+
#google domains
241+
(?:.+\.)?google.*\.com
242+
(?:.+\.)?gstatic\.com
243+
(?:.+\.)?gmail\.com
244+
(?:.+\.)?ntp\.org
245+
(?:.+\.)?glpals\.com
246+
(?:.+\.)?akamai.*\.net
247+
(?:.+\.)?ggpht\.com
248+
(?:.+\.)?android\.com
249+
(?:.+\.)?gvt1\.com
250+
(?:.+\.)?youtube.*\.com
251+
(?:.+\.)?ytimg\.com
252+
(?:.+\.)?goo\.gl
253+
(?:.+\.)?youtu\.be
254+
(?:.+\.)?google\..+
236255
237256
Then start the pproxy
238257

239-
| $ pproxy -i http+socks://:8080 -r http://aa.bb.cc.dd:8080?rules -v
240-
| http www.googleapis.com:443 -> http aa.bb.cc.dd:8080
241-
| socks www.youtube.com:443 -> http aa.bb.cc.dd:8080
242-
| http www.yahoo.com:80
243-
| DIRECT: 1 (0.5K/s,1.2M/s) PROXY: 2 (24.3K/s,1.9M/s)
258+
.. code:: rst
259+
260+
$ pproxy -i http+socks://:8080 -r http://aa.bb.cc.dd:8080?rules -v
261+
http www.googleapis.com:443 -> http aa.bb.cc.dd:8080
262+
socks www.youtube.com:443 -> http aa.bb.cc.dd:8080
263+
http www.yahoo.com:80
264+
DIRECT: 1 (0.5K/s,1.2M/s) PROXY: 2 (24.3K/s,1.9M/s)
244265
245266
With these parameters, this utility will serve incoming traffic by either http/socks5 protocol, redirect all google traffic to http proxy aa.bb.cc.dd:8080, and visit all other traffic locally.
246267

247268
To bridge two servers, add cipher encryption to ensure data can't be intercepted. First, run pproxy locally
248269

270+
.. code:: rst
271+
249272
$ pproxy -i ss://:8888 -r ss://chacha20:cipher_key@aa.bb.cc.dd:12345 -v
250273
251274
Next, run pproxy.py remotely on server "aa.bb.cc.dd"
252275

276+
.. code:: rst
277+
253278
$ pproxy -i ss://chacha20:cipher_key@:12345
254279
255280
By doing this, the traffic between local and aa.bb.cc.dd is encrypted by stream cipher Chacha20 with key "cipher_key". If target hostname is not matched by regex file "rules", traffic will go through locally. Otherwise, traffic will go through the remote server by encryption.
256281

257282
A more complex example:
258283

284+
.. code:: rst
285+
259286
$ pproxy -i ss://salsa20!:complex_cipher_key@/tmp/pproxy_socket -r http+ssl://domain1.com:443#username:password
260287
261288
It listen on the unix domain socket /tmp/pproxy_socket, and use cipher name salsa20, cipher key "complex_cipher_key", and enable explicit OTA encryption for shadowsocks protocol. The traffic is tunneled to remote https proxy with simple authentication. If OTA mode is not specified, server will allow both non-OTA and OTA traffic. If specified OTA mode, server only allow OTA client to connect.
262289

263290
If you want to listen in SSL, you must specify ssl certificate and private key files by parameter "--ssl", there is an example:
264291

292+
.. code:: rst
293+
265294
$ pproxy -i http+ssl://0.0.0.0:443 -i http://0.0.0.0:80 --ssl server.crt,server.key --pac /autopac
266295
267296
It listen on both 80 HTTP and 443 HTTPS ports, use the specified certificate and private key files. The "--pac" enable PAC support, so you can put https://yourdomain.com/autopac in your device's auto-configure url.
268297

269298
A ShadowsocksR example:
270299

300+
.. code:: rst
301+
271302
$ pproxy -i ssr://chacha20:mypass@0.0.0.0:443/,tls1.2_ticket_auth,verify_simple
272303
273304
If you want to route the traffic by different local bind, use the @localbind syntax. For example, server has three ip interfaces: 192.168.1.15, 111.0.0.1, 112.0.0.1. You want to route traffic matched by "rule1" to 111.0.0.2 and traffic matched by "rule2" to 222.0.0.2, and the remaining traffic directly:
274305

306+
.. code:: rst
307+
275308
$ pproxy -i ss://:8000/@in -r ss://111.0.0.2:8000/@111.0.0.1?rule1 -r ss://222.0.0.2:8000/@222.0.0.1?rule2
276309
277310
An iptable NAT redirect example:
278311

279-
| $ iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 5555
280-
| $ pproxy -i redir://:5555 -r http://remote_http_server:3128 -v
312+
.. code:: rst
313+
314+
$ iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 5555
315+
$ pproxy -i redir://:5555 -r http://remote_http_server:3128 -v
281316
282317
This example illustrates how to redirect all local output tcp traffic with destination port 80 to localhost port 5555 listened by **pproxy**, and then tunnel the traffic to remote http proxy.
283318

0 commit comments

Comments
 (0)