Skip to content

Commit 07ededa

Browse files
committed
Merge bitcoin/bitcoin#22050: p2p: remove tor v2 support
5d82a57 contrib: remove torv2 seed nodes (Jon Atack) 5f7e086 contrib: update generate-seeds.py to ignore torv2 addresses (Jon Atack) 8be56f0 p2p, refactor: extract OnionToString() from CNetAddr::ToStringIp() (Jon Atack) 5f9d3c0 p2p: remove torv2 from CNetAddr::ToStringIP() (Jon Atack) 3d39042 p2p: remove torv2 in SetIP() and ADDR_TORV2_SIZE constant (Jon Atack) cff5ec4 p2p: remove pre-addrv2 onions from SerializeV1Array() (Jon Atack) 4192a74 p2p: ignore torv2-in-ipv6 addresses in SetLegacyIPv6() (Jon Atack) 1d631e9 p2p: remove BIP155Network::TORV2 from GetBIP155Network() (Jon Atack) 7d1769b p2p: remove torv2 from SetNetFromBIP155Network() (Jon Atack) eba9a94 fuzz: rename CNetAddr/CService deserialize targets (Jon Atack) c56a1c9 p2p: drop onions from IsAddrV1Compatible(), no longer relay torv2 (Jon Atack) f8e9400 p2p: remove torv2/ADDR_TORV2_SIZE from SetTor() (Jon Atack) 0f1c58a test: update feature_proxy to torv3 (Jon Atack) Pull request description: ![image](https://user-images.githubusercontent.com/2415484/120018909-4d425a00-bfd7-11eb-83c9-95a3dac97926.jpeg) This patch removes support in Bitcoin Core for Tor v2 onions, which are already removed from the release of Tor 0.4.6. - no longer serialize/deserialize and relay Tor v2 addresses - ignore incoming Tor v2 addresses - remove Tor v2 addresses from the addrman and peers.dat on node launch - update generate-seeds.py to ignore Tor v2 addresses - remove Tor v2 hard-coded seeds Tested with tor-0.4.6.1-alpha (no v2 support) and 0.4.5.7 (v2 support). With the latest Tor (no v2 support), this removes all the warnings like those reported with current master in bitcoin/bitcoin#21351 ``` <bitcoind debug log> Socks5() connect to […].onion:8333 failed: general failure <tor log> Invalid hostname [scrubbed]; rejecting ``` and the addrman no longer has Tor v2 addresses on launching bitcoind. ```rake $ ./src/bitcoin-cli -addrinfo { "addresses_known": { "ipv4": 44483, "ipv6": 8467, "torv2": 0, "torv3": 2296, "i2p": 6, "total": 55252 } } ``` After recompiling back to current master and restarting with either of the two Tor versions (0.4.5.7 or 0.4.6.1), -addrinfo initially returns 0 Tor v2 addresses and then begins finding them again. Ran nodes on this patch over the past week on mainnet/testnet/signet/regtest after building with DEBUG_ADDRMAN. Verified that this patch bootstraps an onlynet=onion node from the Tor v3 hardcoded fixed seeds on mainnet and testnet and connects to blocks and v3 onion peers: `rm ~/.bitcoin/testnet3/peers.dat ; ./src/bitcoind -testnet -dnsseed=0 -onlynet=onion` ![Screenshot from 2021-05-28 00-26-17](https://user-images.githubusercontent.com/2415484/119905021-ea02ea00-bf3a-11eb-875f-27ef57640c49.png) Tested using `addnode`, `getaddednodeinfo`,`addpeeraddress`, `disconnectnode` and `-addrinfo` that a currently valid, connectable Tor v2 peer can no longer be added: ![Screenshot from 2021-05-30 11-32-05](https://user-images.githubusercontent.com/2415484/120099282-29435d80-c12a-11eb-81b6-5084244d7d2a.png) Thanks to Vasil Dimov, Carl Dong, and Wladimir J. van der Laan for their work on BIP155 and Tor v3 that got us here. ACKs for top commit: laanwj: Code review ACK 5d82a57 Tree-SHA512: 590ff3d2f6ef682608596facb4b01f44fef69716d2ab3552ae1655aa225f4bf104f9ee08d6769abb9982a8031de93340df553279ce1f5023771f9f2b651178bb
2 parents 907d636 + 5d82a57 commit 07ededa

File tree

9 files changed

+61
-1156
lines changed

9 files changed

+61
-1156
lines changed

contrib/seeds/generate-seeds.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
class BIP155Network(Enum):
3838
IPV4 = 1
3939
IPV6 = 2
40-
TORV2 = 3
40+
TORV2 = 3 # no longer supported
4141
TORV3 = 4
4242
I2P = 5
4343
CJDNS = 6
@@ -46,11 +46,11 @@ def name_to_bip155(addr):
4646
'''Convert address string to BIP155 (networkID, addr) tuple.'''
4747
if addr.endswith('.onion'):
4848
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
5351
return (BIP155Network.TORV3, vchAddr[:32])
52+
elif len(vchAddr) == 10:
53+
return (BIP155Network.TORV2, vchAddr)
5454
else:
5555
raise ValueError('Invalid onion %s' % vchAddr)
5656
elif addr.endswith('.b32.i2p'):
@@ -100,7 +100,10 @@ def parse_spec(s):
100100

101101
host = name_to_bip155(host)
102102

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, )
104107

105108
def ser_compact_size(l):
106109
r = b""
@@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
136139
continue
137140

138141
spec = parse_spec(line)
142+
if spec is None: # ignore this entry (e.g. no longer supported addresses like TORV2)
143+
continue
139144
blob = bip155_serialize(spec)
140145
hoststr = ','.join(('0x%02x' % b) for b in blob)
141146
g.write(f' {hoststr},\n')

0 commit comments

Comments
 (0)