transit URL, transit hints are now unicode

This commit is contained in:
Brian Warner 2015-10-06 19:29:59 -07:00
parent 574d5f2314
commit 7f6410812c
4 changed files with 18 additions and 8 deletions

View File

@ -252,12 +252,12 @@ Some human-readable parameters are passed as strings: "str" in python2, "str"
(i.e. unicode) in python3:
* wormhole code
* transit URLs
* transit connection hints (e.g. "host:port")
And some are always unicode, in both python2 and python3:
* relay URL
* transit URLs
* transit connection hints (e.g. "host:port")
* application identifier
* derived-key "purpose" string: `w.derive_key(PURPOSE)`

View File

@ -84,7 +84,7 @@ def wait_for(skt, expected, description):
# publisher wants anonymity, their only hint's ADDR will end in .onion .
def parse_hint_tcp(hint):
assert isinstance(hint, str)
assert isinstance(hint, type(u""))
# return tuple or None for an unparseable hint
mo = re.search(r'^([a-zA-Z0-9]+):(.*)$', hint)
if not mo:
@ -269,6 +269,7 @@ class RecordPipe:
class Common:
def __init__(self, transit_relay):
if not isinstance(transit_relay, type(u"")): raise UsageError
self._transit_relay = transit_relay
self.winning = threading.Event()
self._negotiation_check_lock = threading.Lock()
@ -279,7 +280,7 @@ class Common:
def _start_server(self):
server = MyTCPServer(("", 0), None)
_, port = server.server_address
self.my_direct_hints = ["tcp:%s:%d" % (addr, port)
self.my_direct_hints = [u"tcp:%s:%d" % (addr, port)
for addr in ipaddrs.find_addresses()]
server.owner = self
server_thread = threading.Thread(target=server.serve_forever)
@ -293,9 +294,17 @@ class Common:
return [self._transit_relay]
def add_their_direct_hints(self, hints):
self._their_direct_hints = [str(h) for h in hints]
for h in hints:
if not isinstance(h, type(u"")):
raise TypeError("hint '%r' should be unicode, not %s"
% (h, type(h)))
self._their_direct_hints = list(hints)
def add_their_relay_hints(self, hints):
self._their_relay_hints = [str(h) for h in hints]
for h in hints:
if not isinstance(h, type(u"")):
raise TypeError("hint '%r' should be unicode, not %s"
% (h, type(h)))
self._their_relay_hints = list(hints)
def _send_this(self):
if self.is_sender:

View File

@ -2,4 +2,4 @@
# This is a relay I run on a personal server. If it gets too expensive to
# run, I'll shut it down.
RENDEZVOUS_RELAY = u"http://wormhole-relay.petmail.org:3000/wormhole-relay/"
TRANSIT_RELAY = "tcp:wormhole-transit-relay.petmail.org:3001"
TRANSIT_RELAY = u"tcp:wormhole-transit-relay.petmail.org:3001"

View File

@ -20,7 +20,8 @@ g = parser.add_argument_group("wormhole configuration options")
g.add_argument("--relay-url", default=public_relay.RENDEZVOUS_RELAY,
metavar="URL", help="rendezvous relay to use", type=type(u""))
g.add_argument("--transit-helper", default=public_relay.TRANSIT_RELAY,
metavar="tcp:HOST:PORT", help="transit relay to use")
metavar="tcp:HOST:PORT", help="transit relay to use",
type=type(u""))
g.add_argument("-c", "--code-length", type=int, default=2,
metavar="WORDS", help="length of code (in bytes/words)")
g.add_argument("-v", "--verify", action="store_true",