Skip to content

Commit 2b4d1bf

Browse files
authored
Add files via upload
1 parent 834495e commit 2b4d1bf

1 file changed

Lines changed: 81 additions & 39 deletions

File tree

README.rst

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
python-proxy
22
===========
33

4-
HTTP/Socks5/Shadowsocks Asynchronous Tunnel Proxy implemented in Python 3.6 asyncio.
4+
HTTP/Socks5/Shadowsocks asynchronous tunnel proxy implemented in Python 3.6 asyncio.
5+
6+
Features
7+
-----------
8+
9+
- Single-thread asynchronous IO with high availability and scalability.
10+
- Compact (~500 lines) and powerful by leveraging python builtin *asyncio* library.
11+
- Automatically detect incoming traffic: HTTP/Socks5/Shadowsocks.
12+
- Specify multiple remote servers for outcoming traffic: HTTP/Socks5/Shadowsocks.
13+
- Unix domain socket support for communicating locally.
14+
- Basic authentication support for all three protocols.
15+
- Regex pattern file support to route/block by hostname matching.
16+
- SSL connection support to prevent Man-In-The-Middle attack.
17+
- Many ciphers support to keep communication securely. (chacha20, aes-256-cfb, etc)
18+
- Shadowsocks OTA (One-Time-Auth) experimental feature support.
19+
- Basic statistics for bandwidth and total traffic by client/hostname.
20+
- PAC support for automatically javascript configuration.
521

622
Python 3.6
723
-----------
824

9-
*Python 3.5* added new syntax *async def* and *await* to make asyncio programming easier. *Python 3.6* added new syntax *formatted string literals*. This utility is to demonstrate these new syntax and is also fully ready for production usage.
25+
*Python 3.5* added new syntax *async def* and *await* to make asyncio programming easier. *Python 3.6* added new syntax *formatted string literals*. This tool is to demonstrate how compact these new syntax can be. It includes many features, and is also fully ready for production usage.
1026

1127
Installation
1228
-----------
1329

14-
$ sudo pip3 install pproxy
30+
$ pip3 install pproxy
1531

16-
Features
32+
Requirement
1733
-----------
1834

19-
- Automatically detect incoming protocol: HTTP/Socks5/Shadowsocks.
20-
- Specify remote servers for outcoming protocol.
21-
- Unix path support for communicating locally.
22-
- Basic authentication method for HTTP/Socks5/Shadowsocks.
23-
- Regex pattern file support for redirecting/blocking by hostname.
24-
- SSL connection support to prevent Man-In-The-Middle attack.
25-
- Many ciphers support to keep communication securely. (chacha20, salsa20, aes-256-cfb, etc)
26-
- Basic statistics for bandwidth and total traffic by client/hostname.
27-
- PAC support for automatically javascript configuration.
35+
*pycryptodome* is the optional required library to enable cipher encryption support. Without installing this, you can still use pproxy with no encryption.
2836

2937
Usage
3038
-----------
@@ -53,19 +61,46 @@ Uri Syntax
5361
{scheme}://[{cipher}@]{netloc}[?{rules}][#{auth}]
5462

