
    ɯei                    $   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
m
Z
 d dlmZ d dlmZ d dlmZmZ d dlmZ d dlZd dlZdd	lmZmZ dd
lmZ ddlmZmZ ddlmZ ddl m!Z!  ee"      Z#erd dl$Z$ddZ%ddZ& G d d      Z'y)    )annotationsN)datetime)	getLogger)Path)AnyAnyStr)
getproxies   )
IS_WINDOWSurlparse)SnowflakeCursor)SessionManagerSessionManagerFactory)&extract_top_level_domain_from_hostname)urllib3c                   i }| j                         D ]t  \  }}t        |t              r|j                         }t        |t              r|j                         }nt        |t              rt        |      }|j                  ||i       v |S N)items
isinstancebytesdecodedict_decode_dictupdate)dresultkeyvalues       k/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/snowflake/connector/connection_diagnostic.pyr   r       su    (*Fggi $
Uc5!**,CeU#LLNEt$ 'EsEl#$ M    c                    t        | t              r)t        d | D              r	 t        j                  |        yy# t
        $ r Y yw xY w)Nc              3  <   K   | ]  }t        |t                y wr   )r   r   ).0items     r   	<genexpr>z+_is_list_of_json_objects.<locals>.<genexpr>.   s      +#'
4+s   TF)r   listalljsondumps	TypeError)	allowlists    r   _is_list_of_json_objectsr,   -   sM    )T"s ++4+ (	JJy!   		s   ; 	AAc                      e Zd ZdZ	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZ	 	 	 d	 	 	 	 	 	 	 	 	 ddZddZddZdddZ		 d	 	 	 	 	 	 	 dd	Z
dd
ZddZddZddZddZddZ	 	 	 	 	 	 	 	 ddZy) ConnectionDiagnosticzyImplementation of a connection test utility for Snowflake connector

    Use new ConnectionTest() to get the object.
    Nc
                   || _         || _        g g g g g g g d| _        d}
| j                  |
d| j                           | j                  |
d| j                          t	        |      }d| d| | j                  v rc|j                  d| dd      d	   d| z   | _        t        j                  d
| d| d       | j                  |
d| d| j                          n|| _        g | _        g | _	        i | _
        d| _        || _        || _        || _        || _        | j                  t!        j"                  d      }d| _        nt%               d   }d| _        | j'                  |      \  | _        | _        | _        | _        | j)                  | j                         |t+        |      nd | _        |t+        |      nd | _        t1        j2                         | _        | j,                  t+        | j4                        | _        n| j,                  j7                         s>t        j                  d| j,                   d       t+        | j4                        | _        nW| j,                  j9                         s=t        j                  d| j,                   d       t+        | j4                        | _        | j,                  dz  | _        t        j=                  d| j:                          | j.                  | j.                  j7                         s@t        j                  d| j.                   d       t        j                  d       d | _        nY| j.                  j9                         s?t        j                  d| j.                   d       t        j                  d       d | _        d| _        | jA                         r0| j                  jC                  d| j                          d | _        n| j                  jC                  d!|        d"| _"        d | _#        |	r|	jI                  d"#      | _'        y tK        jL                  d"#      | _'        y )$N)INITIALPROXYSNOWFLAKE_URLSTAGEOCSP_RESPONDEROUT_OF_BAND_TELEMETRYIGNOREr0   zSpecified snowflake account: z!Host based on specified account: .z.snowflakecomputing.z.snowr
   r   z+Account should not have snowflakecomputing.z in it. You provided z.  Continuing with fixed host.z%We removed extra .snowflakecomputing.z and will continue with host: paramsHTTPS_PROXYenvironmenthttpssystemzPath z% for connection test is not absolute.z$ for connection test does not exist.z!SnowflakeConnectionTestReport.txtzReporting to file zPath 'z0' for connection test allowlist is not absolute.zWill connect to Snowflake for allowlist json instead.  If you did not provide a valid password, please make sure to update and run again.zFile 'z/' for connection test allowlist does not exist.zRselect /* snowflake-connector-python:connection_diagnostics */ system$allowlist();zocsp.z&select system$allowlist_privatelink();zocsp.snowflakecomputing.F)use_pooling)(accounthosttest_results%_ConnectionDiagnostic__append_messager   splitloggerwarning	ocsp_urlscrl_urls	cert_info
proxy_type
proxy_host
proxy_port
proxy_userproxy_passwordosgetenvr	   "_ConnectionDiagnostic__parse_proxy(_ConnectionDiagnostic__https_host_reportr   full_connection_diag_log_path#full_connection_diag_allowlist_pathtempfile
gettempdirtmpdiris_absoluteexistsreport_fileinfoallowlist_sql%_ConnectionDiagnostic__is_privatelinkappendallowlist_retrieval_successcursorcloner   get_manager_session_manager)selfr>   r?   connection_diag_log_pathconnection_diag_allowlist_pathrI   rJ   rK   rL   session_manager	host_typetop_level_domain	proxy_urls                r   __init__zConnectionDiagnostic.__init__?   sY    	 %'3
 	i+H)WX:499+F	
 B$G !!56F5GHDIIU 

