Expand description
A local rotating proxy server: accepts client connections and relays each through a pool
of checked proxies, retrying on a different proxy when one fails. server.py.
Behind the server feature — pure library users mostly do not want a listening socket.
A forward proxy is mostly byte-splicing (copy_bidirectional) plus a CONNECT/negotiate
handshake, so this is built on raw tokio rather than hyper: hyper is structured around
parsed HTTP messages and is awkward for the CONNECT tunnel upgrade this needs.
The pool avoids server.py’s heapq.heappush((avg_resp_time, proxy)), which raises
TypeError on tied f64 (Python compares the Proxy objects, which define no __lt__).
Selection here uses f64::total_cmp, so ties are ordered deterministically, never fatal.
Imports are served by one dedicated task feeding a Notify, not a per-waiter mutex over
the receiver (design critique #22).
Structs§
- Pool
- A pool of checked proxies, refilled from a [
ProxyStream] by a background importer. - Pool
Config - Tuning for proxy eviction and selection (
server.py:ProxyPool). - Pool
Snapshot - A cheap, allocation-light snapshot of the pool’s live state (F1). One producer, shared with the (deferred) F4 dashboard.
- Server
Handle - A running server. Dropping the handle (or calling
ServerHandle::shutdown) stops it.
Enums§
- Client
Key - The identity a
Strategy::Stickysession is keyed on. - Strategy
- How the pool picks an upstream for each client request.
Functions§
- serve
- Start the local proxy server on
addr, relaying throughpool. Binds immediately and returns the handle (solocal_addrworks at once); the accept loop runs in a background task and, whenmin_queue > 0, does not start serving until the pool holds that many proxies (B13).backlogis the TCP listen backlog.auth(user:pass) gates clients: whenSome, a client without a matchingProxy-Authorization: Basic <b64>gets407(B9).