twisterp2pbittorrentblockchainnetworkipv6microbloggingdecentralizedsocial-networkdhttwister-coretwisterarmyp2p-networktwister-servertwister-ipv6
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
901 B
38 lines
901 B
#!/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 = [] |
|
ports = [] |
|
pattern = re.compile(r"^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3}):(\d{1,5})") |
|
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) |
|
ports.append(int(m.group(5))) |
|
|
|
for row in range(0, min(NSEEDS,len(ips)), 8): |
|
print " " + ", ".join([ "0x%08x"%i for i in ips[row:row+8] ]) + "," |
|
|
|
for row in range(0, min(NSEEDS,len(ports)), 8): |
|
print " " + ", ".join([ "0x%04x"%i for i in ports[row:row+8] ]) + "," |
|
|
|
|
|
if __name__ == '__main__': |
|
main()
|
|
|