Hey, so I had a need the other day for something like Twisted's built-in
"twist portforward" module (which takes a TCP port to listen on, and
when someone connects, it proxies that connection to a TCP port on some
other host). Except I wanted something more general: portfoward can
listen on any endpoint, but it can only connect to TCP targets (it takes
a host+port, rather than a generic endpoint description, and there's a
hard-coded reactor.connectTCP inside).

You can add new types of endpoints by installing packages that include
plugins that implement IStreamClientEndpointStringParserWithReactor. For
example, a plugin that knew how to speak SRV (which is TCP except you
have to do a DNS lookup for the port number first) would enable an
endpoint like "srv:example.org:smtp".

With a generic portforwarder, this would let you leave a twist/twistd
process running, and then point your (non-SRV-aware) applications at a
local TCP port, but they'd really connect to the right SRV-mediated
target service. Which might be a lot easier than rewriting the
application, or finding some shared-library tricks that let you modify
the way it does the connect() call.

It was pretty easy to write, and the code is in
https://github.com/warner/tx-endpointforward .

But before I publish it, I wanted to see if anyone had a better idea for
a name. Or whether something like this exists already and I just didn't
find it.

I've seen projects with names like "tx-foo" and "txfoo" and "txFOO", and
I wasn't sure what the current consensus is.

Also, the twist/twistd plugin name could be better, running "twistd
endpointforward" is kind of verbose. "epfwd"? "epforward"?

Or, should this just be a patch to the built-in portforward.py module?
Maybe enhance it to take either a single endpoint argument, or a pair of
HOST,PORT args (which it turns into an endpoint descriptor with

Any thoughts?

Twisted-Python mailing list

Reply via email to