Q/06:1=!DTCU@VV I NN=>N=OOdeidj k. / !!78H7IIg99+ DI$&#%46'$$$,??"		-0I+DO"W-I&DO y)	
OOO  + (3 )* 	* .9 /0 	0
 $..0--515dkk1BD.55AACD>>??de 6:$++5F277>>@D>>??cd 6:$++5F2 ..1TT 	 	()9)9(:;<33?;;GGITEEFFvw J <@8==DDFTEEFFuv J <@8 a 	   "NN!!E$))"56!IDNN!!$<=M<N"OP16(.2
  !!e!4 	 '22uE 	r    c                    t        |      }|j                  }|j                  }|j                  }|j                  }||||fS r   )r   hostnameportusernamepassword)rb   rh   parsedrI   rJ   rK   rL   s          r   __parse_proxyz"ConnectionDiagnostic.__parse_proxy   s?    )$__
[[
__
:z>AAr    c           	        	 | j                  ||       d}t        j                  t        j                  t        j                        }|j	                  |       | j
                  | j
                  | j                  f}| j                  d| j                   d| j                   }|j                  d      }t        j                  |      j                         j                  d      }	d|	 d}|j                  |       n|j                  |t        |      f       |dk(  rW| j
                  Wd	| d| d
| }
|
 d| d}
|j!                  t"        j                  |
             |j%                  d      j                  d       t'        j(                  t&        j*                        }|j-                  t/        j0                                t3        t&        dd      }|r!t5        |d      r|xj6                  |z  c_        |j9                  ||      }t'        j:                  |j=                  d            }d| d| d| d}	 |j!                  t"        j                  |             |jC                          |S | j
                  d	| d| d
| d}
nd| d}
|j!                  t"        j                  |
             |j%                  d      j                  d      }|jC                          |3d}tE        jF                  ||      s| jA                  || d| d|        y| jA                  || d| d       y# t>        $ r$}| jA                  || d| d|        Y d }~d }~ww xY w# t&        jH                  $ r1}dt#        |      v r| jA                  || d| d|        Y d }~yd }~wt>        $ r$}| jA                  || d| d|        Y d }~yd }~ww xY w) N)rf    :utf-8
zProxy-Authorization: Basic z
  zCONNECT z HTTP/1.1
zHost: z

i   VERIFY_X509_PARTIAL_CHAINr   verify_flags)server_hostnameTzGET / z5 HTTP/1.1

                                   Host: z

                                   User-Agent: snowflake-connector-python-diagnostic
                                   

