Skip to content

Commit

Permalink
Merge pull request #70 from mlsecproject/i67_as
Browse files Browse the repository at this point in the history
Fixes #67 by indexing per range, not per org name
  • Loading branch information
Kyle Maxwell committed Sep 16, 2014
2 parents 48cf949 + 5864b39 commit acf3b27
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions winnower.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ def load_gi_org(filename):
with open(filename, 'rb') as f:
org_reader = csv.DictReader(f, fieldnames=['start', 'end', 'org'])
for row in org_reader:
gi_org[row['org']] = IPRange(row['start'], row['end'])
gi_org[IPRange(row['start'], row['end'])] = row['org']
return gi_org


def org_by_addr(address, org_data):
as_num = None
as_name = None
for org in org_data:
if address in org_data[org]:
as_num, sep, as_name = org.partition(' ')
for iprange in org_data:
if address in iprange:
as_num, sep, as_name = org_data[iprange].partition(' ')
as_num = as_num.replace("AS", "") # Making sure the variable only has the number
break
return as_num, as_name

Expand Down

0 comments on commit acf3b27

Please sign in to comment.