aboutsummaryrefslogtreecommitdiff
path: root/contrib/seeds/makeseeds.py
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-05-25 10:43:30 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-06-01 14:40:04 +0200
commit667e316bcb300eec131727a7ce54dd038031e267 (patch)
tree78b43ef249b6d88d4616978cebc7a516ee9b3b30 /contrib/seeds/makeseeds.py
parentae00b9e02c819a69293fdcdab91f57b33e9275d9 (diff)
downloadbitcoin-667e316bcb300eec131727a7ce54dd038031e267.tar.xz
contrib: Update makeseeds to asmap-nextgen
Diffstat (limited to 'contrib/seeds/makeseeds.py')
-rwxr-xr-xcontrib/seeds/makeseeds.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/seeds/makeseeds.py b/contrib/seeds/makeseeds.py
index 12a9f72b93..37c6f5fd7c 100755
--- a/contrib/seeds/makeseeds.py
+++ b/contrib/seeds/makeseeds.py
@@ -7,12 +7,13 @@
#
import argparse
+import ipaddress
import re
import sys
import collections
from typing import List, Dict, Union
-from asmap import ASMap
+from asmap import ASMap, net_to_prefix
NSEEDS=512
@@ -145,8 +146,8 @@ def filterbyasn(asmap: ASMap, ips: List[Dict], max_per_asn: Dict, max_per_net: i
# do not add this ip as we already too many
# ips from this network
continue
- asn = asmap.lookup_asn(ip['ip'])
- if asn is None or asn_count[ip['net'], asn] == max_per_asn[ip['net']]:
+ asn = asmap.lookup(net_to_prefix(ipaddress.ip_network(ip['ip'])))
+ if not asn or asn_count[ip['net'], asn] == max_per_asn[ip['net']]:
# do not add this ip as we already have too many
# ips from this ASN on this network
continue
@@ -177,7 +178,8 @@ def main():
args = parse_args()
print(f'Loading asmap database "{args.asmap}"…', end='', file=sys.stderr, flush=True)
- asmap = ASMap(args.asmap)
+ with open(args.asmap, 'rb') as f:
+ asmap = ASMap.from_binary(f.read())
print('Done.', file=sys.stderr)
print('Loading and parsing DNS seeds…', end='', file=sys.stderr, flush=True)