Skip to content

Commit 5f42481

Browse files
authored
v1.6
1 parent b6a9386 commit 5f42481

1 file changed

Lines changed: 76 additions & 59 deletions

File tree

‎README.rst‎

Lines changed: 76 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,45 @@ QuickStart
1919

2020
.. code:: rst
2121
22-
$ pip3 install pproxy pycryptodome
23-
Successfully installed pproxy-1.4.2 pycryptodome-3.6.4
22+
$ pip3 install pproxy
23+
Successfully installed pproxy-1.6
2424
$ pproxy
2525
Serving on :8080 by http,socks
2626
^C
27-
$ pproxy -i ss://chacha20:abc@:8080 -r ss://aes-256-cfb:123@12.34.56.78:8000 -v
27+
$ pproxy -i ss://chacha20:abc@:8080
28+
Serving on :8080 by ss (chacha20-py)
29+
30+
Optional: (better performance with C ciphers)
31+
32+
.. code:: rst
33+
34+
$ pip3 install pycryptodome
35+
Successfully installed pycryptodome-3.6.4
36+
$ pproxy -i ss://chacha20:abc@:8080
2837
Serving on :8080 by ss (chacha20)
29-
DIRECT: 0 (0.0K/s,0.0K/s) PROXY: 5 (5.0K/s,8.0K/s)
38+
3039
3140
3241
Features
3342
--------
3443

3544
- Single-thread asynchronous IO with high availability and scalability.
3645
- Lightweight (~500 lines) and powerful by leveraging python builtin *asyncio* library.
37-
- No additional library is required. All codes are in Pure Python.
38-
- Automatically detect incoming traffic: HTTP/Socks/Shadowsocks/Redirect.
39-
- Specify multiple remote servers for outcoming traffic: HTTP/Socks/Shadowsocks.
40-
- Unix domain socket support for communicating locally.
41-
- Basic authentication support for all three protocols.
42-
- Regex pattern file support to route/block by hostname matching.
43-
- SSL connection support to prevent Man-In-The-Middle attack.
44-
- Encryption cipher support to keep communication secure. (chacha20, aes-256-cfb, etc)
45-
- Shadowsocks OTA (One-Time-Auth_) experimental feature support.
46-
- SSR plugins support. (http_simple, verify_simple, tls1.2_ticket_auth, etc)
47-
- Basic statistics for bandwidth and total traffic by client/hostname.
48-
- PAC support for automatically javascript configuration.
49-
- Iptables NAT redirect packet tunnel support.
50-
- PyPy3.3 v5.5 support to enable JIT speedup.
46+
- No additional library is required. All codes are in pure Python.
47+
- Auto-detect incoming traffic.
48+
- Tunnel by remote proxy servers.
49+
- Tunnel and relay with several layers.
50+
- Unix domain path socket.
51+
- Basic authentication for all protocols.
52+
- Regex pattern file to route/block by hostname.
53+
- SSL client/server support.
54+
- Built-in encryption ciphers. (chacha20, aes-256-cfb, etc)
55+
- Shadowsocks OTA (One-Time-Auth_).
56+
- SSR plugins. (http_simple, verify_simple, tls1.2_ticket_auth, etc)
57+
- Statistics by bandwidth and traffic.
58+
- PAC support for javascript configuration.
59+
- Iptables NAT redirect packet tunnel.
60+
- PyPy3 support with JIT speedup.
5161

5262
.. _One-Time-Auth: https://shadowsocks.org/en/spec/one-time-auth.html
5363

@@ -58,14 +68,7 @@ Python3
5868

5969
From **pproxy** 1.1.0, the minimal Python requirement is **3.3**, since old python versions are still widely used and PyPy3 only has 3.3 support currently. *Python 2* will not be supported in the future.
6070

61-
From **proxy** 1.3.0, the minimal Python requirement is **3.6**, since **Python 3.7** make the **async**/**await**/ reserved words, we cannot make pproxy compatible with old versions anymore.
62-
63-
Installation
64-
------------
65-
66-
.. code:: rst
67-
68-
$ pip3 install pproxy
71+
From **proxy** 1.3.0, the minimal Python requirement is **3.6**, since **Python 3.7** make the **async**/**await**/ reserved words, we cannot make pproxy compatible with older versions.
6972

