Example #1
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = Level3.applre.match(hostname)
         if match:
             city_code = match.group(1)
             returninfo = base.returninfo.copy()
             returninfo['company'] = 'Verizon'
             returninfo['info'] = 'carrier'
             country = base.get_country_by_iso('us')
             returninfo['country'] = country['name']
             returninfo['accuracy'] = 'country'
             returninfo['lat'] = country['lat']
             returninfo['lng'] = country['lng']
             try:
                 jsondb = json.load(
                     open('./database/carriers/verizon.json'))
                 c = jsondb[city_code.upper()]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
                 returninfo['country'] = c['country']
             except:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #2
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = Comcast.applre.match(hostname)
         if match:
             city_code, state_code = match.group(1, 2)
             returninfo = base.returninfo.copy()
             state = base.get_state_by_code('us', state_code)
             returninfo['country'] = 'United States of America'
             returninfo['state'] = state['name']
             returninfo['accuracy'] = 'state'
             returninfo['lat'] = state['lat']
             returninfo['lng'] = state['lng']
             returninfo['company'] = 'Comcast Corporation'
             returninfo['info'] = 'carrier'
             try:
                 jsondb = json.load(
                     open('./database/carriers/comcast.json'))
                 c = jsondb[city_code.lower()]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
             except:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #3
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = DECIX.applre.search(hostname)
         if match:
             returninfo = base.returninfo.copy()
             returninfo['country'] = 'Germany'
             returninfo['city'] = 'Frankfurt am Main'
             returninfo['accuracy'] = 'city'
             returninfo['info'] = 'exchange'
             returninfo['lat'] = 50.12128335
             returninfo['lng'] = 8.661885971
             returninfo['company'] = 'DE-CIX Management GmbH'
             # try to get street
             match = DECIX.applre_num.search(hostname)
             if match:
                 decix_code = match.group(1)
                 try:
                     jsondb = json.load(open('./database/decix.json'))
                     c = jsondb[decix_code]
                     returninfo['accuracy'] = 'site'
                     returninfo['lat'] = c['lat']
                     returninfo['lng'] = c['lng']
                 except:
                     pass
             return returninfo
     raise exceptions.NotApplicable()
Example #4
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = Hetzner.applre.match(hostname)
         if match:
             returninfo = base.returninfo.copy()
             returninfo['country'] = 'Germany'
             returninfo['info'] = 'isp'
             returninfo['company'] = 'Hetzner Online AG'
             datacenter_code = int(match.group(1))
             try:
                 jsondb = json.load(open('./database/isps/hetzner.json'))
                 if datacenter_code in range(1, 9 + 1):
                     location = 'nuernberg'
                 elif datacenter_code in range(10, 23 + 1):
                     location = 'falkenstein'
                 c = jsondb[location]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
             except:
                 raise
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #5
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = DTag.applre.match(hostname)
         if match:
             city_code, country_code = match.group(1, 2)
             returninfo = base.returninfo.copy()
             country = base.get_country_by_iso(country_code)
             returninfo['country'] = country['name']
             returninfo['accuracy'] = 'country'
             returninfo['lat'] = country['lat']
             returninfo['lng'] = country['lng']
             returninfo['company'] = 'Deutsche Telekom AG'
             returninfo['info'] = 'carrier'
             # try city
             if country_code.upper() in base.get_available_opengeodbs():
                 try:
                     city = base.get_city_by_plate(country_code, city_code)
                     returninfo['city'] = city['name']
                     returninfo['accuracy'] = 'city'
                     returninfo['lat'] = city['lat']
                     returninfo['lng'] = city['lng']
                 except:
                     pass
             return returninfo
     raise exceptions.NotApplicable()
Example #6
0
	def lookup(self, ip=None, hostname=None):
		if hostname:
			match = NEFkom.applre.search(hostname)
			if match:
				returninfo = base.returninfo.copy()
				returninfo['country'] = 'Germany'
				returninfo['city'] = 'Nuremberg'
				returninfo['accuracy'] = 'city'
				returninfo['info'] = 'isp'
				returninfo['lat'] = 49.4538501
				returninfo['lng'] = 11.0773238
				returninfo['company'] = 'M-net Telekommunikations GmbH'
				return returninfo
		raise exceptions.NotApplicable()
Example #7
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = ContentCore.applre.match(hostname)
         if match:
             city_code = match.group(1)
             returninfo = base.returninfo.copy()
             returninfo['company'] = 'IP Exchange GmbH'
             returninfo['info'] = 'carrier'
             try:
                 jsondb = json.load(
                     open('./database/carriers/ipexchange.json'))
                 c = jsondb[city_code.upper()]
                 returninfo['country'] = c['country']
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
             except:
                 pass
             return returninfo
         else:
             match = ContentCore.applre_ext.match(hostname)
             if match:
                 city_code, country_code = match.group(1, 2)
                 returninfo = base.returninfo.copy()
                 country = base.get_country_by_iso(country_code)
                 returninfo['country'] = country['name']
                 returninfo['accuracy'] = 'country'
                 returninfo['lat'] = country['lat']
                 returninfo['lng'] = country['lng']
                 returninfo['company'] = 'IP Exchange GmbH'
                 returninfo['info'] = 'carrier'
                 try:
                     jsondb = json.load(
                         open('./database/carriers/ipexchange.json'))
                     key = "%s-%s" % (country_code.upper(),
                                      city_code.upper())
                     c = jsondb[key]
                     returninfo['city'] = c['city']
                     returninfo['accuracy'] = 'city'
                     returninfo['lat'] = c['lat']
                     returninfo['lng'] = c['lng']
                 except:
                     pass
                 return returninfo
     raise exceptions.NotApplicable()
