def __init__(self, ipaddr, latency): self.ipaddr = ipaddr self.fqdn = None self.dquad = num_to_dq(ipaddr) self.latency = latency self.asnum = None self.mm = None # from the MaxMind database self.xyz = (0.0, 0.0, 0.0) self.ch_num = None self.interest = None
def parse_line_pair(self, genericness, line1, line2): """parse a line pair from a whois network summary query to ARIN. line1 holds the OrgName, NetName and, in parentheses, NetHandle. line2 holds the NetRange preceeded by a run of blanks.""" l1_parts=string.strip(line1).split(" ") net_range=[s for s in line2.split(" ") if len(s) > 1] #print l1_parts OrgName=" ".join(l1_parts[:-2]) NetName=l1_parts[-2] NetHandle=l1_parts[-1][1:-1] if self.verbose: print "OrgName=%s NetName=%s NetHandle=%s NetRange=%s - %s" % (OrgName, NetName, NetHandle, net_range[0], net_range[1]) range_id = self.req.put_range(genericness, OrgName, NetName, NetHandle, net_range[0], net_range[1]) n_start = dq_to_num(net_range[0]) n_end = dq_to_num(net_range[1]) #print "%08x %08x" % (n_start, n_end) # 108.0.0.0 - 108.57.191.255 is a good example of where we need CIDR pl=nr_to_cidr(n_start, n_end) for p in pl: dquad = num_to_dq(p[0]) if self.verbose: print "CIDR: %s/%d" % (dquad, p[1]) self.req.put_cidr(range_id, dquad, p[1])