z(: URL Check: Failed: Unknown Exception: zGET / HTTP/1.1
Host: z
Connection: close

z(200|301|cloudfront)z: URL Check: Failed: FAILED#: URL Check: Connected SuccessfullySUCCESSWRONG_VERSION_NUMBERz': URL Check: Failed: Proxy Auth Error: )%_ConnectionDiagnostic__list_ipssocketAF_INETSOCK_STREAM
settimeoutrI   rJ   rK   rL   encodebase64	b64encoder   stripconnectintsendstrrecvssl
SSLContextPROTOCOL_TLS_CLIENTload_verify_locationscertifiwheregetattrhasattrrx   wrap_socketDER_cert_to_PEM_certgetpeercert	ExceptionrA   closeresearchSSLError)rb   r?   rl   timeoutrf   connect_credsconn
proxy_addr
proxy_authcredentialsr   context_partial_flagsockcertificatehttp_requesteresponsegood_responsess                      r   __test_socket_get_certz+ConnectionDiagnostic.__test_socket_get_cert   s   P	OODIO6!#M==1C1CDDOOG$*"oot?
??.$(OO#4Ad6I6I5J!KJ!+!2!27!;J"("2"2:">"E"E"G"M"Md"SK&A+d$SMZ(dCI./s{??. (av]=/RG!(	vX>GIIcjj12IIdO**73..)@)@A--gmmo> '-H! L WWn%E((M9(**4*F!66t7G7G7MN#)$q 7**. 0, /IIcjj67 

""??."4&$}]O8T 
 34&8UV  		#**W-.99T?11':

#!7yy:))!dV1TF2Gz#R $!!dV1TF*MN ? ! ))!&$'OPQsS @ || 	%Q/%%fAdV#J1#N  	!!dV1TF*RSTRUV 		s[   I M* $L: 'M* 9B'M* !M* :	M'M"M* "M''M* *O='N))O5OOc           	     8   d }| j                   n| j                  	 | j                  j                  | j                  d      j	                         d   d   }t        j                  t        |            }d| _        n2t        | j                         }	 t        j                  |      }d| _        t        |      rY|D ]S  }|d	   }|d
   }|d   }|dv r$|| j                   vs%| j#                  |||       :|dv s?	 | j%                  |||       U y | j                  dd       y # t        $ r"}t        j                  d|        Y d }~d }~ww xY w# t        $ r-}| j                  dd| d| j                    d       Y d }~d }~ww xY w# t        $ r Y w xY w)NT)_is_internalr   z*Unable to do allowlist checks: exception: r0   zAllowlist was not valid json: 'zB'.  Please run 'select system$allowlist();' and validate the file z is correct.typer?   rl   r4   rl   rf   )r3   r5   zAllowlist is not a valid list of json objects. Please run 'select system$allowlist();' and provide as a json file using the connection_diag_allowlist_path option.)rR   r^   executerZ   fetchallr(   loadsr   r]   r   rC   rD   openloadrA   r,   rE   +_ConnectionDiagnostic__test_socket_get_certrP   )rb   resultsr   results_filer   rf   r?   	host_ports           r   run_post_testz"ConnectionDiagnostic.run_post_test1  s   !33;{{&U"kk11** 2 hj$$%'G #jjW6G7;D4   H HIL))L1370 $G,! "6N	f~"6N	!124>>133 yI 4  "DD00 yI 1 $ !! uC ! UNN%OPQs#STTU  %%5aS8z{  |d  |d  {e  eq  r . % sB   A D& E <F&	E/EE	F
#FF
	FFc                    d| j                   v S )Nprivatelink)r?   )rb   s    r   __is_privatelinkz%ConnectionDiagnostic.__is_privatelinka  s    		))r    c                   	 t        j                  |      d   }| d}d|v r|D ]  }t        j                  |      j                  r*| j                         r3| j                  || d| d       L| j                         r| j                  || d| d       u| j                  || d|         y | j                  || d|        y # t        $ r"}t        j                  d	|        Y d }~y d }~ww xY w)
