transit URL, transit hints are now unicode
This commit is contained in:
parent
574d5f2314
commit
7f6410812c
|
@ -252,12 +252,12 @@ Some human-readable parameters are passed as strings: "str" in python2, "str"
|
||||||
(i.e. unicode) in python3:
|
(i.e. unicode) in python3:
|
||||||
|
|
||||||
* wormhole code
|
* wormhole code
|
||||||
* transit URLs
|
|
||||||
* transit connection hints (e.g. "host:port")
|
|
||||||
|
|
||||||
And some are always unicode, in both python2 and python3:
|
And some are always unicode, in both python2 and python3:
|
||||||
|
|
||||||
* relay URL
|
* relay URL
|
||||||
|
* transit URLs
|
||||||
|
* transit connection hints (e.g. "host:port")
|
||||||
* application identifier
|
* application identifier
|
||||||
* derived-key "purpose" string: `w.derive_key(PURPOSE)`
|
* derived-key "purpose" string: `w.derive_key(PURPOSE)`
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ def wait_for(skt, expected, description):
|
||||||
# publisher wants anonymity, their only hint's ADDR will end in .onion .
|
# publisher wants anonymity, their only hint's ADDR will end in .onion .
|
||||||
|
|
||||||
def parse_hint_tcp(hint):
|
def parse_hint_tcp(hint):
|
||||||
assert isinstance(hint, str)
|
assert isinstance(hint, type(u""))
|
||||||
# return tuple or None for an unparseable hint
|
# return tuple or None for an unparseable hint
|
||||||
mo = re.search(r'^([a-zA-Z0-9]+):(.*)$', hint)
|
mo = re.search(r'^([a-zA-Z0-9]+):(.*)$', hint)
|
||||||
if not mo:
|
if not mo:
|
||||||
|
@ -269,6 +269,7 @@ class RecordPipe:
|
||||||
|
|
||||||
class Common:
|
class Common:
|
||||||
def __init__(self, transit_relay):
|
def __init__(self, transit_relay):
|
||||||
|
if not isinstance(transit_relay, type(u"")): raise UsageError
|
||||||
self._transit_relay = transit_relay
|
self._transit_relay = transit_relay
|
||||||
self.winning = threading.Event()
|
self.winning = threading.Event()
|
||||||
self._negotiation_check_lock = threading.Lock()
|
self._negotiation_check_lock = threading.Lock()
|
||||||
|
@ -279,7 +280,7 @@ class Common:
|
||||||
def _start_server(self):
|
def _start_server(self):
|
||||||
server = MyTCPServer(("", 0), None)
|
server = MyTCPServer(("", 0), None)
|
||||||
_, port = server.server_address
|
_, 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()]
|
for addr in ipaddrs.find_addresses()]
|
||||||
server.owner = self
|
server.owner = self
|
||||||
server_thread = threading.Thread(target=server.serve_forever)
|
server_thread = threading.Thread(target=server.serve_forever)
|
||||||
|
@ -293,9 +294,17 @@ class Common:
|
||||||
return [self._transit_relay]
|
return [self._transit_relay]
|
||||||
|
|
||||||
def add_their_direct_hints(self, hints):
|
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):
|
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):
|
def _send_this(self):
|
||||||
if self.is_sender:
|
if self.is_sender:
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
# This is a relay I run on a personal server. If it gets too expensive to
|
# This is a relay I run on a personal server. If it gets too expensive to
|
||||||
# run, I'll shut it down.
|
# run, I'll shut it down.
|
||||||
RENDEZVOUS_RELAY = u"http://wormhole-relay.petmail.org:3000/wormhole-relay/"
|
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"
|
||||||
|
|
|
@ -20,7 +20,8 @@ g = parser.add_argument_group("wormhole configuration options")
|
||||||
g.add_argument("--relay-url", default=public_relay.RENDEZVOUS_RELAY,
|
g.add_argument("--relay-url", default=public_relay.RENDEZVOUS_RELAY,
|
||||||
metavar="URL", help="rendezvous relay to use", type=type(u""))
|
metavar="URL", help="rendezvous relay to use", type=type(u""))
|
||||||
g.add_argument("--transit-helper", default=public_relay.TRANSIT_RELAY,
|
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,
|
g.add_argument("-c", "--code-length", type=int, default=2,
|
||||||
metavar="WORDS", help="length of code (in bytes/words)")
|
metavar="WORDS", help="length of code (in bytes/words)")
|
||||||
g.add_argument("-v", "--verify", action="store_true",
|
g.add_argument("-v", "--verify", action="store_true",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user