コード例 #1
0
ファイル: base.py プロジェクト: timothyclemans/djangocg
 def country_name(self, query):
     "Returns the country name for the given IP Address or FQDN."
     query = self._check_query(query, city_or_country=True)
     if self._country:
         if ipv4_re.match(query):
             return GeoIP_country_name_by_addr(self._country, query)
         else:
             return GeoIP_country_name_by_name(self._country, query)
     else:
         return self.city(query)['country_name']
コード例 #2
0
ファイル: base.py プロジェクト: timothyclemans/djangocg
 def city(self, query):
     """
     Returns a dictionary of city information for the given IP address or
     Fully Qualified Domain Name (FQDN).  Some information in the dictionary
     may be undefined (None).
     """
     query = self._check_query(query, city=True)
     if ipv4_re.match(query):
         # If an IP address was passed in
         return GeoIP_record_by_addr(self._city, c_char_p(query))
     else:
         # If a FQDN was passed in.
         return GeoIP_record_by_name(self._city, c_char_p(query))