N   z: nslookup resultssnowflakecomputingz: private ip: z<: WARNING: this is not typical for a non-privatelink accountz: public ip: z7: WARNING: privatelink accounts must have a private ip.: z)Connectivity Test Exception in list_ips: )
r   gethostbyname_ex	ipaddress
ip_address
is_privater[   rA   r   rC   rD   )rb   r?   rf   ipsbase_messageipr   s          r   
__list_ipszConnectionDiagnostic.__list_ipsd  s%   	L))$/2C"V#56L#t+ B ++B/::#446 11 )#/.rd CH !I  002 11 )#/.bT B: !; !11 )l^=+M!( %%iL>C51IJ 	LNNFqcJKK	Ls%   AC AC 4C 	C7C22C7c                   	 | j                  |||      }d|v rt        j                  j                  t        j                  j                  |      t        j                         j                               t        j                         j                               j                         j                         t        j                  t        j                         j                  d            d      t        j                  t        j!                         j                  d            d      d}|| j"                  |<   fdt%        j'                               D        }i }|D ]-  }t        |      ||j)                         j                  d      <   / |j+                  d      \  }	}	}
|
t        |d         v r| j-                  || d	| d
       nEd|v rA|
t        |d         v r| j-                  || d	| d
       n| j-                  || d	| d       | j-                  || d       t/        |d         }| j-                  || d|        t/        |d         }| j-                  || d|        | j-                  || d|d           | j-                  || d|d           | j-                  || d|d           | j-                  || d|d           |dk(  rd|v rNt1        j2                  d|d         }|D ]/  }| j4                  j7                  |j9                  d      d          1 n| j-                  dd       d |v rNt1        j2                  d|d          }|D ]/  }| j:                  j7                  |j9                  d      d          1 n| j-                  d!d"       d|v r| j-                  || d#|d           | j-                  || d$| j:                          | j-                  || d%| j4                          y y # t<        $ r"}t>        jA                  d&|        Y d }~y d }~ww xY w)'Nr   zBEGIN CERTIFICATErt   z%Y%m%d%H%M%SZ)subjectissuerserialNumberversion	notBeforenotAfterc              3  @   K   | ]  }j                  |        y wr   )get_extension)r#   ix509s     r   r%   z;ConnectionDiagnostic.__https_host_report.<locals>.<genexpr>  s!      ./D&&q)s   r7   r   rs   r{   subjectAltNamezK: URL Check: Failed: Certificate mismatch: Host not in subject or alt namesz: Cert info:z: subject: r   z
: issuer: z: serialNumber: r   z: version: r   z: notBefore: r   z: notAfter: r   r2   authorityInfoAccessz(https?://\S+)/r   r0   z(Unable to find ocsp URLs in certificate.crlDistributionPointsr6   z'Unable to find crl URLs in certificate.z: subjectAltName: z: crlUrls: z: ocspURLs: z2Connectivity Test Exception in https_host_report: )!r   OpenSSLcryptoload_certificateFILETYPE_PEMr   get_subjectget_components
get_issuerget_serial_numberget_versionr   strptimer   get_notBeforer   get_notAfterrG   rangeget_extension_countget_short_name	partitionrA   r   r   findallrE   r\   rB   rF   r   rC   rD   )rb   r?   rl   rf   r   r   
extensionsextension_datar   _host_suffixsubject_str
issuer_strocsp_urls_origurlcrl_urls_origr   s                   @r   __https_host_reportz(ConnectionDiagnostic.__https_host_report  s   b	U5549 6 K #k1~~66NN//
  $D$4$4$6$E$E$GH"4??#4#C#C#EF$($:$:$<#//1!)!2!2D..077@A?" !) 1 1D--/66w?@/! (.t$389Q9Q9S3T
 "$# PAILQN1#3#3#5#<#<W#EFP %)NN3$7!1k#fY&7"88))!dV1TF2U#V &7"c.9I*J&KK--%#fAdV+NO
 --%#fAdV+vw %%iD61FG*6)+<=%%iD6[M1RS)&*:;
