Skip to content

Commit 55bd5d8

Browse files
committed
Merge bitcoin/bitcoin#29561: Fixed seeds update for 27.0
7ab5439 seeds: Update testnet seeds (Ava Chow) 34a233b seeds: Update mainnet seeds (Ava Chow) 9701bc4 makeseeds: Check i2p seeds too (Ava Chow) a8ec9ee makeseeds: Update PATTERN_AGENT (Ava Chow) Pull request description: The ipv4 and ipv6 seeds are updated from sipa's crawler, as outlined in contrib/seeds/README.md. The onion and i2p seeds are pulled from my node's addrman using `getrawaddrman` and then a connection was made to each node to retrieve the current service flags, block height, and user agent string before filtering through makeseeds.py. The CJDNS nodes were not updated as my node is not connected to that network. makeseeds.py is also updated for more recent user agent strings as well as being able to handle i2p addresses. Also updated the testnet seeds. ACKs for top commit: fanquake: ACK 7ab5439 Tree-SHA512: 5edba63d51116e5d9a8ae23561ba5a311f4df88c555c60b2d7a6066e63f8cdfd256be7dac9acea4b370879d0d3c3a4b55328c15de4284b5f0d86e6cac2e5ba9b
2 parents 6c77dbf + 7ab5439 commit 55bd5d8

File tree

5 files changed

+4183
-1646
lines changed

5 files changed

+4183
-1646
lines changed

contrib/seeds/makeseeds.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PATTERN_IPV4 = re.compile(r"^((\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})):(\d+)$")
2828
PATTERN_IPV6 = re.compile(r"^\[([0-9a-z:]+)\]:(\d+)$")
2929
PATTERN_ONION = re.compile(r"^([a-z2-7]{56}\.onion):(\d+)$")
30+
PATTERN_I2P = re.compile(r"^([a-z2-7]{52}\.b32.i2p):(\d+)$")
3031
PATTERN_AGENT = re.compile(
3132
r"^/Satoshi:("
3233
r"0.14.(0|1|2|3|99)|"
@@ -40,7 +41,8 @@
4041
r"22.(0|1|99)|"
4142
r"23.(0|1|99)|"
4243
r"24.(0|1|99)|"
43-
r"25.99"
44+
r"25.(0|1|99)|"
45+
r"26.(0|99)|"
4446
r")")
4547

4648
def parseline(line: str) -> Union[dict, None]:
@@ -65,7 +67,13 @@ def parseline(line: str) -> Union[dict, None]:
6567
if m is None:
6668
m = PATTERN_ONION.match(sline[0])
6769
if m is None:
68-
return None
70+
m = PATTERN_I2P.match(sline[0])
71+
if m is None:
72+
return None
73+
else:
74+
net = 'i2p'
75+
ipstr = sortkey = m.group(1)
76+
port = int(m.group(2))
6977
else:
7078
net = 'onion'
7179
ipstr = sortkey = m.group(1)
@@ -140,6 +148,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
140148
# Sift out ips by type
141149
ips_ipv46 = [ip for ip in ips if ip['net'] in ['ipv4', 'ipv6']]
142150
ips_onion = [ip for ip in ips if ip['net'] == 'onion']
151+
ips_i2p = [ip for ip in ips if ip['net'] == 'i2p']
143152

144153
# Filter IPv46 by ASN, and limit to max_per_net per network
145154
result = []
@@ -163,6 +172,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
163172

164173
# Add back Onions (up to max_per_net)
165174
result.extend(ips_onion[0:max_per_net])
175+
result.extend(ips_i2p[0:max_per_net])
166176
return result
167177

168178
def ip_stats(ips: list[dict]) -> str:
@@ -172,7 +182,7 @@ def ip_stats(ips: list[dict]) -> str:
172182
if ip is not None:
173183
hist[ip['net']] += 1
174184

175-
return f"{hist['ipv4']:6d} {hist['ipv6']:6d} {hist['onion']:6d}"
185+
return f"{hist['ipv4']:6d} {hist['ipv6']:6d} {hist['onion']:6d} {hist['i2p']:6d}"
176186

177187
def parse_args():
178188
argparser = argparse.ArgumentParser(description='Generate a list of bitcoin node seed ip addresses.')
@@ -194,7 +204,7 @@ def main():
194204
ips = [parseline(line) for line in lines]
195205
print('Done.', file=sys.stderr)
196206

197-
print('\x1b[7m IPv4 IPv6 Onion Pass \x1b[0m', file=sys.stderr)
207+
print('\x1b[7m IPv4 IPv6 Onion I2P Pass \x1b[0m', file=sys.stderr)
198208
print(f'{ip_stats(ips):s} Initial', file=sys.stderr)
199209
# Skip entries with invalid address.
200210
ips = [ip for ip in ips if ip is not None]
@@ -208,11 +218,12 @@ def main():
208218
# Require service bit 1.
209219
ips = [ip for ip in ips if (ip['service'] & 1) == 1]
210220
print(f'{ip_stats(ips):s} Require service bit 1', file=sys.stderr)
211-
# Require at least 50% 30-day uptime for clearnet, 10% for onion.
221+
# Require at least 50% 30-day uptime for clearnet, 10% for onion and i2p.
212222
req_uptime = {
213223
'ipv4': 50,
214224
'ipv6': 50,
215225
'onion': 10,
226+
'i2p' : 10,
216227
}
217228
ips = [ip for ip in ips if ip['uptime'] > req_uptime[ip['net']]]
218229
print(f'{ip_stats(ips):s} Require minimum uptime', file=sys.stderr)

0 commit comments

Comments
 (0)