37
37
class BIP155Network (Enum ):
38
38
IPV4 = 1
39
39
IPV6 = 2
40
- TORV2 = 3
40
+ TORV2 = 3 # no longer supported
41
41
TORV3 = 4
42
42
I2P = 5
43
43
CJDNS = 6
@@ -46,11 +46,11 @@ def name_to_bip155(addr):
46
46
'''Convert address string to BIP155 (networkID, addr) tuple.'''
47
47
if addr .endswith ('.onion' ):
48
48
vchAddr = b32decode (addr [0 :- 6 ], True )
49
- if len (vchAddr ) == 10 :
50
- return (BIP155Network .TORV2 , vchAddr )
51
- elif len (vchAddr ) == 35 :
52
- assert (vchAddr [34 ] == 3 )
49
+ if len (vchAddr ) == 35 :
50
+ assert vchAddr [34 ] == 3
53
51
return (BIP155Network .TORV3 , vchAddr [:32 ])
52
+ elif len (vchAddr ) == 10 :
53
+ return (BIP155Network .TORV2 , vchAddr )
54
54
else :
55
55
raise ValueError ('Invalid onion %s' % vchAddr )
56
56
elif addr .endswith ('.b32.i2p' ):
@@ -100,7 +100,10 @@ def parse_spec(s):
100
100
101
101
host = name_to_bip155 (host )
102
102
103
- return host + (port , )
103
+ if host [0 ] == BIP155Network .TORV2 :
104
+ return None # TORV2 is no longer supported, so we ignore it
105
+ else :
106
+ return host + (port , )
104
107
105
108
def ser_compact_size (l ):
106
109
r = b""
@@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
136
139
continue
137
140
138
141
spec = parse_spec (line )
142
+ if spec is None : # ignore this entry (e.g. no longer supported addresses like TORV2)
143
+ continue
139
144
blob = bip155_serialize (spec )
140
145
hoststr = ',' .join (('0x%02x' % b ) for b in blob )
141
146
g .write (f' { hoststr } ,\n ' )
0 commit comments