Skip to content

Commit f81e320

Browse files
author
Jonney
authored
Merge pull request #2 from qwj/master
pull
2 parents f70708d + 542cc8a commit f81e320

File tree

8 files changed

+1018
-566
lines changed

8 files changed

+1018
-566
lines changed

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include LICENSE
2+
graft tests

README.rst

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
python-proxy
22
============
33

4-
|made-with-python| |PyPI-version| |Hit-Count| |Downloads|
4+
|made-with-python| |PyPI-version| |Hit-Count| |Downloads| |Downloads-month| |Downloads-week|
55

66
.. |made-with-python| image:: https://img.shields.io/badge/Made%20with-Python-1f425f.svg
77
:target: https://www.python.org/
@@ -11,8 +11,12 @@ python-proxy
1111
:target: https://pypi.python.org/pypi/pproxy/
1212
.. |Downloads| image:: https://pepy.tech/badge/pproxy
1313
:target: https://pepy.tech/project/pproxy
14+
.. |Downloads-month| image:: https://pepy.tech/badge/pproxy/month
15+
:target: https://pepy.tech/project/pproxy
16+
.. |Downloads-week| image:: https://pepy.tech/badge/pproxy/week
17+
:target: https://pepy.tech/project/pproxy
1418

15-
HTTP/Socks4/Socks5/Shadowsocks/ShadowsocksR/SSH/Redirect/Pf TCP/UDP asynchronous tunnel proxy implemented in Python3 asyncio.
19+
HTTP/HTTP2/HTTP3/Socks4/Socks5/Shadowsocks/SSH/Redirect/Pf/QUIC TCP/UDP asynchronous tunnel proxy implemented in Python3 asyncio.
1620

1721
QuickStart
1822
----------
@@ -73,8 +77,9 @@ Features
7377
- Proxy client/server for TCP/UDP.
7478
- Schedule (load balance) among remote servers.
7579
- Incoming traffic auto-detect.
76-
- Tunnel/relay/backward-relay support.
80+
- Tunnel/jump/backward-jump support.
7781
- Unix domain socket support.
82+
- HTTP v2, HTTP v3 (QUIC)
7883
- User/password authentication support.
7984
- Filter/block hostname by regex patterns.
8085
- SSL/TLS client/server support.
@@ -98,6 +103,10 @@ Protocols
98103
| http | || | | httponly:// |
99104
| (get,post,etc) | | | | | (as client) |
100105
+-------------------+------------+------------+------------+------------+--------------+
106+
| http v2 (connect) ||| | | h2:// |
107+
+-------------------+------------+------------+------------+------------+--------------+
108+
| http v3 (connect) | ✔ by UDP | ✔ by UDP | | | h3:// |
109+
+-------------------+------------+------------+------------+------------+--------------+
101110
| https ||| | | http+ssl:// |
102111
+-------------------+------------+------------+------------+------------+--------------+
103112
| socks4 ||| | | socks4:// |
@@ -112,8 +121,12 @@ Protocols
112121
+-------------------+------------+------------+------------+------------+--------------+
113122
| shadowsocksR ||| | | ssr:// |
114123
+-------------------+------------+------------+------------+------------+--------------+
124+
| trojan ||| | | trojan:// |
125+
+-------------------+------------+------------+------------+------------+--------------+
115126
| ssh tunnel | || | | ssh:// |
116127
+-------------------+------------+------------+------------+------------+--------------+
128+
| quic | ✔ by UDP | ✔ by UDP ||| http+quic:// |
129+
+-------------------+------------+------------+------------+------------+--------------+
117130
| iptables nat || | | | redir:// |
118131
+-------------------+------------+------------+------------+------------+--------------+
119132
| pfctl nat (macos) || | | | pf:// |
@@ -230,6 +243,8 @@ URI Syntax
230243
+----------+-----------------------------+
231244
| ssr | shadowsocksr (SSR) protocol |
232245
+----------+-----------------------------+
246+
| trojan | trojan_ protocol |
247+
+----------+-----------------------------+
233248
| ssh | ssh client tunnel |
234249
+----------+-----------------------------+
235250
| redir | redirect (iptables nat) |
@@ -249,6 +264,8 @@ URI Syntax
249264
| direct | direct connection |
250265
+----------+-----------------------------+
251266

267+
.. _trojan: https://trojan-gfw.github.io/trojan/protocol
268+
252269
- "http://" accepts GET/POST/CONNECT as server, sends CONNECT as client. "httponly://" sends "GET/POST" as client, works only on http traffic.
253270

254271
- Valid schemes: http://, http+socks4+socks5://, http+ssl://, ss+secure://, http+socks5+ss://
@@ -360,7 +377,7 @@ URI Syntax
360377

361378
- The username, colon ':', and the password
362379

363-
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.
380+
URIs can be joined by "__" to indicate tunneling by jump. 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 jump to the second http proxy server.
364381

365382
.. _AEAD: http://shadowsocks.org/en/spec/AEAD-Ciphers.html
366383

@@ -553,9 +570,7 @@ Examples
553570
554571
Make sure **pproxy** runs in root mode (sudo), otherwise it cannot redirect pf packet.
555572

556-
- Relay tunnel
557-
558-
Relay tunnel example:
573+
- Multiple jumps example
559574

560575
.. code:: rst
561576
@@ -653,6 +668,12 @@ Examples
653668
654669
Server connects to client_ip:8081 and waits for client proxy requests. The protocol http specified is just an example. It can be any protocol and cipher **pproxy** supports. The scheme "**in**" should exist in URI to inform **pproxy** that it is a backward proxy.
655670

