Ticket #151: 151-accept-I2P-destinations.patch
File 151-accept-I2P-destinations.patch, 2.6 KB (added by , 13 years ago) |
---|
-
foolscap/referenceable.py
diff --git foolscap/referenceable.py foolscap/referenceable.py index 8af48d7..ca044e1 100644
def decode_location_hints(hints_s): 775 775 if mo: 776 776 hint = ( "ipv4", mo.group(1), int(mo.group(2)) ) 777 777 hints.append(hint) 778 elif hint_s.startswith("i2p:"): 779 (protocol, destination) = hints_s.split(":", 2) 780 hint = ( "ipv4", destination, 0) # I2P destinations have no port 781 hints.append(hint) 782 elif hint_s.endswith(".b32.i2p"): # For compatibility, to be removed in a future version 783 hint = ( "ipv4", hint_s, 0) 784 hints.append(hint) 778 785 else: 779 786 # some extension from the future that we will ignore 780 787 pass -
foolscap/test/test_reference.py
diff --git foolscap/test/test_reference.py foolscap/test/test_reference.py index db57e33..7f2b9cf 100644
class LocalReference(unittest.TestCase, ShouldFailMixin): 52 52 "you asked me to fail", 53 53 rref.callRemote, "fail") 54 54 55 class LocationTest(unittest.TestCase): 56 def test_encode_ipv4(self): 57 hint = ("ipv4", "127.0.0.1", 1234) 58 location = referenceable.encode_location_hint(hint) 59 self.failUnlessEqual(location, "127.0.0.1:1234") 60 61 def test_decode_ipv4(self): 62 hints_s1 = "127.0.0.1:1234" 63 hints1 = referenceable.decode_location_hints(hints_s1) 64 self.failUnlessEqual(hints1, [("ipv4", "127.0.0.1", 1234)]) 65 66 hints_s2 = "127.0.0.1:1234,192.168.0.1:0" 67 hints2 = referenceable.decode_location_hints(hints_s2) 68 self.failUnless(("ipv4", "127.0.0.1", 1234) in hints2, hints2) 69 self.failUnless(("ipv4", "192.168.0.1", 0) in hints2, hints2) 70 71 def test_decode_i2p(self): 72 hints_s = "i2p:ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p" 73 hints = referenceable.decode_location_hints(hints_s) 74 self.failUnlessEqual(hints, [("ipv4", 75 "ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p", 0)]) 76 77 def test_decode_i2p_deprecated(self): 78 hints_s = "ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p" 79 hints = referenceable.decode_location_hints(hints_s) 80 self.failUnlessEqual(hints, [("ipv4", 81 "ukeu3k5oycgaauneqgtnvselmt4yemvoilkln7jpvamvfx7dnkdq.b32.i2p", 0)]) 82 55 83 class TubID(unittest.TestCase): 56 84 def test_tubid_must_match(self): 57 85 good_tubid = "fu2bixsrymp34hwrnukv7hzxc2vrhqqa"