5563
- scheme
56-
- Currently supported scheme: http, socks, ss, ssl, secure. You can use + to add multiple protocols together.
57-
- http - http protocol
58-
- socks - socks5 protocol
59-
- ss - shadowsocks protocol
60-
- ssl - communicate in (unsecured) ssl
61-
- secure - comnunicate in (secured) ssl
62-
- Valid schemes are: http://, http+socks://, http+ssl://, ss+secure://
63-
- Invalid schemes are: ssl://, secure://
64+
- Currently supported scheme: http, socks, ss, ssl, secure. You can use + to link multiple protocols together.
65+
:http: http protocol
66+
:socks: socks5 protocol
67+
:ss: shadowsocks protocol
68+
:ssl: communicate in (unsecured) ssl
69+
:secure: comnunicate in (secured) ssl
70+
- Valid schemes: http://, http+socks://, http+ssl://, ss+secure://, http+socks+ss://
71+
- Invalid schemes: ssl://, secure://
6472
- cipher
6573
- Cipher is consisted by cipher name, colon ':' and cipher key.
66-
- Full cipher list: table, rc4, rc4-md5, chacha20, salsa20, aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, cast5-fb, des-cfb
74+
- Full supported cipher list:
75+
+------------+------------+-----------+-------------+
76+
| Cipher | Key Length | IV Length | Security |
77+
+============+============+===========+=============+
78+
| table | any | 0 | 0 (lowest) |
79+
+------------+------------+-----------+-------------+
80+
| rc4 | 16 | 0 | 0 (lowest) |
81+
+------------+------------+-----------+-------------+
82+
| rc4-md5 | 16 | 16 | 0.5 |
83+
+------------+------------+-----------+-------------+
84+
| chacha20 | 32 | 8 | 5 (highest) |
85+
+------------+------------+-----------+-------------+
86+
| salsa20 | 32 | 8 | 5 (highest) |
87+
+------------+------------+-----------+-------------+
88+
| aes-128-cfb| 16 | 16 | 3 |
89+
+------------+------------+-----------+-------------+
90+
| aes-192-cfb| 24 | 16 | 3.5 |
91+
+------------+------------+-----------+-------------+
92+
| aes-256-cfb| 32 | 16 | 4.5 |
93+
+------------+------------+-----------+-------------+
94+
| bf-cfb | 16 | 8 | 2 |
95+
+------------+------------+-----------+-------------+
96+
| cast5-cfb | 16 | 8 | 2.5 |
97+
+------------+------------+-----------+-------------+
98+
| des-cfb | 8 | 8 | 1 |
99+
+------------+------------+-----------+-------------+
100+
- To enable OTA encryption with shadowsocks, add '!' immediately after cipher name.
67101
- netloc
68-
- It can be "hostname:port" or "/unix_path". If the hostname is empty, server will listen on all interfaces.
102+
- It can be "hostname:port" or "/unix_domaon_path". If the hostname is empty, server will listen on all interfaces.
103+
- Valid netloc: localhost:8080, 0.0.0.0:8123, /tmp/domain_socket, :8123
69104
- rules
70105
- The filename that contains regex rules
71106
- auth
@@ -76,21 +111,21 @@ Examples
76111

77112
We can define file "rules" as follow:
78113

79-
#google domains
80-
(?:.+\.)?google.*\.com
81-
(?:.+\.)?gstatic\.com
82-
(?:.+\.)?gmail\.com
83-
(?:.+\.)?ntp\.org
84-
(?:.+\.)?glpals\.com
85-
(?:.+\.)?akamai.*\.net
86-
(?:.+\.)?ggpht\.com
87-
(?:.+\.)?android\.com
88-
(?:.+\.)?gvt1\.com
89-
(?:.+\.)?youtube.*\.com
90-
(?:.+\.)?ytimg\.com
91-
(?:.+\.)?goo\.gl
92-
(?:.+\.)?youtu\.be
93-
(?:.+\.)?google\..+
114+
| #google domains
115+
| (?:.+\.)?google.*\.com
116+
| (?:.+\.)?gstatic\.com
117+
| (?:.+\.)?gmail\.com
118+
| (?:.+\.)?ntp\.org
119+
| (?:.+\.)?glpals\.com
120+
| (?:.+\.)?akamai.*\.net
121+
| (?:.+\.)?ggpht\.com
122+
| (?:.+\.)?android\.com
123+
| (?:.+\.)?gvt1\.com
124+
| (?:.+\.)?youtube.*\.com
125+
| (?:.+\.)?ytimg\.com
126+
| (?:.+\.)?goo\.gl
127+
| (?:.+\.)?youtu\.be
128+
| (?:.+\.)?google\..+
94129
95130
Then start the pproxy
96131

@@ -106,5 +141,12 @@ Next, run pproxy.py remotely on server "aa.bb.cc.dd"
106141

107142
pproxy -i ss://chacha20:cipher_key@:12345
108143

109-
By doing this, the traffic between local and aa.bb.cc.dd is encrypted by stream cipher Chacha20 with key "This is a cipher key". If target hostname is not in "rules", traffic will go through locally. Otherwise, traffic will go through the remote server by encryption.
144+
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.
145+
146+
A more complex example:
147+
148+
pproxy -i ss://salsa20!:complex_cipher_key@/tmp/pproxy_socket -r http+ssl://domain1.com:443#username:password
149+
150+
It listen on the unix domain socket /tmp/pproxy_socket, and use cipher name salsa20, cipher key "complex_cipher_key", and enable OTA encryption for shadowsocks protocol. The traffic is tunneled to remote https proxy with simple authentication.
151+
110152

0 commit comments

Comments
 (0)