mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 23:07:59 +01:00
contrib: parse I2P addresses in generate-seeds.py
This commit is contained in:
parent
d22e7ee933
commit
ea269c7ef1
1 changed files with 7 additions and 0 deletions
|
@ -16,6 +16,7 @@ These files must consist of lines in the format
|
|||
<ip>:<port>
|
||||
[<ipv6>]:<port>
|
||||
<onion>.onion:<port>
|
||||
<i2p>.b32.i2p:<port>
|
||||
|
||||
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])
|
||||
else:
|
||||
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
|
||||
return (BIP155Network.IPV4, bytes((int(x) for x in addr.split('.'))))
|
||||
elif ':' in addr: # IPv6
|
||||
|
|
Loading…
Add table
Reference in a new issue