mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-19 05:45:05 +01:00
makeseeds: Support CJDNS
This commit is contained in:
parent
d5a8c4c4bd
commit
af550b3a0f
@ -88,6 +88,8 @@ def parseline(line: str) -> Union[dict, None]:
|
||||
if m.group(1) in ['::']: # Not interested in localhost
|
||||
return None
|
||||
ipstr = m.group(1)
|
||||
if ipstr.startswith("fc"): # cjdns looks like ipv6 but always begins with fc
|
||||
net = "cjdns"
|
||||
sortkey = ipstr # XXX parse IPv6 into number, could use name_to_ipv6 from generate-seeds
|
||||
port = int(m.group(2))
|
||||
else:
|
||||
@ -154,6 +156,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
|
||||
ips_ipv46 = [ip for ip in ips if ip['net'] in ['ipv4', 'ipv6']]
|
||||
ips_onion = [ip for ip in ips if ip['net'] == 'onion']
|
||||
ips_i2p = [ip for ip in ips if ip['net'] == 'i2p']
|
||||
ips_cjdns = [ip for ip in ips if ip["net"] == "cjdns"]
|
||||
|
||||
# Filter IPv46 by ASN, and limit to max_per_net per network
|
||||
result = []
|
||||
@ -178,6 +181,7 @@ def filterbyasn(asmap: ASMap, ips: list[dict], max_per_asn: dict, max_per_net: i
|
||||
# Add back Onions (up to max_per_net)
|
||||
result.extend(ips_onion[0:max_per_net])
|
||||
result.extend(ips_i2p[0:max_per_net])
|
||||
result.extend(ips_cjdns[0:max_per_net])
|
||||
return result
|
||||
|
||||
def ip_stats(ips: list[dict]) -> str:
|
||||
@ -187,7 +191,7 @@ def ip_stats(ips: list[dict]) -> str:
|
||||
if ip is not None:
|
||||
hist[ip['net']] += 1
|
||||
|
||||
return f"{hist['ipv4']:6d} {hist['ipv6']:6d} {hist['onion']:6d} {hist['i2p']:6d}"
|
||||
return f"{hist['ipv4']:6d} {hist['ipv6']:6d} {hist['onion']:6d} {hist['i2p']:6d} {hist['cjdns']:6d}"
|
||||
|
||||
def parse_args():
|
||||
argparser = argparse.ArgumentParser(description='Generate a list of bitcoin node seed ip addresses.')
|
||||
@ -209,7 +213,7 @@ def main():
|
||||
ips = [parseline(line) for line in lines]
|
||||
print('Done.', file=sys.stderr)
|
||||
|
||||
print('\x1b[7m IPv4 IPv6 Onion I2P Pass \x1b[0m', file=sys.stderr)
|
||||
print('\x1b[7m IPv4 IPv6 Onion I2P CJDNS Pass \x1b[0m', file=sys.stderr)
|
||||
print(f'{ip_stats(ips):s} Initial', file=sys.stderr)
|
||||
# Skip entries with invalid address.
|
||||
ips = [ip for ip in ips if ip is not None]
|
||||
@ -229,6 +233,7 @@ def main():
|
||||
'ipv6': 50,
|
||||
'onion': 10,
|
||||
'i2p' : 10,
|
||||
'cjdns': 10,
|
||||
}
|
||||
ips = [ip for ip in ips if ip['uptime'] > req_uptime[ip['net']]]
|
||||
print(f'{ip_stats(ips):s} Require minimum uptime', file=sys.stderr)
|
||||
@ -246,7 +251,7 @@ def main():
|
||||
# Sort the results by IP address (for deterministic output).
|
||||
ips.sort(key=lambda x: (x['net'], x['sortkey']))
|
||||
for ip in ips:
|
||||
if ip['net'] == 'ipv6':
|
||||
if ip['net'] == 'ipv6' or ip["net"] == "cjdns":
|
||||
print(f"[{ip['ip']}]:{ip['port']}", end="")
|
||||
else:
|
||||
print(f"{ip['ip']}:{ip['port']}", end="")
|
||||
|
Loading…
Reference in New Issue
Block a user