X-Git-Url: https://git.rkrishnan.org/?a=blobdiff_plain;f=src%2Fallmydata%2Futil%2Frrefutil.py;h=6481cabc9e3a82f9d8cde7df0b494a7a8c3ca2ee;hb=67dcedd8df386905a60757f91d70440da8328be4;hp=b991267f1ad1998e1f8994bd4f31b2a23807ee6d;hpb=8f0c417910ac5eb0a3b8cde1fa11d571755dbf06;p=tahoe-lafs%2Ftahoe-lafs.git diff --git a/src/allmydata/util/rrefutil.py b/src/allmydata/util/rrefutil.py index b991267f..6481cabc 100644 --- a/src/allmydata/util/rrefutil.py +++ b/src/allmydata/util/rrefutil.py @@ -27,16 +27,18 @@ def trap_deadref(f): return trap_and_discard(f, DeadReferenceError) -def hosts_for_furl(furl, ignore_localhost=True): - advertised = [] - for hint in SturdyRef(furl).locationHints: - assert not isinstance(hint, str), hint - if hint[0] == "ipv4": - host = hint[1] - if ignore_localhost and host == "127.0.0.1": - continue - advertised.append(host) - return advertised +def connection_hints_for_furl(furl): + hints = [] + for h in SturdyRef(furl).locationHints: + # Foolscap-0.2.5 and earlier used strings in .locationHints, 0.2.6 + # through 0.6.4 used tuples of ("ipv4",host,port), 0.6.5 through + # 0.8.0 used tuples of ("tcp",host,port), and >=0.9.0 uses strings + # again. Tolerate them all. + if isinstance(h, tuple): + hints.append(":".join([str(s) for s in h])) + else: + hints.append(h) + return hints def stringify_remote_address(rref): remote = rref.getPeer()