commit 40e96dde1662004a06ae7d2f759dac518c32fcf9 Author: David Fifield david@bamsoftware.com Date: Fri Sep 20 22:44:35 2013 -0700
Comments and variable names. --- facilitator/facilitator | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/facilitator/facilitator b/facilitator/facilitator index 57f39bf..29714e3 100755 --- a/facilitator/facilitator +++ b/facilitator/facilitator @@ -77,20 +77,23 @@ again. Listen on 127.0.0.1 and port PORT (by default %(port)d). "log": DEFAULT_LOG_FILENAME, }
-def parse_transport_chain(transport_chain): - """Given a combined transport name in 'transport', return a tuple that - contains the transport chain. e.g. if 'transport' == 'obfs3|websocket' we - return (obfs3, websocket)""" - assert(transport_chain) +def parse_transport_chain(spec): + """Parse a transport chain string and return a tuple of individual + transports, each of which is a string. + >>> parse_transport_chain("obfs3|websocket") + ('obfs3', 'websocket') + """ + assert(spec) # XXX We explicitly cast to tuple so that the return value can be # used as a dictionary key. Transport chains are not supposed to # be manipulated so it should be cool. - return tuple(transport_chain.split("|")) + return tuple(spec.split("|"))
def get_outermost_transport(transports): - """Given a combined transport name in 'transport', return the name of the - outermost transport. e.g. if 'transport' is (obfs3, websocket) this function - returns 'websocket'""" + """Given a transport chain tuple, return the last element. + >>> get_outermost_transport(("obfs3", "websocket")) + 'websocket' + """ assert(transports) return transports[-1]
@@ -112,7 +115,6 @@ def log(msg):
class TCPReg(object): def __init__(self, host, port, transports): - """transports: transport chain list. e.g. (obfs3, websocket)""" self.host = host self.port = port self.transports = transports @@ -121,7 +123,7 @@ class TCPReg(object): self.relay = self._get_matching_relay()
def _get_matching_relay(self): - """Return a matching relay addrspec for this registration. Raise + """Return a matching relay addr_spec for this registration. Raise UnknownTransport if a relay with a matching transport chain could not be found.""" if self.transports not in options.relays:
tor-commits@lists.torproject.org