|
1 | | -# python-proxy |
2 | | -HTTP/Socks5/PSocks Proxy written in Python 3.6 |
| 1 | +python-proxy |
| 2 | +=========== |
| 3 | + |
| 4 | +HTTP/Socks5/PSocks Asynchronous Proxy implemented in Python 3.6 asyncio with multiple useful features. |
| 5 | + |
| 6 | +Overview |
| 7 | +----------- |
| 8 | + |
| 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. |
| 10 | + |
| 11 | +Features |
| 12 | +----------- |
| 13 | + |
| 14 | +- This utility can automatically detect incoming protocol from HTTP/Socks5/PSocks. |
| 15 | +- Implemented basic authentication method for HTTP/Socks5/PSocks. |
| 16 | +- Regex pattern file support for redirecting/blocking the incoming hosts. |
| 17 | +- Basic statistics for bandwidth and total traffic by client/hostname |
| 18 | + |
| 19 | +Usage |
| 20 | +----------- |
| 21 | + |
| 22 | + $ python3.6 pproxy.py -h |
| 23 | + usage: pproxy.py [-h] [-p PORT] [-t TYPES] [-a AUTH] [-rs RSERVER] [-rt RTYPE] |
| 24 | + [-ra RAUTH] [-m MATCH] [-b BLOCK] [-v] |
| 25 | + |
| 26 | + Proxy server that can tunnel by http,socks,psocks protocol. |
| 27 | + |
| 28 | + optional arguments: |
| 29 | + -h, --help show this help message and exit |
| 30 | + -p PORT listen port server bound to (default: 8080) |
| 31 | + -t TYPES proxy server protocols (default: socks,http) |
| 32 | + -a AUTH authentication requirement |
| 33 | + -rs RSERVER remote server address (default: direct) |
| 34 | + -rt RTYPE remote server type (default: psocks) |
| 35 | + -ra RAUTH remote authorization code |
| 36 | + -m MATCH match pattern file |
| 37 | + -b BLOCK block pattern file |
| 38 | + -v print verbose output |
| 39 | + |
| 40 | +Examples |
| 41 | +----------- |
| 42 | + |
| 43 | +We can define file "rules" as follow: |
| 44 | + |
| 45 | + #google domains |
| 46 | + (?:.+\.)?google.*\.com |
| 47 | + (?:.+\.)?gstatic\.com |
| 48 | + (?:.+\.)?gmail\.com |
| 49 | + (?:.+\.)?ntp\.org |
| 50 | + (?:.+\.)?glpals\.com |
| 51 | + (?:.+\.)?akamai.*\.net |
| 52 | + (?:.+\.)?ggpht\.com |
| 53 | + (?:.+\.)?android\.com |
| 54 | + (?:.+\.)?gvt1\.com |
| 55 | + (?:.+\.)?youtube.*\.com |
| 56 | + (?:.+\.)?ytimg\.com |
| 57 | + (?:.+\.)?goo\.gl |
| 58 | + (?:.+\.)?youtu\.be |
| 59 | + (?:.+\.)?google\..+ |
| 60 | + |
| 61 | +Then start the pproxy.py |
| 62 | + |
| 63 | + python3.6 pserver.py -rs aa.bb.cc.dd:8080 -rt http -m rules -v |
| 64 | + |
| 65 | +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. |
| 66 | + |
| 67 | + |
0 commit comments