%%iD6J<1PQ%%$'7~8N7OP %%${6)3D2EF %%$}VK5H4IJ %%$|F:4F3GH /,>)+-~>S/T* $2 EC NN11#))C.2CDE --%'Q /.@(*

-~>U/V) $1 DC MM0031BCD --$&O $~5))!& 2>BR3S2TU
 %%iD6T]]O1TU%%iD6dnnEU1VWw 2z  	UNNOPQsSTT	Us   PP 	Q P;;Q c           	         t        j                  ddt        j                  t	        |                  j                  dd      j                  dd      }|S )Nz[{}"]rr   r   =,;)r   subr(   r)   r   replace)rb   r   r   s      r   __get_issuer_stringz(ConnectionDiagnostic.__get_issuer_string  sE    FF7B

<+? @AWT3WS# 	
 r    c                J    | j                   |   j                  | d|        y )Nr   )r@   r\   )rb   rf   messages      r   __append_messagez%ConnectionDiagnostic.__append_message  s&    )$++ykG9,EFr    c           	        i }d}g }|D ]g  }|t         j                  j                         v s$t         j                  j                  |      ||<   t         j                  |= |j	                  |       i d}t               }| j                  |d|        d|j                         v rS| j                  t               d         \  }}}	}
|	d|	 d|
 d| d| }nd| d| }| j                  |d| d	| d
       |D ]  }||   t         j                  |<    | j                  |dt                       d}ddj                  |       d}| j                  | j                  j                         v rf| j                  | j                  | j                     d         }t        j                  ||      s%| j                  |d| j                   d| d|        d}| j                  |dd       || j                  j                         v rR| j                  | j                  |   d         }t        j                  ||      s| j                  |d| d| d|        t        r d}ddg}|D ]  }| j!                  |||        	 t#        j$                          ddd}| j&                  g| j(                  7d| j(                   d| j*                   d| j&                   d| j,                   }nd| j&                   d| j,                   }||d|d<    | j.                  j                  	 d(d di|}d!|j0                  v r| j                  |d"       y y # t2        $ ro}d#t5        |      v r| j                  |d$|        nBd%t5        |      v r| j                  |d&|        n| j                  |d'|        Y d }~y Y d }~y Y d }~y d }~ww xY w))N)
HTTP_PROXYr9   https_proxy
http_proxyr1   z/Proxies with Env vars removed(SYSTEM PROXIES): r;   http://rs   @zIf there are failures, try using the SYSTEM PROXY: On Windows, do
                                                 "set HTTPS_PROXY='z]'".  On Linux/Mac, do
                                                  "export HTTPS_PROXY='z'" z-Proxies with Env vars restored(ENV PROXIES): )z!C=US; O=Google Trust Services LLCzC=US; O=AmazonzC=US; O=DigiCert Incz(^z|^)r   z/There is likely a proxy because the issuer for z is not correct. Got z and expected one of zwww.google.comrv   r6   r   z)Software\Microsoft\Windows\CurrentVersionHKEY_CURRENT_USERHKEY_LOCAL_MACHINE
   F)r   verify)httpr;   proxiesr=   zdoes not existz5It is likely there is a proxy based on HTTP response.NewConnectionErrorzfProxy check using invalid URL did not show proxy: Review result, but you can probably ignore: Result: 
ProxyErrorz2It is likely there is a proxy based on Exception: zJCould not determine if a proxy does or does not exist based on Exception: )z!https://nonexistentdomain.invalid)rM   environkeysgetr\   r	   rA   rO   joinr?   rG   (_ConnectionDiagnostic__get_issuer_stringr   r   rP   r   (_ConnectionDiagnostic__walk_win_registryr   disable_warningsrI   rK   rL   rJ   ra   textr   r   )rb   env_proxy_backup
proxy_keysrestore_keys	proxy_keyrf   system_proxiesrI   rJ   rK   rL   proxy_url_examplerestore_keycert_authoritiescheck_patternr   	test_hostregistry_start_keyhkey_stringshkey_strrequest_kwargsrh   respr   s                           r   __check_for_proxiesz(ConnectionDiagnostic.__check_for_proxies  sr    ,.O
# 	/IBJJOO--.0jjnnY.G +JJy)##I.		/ 	#=n=MN	

 n))++AEASASW%B>J
