[Twisted-Python] Status of current proxy support (of various kinds)

Peter Le Bek peter at hyperplex.net
Mon Aug 8 22:10:50 EDT 2011

Myself and another are working on adding SOCKS client support to Twisted for 
use in Tor related projects. I'm also convinced there's an abstraction that would 
make it easier to implement proxy clients (or any transparent data/endpoint 
modifying protocol) in Twisted. I agree that it's difficult to generalise, but there's a 
class of protocol that does one or more of the following, transparently, and little 

- append data, before switching to application protocol (SSL handshake, 
  SOCKS connect/bind)
- prepend data, after losing connection on application protocol (SSL shutdown)
- modify application data (SSL "recordification", encryption)
- modify the endpoint (any proxy)

Endpoints can do all these things - SSL4ClientEndpoint, for example, does the first 
three - but does it make sense to use Endpoints for this purpose? 

Endpoints aren't stackable, so no good if I want to run a SOCKS client over SSL. 
Also, with a proxied connection you have two Endpoints, one to the proxy server 
and one 'virtual Endpoint' to wherever. The Endpoints API doesn't accommodate 

Would it make sense to have Endpoint wrappers for this purpose? A sort of 
middleware (hate that word) to intercept transport events (including transport 
formation, i.e. Endpoint.connect()).

I'm looking forward to being proven wrong on this as it will make my SOCKS work 
easier, or else if this turns out to be interesting then I have more ideas on how it 
should be implemented.


More information about the Twisted-Python mailing list