diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2013-01-29 22:17:56 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2013-01-29 22:24:21 -0500 |
commit | 9126e08739f5115c3032997cabd23f27037131ef (patch) | |
tree | 638798aedd27dcf6f1ff3cb01fe0b850e8cee7c5 /contrib/seeds/makeseeds.py | |
parent | 2835080e164527ecc2db31e68d86ab8a8337c62b (diff) |
Utility to create pnSeed array
Diffstat (limited to 'contrib/seeds/makeseeds.py')
-rwxr-xr-x | contrib/seeds/makeseeds.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/seeds/makeseeds.py b/contrib/seeds/makeseeds.py new file mode 100755 index 0000000000..1d01fd7d20 --- /dev/null +++ b/contrib/seeds/makeseeds.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# +# Generate pnSeed[] from Pieter's DNS seeder +# + +NSEEDS=600 + +import re +import sys +from subprocess import check_output + +def main(): + lines = sys.stdin.readlines() + + ips = [] + pattern = re.compile(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}):8333") + for line in lines: + m = pattern.match(line) + if m is None: + continue + ip = 0 + for i in range(0,4): + ip = ip + (int(m.group(i+1)) << (8*(i))) + if ip == 0: + continue + ips.append(ip) + + for row in range(0, min(NSEEDS,len(ips)), 8): + print " " + ", ".join([ "0x%08x"%i for i in ips[row:row+8] ]) + "," + +if __name__ == '__main__': + main() |