mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
contrib: parse I2P addresses in generate-seeds.py
This commit is contained in:
@@ -16,6 +16,7 @@ These files must consist of lines in the format
|
|||||||
<ip>:<port>
|
<ip>:<port>
|
||||||
[<ipv6>]:<port>
|
[<ipv6>]:<port>
|
||||||
<onion>.onion:<port>
|
<onion>.onion:<port>
|
||||||
|
<i2p>.b32.i2p:<port>
|
||||||
|
|
||||||
The output will be two data structures with the peers in binary format:
|
The output will be two data structures with the peers in binary format:
|
||||||
|
|
||||||
@@ -52,6 +53,12 @@ def name_to_bip155(addr):
|
|||||||
return (BIP155Network.TORV3, vchAddr[:32])
|
return (BIP155Network.TORV3, vchAddr[:32])
|
||||||
else:
|
else:
|
||||||
raise ValueError('Invalid onion %s' % vchAddr)
|
raise ValueError('Invalid onion %s' % vchAddr)
|
||||||
|
elif addr.endswith('.b32.i2p'):
|
||||||
|
vchAddr = b32decode(addr[0:-8] + '====', True)
|
||||||
|
if len(vchAddr) == 32:
|
||||||
|
return (BIP155Network.I2P, vchAddr)
|
||||||
|
else:
|
||||||
|
raise ValueError(f'Invalid I2P {vchAddr}')
|
||||||
elif '.' in addr: # IPv4
|
elif '.' in addr: # IPv4
|
||||||
return (BIP155Network.IPV4, bytes((int(x) for x in addr.split('.'))))
|
return (BIP155Network.IPV4, bytes((int(x) for x in addr.split('.'))))
|
||||||
elif ':' in addr: # IPv6
|
elif ':' in addr: # IPv6
|
||||||
|
|||||||
Reference in New Issue
Block a user