Example #1
0
def get_endpoint(location, connectionPlugins):
    hint = convert_legacy_hint(location)
    if ":" not in hint:
        raise InvalidHintError("no colon in hint")
    hint_type = hint.split(":", 1)[0]
    plugin = connectionPlugins.get(hint_type)
    if not plugin:
        raise InvalidHintError("no handler registered for hint")
    ep, host = plugin.hint_to_endpoint(hint, reactor)
    return ep, host
Example #2
0
 def testConvertLegacyHint(self):
     self.failUnlessEqual(convert_legacy_hint("127.0.0.1:9900"),
                          "tcp:127.0.0.1:9900")
     self.failUnlessEqual(convert_legacy_hint("tcp:127.0.0.1:9900"),
                          "tcp:127.0.0.1:9900")
     self.failUnlessEqual(convert_legacy_hint("other:127.0.0.1:9900"),
                          "other:127.0.0.1:9900")
     # this is unfortunate
     self.failUnlessEqual(convert_legacy_hint("unix:1"), "tcp:unix:1")
     # so new hints should do one of these:
     self.failUnlessEqual(convert_legacy_hint("tor:host:1234"),
                          "tor:host:1234") # multiple colons
     self.failUnlessEqual(convert_legacy_hint("unix:fd=1"),
                          "unix:fd=1") # equals signs, key=value -style