Wcߑcs* ddlZddlTddlZddlZddlZddlZddlmZmZ ddlZe eddZ e eddZ e eddZ gd Zejej eej"d ed ej"d ed ej"dedej"deddZdZdZej,j/j1driZded<ded<ded<ded<ded<d ed!<d"ed#<d$ed%<d&ed'<d(ed)<d*ed+<d,ed-<d.ed/<d0ed1<d2ed3<d4ed5<d6ed7<d8ed9<d:ed;<ded?<d@edA<dBedC<dDedE<dFedG<dHedI<dJedK<dLedM<dNedO<dPedQ<dRedS<dTedU<dVedW<dXedY<dZed[<d\ed]<d^ed_<d`eda<dbedc<ddede<dfedg<dhedi<djedk<dledm<dnedo<dpedq<dreds<dtedu<dvedw<dxedy<dzed{<d|ed}<d~ed<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ej5dҫGdӄdeZGdՄdej:ZddׄZeej:dثrddl Z ddلZ!ej5dګeej:d۫rddl Z dd܄Z"ej5dݫeej:dޫrd߄Z#ej5deedrde$dfdZ%ne&e$dfdZ%ej5dde%_'e e hZ(GddejRZ*ddZ+e,Z-e-dfdddZ.dZ/e&dddddZ0ddZ1dS#e $rdZYwxYw)N)Z*)IntEnumIntFlagEBADFi EAGAINi EWOULDBLOCK)fromfdgetfqdncreate_connection create_serverhas_dualstack_ipv6 AddressFamily SocketKindr cH|jo|jdS)NZAF_Zisupper startswithZC /usr/lib64/python3.12/socket.pyrO!))+5!,,u"5r cr )NZSOCK_rrrrrrTs!))+7!,,w"7rZMsgFlagcr )NZMSG_rrrrrrYs!))+6!,,v"6rZ AddressInfocr )NZAI_rrrrrr^rrz 127.0.0.1z::1cs< ||S#t$r|cYSwxYwN) ValueError)ZvalueZ enum_klass r_intenum_converterrds=z%   s  Zwinz)Specified event object handle is invalid.izInsufficient memory available.iz#One or more parameters are invalid.iWzOverlapped operation aborted.iz2Overlapped I/O event object not in signaled state.iz)Overlapped operation will complete later.izThe operation was interrupted.i'zA bad file handle was passed.i'zPermission denied.i'z!A fault occurred on the network??i'z#An invalid operation was attempted.i&'zToo many open files.i('z!The socket operation would block.i3'z,A blocking operation is already in progress.i4'zOperation already in progress.i5'zSocket operation on nonsocket.i6'zDestination address required.i7'zMessage too long.i8'zProtocol wrong type for socket.i9'zBad protocol option.i:'zProtocol not supported.i;'zSocket type not supported.i<'zOperation not supported.i='zProtocol family not supported.i>'z0Address family not supported by protocol family.i?'zThe network address is in use.i@'z Cannot assign requested address.iA'zNetwork is down.iB'zNetwork is unreachable.iC'z$Network dropped connection on reset.iD'z!Software caused connection abort.iE'zThe connection has been reset.iF'zNo buffer space available.iG'zSocket is already connected.iH'zSocket is not connected.iI'zThe network has been shut down.iJ'zToo many references.iK'zThe operation timed out.iL'zConnection refused.iM'zCannot translate name.iN'zThe name is too long.iO'zThe host is down.iP'zThe host is unreachable.iQ'zDirectory not empty.iR'zToo many processes.iS'zUser quota exceeded.iT'zDisk quota exceeded.iU'zStale file handle reference.iV'zItem is remote.iW'z!Network subsystem is unavailable.ik'z!Winsock.dll version out of range.il'z(Successful WSAStartup not yet performed.im'zGraceful shutdown in progress.iu'z*No more results from WSALookupServiceNext.iv'zCall has been canceled.iw'z Procedure call table is invalid.ix'zService provider is invalid.iy'z&Service provider failed to initialize.iz'zSystem call failure.i{'zService not found.i|'zClass type not found.i}'i~'zCall was canceled.i'zDatabase query was refused.i'zHost not found.i*z Nonauthoritative host not found.i*zThis is a nonrecoverable error.i*z*Valid name, no data record requested type.i*zQoS receivers.i*z QoS senders.i*zNo QoS senders.i*zQoS no receivers.i+zQoS request confirmed.i+zQoS admission error.i+zQoS policy failure.i+zQoS bad style.i+zQoS bad object.i+zQoS traffic control error.i+zQoS generic error.i+zQoS service type error.i+zQoS flowspec error.i +zInvalid QoS provider buffer.i +zInvalid QoS filter style.i +i +zIncorrect QoS filter count.i +zInvalid QoS object length.i+zIncorrect QoS flow count.i+zUnrecognized QoS object.i+zInvalid QoS policy object.i+zInvalid QoS flow descriptor.i+z'Invalid QoS provider-specific flowspec.i+z)Invalid QoS provider-specific filterspec.i+z&Invalid QoS shape discard mode object.i+z Invalid QoS shaping rate object.i+z!Reserved policy QoS element type.i+errorTabcseZdZdS)_GiveupOnSendfileN)__name__ __module__ __qualname__rrrrsrrcsNeZdZ gdZd"dZdZdZdZdZd Z d Z d#dddd d Z e e drd$dZnd$dZd$dZdZd$dZdZej(fdZdZfdZefdZefdZe j6dkrdZdZndZdZd e_d!e_xZS)%socket)Z __weakref___io_refs_closedNcs|"|dkrt}|dkrt}|dkrd}tjj |||||d|_d|_dS)Nr#rF)AF_INET SOCK_STREAM_socketr __init__r!r")selffamilytypeprotofileno rr'zsocket.__init__sb >|| rzz"{{fdE6BB  rcs|Srrr(rr __enter__zsocket.__enter__s rcsD|js|jdSdSr)r"close)r(Zargsrr__exit__zsocket.__exit__s!||| JJLLLL|rcs t|dd}d|jj|jj|rdnd|j |j |j |jfz}|sN |j}|r|dt|zz } |j}|r|dt|zz }|dz }|S#ttf$rYAwxYw#ttf$rY1wxYw) Nr"Fz,<%s.%s%s fd=%i, family=%s, type=%s, proto=%iz [closed]z , laddr=%sz , raddr=%sz>) getattr __class__rrr,r)r*r+ getsocknameZstrerrorAttributeErrorZ getpeername)r(closedZsZladdrZraddrr-r__repr__zsocket.__repr__s$ y%0 :~~((~~**$f{{"{{}{{yyzz  v ((*5E 22A ((*5E 22A S>*     >*    s$9&C &C$ C! C!$C87C8csLtd|jjd)Nzcannot pickle z object) TypeErrorr4rr.rr __getstate__zsocket.__getstate__s#K)@)@KKKLLrcs t|j}|j|j|j|j |}|j |j|S)Nr,)dupr,r4r)r*r+ settimeout gettimeout)r(fdsock rr=z socket.dupsV  ~~dkk499djj~L )** rcs |j\}}t|j|j|j|}t #|j r|jd||fS)Nr<T)Z_acceptr r)r*r+Zgetdefaulttimeoutr? setblocking)r(r@addrrA racceptz socket.accept si <<>Ddkk499djjDD   &4??+<+<   T " "Tzrr)encodingerrorsnewlinecsR t|hdkstd|dd|v}d|vp| }d|v}d} |r| dz } |r| dz } t|| } |xjdz c_|d }|d krtj }|d kr|s td | S|r|rt j | | |} n3|rt j| |} nt j| |} |r| St j|}t j| |||} || _ | S) N>brGwz invalid mode z (only r, w, b allowed)rLrGrKr2r#rz!unbuffered streams must be binary) ZsetrSocketIOr!ioZDEFAULT_BUFFER_SIZEZBufferedRWPairZBufferedReaderZBufferedWriterZ text_encodingZ TextIOWrappermode) r(rPZ bufferingrHrIrJZwritingZreadingZbinaryZrawmodeZrawZbufferZtexts rmakefilezsocket.makefile0sW 4yOOO++*OP P++,W 7 sNG 7 sNGtW%   I q==..I >>6 !DEEJ 7ww&&sC;FF W&&sI6FF&&sI6F 6M##H-&'B  rsendfilercsv|j||||j} |j} t j|j}|sdSt|p|d}|j} | dkr tdttdrtj} ntj } | j#|tj$d} | j&} t j(} | r| | s t+d|r || z }|dkrn | ||||}|dkrn ||z }| |z } E| | dkr"t|dr|j/|SSS#ttjf$r}t |d}~wwxYw#t$r}t |d}~wwxYw#t,$r | s| Yt$r}| dkr t ||dd}~wwxYw#| dkr t|dr|j/|wxYw)Nri@&non-blocking sockets are not supported PollSelectorTz timed outseek)_check_sendfile_paramsr,r7rOZUnsupportedOperationrosZfstatZst_sizeOSErrorminr?rhasattr selectorsrTZSelectSelectorZregisterZ EVENT_WRITEZselectrRZ TimeoutErrorBlockingIOErrorrU)r(fileoffsetcountZsocknor,errZfsize blocksizetimeoutZselector total_sentZselector_selectZ os_sendfilesent r_sendfile_use_sendfilesocket._sendfile_use_sendfile]s  ' 'fe < <[[]F - -(005qENUG4Ioo'G!|| !IJJy.11$113$335   fi&;&; < <J&ooO++K &ww'?'?*;77u$)J$6 $>>!+*{6669M  199!$"d* 78">>gdF&;&;IIf%%%'<>s#B$;$;< - - -',, - - - -',, -@+!!!&w,O-- ",,,%?? #4C"88!t+,>>gdF&;&;IIf%%&&&&sjF!F4'H< GHF1 F,,F14 G> G  GH 'H) H 2HH  H(H8cstd)Nz,os.sendfile() not available on this platform)rr(r]r^r_rErrfrgs#>@ @rcs~|j||||jdkr td|r|j||rt |dnd}d}|j }|j } |rt ||z |}|dkrnAt||}|sn* ||} || z }| t|kr|| d}nn([||dkr%t|dr|j||zSSS#t$rYcwxYw#|dkr#t|dr|j||zwxYw)NrrSi TrU) rVr?rrUrYZreadsendZ memoryviewlenr\rZ) r(r]r^r_rarcZ file_readZ sock_sendZdatard r_sendfile_use_sendzsocket._sendfile_use_sends ##D&%88 ??  ! !EF F 6 IIf  (-Ct$$4  II II  /5 #EJ$6 BI A~~!))I"67t "(y#d* #d)++#';DD!&A~~'$"7"7 &:-...#8~+!!! !A~~'$"7"7 &:-.. / / / /s083D, D5 D D D DD+D<cs2dt|ddvr td|jtzs td|Ut |t st dj||dkrtdj|dSdS)NrKrPz$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})r)r3rr*r%Z isinstanceZintr:ZformatrhrErrVzsocket._check_sendfile_paramss gdFC0 0 0CD Dyy;&&JK K  eS))AHHOQQzz AHHOQQz  rcsv |j|||S#t$r|j|||cYSwxYwr)rfrrlrhrErrRzsocket.sendfiles\ " @..tVUC C  @ @ @**4? ? ? ? @s 88cs|jdkr|xjdzc_|jr|jdSdS)NrrM)r!r"r0r.rr_decref_socketioszsocket._decref_socketiossB ==1   MMMQ MM <<< JJLLLL  t|}t||||Sr)r=r )r@r)r*r+Znfdr-rrrs# b'C &$s ++rsendmsgc s |j|tjtjt jd|fgSNZi)rr& SOL_SOCKET SCM_RIGHTSarray)rAZbuffersfdsflagsaddressr-rsend_fdsr)sD ||Gw'9'9    C 5'7&89 9rrrecvmsgc s tjd}|j|tj||jz\}}}}|D]m\}} } |tj ks| tj ks3|j| dt| t| |jzz o|t|||fSr) rrr&ZCMSG_LENZitemsizerrZ frombytesrjZlist) rAZbufsizeZmaxfdsrrmsgZancdatarDZ cmsg_levelZ cmsg_typeZ cmsg_datas rrecv_fdsr5s kk#$(LL   Vcll2 3%5!WeT07 K K ,J 9g0000Y'BTBT5T5T i)II#i.3<<*GHJKKKDIud**rrZsharecs$ tddd|S)Nr)r )Zinforr fromsharerIs aAt$$rr socketpaircs | t}tj|||\}}t ||||j }t ||||j }||fS#t$r t}YqwxYwr)ZAF_UNIXZ NameErrorr$r&rr rp)r)r*r+ZarKr-rrrTs  > ! !!&$61 64 3 64 3!t  ! ! !  !sA**A>=A>cs|tkrt}n |tkrt}n t d|t kr t d|dkr t dt |||} |j|df|j|jdd\}}t |||} |jd |j||f|jd|j\}} |j||fS#ttf$rYOwxYw#|jxYw#|jwxYw)Nz?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportediFT)r$ _LOCALHOSTAF_INET6 _LOCALHOST_V6rr%r bindlistenr5rCconnectr\ZInterruptedErrorrFr0) r)r*r+hostZlsockrDportZcsockZssockZ_rkrrrisz W  DD x   DD-. . ;  HI I A::>? ?vtU+  JJay ! ! LLNN**,Ra0JD$64/E !!%((MM4,//!!$'' <<>qq KKMMu~()9:D   KKMMMMMMsC/A E ;D5D"&D5D2/D51D22D55E  E Ea8socketpair([family[, type[, proto]]]) -> (socket object, socket object) Create a pair of socket objects from the sockets returned by the platform socketpair() function. The arguments are the same as for socket() except the default family is AF_UNIX if defined on the platform; otherwise, the default is AF_INET. csneZdZ dZdZdZdZdZfdZdZ e dZ e d Z d Z xZS) rNcs|dvrtd|ztjj|||_d|vr|dz }||_d|v|_d|v|_d|_dS)N)rGrLZrwZrbZwbZrwbzinvalid mode: %rrKrGrLF) rrO RawIOBaser'_sock_mode_reading_writing_timeout_occurred)r(rArPrBrr'zSocketIO.__init__sx : : :/$67 7 d## d?? CKD t  t  !&rcs0 |j|j|jr td |jj |S#t $r d|_t$r}|jtvrYd}~dSd}~wwxYw)Nz!cannot read from timed out objectT) _checkClosedZ_checkReadablerrXrZ recv_intorbr6errno_blocking_errnosr(rKZerBrreadintozSocketIO.readintos     ! ! !=> > zz++A..   )-&   77...44444 sAB6BBBcs |j|j |jj|S#t$r}|j t vrYd}~dSd}~wwxYwr)rZ_checkWritablerrir6rrrrBrwritezSocketIO.writes~   ::??1% %   ww***ttttt   sA A* A%$A%%A*cN |jr td|jSNzI/O operation on closed socket.)r8rrr.rrreadablezSocketIO.readable& ;;;>? ?}}rcrr)r8rrr.rrwritablezSocketIO.writablerrcsn |jr tdtjSr)r8rroseekablerqrrrrzSocketIO.seekables. ;;;>? ?w!!rcs\ |j|jjSr)rrr,r.rrr,zSocketIO.filenos)  zz  ""rcs@|js|jSdS)Nr#)r8r,r.rrr~z SocketIO.names{{{;;= 2rcs|jSr)rr.rrrPz SocketIO.modes zzrcs |jrdStjj||jj d|_dSr)r8rOrr0rrmr.rrr0zSocketIO.closesJ  ;;; F 4   $$&& r)rrrr'rrrrrr,r}r~rPr0rrrrrNrNs ' ' '. """""###  rrNr2cs |j}|r|dkr t} t|\}}}|jd||D] }d|vs|S|}|S#t$rY|SwxYw)Nz0.0.0.0rz.)ZstripZ gethostnameZ gethostbyaddrZinsertr6)r~ZhostnameZaliasesZipaddrsrErrr s ::rrZclearr6appendr0rjZExceptionGroup)rrbZsource_addressrrrZ exceptionsresafsocktyper+ canonnamesarAZexcrerrr*sd JD$J4q+6-0*HeY "h.D555((~ .)) LL       KKK : : m# !;ZH H 788!   :  ""   c " "           s$A"CD D8D  DD&cs& tr&ttdrttdsdS ttt 5}|j ttd ddddS#1swYdSxYw#t$rYdSwxYw)N IPPROTO_IPV6 IPV6_V6ONLYFrT) has_ipv6rZr&r rr% setsockoptrrr6)rArrr r ]s 87N337M22u Hk * d OOL+q 9 9                  uus/B A5* B5A?:B?B BB)r)backlog reuse_portdualstack_ipv6cs |r ttds td|r1ts td|tkr tdt |t } tjdvr2ttdr |jttd|r|jttdtrp|tkre|r|jtt dnDttd r1ttd r|jtt d |j#|||j)|S|j)||S#t$rYwxYw#t$r0}|j$d |d }t|j&|dd}~wwxYw#t$r|j+wxYw) N SO_REUSEPORTz+SO_REUSEPORT not supported on this platformz-dualstack_ipv6 not supported on this platformz'dualstack_ipv6 requires AF_INET6 family)rtZcygwin SO_REUSEADDRrMrrrz& (while attempting to bind on address z))rZr&rr rr r%rWr~rrrr6rrrrrZstrerrorrrr0)rr)rrrrAr`rs rr r ms"z''>::FGG~!##LM M X  FG G &+ &D' 77* * *00  L!<< : OOJ a 8 8 8(**~ k1===-00G^44 k1== 2 IIg   ? KKMM  KK  -     2 2 2www(C 3'T 1 2   s[+&GF0BGFG/G F GFG G +GG  GG-cs g}tj||||||D]C}|\}} }} } |jt|tt| t || | fE|Sr)r&rrrr r ) rrr)r*r+rZaddrlistrrrrrs rrrs H""4vtUEJ00-0*HeY+B >+HjA 2/ 0 0 0 Or)rr|)r2)rrrr)2r&rWZsysrOr[ZenumrrrZ ImportErrorr3rrrZ__all__ZextendZ_get_exports_listZ _convert_rrrrZplatformZlowerrrrZ Exceptionrr rrZrrrrr%rr$rrrrNrZobjectrrr r rrrrrs.`!!!!!!!!LLL w" " %ge]B/  @ @ @#r##G,--5577 7799 6688 5577   <<""5))H=HQK2HQK8HRL3HSMHHSM?HSM6HUO5HUO*HUO9HUO;HUO,HUO9HUODHUO6HUO6HUO5HUO)HUO7HUO,HUO/HUO2HUO0HUO6HUOHHUO6HUO8HUO(HUO/HUOHUO,HUO*HUO-HUOBHUO*HUO3HUO'HUO8HUO7HUOBHUO&HUO$HUO'HUO)HUO.HUO,HUO+HUO&HUO'HUO2HUO*HUO/HUO+HUO4HUO1HUO1HUO3HUO2HUO1HUO0HUO2HUO4HUO?HUOAHUO>HUO8HUO9HUO NN:)(((( ((DGDGDGDGDGW^^DGDGL ,,,, 77>>9%%LLL9999 NN: 77>>9%%LLL++++" NN: 77>>7##%%% NN; 77L!![*" 1####H NN<   [*rrrrrr||rrj6!&('>%)099>0909090909f    &-du!&BBBBBJm EEEsPPP