Example #8
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = DFN.applre.match(hostname)
         if match:
             city_code = match.group(1)
             returninfo = base.returninfo.copy()
             jsondb = json.load(open('./database/carriers/dfn.json'))
             c = jsondb[city_code.upper()]
             returninfo['city'] = c['city']
             returninfo['accuracy'] = 'city'
             returninfo['lat'] = c['lat']
             returninfo['lng'] = c['lng']
             returninfo['country'] = c['country']
             returninfo['company'] = 'Deutschen Forschungsnetz'
             returninfo['info'] = 'carrier'
             return returninfo
     raise exceptions.NotApplicable()
Example #9
0
	def lookup(self, ip=None, hostname=None):
		if hostname:
			match = TeliaSonera.applre.match(hostname)
			if match:
				city_code = match.group(1)
				returninfo = base.returninfo.copy()
				returninfo['company'] = 'TeliaSonera International Carrier AB'
				returninfo['info'] = 'carrier'
				try:
					jsondb = json.load(open('./database/carriers/telia.json'))
					c = jsondb[city_code.lower()]
					returninfo['city'] = c['city']
					returninfo['accuracy'] = 'city'
					returninfo['lat'] = c['lat']
					returninfo['lng'] = c['lng']
					returninfo['country'] = c['country']
				except:
					pass
				return returninfo
		raise exceptions.NotApplicable()
Example #10
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = ATT.applre.match(hostname)
         if match:
             city_code = match.group(1)
             returninfo = base.returninfo.copy()
             returninfo['company'] = 'American Telegraph and Telephone'
             returninfo['info'] = 'carrier'
             try:
                 jsondb = json.load(open('./database/carriers/att.json'))
                 c = jsondb[city_code.lower()]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
                 returninfo['country'] = c['country']
             except:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #11
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = Level3.applre.match(hostname)
         if match:
             city_raw = match.group(1)
             returninfo = base.returninfo.copy()
             returninfo['company'] = 'Level 3 Communications, Inc'
             returninfo['info'] = 'carrier'
             try:
                 jsondb = json.load(open('./database/carriers/level3.json'))
                 c = jsondb[city_raw]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
                 returninfo['country'] = c['country']
             except KeyError:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #12
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = CogentCO.applre.match(hostname)
         if match:
             city_code = match.group(1)
             returninfo = base.returninfo.copy()
             returninfo['company'] = 'Cogent Communications, Inc.'
             returninfo['info'] = 'carrier'
             try:
                 jsondb = json.load(
                     open('./database/carriers/cogentco.json'))
                 c = jsondb[city_code.lower()]
                 returninfo['city'] = c['city']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
                 returninfo['country'] = c['country']
             except:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #13
0
 def lookup(self, ip=None, hostname=None):
     if hostname:
         match = AboveNet.applre.match(hostname)
         if match:
             iata_code, country_code = match.group(1, 2)
             returninfo = base.returninfo.copy()
             country = base.get_country_by_iso(country_code)
             returninfo['country'] = country['name']
             returninfo['accuracy'] = 'country'
             returninfo['lat'] = country['lat']
             returninfo['lng'] = country['lng']
             returninfo['company'] = 'AboveNet Inc'
             returninfo['info'] = 'carrier'
             try:
                 c = base.get_city_by_iata(iata_code)
                 returninfo['city'] = c['name']
                 returninfo['accuracy'] = 'city'
                 returninfo['lat'] = c['lat']
                 returninfo['lng'] = c['lng']
             except:
                 pass
             return returninfo
     raise exceptions.NotApplicable()
Example #14
0
	def lookup(self, ip=None, hostname=None):
		if hostname:
			match = NTT.applre.match(hostname)
			if match:
				city_code, country_code = match.group(1,2)
				returninfo = base.returninfo.copy()
				country = base.get_country_by_iso(country_code)
				returninfo['country'] = country['name']
				returninfo['accuracy'] = 'country'
				returninfo['lat'] = country['lat']
				returninfo['lng'] = country['lng']
				returninfo['company'] = 'Nippon Telegraph and Telephone'
				returninfo['info'] = 'carrier'
				try:
					jsondb = json.load(open('./database/carriers/ntt.json'))
					c = jsondb[city_code.upper()]
					returninfo['city'] = c['city']
					returninfo['accuracy'] = 'city'
					returninfo['lat'] = c['lat']
					returninfo['lng'] = c['lng']
				except:
					pass
				return returninfo
		raise exceptions.NotApplicable()
Example #15
0
 def lookup(self, ip=None, hostname=None):
     raise exceptions.NotApplicable()
     if not self.initialized: self._inizialize()
     return returninfo