High-performance async proxy server with uvloop, connection pooling, and multi-process support.
Project description
High-performance HTTP/Socks4/Socks5/Shadowsocks/SSH async proxy server with uvloop, connection pooling, and multi-process support.
pproxy2 is a performance-optimized fork of the original pproxy by Qian Wenjie.
Credits
This project is based on the excellent work of:
Original Author: Qian Wenjie (qianwenjie@gmail.com)
Original Project: https://github.com/qwj/python-proxy
License: MIT
We extend our gratitude to Qian Wenjie for creating the original pproxy project.
What’s New in pproxy2
Performance optimizations that make pproxy2 significantly faster:
Feature |
Performance Gain |
Description |
|---|---|---|
pycryptodome (required) |
60-288x |
Fast C-based encryption |
uvloop (auto-enabled) |
2-3x |
High-performance event loop |
Connection pooling |
60x |
Reuse TCP connections |
TCP_NODELAY |
Lower latency |
Disable Nagle’s algorithm |
Multi-process workers |
Scale to cores |
--workers N option |
Batched I/O |
Reduced syscalls |
Optimized drain() calls |
QuickStart
$ pip3 install pproxy2
$ pproxy2
Using uvloop (faster event loop)
Serving on :8080 by http,socks4,socks5
With encryption (Shadowsocks-compatible):
$ pproxy2 -l ss://aes-256-gcm:password@:8080
Using uvloop (faster event loop)
Serving on :8080 by ss (aes-256-gcm)
High-performance mode with multiple workers:
$ pproxy2 -l http+socks5://:8080 --workers 4
Worker 1 started (PID: 12345)
Worker 2 started (PID: 12346)
Worker 3 started (PID: 12347)
Master process (PID: 12344) with 3 workers
Using uvloop (faster event loop)
Serving on :8080 by http,socks5
Installation
$ pip3 install pproxy2
This will automatically install:
pycryptodome - Fast encryption (required)
uvloop - Fast event loop (Linux/macOS only)
Optional dependencies:
$ pip3 install pproxy2[sshtunnel] # SSH tunnel support
$ pip3 install pproxy2[quic] # QUIC/HTTP3 support
$ pip3 install pproxy2[daemon] # Daemon mode support
New Command-Line Options
--workers N Number of worker processes (Linux only, auto-enables SO_REUSEPORT)
--reuse Enable SO_REUSEPORT for port sharing between processes
Recommended Commands
Basic proxy server:
$ pproxy2 -l http+socks5://:8080 -vv
With authentication:
$ pproxy2 -l http+socks5://:8080#user:password
Encrypted (Shadowsocks):
$ pproxy2 -l ss://aes-256-gcm:password@:8080
High-load production:
$ pproxy2 -l ss://aes-256-gcm:password@:8080 --workers 4 --daemon
Proxy chain (forward to upstream):
$ pproxy2 -l http+socks5://:8080 -r socks5://upstream:1080
Features
All original pproxy features are preserved:
Lightweight single-thread asynchronous IO (now with uvloop)
Proxy client/server for TCP/UDP
Schedule (load balance) among remote servers
Incoming traffic auto-detect
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
Shadowsocks OTA (One-Time-Auth), SSR plugins
Statistics by bandwidth and traffic
PAC support for javascript configuration
Iptables/Pf NAT redirect packet tunnel
System proxy auto-setting support
Client/Server API provided
Plus new performance features:
uvloop - 2-3x faster event loop (auto-enabled on Linux/macOS)
Connection pooling - 60x faster for repeated connections
Multi-process workers - Scale across CPU cores
TCP_NODELAY - Lower latency connections
Optimized encryption - pycryptodome required (60-288x faster)
Supported Protocols
Name |
TCP server |
TCP client |
UDP server |
UDP client |
scheme |
|---|---|---|---|---|---|
http (connect) |
Y |
Y |
|||
socks4 |
Y |
Y |
socks4:// |
||
socks5 |
Y |
Y |
Y |
Y |
socks5:// |
shadowsocks |
Y |
Y |
Y |
Y |
ss:// |
shadowsocks aead |
Y |
Y |
ss:// |
||
shadowsocksR |
Y |
Y |
ssr:// |
||
trojan |
Y |
Y |
trojan:// |
||
ssh tunnel |
Y |
||||
http v2 |
Y |
Y |
h2:// |
||
http v3 (quic) |
Y |
Y |
h3:// |
||
websocket |
Y |
Y |
ws:// |
Supported Ciphers
AEAD ciphers (recommended):
aes-256-gcm, aes-192-gcm, aes-128-gcm
chacha20-ietf-poly1305
Stream ciphers:
chacha20, chacha20-ietf, salsa20
aes-256-cfb, aes-192-cfb, aes-128-cfb
aes-256-ctr, aes-256-ofb
rc4-md5, bf-cfb, cast5-cfb, des-cfb
Performance Benchmarks
Encryption performance (pycryptodome vs pure Python):
Cipher |
Speedup |
|---|---|
AES-256-GCM |
288x faster |
ChaCha20-Poly1305 |
195x faster |
AES-256-CFB |
76x faster |
ChaCha20 |
60x faster |
Connection pooling performance:
Scenario |
Speedup |
|---|---|
Repeated connections |
60x faster |
Sequential HTTP reuse |
150,000x |
API Usage
TCP Client:
import asyncio
import pproxy
async def main():
conn = pproxy.Connection('ss://aes-256-gcm:password@server:8080')
reader, writer = await conn.tcp_connect('google.com', 443)
writer.write(b'GET / HTTP/1.1\r\nHost: google.com\r\n\r\n')
data = await reader.read(1024)
print(data)
asyncio.run(main())
Server API:
import asyncio
import pproxy
async def main():
server = pproxy.Server('ss://aes-256-gcm:password@:8080')
handler = await server.start_server({'verbose': print})
await handler.wait_closed()
asyncio.run(main())
Migration from pproxy
pproxy2 is fully backward compatible with pproxy. Simply replace:
$ pip3 uninstall pproxy
$ pip3 install pproxy2
The pproxy command still works for compatibility. Use pproxy2 for the new optimized version.
License
MIT License - Same as the original pproxy project.
Links
pproxy2: https://github.com/iqzer0/pproxy2
Original pproxy: https://github.com/qwj/python-proxy
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pproxy2-2.3.0.tar.gz.
File metadata
- Download URL: pproxy2-2.3.0.tar.gz
- Upload date:
- Size: 49.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148a61deca51ab28974fc941c60fbfde16f24c6c8be6c06fcd371a655867550d
|
|
| MD5 |
9ffff9cd81326cd99f08e050cdb1edd0
|
|
| BLAKE2b-256 |
c4da1b0ff1b0c06883ababe561afac214ce2653f3532c9799eda92fbb6bdf5f8
|
File details
Details for the file pproxy2-2.3.0-py3-none-any.whl.
File metadata
- Download URL: pproxy2-2.3.0-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b19aad416fa5e6b0dd70f8dd49721e0069b8b86fe966bdd58a9d99ea339de17f
|
|
| MD5 |
5766a070a872c1c5a442ca8abff823a4
|
|
| BLAKE2b-256 |
ab67083a5d4d9e9750eaef296b50739194e8b8743749324e595d2759fe98e47d
|