7073
PyPy3
7174
-----
@@ -78,18 +81,17 @@ PyPy3
7881
Requirement
7982
-----------
8083

81-
pycryptodome_ is an optional library to enable faster (C version) cipher encryption. **pproxy** has many built-in pure python ciphers without need to install pycryptodome_. They are lightweight and stable, but a little slow. After speed up with PyPy_, the pure python ciphers can achieve similar performance as pycryptodome_ (C version). If you care about cipher performance and don't run in PyPy_, just install pycryptodome_ to enable faster ciphers.
82-
83-
These are some performance comparisons between Python ciphers and C ciphers (process 8MB data totally):
84+
pycryptodome_ is an optional library to enable faster (C version) cipher. **pproxy** has many built-in pure python ciphers. They are lightweight and stable, but slower than C ciphers. After speedup with PyPy_, the pure python ciphers can get similar performance as C version. If the performance is important and don't have PyPy_, install pycryptodome_ instead.
8485

85-
.. code:: rst
86+
These are some performance benchmarks between Python and C ciphers (dataset: 8M):
8687

87-
$ python3 speed.py chacha20
88-
chacha20 0.6451280117034912
89-
$ pypy3 speed.py chacha20-py
90-
chacha20-py 1.3277630805969238
91-
$ python3 speed.py chacha20-py
92-
chacha20-py 48.85661292076111
88+
+---------------------+----------------+
89+
| chacha20-c | 0.64 secs |
90+
+---------------------+----------------+
91+
| chacha20-py (pypy3) | 1.32 secs |
92+
+---------------------+----------------+
93+
| chacha20-py | 48.86 secs |
94+
+---------------------+----------------+
9395

