+
    Tj'"                         R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt R.t ^ RItRt]R	R
.,          t0 Rmt ! R R
]4      t ! R R	4      tR#   ] d    Rt L&i ; i)aU  
This module houses the GeoIP2 object, a wrapper for the MaxMind GeoIP2(R)
Python API (https://geoip2.readthedocs.io/). This is an alternative to the
Python GeoIP2 interface provided by MaxMind.

GeoIP(R) is a registered trademark of MaxMind, Inc.

For IP-based geolocation, this module requires the GeoLite2 Country and City
datasets, in binary format (CSV will not work!). The datasets may be
downloaded from MaxMind at https://dev.maxmind.com/geoip/geoip2/geolite2/.
Grab GeoLite2-Country.mmdb.gz and GeoLite2-City.mmdb.gz, and unzip them in the
directory corresponding to settings.GEOIP_PATH.
N)settings)ValidationError)validate_ipv46_address)to_path)cached_property
HAS_GEOIP2TGeoIP2GeoIP2ExceptionFc                       ] tR t^/tRtR# )r	    N)__name__
__module____qualname____firstlineno____static_attributes__r       N/var/www/idalgo/venv/lib/python3.14/site-packages/django/contrib/gis/geoip2.pyr	   r	   /   s    r   c                      a  ] tR t^3t o ^ t^t^t^t^t]	! ]]]]]34      t
RtRtRR ltR tR t]R 4       t]R 4       t]R 4       tRR	/R
 ltR tR tR tR tR tR tR tRtV tR# )r   Nc                R   W P                   9  d   \        RV,          4      hT;'       g    \        \        RR4      pT;'       g    \        \        RR4      pT;'       g    \        \        RR4      pV'       g   \        R4      h\	        V4      pWV,          W,          3 FF  pVP                  4       '       g   K  Wn        \        P                  P                  WR	7      V n
         M	  \        R
4      hV P                  P                  pV\        9  d   \        RV 24      hR# )a  
Initialize the GeoIP object. No parameters are required to use default
settings. Keyword arguments may be passed in to customize the locations
of the GeoIP datasets.

* path: Base directory to where GeoIP data is located or the full path
    to where the city or country data files (*.mmdb) are located.
    Assumes that both the city and country data sets are located in
    this directory; overrides the GEOIP_PATH setting.

* cache: The cache settings when opening up the GeoIP datasets. May be
    an integer in (0, 1, 2, 4, 8) corresponding to the MODE_AUTO,
    MODE_MMAP_EXT, MODE_MMAP, MODE_FILE, and MODE_MEMORY,
    `GeoIPOptions` C API settings, respectively. Defaults to 0,
    meaning MODE_AUTO.

* country: The name of the GeoIP country data file. Defaults to
    'GeoLite2-Country.mmdb'; overrides the GEOIP_COUNTRY setting.

* city: The name of the GeoIP city data file. Defaults to
    'GeoLite2-City.mmdb'; overrides the GEOIP_CITY setting.
z Invalid GeoIP caching option: %s
GEOIP_PATHN
GEOIP_CITYzGeoLite2-City.mmdbGEOIP_COUNTRYzGeoLite2-Country.mmdbzDGeoIP path must be provided via parameter or the GEOIP_PATH setting.)modez@Path must be a valid database or directory containing databases.z#Unable to handle database edition: )cache_optionsr	   getattrr   r   is_file_pathgeoip2databaseReader_reader	_metadatadatabase_typeSUPPORTED_DATABASE_TYPES)selfpathcachecountrycityr"   s   &&&&& r   __init__GeoIP2.__init__F   s
   . ***!"Du"LMM<<wxt<LLwx7KLXXWX@WX!V  t} $;7D||~~!
%55d5G	 8 "R  44 88!$G"WXX 9r   c                b    V P                   '       d   V P                   P                  4        R # R # N)r    closer$   s   &r   __del__GeoIP2.__del__z   s     <<<LL  r   c                    V P                   pR VP                   RVP                   2pRV P                  P                   RV RV P
                   R2# )v.<z [z	] _path='z'>)r!   binary_format_major_versionbinary_format_minor_version	__class__r   r   )r$   mversions   &  r   __repr__GeoIP2.__repr__   sU    NNa334Aa6S6S5TU4>>**+2gYi