J %j\>*:!J<qU " '.j\:,$G!!!DDUCV WHHYGZZ]a ( 	DK&6{&CBJJ{#	D 	Fz|nU	

 TYY'789;99++----dnnTYY.G.QRF99]F3%%Edii[ Q((.x/DEUDVX %	   I++----dnnY.G.QRF99]F3%%Ei[ Q((.x/DEUDVX !O/1EFL( R((H>PQR-	$$& N *??.")$//):!D<O<O;PPQRVRaRaQbbcdhdsdsct uI")$//):!DOO;L MI5>,Sy),4((,,3AFJXD
  499,%%K -
  	#s1v-%%<<=3@
 Q'%%!STUSVW %%`ab`cd 		s   CM 	OAOOc                    | j                          t        t        | j                              | _        | j                  D ]  }| j	                  |dd        y )NP   r4   r   )(_ConnectionDiagnostic__check_for_proxiesr&   setrE   r   )rb   r   s     r   run_testzConnectionDiagnostic.run_testq  sN      "c$..12>> 	RC''"@P'Q	Rr    c                   d}dj                  | j                  d         }| d| d}dj                  | j                  d         }| d| d}dj                  | j                  d         }| d| d}| j                  r'dj                  | j                  d         }| d	| d}n| d
}| d}dj                  | j                  d         }| j                  r| d}n| d}| d| d}| j                  r&dj                  | j                  d         }| d| d}t        j	                  |       | j
                  j                  |       y )NzG=========Connectivity diagnostic report================================ru   r0   r1   zI
=========Proxy information - These are best guesses, not guarantees====
r2   zI
=========Snowflake URL information=====================================
r3   zt
=========Snowflake Stage information===================================
We retrieved stage info from the allowlist
z
=========Snowflake Stage information - Unavailable=====================
We could not connect to Snowflake to get allowlist, so we do not have stage
diagnostic info
zH
=========Snowflake OCSP information====================================r4   zi
We were able to retrieve system allowlist.
These OCSP hosts came from the certificate and the allowlist.z^
We were unable to retrieve system allowlist.
These OCSP hosts only came from the certificate.r5   zI
=========Snowflake Out of bound telemetry check========================
)r  r@   r]   rC   debugrX   
write_text)rb   r   initial_joined_resultsproxy_joined_resultssnowflake_url_joined_resultssnowflake_stage_joined_resultssnowflake_ocsp_joined_results"snowflake_telemetry_joined_resultss           r   generate_reportz$ConnectionDiagnostic.generate_reportw  s   U 	 "&4+<+<Y+G!HIR$:#;2>#yy):):7)CDi X#$B( 	 (,yy1B1B?1S'T$i X+,B0 	 ++-1YYt7H7H7Q-R*) ? 22"6  ) $ %  i V V 	 )-		$2C2CDT2U(V%++) P P  ) C C 
 IR$A#B"E++15!!"9:2. ) \56b:  	W##G,r    c                |    i }d}	 	 t        j                  ||      }|dd ||d   <   |dz   }(# t        $ r Y |S w xY w)z%Gets values from windows registry keyr   r
   N)winreg	EnumValueOSError)rb   registry_keyregistry_key_valuesr   registry_key_values        r   __get_win_registry_valuesz.ConnectionDiagnostic.__get_win_registry_values  sm    $&%+%5%5lA%F" :LAB9O 21 56AA    #"	s   . 	;;c           	     f   |dk(  rt         j                  }n|dk(  rt         j                  }nd}t        j                  ||      }d}|	 	 t        j                  ||      }|dz   }|rt
        j                  j                  ||      }dt        |      j                         v sdt        |      j                         v r>t        j                  ||dt         j                        }	| j                  |	      }