9496
.. _pycryptodome: https://pycryptodome.readthedocs.io/en/latest/src/introduction.html
9597
.. _PyPy: http://pypy.org
@@ -100,21 +102,25 @@ Usage
100102
.. code:: rst
101103
102104
$ pproxy -h
103-
usage: pproxy [-h] [-i LISTEN] [-r RSERVER] [-b BLOCK] [-v] [--ssl SSLFILE] [--pac PAC] [--get GETS] [--version]
105+
usage: pproxy [-h] [-i LISTEN] [-r RSERVER] [-b BLOCK] [-a ALIVED] [-v]
106+
[--ssl SSLFILE] [--pac PAC] [--get GETS] [--test TESTURL]
107+
[--version]
104108
105109
Proxy server that can tunnel among remote servers by regex rules. Supported
106110
protocols: http,socks,shadowsocks,shadowsocksr,redirect
107111
108112
optional arguments:
109-
-h, --help show this help message and exit
110-
-i LISTEN proxy server setting uri (default: http+socks://:8080/)
111-
-r RSERVER remote server setting uri (default: direct)
112-
-b BLOCK block regex rules
113-
-v print verbose output
114-
--ssl SSLFILE certfile[,keyfile] if server listen in ssl mode
115-
--pac PAC http PAC path
116-
--get GETS http custom path/file
117-
--version show program's version number and exit
113+
-h, --help show this help message and exit
114+
-i LISTEN proxy server setting uri (default: http+socks://:8080/)
115+
-r RSERVER remote server setting uri (default: direct)
116+
-b BLOCK block regex rules
117+
-a ALIVED interval to check remote alive (default: no check)
118+
-v print verbose output
119+
--ssl SSLFILE certfile[,keyfile] if server listen in ssl mode
120+
--pac PAC http PAC path
121+
--get GETS http custom {path,file}
122+
--test TESTURL test this url for all remote proxies and exit
123+
--version show program's version number and exit
118124
119125
Online help: <https://github.com/qwj/python-proxy>
120126
@@ -141,6 +147,8 @@ URI Syntax
141147
+--------+-----------------------------+
142148
| secure | secured ssl (required cert) |
143149
+--------+-----------------------------+
150+
| direct | direct connection |
151+
+--------+-----------------------------+
144152

145153
- Valid schemes: http://, http+socks://, http+ssl://, ss+secure://, http+socks+ss://
146154
- Invalid schemes: ssl://, secure://
@@ -231,12 +239,14 @@ URI Syntax
231239
- auth
232240
- The username, colon ':', and the password
233241

242+
URIs can be joined by "__" to indicate tunneling by relay. For example, ss://1.2.3.4:1324__http://4.5.6.7:4321 make remote connection to the first shadowsocks proxy server, and then tunnel to the second http proxy server.
243+
234244
.. _AEAD: http://shadowsocks.org/en/spec/AEAD-Ciphers.html
235245

236246
Examples
237247
--------
238248

239-
We can define file "rules" as follow:
249+
Define regex file "rules" as follow:
240250

241251
.. code:: rst
242252
@@ -256,7 +266,7 @@ We can define file "rules" as follow:
256266
(?:.+\.)?youtu\.be
257267
(?:.+\.)?google\..+
258268
259-
Then start the pproxy
269+
Then start the *pproxy*
260270

261271
.. code:: rst
262272
@@ -266,9 +276,9 @@ Then start the pproxy
266276
http www.yahoo.com:80
267277
DIRECT: 1 (0.5K/s,1.2M/s) PROXY: 2 (24.3K/s,1.9M/s)
268278
269-
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.
279+
*pproxy* will serve incoming traffic by auto-detect http/socks5 protocol, redirect all google traffic to http proxy aa.bb.cc.dd:8080, and visit all other traffic directly from local server.
270280

271-
To bridge two servers, add cipher encryption to ensure data can't be intercepted. First, run pproxy locally
281+
Add cipher encryption to make sure data can't be intercepted. Run *pproxy* locally as:
272282

273283
.. code:: rst
274284
@@ -280,43 +290,50 @@ Next, run pproxy.py remotely on server "aa.bb.cc.dd"
280290
281291
$ pproxy -i ss://chacha20:cipher_key@:12345
282292
283-
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.
293+
The traffic between local and aa.bb.cc.dd is encrypted by stream cipher Chacha20 with key "cipher_key".
284294

285295
A more complex example:
286296

287297
.. code:: rst
288298
289299
$ pproxy -i ss://salsa20!:complex_cipher_key@/tmp/pproxy_socket -r http+ssl://domain1.com:443#username:password
290300
291-
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.
301+
*pproxy* listen on the unix domain socket "/tmp/pproxy_socket" with cipher "salsa20" and key "complex_cipher_key". OTA packet protocol is enabled by adding ! after cipher name. The traffic is tunneled to remote https proxy with simple http authentication.
292302

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

295305
.. code:: rst
296306
297307
$ pproxy -i http+ssl://0.0.0.0:443 -i http://0.0.0.0:80 --ssl server.crt,server.key --pac /autopac
298308
299-
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.
309+
*pproxy* listen on both 80 HTTP and 443 HTTPS ports, use the specified SSL certificate and private key files. The "--pac" enable PAC feature, so you can put "https://yourdomain.com/"" path in your device's auto-configure url.
300310

301-
A ShadowsocksR example:
311+
ShadowsocksR example with plugin "tls1.2_ticket_auth" to emulate common tls traffic:
302312

303313
.. code:: rst
304314
305315
$ pproxy -i ssr://chacha20:mypass@0.0.0.0:443/,tls1.2_ticket_auth,verify_simple
306316
307-
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:
317+
If you want to route the traffic by different local bind, use the @localbind URI 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:
308318

309319
.. code:: rst
310320
311321
$ 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
312322
313-
An iptable NAT redirect example:
323+
IPtable NAT redirect example:
314324

315325
.. code:: rst
316326
317-
$ iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 5555
327+
$ sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 5555
318328
$ pproxy -i redir://:5555 -r http://remote_http_server:3128 -v
319329
320-
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.
330+
The above 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.
331+
332+
Relay tunnel example:
333+
334+
.. code:: rst
335+
336+
$ pproxy -r http://server1__ss://server2__socks://server3
321337
338+
*pproxy* will try to connect to server1 first, tell server1 proxy tunnel to server2, and tell server2 proxy tunnel to server3, and make traffic by server3.
322339

0 commit comments

Comments
 (0)