Skip to content

pull #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Mar 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d79de55
Check if peername is none
Nov 1, 2020
c851838
Merge pull request #93 from Jonney/patch-1
qwj Nov 1, 2020
73d7fbd
build
qwj Nov 9, 2020
ac87924
fix socks5 issue
qwj Nov 10, 2020
79584ce
trojan protocol
qwj Nov 10, 2020
4750140
fix bug
qwj Nov 10, 2020
21cbad4
add trojan readme
qwj Nov 10, 2020
aa963be
add trojan readme
qwj Nov 10, 2020
436e0c1
udp_pack udp_unpack
qwj Nov 10, 2020
0959863
add user stat
qwj Nov 10, 2020
dd33604
fix pac bug
qwj Nov 10, 2020
78856a3
udp associate
qwj Nov 11, 2020
ba9c155
python3.9 compatibility
qwj Nov 12, 2020
29576be
parse hostname in url without port issue
keenser Dec 3, 2020
c61f74c
Merge pull request #98 from keenser/rserver-url-default-port
qwj Dec 3, 2020
c8704c2
ipv6 hostname
qwj Dec 3, 2020
8d7dc7c
Include LICENSE and tests in PyPI sdist and wheel
yan12125 Dec 5, 2020
b29c29e
Merge pull request #99 from yan12125/pypi-license-tests
qwj Dec 5, 2020
95d81cd
add tag version
qwj Dec 5, 2020
77eaf59
2.4.9
qwj Dec 5, 2020
7d6e43f
fix version
qwj Dec 5, 2020
289b6ea
ssh jump
qwj Dec 22, 2020
629b430
clear code
qwj Dec 22, 2020
d2eb695
Use Host header for host name, transparent proxy compatibility
ValdikSS Jan 2, 2021
a69cd95
Merge pull request #106 from ValdikSS/master
qwj Jan 3, 2021
1e94ecd
netloc parse
qwj Jan 3, 2021
9c72abf
netloc parse
qwj Jan 3, 2021
290a40b
netloc parse
qwj Jan 3, 2021
2cd2dec
netloc parse
qwj Jan 3, 2021
19622a0
vpn example
qwj Feb 15, 2021
cb2669b
quic:// protocol
qwj Feb 16, 2021
6c7f0f8
fix
qwj Feb 16, 2021
93a0d05
fix bug
qwj Feb 16, 2021
46d78c8
quic protocol
qwj Feb 16, 2021
09fb14a
quic backward
qwj Feb 17, 2021
b43c5ac
keepalive
qwj Feb 17, 2021
0c02d15
ssh tunnel
qwj Feb 18, 2021
dc5a0ee
quic example
qwj Feb 18, 2021
a733ac4
quic udp
qwj Feb 18, 2021
968f085
del streamreader patch
qwj Feb 19, 2021
ea9b4fd
fix
qwj Feb 19, 2021
ef163aa
fix
qwj Feb 19, 2021
2447130
python3.6 fix
qwj Feb 19, 2021
ee1edff
h2 proto
qwj Feb 20, 2021
1912b35
h2 proto
qwj Feb 20, 2021
5326c17
h2 proto
qwj Feb 20, 2021
7f9a523
h3 proto
qwj Feb 20, 2021
401186a
h3 proto
qwj Feb 21, 2021
7562c10
quic config
qwj Feb 21, 2021
9fbfbd1
fix http api
qwj Feb 23, 2021
c3a78e6
QUIC description
qwj Feb 24, 2021
cc9dedf
QUIC description
qwj Feb 24, 2021
46128d7
QUIC description
qwj Feb 24, 2021
9f0ce6d
quic param
qwj Feb 24, 2021
542cc8a
quic config
qwj Feb 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
graft tests
102 changes: 93 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
python-proxy
============

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

.. |made-with-python| image:: https://img.shields.io/badge/Made%20with-Python-1f425f.svg
:target: https://www.python.org/
Expand All @@ -11,8 +11,12 @@ python-proxy
:target: https://pypi.python.org/pypi/pproxy/
.. |Downloads| image:: https://pepy.tech/badge/pproxy
:target: https://pepy.tech/project/pproxy
.. |Downloads-month| image:: https://pepy.tech/badge/pproxy/month
:target: https://pepy.tech/project/pproxy
.. |Downloads-week| image:: https://pepy.tech/badge/pproxy/week
:target: https://pepy.tech/project/pproxy

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