d|
j                         v ri|
d   d   }| j                  |d	| d
| d|        d| d}	 | j                  j                  |d      }|j                   }| j                  |d|        nd|
j                         v r$|
d   d   }| j                  |d| d
| d|        nVd|
j                         v r)|
d   d   }|dk(  r7| j                  |d| d
| d|        n| j                  |d| d
| d|
        | j%                  |||       y# t"        $ r Y !w xY w# t&        $ r Y yw xY w)z@Walks the windows registry to search for key relating to proxiesr  r  Nr   r
   zinternet settingswpadAutoConfigURLziThere may be a proxy: Found a Wpad in Windows registry: Check proxy config for auto detect script: hkey: z : z	 : wpad: r   z	/wpad.datr  )r   z&Wpad request returned possible proxy: ProxyServerzFThere may be a proxy: Found a proxy server in Windows registry: hkey: z : ProxyServer: ProxyEnablez?There may be a proxy: Proxy is enabled per the registry: hkey: z : ProxyEnable: zCFound Wpad key in registry: Most likely nothing, but review: hkey: z	: value: )r3  r  r  OpenKeyEnumKeyrM   pathr  r   lowerKEY_READ._ConnectionDiagnostic__get_win_registry_valuesr  rA   ra   r  r  r   r  r5  )rb   rf   r  registry_key_strhkeyregistryr   r6  new_registry_key_strnew_registry_keyvaluesr;  r   r!  
proxy_infoproxyproxy_enables                    r   __walk_win_registryz(ConnectionDiagnostic.__walk_win_registry  s    **++D--,,DD>>$(89B#)>>(A#>LAA#/1ww||,l0, 03|3D3J3J3LL%\):)@)@)BB/5~~ $&:Av0, &*%C%CDT%UF.&++-?'-o'>q'A $ 5 5$-'55=JcBVAW X--1F%4!" )0vY&?!)+/+@+@+D+DSRT+D+UD15J$($9$9(1*PQ[P\(]%& "/&++-!?(.}(=a(@ $ 5 5$-'??Cf E((<'==MeW%V!" "/&++-!?/5m/DQ/G#/1#4$($9$9(1+;;?&DXCY*:<.)J%& !% 5 5$-'99A
#';&<IfX%O!" 00%x1E{  F (1 !)$(!)>  s8   C(H$ 4>H 2B"H$ 	H!H$  H!!H$ $	H0/H0)NNNNNNN)r>   r   r?   r   rc   
str | Nonerd   rO  rI   rO  rJ   rO  rK   rO  rL   rO  re   zSessionManager | NonereturnNone)rh   r   rP  ztuple[str, str, str, str])rv   r  r2   )
r?   r   rl   r   r   r   rf   r   rP  r   )rP  rQ  )rP  bool)r2   )r?   r   rf   r   rP  rQ  )rv   r2   )r?   r   rl   r   rf   r   rP  rQ  )r   zdict[bytes, bytes]rP  r   )rf   r   r   r   rP  rQ  )r6  r   rP  zdict[str, str])rf   r   r  r   rE  r   rP  rQ  )__name__
__module____qualname____doc__ri   rO   r   r   r[   r~   rP   r  rA   r%  r'  r1  rD  r   r    r   r.   r.   9   ss    0459!%!%!%%)15J
J
 J
 #-	J

 )3J
 J
 J
 J
 #J
 /J
 
J
XB (\\ \ 	\
 \ 
\|.`*L< <KeUeU"eU58eU	eUNG||RC-J#PP(+P?BP	Pr    r.   )r   zdict[str, dict[str, Any]])r+   zlist[dict[str, Any]])(
__future__r   r   r   r(   rM   r   r   r   rS   r   loggingr   pathlibr   typingr   r   urllib.requestr	   r   r   compatr   r   r^   r   re   r   r   url_utilr   vendoredr   rS  rC   r3  r   r,   r.   rW  r    r   <module>r`     sj    "    	 	  
      %   ( # B < 	8	
	` `r    