|2NNr   c                6    V P                   P                  4       # r,   )r    metadatar.   s   &r   r!   GeoIP2._metadata   s    ||$$&&r   c                4    R V P                   P                  9   # )Cityr!   r"   r.   s   &r   is_cityGeoIP2.is_city   s    5555r   c                4    R V P                   P                  9   # )CountryrA   r.   s   &r   
is_countryGeoIP2.is_country   s    DNN8888r   require_cityFc               8   \        V\        \        P                  \        P                  34      '       g&   \        R \        V4      P                  ,          4      hV'       d+   V P                  '       g   \        RV P                   24      h\        V\        4      '       d    \        V4       V P                  '       d   V P                  P                   MV P                  P"                  pV! V4      #   \         d    \        P                  ! T4      p Lii ; i)zSGeoIP query must be a string or instance of IPv4Address or IPv6Address, not type %szInvalid GeoIP city data file: )
isinstancestr	ipaddressIPv4AddressIPv6Address	TypeErrortyper   rB   r	   r   r   r   socketgethostbynamer    r(   r'   )r$   queryrH   functions   &&$ r   _queryGeoIP2._query   s    %#y'<'<i>S>S!TUU+-1%[-A-AB 
 !$B4::,"OPPeS!!4&u-
 )-4<<$$$,,:N:N # 4,,U34s   $C5 5!DDc                \   V P                  VRR7      pVP                  '       d   VP                  ^ ,          MRp/ RVP                  P                  bRVP                  P
                  bRVP                  P                  bRVP                  P
                  bRVP                  P                  bR	VP                  P
                  bR
VP                  P                  bRVP                  P                  bRVP                  P                  bRVP                  P                  bRVP                  P                  bRV'       d   VP                  MRbRV'       d   VP
                  MRbRVP                  P                  bRVP                  P                  bRV'       d   VP                  b# Rb# )z
Return 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).
TrH   Naccuracy_radiusr(   continent_codecontinent_namecountry_codecountry_nameis_in_european_unionlatitude	longitude
metro_codepostal_coderegion_coderegion_name	time_zonedma_coderegion)rU   subdivisionslocationrY   r(   name	continentcoder'   iso_coder^   r_   r`   ra   postalre   )r$   rS   responserg   s   &&  r   r(   GeoIP2.city   s    ;;u4;8-5-B-B-B&&q)
x00@@
HMM&&
 h0055
 h0055	

 H,,55
 H,,11
 #H$4$4$I$I
 ))22
 **44
 (++66
 8??//
 f6??$
 &6;;d
 **44
  ))44!
" foo#
 	
" 6:#
 	
r   c                2    V P                  V4      R,          # )z9Return the country code for the given IP Address or FQDN.r\   r'   r$   rS   s   &&r   r\   GeoIP2.country_code       ||E">22r   c                2    V P                  V4      R,          # )z9Return the country name for the given IP Address or FQDN.r]   rr   rs   s   &&r   r]   GeoIP2.country_name   ru   r   c           
        V P                  VRR7      pRVP                  P                  RVP                  P                  RVP                  P
                  RVP                  P                  RVP                  P                  /# )z
Return a dictionary with the country code and name when given an
IP address or a Fully Qualified Domain Name (FQDN). For example, both
'24.124.1.80' and 'djangoproject.com' are valid parameters.
FrX   rZ   r[   r\   r]   r^   )rU   rk   rl   rj   r'   rm   r^   )r$   rS   ro   s   && r   r'   GeoIP2.country   su     ;;u5;9h0055h0055H,,55H,,11"H$4$4$I$I
 	
r   c                H    V P                  V4      pVR,          VR,          3# )z@Return a tuple of the (longitude, latitude) for the given query.r`   r_   r(   r$   rS   datas   && r   lon_latGeoIP2.lon_lat   s%    yyK $z"222r   c                H    V P                  V4      pVR,          VR,          3# )z@Return a tuple of the (latitude, longitude) for the given query.r_   r`   r{   r|   s   && r   lat_lonGeoIP2.lat_lon   s%    yyJk!222r   c                @    ^ RI Hp V! V P                  V4      RR7      # )z/Return a GEOS Point object for the given query.)Pointi  )srid)django.contrib.gis.geosr   r~   )r$   rS   r   s   && r   geosGeoIP2.geos   s     	2T\\%(t44r   )r   r    )N    NN)r   r   r   r   	MODE_AUTOMODE_MMAP_EXT	MODE_MMAP	MODE_FILEMODE_MEMORY	frozensetr   r   r    r)   r/   r:   r   r!   rB   rF   rU   r(   r\   r]   r'   r~   r   r   r   __classdictcell__)__classdict__s   @r   r   r   3   s      IMIIK	M9iEM EG2Yh!
O
 ' ' 6 6 9 9E (
833
3
3
5 5r   >   GeoIP2-CityGeoLite2-CityDBIP-City-LiteGeoIP2-CountryGeoLite2-CountryDBIP-Country-Lite)__doc__rL   rQ   django.confr   django.core.exceptionsr   django.core.validatorsr   django.utils._osr   django.utils.functionalr   __all__geoip2.databaser   r   ImportErrorr#   	Exceptionr	   r   r   r   r   <module>r      s}        2 9 $ 3.- J+,,G
 	i 	s5 s5/  Js   A 	A%$A%