671+
.. code:: rst
672+
673+
$ pproxy -l http+in://jumpserver__http://client_ip:8081
674+
675+
It is a complicated example. Server connects to client_ip:8081 by jump http://jumpserver. The backward proxy works through jumps.
676+
656677
- SSH client tunnel
657678

658679
SSH client tunnel support is enabled by installing additional library asyncssh_. After "pip3 install asyncssh", you can specify "**ssh**" as scheme to proxy via ssh client tunnel.
@@ -669,10 +690,73 @@ Examples
669690
670691
SSH connection known_hosts feature is disabled by default.
671692

693+
- SSH jump
694+
695+
SSH jump is supported by using "__" concatenation
696+
697+
.. code:: rst
698+
699+
$ pproxy -r ssh://server1__ssh://server2__ssh://server3
700+
701+
First connection to server1 is made. Second, ssh connection to server2 is made from server1. Finally, connect to server3, and use server3 for proxying traffic.
702+
703+
- SSH remote forward
704+
705+
.. code:: rst
706+
707+
$ pproxy -l ssh://server__tunnel://0.0.0.0:1234 -r tunnel://127.0.0.1:1234
708+
709+
TCP :1234 on remote server is forwarded to 127.0.0.1:1234 on local server
710+
711+
.. code:: rst
712+
713+
$ pproxy -l ssh://server1__ssh://server2__ss://0.0.0.0:1234 -r ss://server3:1234
714+
715+
It is a complicated example. SSH server2 is jumped from SSH server1, and ss://0.0.0.0:1234 on server2 is listened. Traffic is forwarded to ss://server3:1234.
716+
717+
- Trojan protocol example
718+
719+
Normally trojan:// should be used together with ssl://. You should specify the SSL crt/key file for ssl usage. A typical trojan server would be:
720+
721+
.. code:: rst
722+
723+
$ pproxy --ssl ssl.crt,ssl.key -l trojan+tunnel{localhost:80}+ssl://:443#yourpassword -vv
724+
725+
If trojan password doesn't match, the tunnal{localhost:80} will be switched to. It looks exactly the same as a common HTTPS website.
726+
727+
- QUIC protocol example
728+
729+
QUIC is a UDP stream protocol used in HTTP/3. Library **aioquic** is required if you want to proxy via QUIC.
730+
QUIC is listened on UDP port, but can handle TCP or UDP traffic. If you want to handle TCP traffic, you should use "-l quic+http" instead of "-ul quic+http".
731+
732+
.. code:: rst
733+
734+
$ pip3 install aioquic
735+
$ pproxy --ssl ssl.crt,ssl.key -l quic+http://:1234
736+
737+
On the client:
738+
739+
$ pproxy -r quic+http://server:1234
740+
741+
QUIC protocol can transfer a lot of TCP streams on one single UDP stream. If the connection number is hugh, QUIC can benefit by reducing TCP handshake time.
742+
743+
- VPN Server Example
744+
745+
You can run VPN server simply by installing pvpn (python vpn), a lightweight VPN server with pproxy tunnel feature.
746+
747+
.. code:: rst
748+
749+
$ pip3 install pvpn
750+
Successfully installed pvpn-0.2.1
751+
$ pvpn -wg 9999 -r http://remote_server:remote_port
752+
Serving on UDP :500 :4500...
753+
Serving on UDP :9000 (WIREGUARD)...
754+
TCP xx.xx.xx.xx:xx -> HTTP xx.xx.xx.xx:xx -> xx.xx.xx.xx:xx
755+
672756
673757
Projects
674758
--------
675759

676-
+ `python-esp <https://github.com/qwj/python-esp>`_ - Pure python VPN (IPSec,IKE,IKEv2,L2TP)
677-
+ `shadowproxy <https://github.com/guyingbo/shadowproxy>`_ - Another awesome proxy implementation by guyingbo
760+
+ `python-vpn <https://github.com/qwj/python-vpn>`_ - VPN Server (IPSec,IKE,IKEv2,L2TP,WireGuard) in pure python
761+
+ `shadowproxy <https://github.com/guyingbo/shadowproxy>`_ - Awesome python proxy implementation by guyingbo
678762

pproxy/__doc__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
__title__ = "pproxy"
2-
__version__ = "2.3.7"
32
__license__ = "MIT"
43
__description__ = "Proxy server that can tunnel among remote servers by regex rules."
54
__keywords__ = "proxy socks http shadowsocks shadowsocksr ssr redirect pf tunnel cipher ssl udp"
65
__author__ = "Qian Wenjie"
76
__email__ = "qianwenjie@gmail.com"
87
__url__ = "https://github.com/qwj/python-proxy"
98

9+
try:
10+
from setuptools_scm import get_version
11+
__version__ = get_version()
12+
except Exception:
13+
try:
14+
from pkg_resources import get_distribution
15+
__version__ = get_distribution('pproxy').version
16+
except Exception:
17+
__version__ = 'unknown'
18+
1019
__all__ = ['__version__', '__description__', '__url__']

pproxy/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from . import server
22

3-
Connection = server.ProxyURI.compile_relay
4-
DIRECT = server.ProxyURI.DIRECT
5-
Server = server.ProxyURI.compile
6-
Rule = server.ProxyURI.compile_rule
3+
Connection = server.proxies_by_uri
4+
Server = server.proxies_by_uri
5+
Rule = server.compile_rule
6+
DIRECT = server.DIRECT

0 commit comments

Comments
 (0)