MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/libexec/kcare/python/kcarectl/ipv6_support.pyo
�
%��ic@sddlZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
ddlmZe
r�ddlmZndZdZdZejjejd�ZdZdefd��YZe�Zd
�Zd�Zd�Zd�Zd�ZdS(i����Ni(tconfigt	constantst
http_utilst	log_utilstserveridtutils(tjson_loads_nstr(tOptionaliisipv6_preference.jsonii<tIPProtoSelectorcBs/eZd�Zed��Zed��ZRS(cCs�tjrtjd�tStjjd�s=tjd�tStjrWtjd�tSt	�}|dk	r�tjdj|r�dnd��|Sd}|jtj
�s�tjd�t}nJ|jtj�s�tjd�t}n"tj�r
tjd	�t}n|dk	r$t|�|S|jdt�}|jdt�}|tkrjtjd
�t}nl|tkr�tjd�t}nJ|tkr�tjd�t}n(|tkr�tjd
�t}nt}t|�|S(sk
        Choose ipv6 if it is more suitable.
        Checks order:
        - check config values (it is faster) - eportal setup and FORCE_IPVx
        - then check each proto availability using HEAD requests
        - then check if we have server_id, it means we don't expect an ip license
        - and finally we need to check if there is an ip license
        s,decided to use ipv4 because of config valuesskernelcare.coms,decided to use ipv6 because of config valuess%decided to use {0} from on-disk cachetipv6tipv4s1decided to use ipv4 because ipv6 is not availables1decided to use ipv6 because ipv4 is not availables/decided to use ipv4 because server id was founds2decided to use ipv4 because ipv4 license was founds2decided to use ipv6 because ipv6 license was founds8decided to use ipv4 because ipv4 trial license was founds8decided to use ipv6 because ipv6 trial license was foundN(Rt
FORCE_IPV4RtlogdebugtFalsetPATCH_SERVERtendswitht
FORCE_IPV6tTruet_read_cachetNonetformatt_is_url_reachabletPATCH_SERVER_IPV6Rtget_serveridt_write_cachet_get_cln_licensetCLN_VALID_LICENSEtCLN_TRIAL_ACTIVE_LICENSE(tselftcachedtresulttipv4_licensetipv6_license((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pytis_ipv6_preferredsV	

	
	"
	
	
	

	
	
	
	
cCs|tj|dddd�}y'tj|dddtdd�tSWn3tk
rw}tjd	j	|t
|���tSXdS(
NtmethodtHEADtauth_stringttimeouti
tretry_on_500tretry_countis%error during HEAD request to {0}: {1}(Rthttp_requestRturlopenR
Rt	ExceptionRRRtstr(turltrequestte((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyR`scCs�|rtjntj}|d}tjtj|dt�j��}tj	|�}|sl|j
d�r�tjj
dj|��tSyt|d�SWntk
r�tSXdS(Ns/check.plainR&tcodesUnexpected CLN response: {0}(RtREGISTRATION_URL_IPV6tREGISTRATION_URLRtnstrRR)R
treadtdata_as_dicttgetRtkcarelogterrorRtCLN_NO_LICENSEtintt
ValueError(R	tbase_urlR,tcontenttinfo((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyRks
$
(t__name__t
__module__R!tstaticmethodRR(((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyRs	AcCsmtjt�}|sdSyt|�}Wn4ttfk
r_tjdj	|�dt
�dSXt|t�s�tjdj	|�dt
�dS|j
d�}t|t�s�tjdj	|�dt
�dS|j
d�}t|tj�s�t|t�rtjdj	|�dt
�dStj�t|�}|dksL|tkritjd	j	|t��dS|S(
Ns+ipv6 preference cache: malformed json {0!r}t	print_msgs/ipv6 preference cache: unexpected payload {0!r}tprefer_ipv6s3ipv6 preference cache: unexpected prefer_ipv6 {0!r}ttss)ipv6 preference cache: malformed ts {0!r}is;ipv6 preference cache: stale entry (age={0:.0f}s, ttl={1}s)(Rttry_to_readt
CACHE_FILERRR:t	TypeErrorRtlogwarnRR
t
isinstancetdictR5tbooltnumberstIntegralttimeR9tCACHE_TTL_SECONDSR(R<tdataRBt	cached_tstage((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyR�s0"cCsi|d6ttj��d6}y#tjttj|�dt�Wn5tt	fk
rz}t
jdj|�dt
�nXdS(NRBRCt
ensure_dirs*failed to write ipv6 preference cache: {0}RA(R9RMRtatomic_writeREtjsontdumpsRtOSErrortIOErrorRRGRR
(RROR.((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyR�s#cCs)ytjt�Wntk
r$nXdS(s'Drop the on-disk ipv6 preference cache.N(tostunlinkRERV(((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pytclear_cache�s
cCstj�rtjStjS(N(tip_proto_selectorR!RRR(((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pytget_patch_server�scCstj�rtjStjS(N(R[R!RR0R1(((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pytget_registration_url�si�i�Q( RTRKRXRMtRRRRRRtpy23RR
ttypingRRRR8tpathtjointPATCH_CACHERERNtobjectRR[RRRZR\R](((s2/usr/libexec/kcare/python/kcarectl/ipv6_support.pyt<module>s&.b		'