mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
makeseeds: Support CJDNS
This commit is contained in:
parent
d5a8c4c4bd
commit
af550b3a0f
1 changed files with 8 additions and 3 deletions
|
@ -88,6 +88,8 @@ def parseline(line: str) -> Union[dict, None]:
|
||||||
if m.group(1) in ['::']: # Not interested in localhost
|
if m.group(1) in ['::']: # Not interested in localhost
|
||||||
return None
|
return None
|
||||||
ipstr = m.group(1)
|
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
|
sortkey = ipstr # XXX parse IPv6 into number, could use name_to_ipv6 from generate-seeds
|
||||||
port = int(m.group(2))
|
port = int(m.group(2))
|
||||||
else:
|
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_ipv46 = [ip for ip in ips if ip['net'] in ['ipv4', 'ipv6']]
|
||||||
ips_onion = [ip for ip in ips if ip['net'] == 'onion']
|
ips_onion = [ip for ip in ips if ip['net'] == 'onion']
|
||||||
ips_i2p = [ip for ip in ips if ip['net'] == 'i2p']
|
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
|
# Filter IPv46 by ASN, and limit to max_per_net per network
|
||||||
result = []
|
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)
|
# Add back Onions (up to max_per_net)
|
||||||
result.extend(ips_onion[0:max_per_net])
|
result.extend(ips_onion[0:max_per_net])
|
||||||
result.extend(ips_i2p[0:max_per_net])
|
result.extend(ips_i2p[0:max_per_net])
|
||||||
|
result.extend(ips_cjdns[0:max_per_net])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def ip_stats(ips: list[dict]) -> str:
|
def ip_stats(ips: list[dict]) -> str:
|
||||||
|
@ -187,7 +191,7 @@ def ip_stats(ips: list[dict]) -> str:
|
||||||
if ip is not None:
|
if ip is not None:
|
||||||
hist[ip['net']] += 1
|
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():
|
def parse_args():
|
||||||
argparser = argparse.ArgumentParser(description='Generate a list of bitcoin node seed ip addresses.')
|
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]
|
ips = [parseline(line) for line in lines]
|
||||||
print('Done.', file=sys.stderr)
|
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)
|
print(f'{ip_stats(ips):s} Initial', file=sys.stderr)
|
||||||
# Skip entries with invalid address.
|
# Skip entries with invalid address.
|
||||||
ips = [ip for ip in ips if ip is not None]
|
ips = [ip for ip in ips if ip is not None]
|
||||||
|
@ -229,6 +233,7 @@ def main():
|
||||||
'ipv6': 50,
|
'ipv6': 50,
|
||||||
'onion': 10,
|
'onion': 10,
|
||||||
'i2p' : 10,
|
'i2p' : 10,
|
||||||
|
'cjdns': 10,
|
||||||
}
|
}
|
||||||
ips = [ip for ip in ips if ip['uptime'] > req_uptime[ip['net']]]
|
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)
|
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).
|
# Sort the results by IP address (for deterministic output).
|
||||||
ips.sort(key=lambda x: (x['net'], x['sortkey']))
|
ips.sort(key=lambda x: (x['net'], x['sortkey']))
|
||||||
for ip in ips:
|
for ip in ips:
|
||||||
if ip['net'] == 'ipv6':
|
if ip['net'] == 'ipv6' or ip["net"] == "cjdns":
|
||||||
print(f"[{ip['ip']}]:{ip['port']}", end="")
|
print(f"[{ip['ip']}]:{ip['port']}", end="")
|
||||||
else:
|
else:
|
||||||
print(f"{ip['ip']}:{ip['port']}", end="")
|
print(f"{ip['ip']}:{ip['port']}", end="")
|
||||||
|
|
Loading…
Add table
Reference in a new issue