6 def query(query, hostname, flags):
7 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
8 s.connect((hostname, 43))
9 # as IPv6 is not supported by flowspec for the time ommit -T route6
10 s.send(" -i origin -r -K -T route " + query + "\r\n")
18 query = response.splitlines()
24 m = re.match(r"(^route6?\:\s+)(?P<subnets>\S+)", line)
26 if IPNetwork(m.group('subnets')).version == 4:
27 routes4.append(IPNetwork(m.group('subnets')))
28 if IPNetwork(m.group('subnets')).version == 6:
29 routes6.append(IPNetwork(m.group('subnets')))
32 final_routes4 = collapse_address_list(routes4)
34 final_routes6 = collapse_address_list(routes6)
35 final_routes = final_routes4 + final_routes6
39 routes = query(queryas,settings.PRIMARY_WHOIS, None)
41 routes = query(queryas,settings.ALTERNATE_WHOIS, None)