Skip to main content

High-performance async proxy server with uvloop, connection pooling, and multi-process support.

Project description

made-with-python PyPI-version GitHub

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:

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

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

http://

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

ssh://

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.

Author

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

pproxy2-2.3.2.tar.gz (65.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pproxy2-2.3.2-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file pproxy2-2.3.2.tar.gz.

File metadata

  • Download URL: pproxy2-2.3.2.tar.gz
  • Upload date:
  • Size: 65.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pproxy2-2.3.2.tar.gz
Algorithm Hash digest
SHA256 6a4ac1892a47b681706390ca3dd30db42f2708bbe892b5df648a20cbe959baab
MD5 ce2cb006390b85199f83515953a8c063
BLAKE2b-256 2bc7c964575679563eccf13bafd88af8e2e8df3b001cc8950de49e437d617a14

See more details on using hashes here.

File details

Details for the file pproxy2-2.3.2-py3-none-any.whl.

File metadata

  • Download URL: pproxy2-2.3.2-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pproxy2-2.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3c4fc0af4822220a06e9e8f85d4f31c1e67ff8599da7a2404fff689a28db68
MD5 f7002ba816eebbf6e4461388c7bc1cc2
BLAKE2b-256 6cea3843b3f30c78866d6e0a5fef7005fc57c3f22c6ab921c636700cbf2d253a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page