[Twisted-Python] Endpoint composition syntax

Tristan Seligmann mithrandi at mithrandi.net
Tue Sep 6 12:55:03 MDT 2016


I'm kicking off this discussion on the mailing list as I don't have
anything well-formed enough to take to the bug tracker, and I am hoping to
get some more engagement on the matter.

Currently there is no way to explicitly compose Twisted endpoints, but
several endpoint implementations have arisen that explicitly wrap another
endpoint, and so have needed a way to do this. So far, this has been
implementing by passing in an endpoint description, and then calling
serverFromString/clientFromString internally in the endpoint to construct
the wrapped endpoint. I've seen two different ways of encoding the "inner"
endpoint:

1. Backslash escaping; for example:

tls:awesome.site.example.com:443:endpoint=tcp\:7.6.5.4\:443

This has the advantage that it is endlessly nestable, for example:

tls:internal.hostname.whatever:42:endpoint=tls\:awesome.site.example.com
\:443\:endpoint=tcp\\\:7.6.5.4\\\:443

It has the disadvantage that it is a bit tricky to read and write.

2. Splitting keyword and positional arguments; for example:

txsni:/srv/certs:tcp:443

This has the advantage that it is easier to read and write, but the
disadvantage that it isn't nestable. It also starts to break down when you
have a lot of parameters, as the positional syntax becomes much harder to
read.

Neither of these solutions is entirely satisfactory; I initially followed
approach 2 for txacme, but now that I need to add more parameters to the
le:/lets: endpoints, it is starting to break down.

Cory suggested a third possibility; an explicit syntax for composing
endpoints. In this model, the endpoint string parsing machinery would
construct the different endpoints, and compose them together (presumably
the API of the parsers would need to be extended a bit for this). For
example:

tls:awesome.site.example.com:443->tcp:7.6.5.4:443

A less whimsical syntax than "->" might be better; for example, semicolons,
or something like that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20160906/d3de1850/attachment.html>


More information about the Twisted-Python mailing list