PROXY protocol library with asyncio server implementation
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install proxy-protocolproxy-protocol
PROXY protocol library with asyncio server implementation.
Specification
API Reference
Docker Image
Table of Contents
Install and Usage
$ pip install proxy-protocol
Integration with an asyncio.start_server based server is intended to be
extremely simple. Here is an example, which will detect PROXY protocol v1 or
v2.
from proxyprotocol import ProxyProtocol
from proxyprotocol.detect import ProxyProtocolDetect
from proxyprotocol.reader import ProxyProtocolReader
from proxyprotocol.sock import SocketInfo
async def run(host: str, port: int) -> None:
pp_detect = ProxyProtocolDetect()
callback = ProxyProtocolReader(pp_detect).get_callback(on_connection)
server = await asyncio.start_server(callback, host, port)
async with server:
await server.serve_forever()
async def on_connection(reader: StreamReader, writer: StreamWriter,
info: SocketInfo) -> None:
print(info.family, info.peername)
# ... continue using connection