QuickStart
----------
Expand Down Expand Up @@ -73,8 +77,9 @@ Features
- Proxy client/server for TCP/UDP.
- Schedule (load balance) among remote servers.
- Incoming traffic auto-detect.
- Tunnel/relay/backward-relay support.
- Tunnel/jump/backward-jump support.
- Unix domain socket support.
- HTTP v2, HTTP v3 (QUIC)
- User/password authentication support.
- Filter/block hostname by regex patterns.
- SSL/TLS client/server support.
Expand All @@ -98,6 +103,10 @@ Protocols
| http | | ✔ | | | httponly:// |
| (get,post,etc) | | | | | (as client) |
+-------------------+------------+------------+------------+------------+--------------+
| http v2 (connect) | ✔ | ✔ | | | h2:// |
+-------------------+------------+------------+------------+------------+--------------+
| http v3 (connect) | ✔ by UDP | ✔ by UDP | | | h3:// |
+-------------------+------------+------------+------------+------------+--------------+
| https | ✔ | ✔ | | | http+ssl:// |
+-------------------+------------+------------+------------+------------+--------------+
| socks4 | ✔ | ✔ | | | socks4:// |
Expand All @@ -112,8 +121,12 @@ Protocols
+-------------------+------------+------------+------------+------------+--------------+
| shadowsocksR | ✔ | ✔ | | | ssr:// |
+-------------------+------------+------------+------------+------------+--------------+
| trojan | ✔ | ✔ | | | trojan:// |
+-------------------+------------+------------+------------+------------+--------------+
| ssh tunnel | | ✔ | | | ssh:// |
+-------------------+------------+------------+------------+------------+--------------+
| quic | ✔ by UDP | ✔ by UDP | ✔ | ✔ | http+quic:// |
+-------------------+------------+------------+------------+------------+--------------+
| iptables nat | ✔ | | | | redir:// |
+-------------------+------------+------------+------------+------------+--------------+
| pfctl nat (macos) | ✔ | | | | pf:// |
Expand Down Expand Up @@ -230,6 +243,8 @@ URI Syntax
+----------+-----------------------------+
| ssr | shadowsocksr (SSR) protocol |
+----------+-----------------------------+
| trojan | trojan_ protocol |
+----------+-----------------------------+
| ssh | ssh client tunnel |
+----------+-----------------------------+
| redir | redirect (iptables nat) |
Expand All @@ -249,6 +264,8 @@ URI Syntax
| direct | direct connection |
+----------+-----------------------------+

.. _trojan: https://trojan-gfw.github.io/trojan/protocol

- "http://" accepts GET/POST/CONNECT as server, sends CONNECT as client. "httponly://" sends "GET/POST" as client, works only on http traffic.

- Valid schemes: http://, http+socks4+socks5://, http+ssl://, ss+secure://, http+socks5+ss://
Expand Down Expand Up @@ -360,7 +377,7 @@ URI Syntax

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

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.
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.

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

Expand Down Expand Up @@ -553,9 +570,7 @@ Examples

Make sure **pproxy** runs in root mode (sudo), otherwise it cannot redirect pf packet.

- Relay tunnel

Relay tunnel example:
- Multiple jumps example

.. code:: rst

Expand Down Expand Up @@ -653,6 +668,12 @@ Examples

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.

.. code:: rst

$ pproxy -l http+in://jumpserver__http://client_ip:8081

It is a complicated example. Server connects to client_ip:8081 by jump http://jumpserver. The backward proxy works through jumps.

- SSH client tunnel

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.
Expand All @@ -669,10 +690,73 @@ Examples

SSH connection known_hosts feature is disabled by default.

- SSH jump

SSH jump is supported by using "__" concatenation

.. code:: rst

$ pproxy -r ssh://server1__ssh://server2__ssh://server3

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.

- SSH remote forward

.. code:: rst

$ pproxy -l ssh://server__tunnel://0.0.0.0:1234 -r tunnel://127.0.0.1:1234

TCP :1234 on remote server is forwarded to 127.0.0.1:1234 on local server

.. code:: rst

$ pproxy -l ssh://server1__ssh://server2__ss://0.0.0.0:1234 -r ss://server3:1234

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.

- Trojan protocol example

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:

.. code:: rst

$ pproxy --ssl ssl.crt,ssl.key -l trojan+tunnel{localhost:80}+ssl://:443#yourpassword -vv

If trojan password doesn't match, the tunnal{localhost:80} will be switched to. It looks exactly the same as a common HTTPS website.

- QUIC protocol example

QUIC is a UDP stream protocol used in HTTP/3. Library **aioquic** is required if you want to proxy via QUIC.
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".

.. code:: rst

$ pip3 install aioquic
$ pproxy --ssl ssl.crt,ssl.key -l quic+http://:1234

On the client:

$ pproxy -r quic+http://server:1234

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.

- VPN Server Example

You can run VPN server simply by installing pvpn (python vpn), a lightweight VPN server with pproxy tunnel feature.

.. code:: rst

$ pip3 install pvpn
Successfully installed pvpn-0.2.1
$ pvpn -wg 9999 -r http://remote_server:remote_port
Serving on UDP :500 :4500...
Serving on UDP :9000 (WIREGUARD)...
TCP xx.xx.xx.xx:xx -> HTTP xx.xx.xx.xx:xx -> xx.xx.xx.xx:xx


Projects
--------

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

11 changes: 10 additions & 1 deletion pproxy/__doc__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
__title__ = "pproxy"
__version__ = "2.3.7"
__license__ = "MIT"
__description__ = "Proxy server that can tunnel among remote servers by regex rules."
__keywords__ = "proxy socks http shadowsocks shadowsocksr ssr redirect pf tunnel cipher ssl udp"
__author__ = "Qian Wenjie"
__email__ = "qianwenjie@gmail.com"
__url__ = "https://github.com/qwj/python-proxy"

try:
from setuptools_scm import get_version
__version__ = get_version()
except Exception:
try:
from pkg_resources import get_distribution
__version__ = get_distribution('pproxy').version
except Exception:
__version__ = 'unknown'

__all__ = ['__version__', '__description__', '__url__']
8 changes: 4 additions & 4 deletions pproxy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from . import server

Connection = server.ProxyURI.compile_relay
DIRECT = server.ProxyURI.DIRECT
Server = server.ProxyURI.compile
Rule = server.ProxyURI.compile_rule
Connection = server.proxies_by_uri
Server = server.proxies_by_uri
Rule = server.compile_rule
DIRECT = server.DIRECT
Loading