bg/=,dZddlmZddlmZddlmZddlmZddlmZddlZddlTddl Z ddl Z ddl Z ddl Z n #e $rdZ YnwxYwee d d Zee d d Zee d d ZddgZee jeeZe jdrbiZded<ded<ded<ded<ded<ded<ded<ded <d!ed"<d#ed$<d%ed&<d'ed(<d)ed*<d+ed,<d-ed.<ed/Gd0d1ejZd=d2Zeejd3rd4Zeed5rdedfd6Z e!eegZ"Gd7d8e j#Z$d>d:Z%dd;lm&Z&e&dfd<Z'dS)?aThis module provides socket operations and some related functions. On Unix, it supports IP (Internet Protocol) and Unix domain sockets. On other systems, it only supports IP. Functions specific for a socket are available as methods of the socket object. Functions: socket() -- create a new socket object socketpair() -- create a pair of new socket objects [*] fromfd() -- create a socket object from an open file descriptor [*] fromshare() -- create a socket object from data received from socket.share() [*] gethostname() -- return the current hostname gethostbyname() -- map a hostname to its IP number gethostbyaddr() -- map an IP number or hostname to DNS info getservbyname() -- map a service name and a protocol name to a port number getprotobyname() -- map a protocol name (e.g. 'tcp') to a number ntohs(), ntohl() -- convert 16, 32 bit int from network to host byte order htons(), htonl() -- convert 16, 32 bit int from host to network byte order inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89) socket.getdefaulttimeout() -- get the default timeout value socket.setdefaulttimeout() -- set the default timeout value create_connection() -- connects to an address, with an optional timeout and optional source address. [*] not available on all platforms! Special objects: SocketType -- type object for socket objects error -- exception raised for I/O errors has_ipv6 -- boolean value indicating if IPv6 is supported Integer constants: AF_INET, AF_UNIX -- socket domains (first argument to socket() call) SOCK_STREAM, SOCK_DGRAM, SOCK_RAW -- socket types (second argument) Many other constants may be defined; these may be used in calls to the setsockopt() and getsockopt() methods. )unicode_literals)print_function)division)absolute_import)superN)*EBADF EAGAIN EWOULDBLOCKgetfqdncreate_connectionwinzThe 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&'z The socket operation would blocki3'z,A blocking operation is already in progress.i4'zThe network address is in use.i@'zThe connection has been reset.iF'zThe network has been shut down.iJ'zThe operation timed out.iL'zConnection refused.iM'zThe name is too long.iO'zThe host is down.iP'zThe host is unreachable.iQ'errorTabceZdZdZgdZeeddfdZdZdZ dZ d Z d Z d Z dd ZdZejfdZdZfdZxZS)socketz:A subclass of _socket.socket adding the makefile() method.) __weakref___io_refs_closedrNc|#tj||||n#tj|||||d|_d|_dS)NrF)_socketr__init__rr)selffamilytypeprotofilenos h/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/socket.pyrzsocket.__init__csV > N # #D&$ > > > > N # #D&$v F F F  c|SNrs r __enter__zsocket.__enter__ks r c@|js|dSdSr")rclose)rargss r__exit__zsocket.__exit__ns'|  JJLLLLL  r c tj|}|dr;d|jjd|jjt|ddrdpd|dd }|S) z.Wrap __repr__() to reveal the real class name.z socket object Return a new socket object connected to the same system resource. r)duprr1rrr settimeout gettimeout)rfdsocks rr;z socket.dupsY   ~~dk49dj~LL ))*** r c|\}}t|j|j|j|}t )|r|d||fS)zaccept() -> (socket object, address info) Wait for an incoming connection. Return a new socket representing the connection, and the address of the client. For IP sockets, the address info is a pair (hostaddr, port). r:NT)_acceptrrrrgetdefaulttimeoutr= setblocking)rr>addrr?s racceptz socket.acceptsl<<>>Ddk49djDDD    &4??+<+< &   T " " "Tzr rc fd|vr |d}|d=nd}d|vr |d}|d=nd}d|vr |d}|d=nd}|D]}|dvrtdd|v}d|vp| } | s|sJd |v} d } | r| dz } |r| dz } t|| } |xjd z c_|d }|d kr tj}|d kr| std| S| r|rtj| | |} n1| rtj| |} n|sJtj| |} | r| Stj| |||}||_ |S)a makefile(...) -> an I/O stream connected to the socket The arguments are as for io.open() after the filename, except the only mode characters supported are 'r', 'w' and 'b'. The semantics are similar too. (XXX refactor to share code?) newlineNerrorsencoding)rFwbz&invalid mode %r (only r, w, b allowed)rKrFrLr-rz!unbuffered streams must be binary) ValueErrorSocketIOrioDEFAULT_BUFFER_SIZEBufferedRWPairBufferedReaderBufferedWriter TextIOWrappermode)rrW buffering _3to2kwargsrHrIrJcwritingreadingbinaryrawmoderawbuffertexts rmakefilezsocket.makefiles  # #{9/EW;W`KaKag { " "[-BF T\H]H]f  $ $Z1HhkZdNeNeh K KA'' !IJJJ(++,W!'!!!   sNG   sNGtW%%   I q==.I >> F !DEEEJ  7w 7&sC;;FF  7&sI66FFNN7&sI66F  M&'BB  r cv|jdkr|xjdzc_|jr|dSdS)NrrM)rrr'r$s r_decref_socketioszsocket._decref_socketiossD =1   MMQ MM <  JJLLLLL  r c0||dSr")r')r_sss r _real_closezsocket._real_closes $r cVd|_|jdkr|dSdS)NTr)rrrgr$s rr'z socket.closes6 =A            r cRd|_tS)a detach() -> file descriptor Close the socket object without closing the underlying file descriptor. The object cannot be used after this call, but the file descriptor can be reused for other purposes. The file descriptor is returned. T)rrdetachrr1s rrjz socket.detachs  ww~~r )rFN)r3r2 __qualname____doc__ __slots__AF_INET SOCK_STREAMrr%r)r/r8r;rErbrdrrrgr'rj __classcell__r1s@rrr]sDD666I%Kq::: ....` &n          r rcDt|}t||||S)z fromfd(fd, family, type[, proto]) -> socket object Create a socket object from a duplicate of the given file descriptor. The remaining arguments are the same as for socket(). )r;r)r>rrrnfds rfromfdrus# b''C &$s + ++r sharec&tddd|S)z fromshare(info) -> socket object Create a socket object from a the bytes object returned by socket.share(pid). r)r)infos r fromsharerys aAt$$$r socketpairc| t}n#t$r t}YnwxYwtj|||\}}t ||||}t ||||}||fS)aasocketpair([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. )AF_UNIX NameErrorrorrzrrj)rrrarLs rrzrzs > !  ! ! !  !!&$661 64 3 3 64 3 3!t s    cxeZdZdZdZdZdZdZdZfdZ dZ e d Z e d Z d ZxZS) rPzRaw I/O implementation for stream sockets. This class supports the makefile() method on sockets. It provides the raw I/O interface on top of a socket object. c|dvrtd|ztj|||_d|vr|dz }||_d|v|_d|v|_d|_dS)N)rFrKrwrbwbrwbzinvalid mode: %rrLrFrKF) rOrQ RawIOBaser_sock_mode_reading_writing_timeout_occurred)rr?rWs rrzSocketIO.__init__s| : : :/$677 7 d### d?? CKD t  t  !&r c2|||jrtd |j|S#t $r d|_t$r }|jdtvrYd}~dSd}~wwxYw)a3Read up to len(b) bytes into the writable buffer *b* and return the number of bytes read. If the socket is non-blocking and no bytes are available, None is returned. If *b* is non-empty, a 0 return value indicates that the connection was shutdown at the other end. z!cannot read from timed out objectTrN) _checkClosed_checkReadablerIOErrorr recv_intotimeouterrorr(_blocking_errnosrrLes rreadintozSocketIO.readinto)s    ! ?=>> >  z++A...   )-&   6!9 00044444 sAB6BBBc|| |j|S#t$r }|jdt vrYd}~dSd}~wwxYw)aWrite the given bytes or bytearray object *b* to the socket and return the number of bytes written. This can be less than len(b) if not all data could be written. If the socket is non-blocking and no bytes could be written None is returned. rN)r_checkWritablersendrr(rrs rwritezSocketIO.writeBs   :??1%% %   vay,,,ttttt   sA A.A)(A))A.c<|jrtd|jS)z2True if the SocketIO is open for reading. I/O operation on closed socket.)closedrOrr$s rreadablezSocketIO.readableR& ; @>?? ?}r c<|jrtd|jS)z2True if the SocketIO is open for writing. r)rrOrr$s rwritablezSocketIO.writableYrr cp|jrtdtS)z2True if the SocketIO is open for seeking. r)rrOrseekablerks rrzSocketIO.seekable`s5 ; @>?? ?ww!!!r c\||jS)z=Return the file descriptor of the underlying socket. )rrrr$s rrzSocketIO.filenogs* z  """r c<|js|SdS)NrN)rrr$s rnamez SocketIO.namems{ ;;== 2r c|jSr")rr$s rrWz SocketIO.modets zr c|jrdStj||jd|_dS)zClose the SocketIO object. This doesn't close the underlying socket, except if all references to it have disappeared. N)rrQrr'rrdr$s rr'zSocketIO.closexsH ;  F 4    $$&&& r )r3r2rlrmrrrrrrrpropertyrrWr'rqrrs@rrPrP s ' ' '2 """""### X Xr rPr-c|}|r|dkrt} t|\}}}|d||D]}d|vrn |}n#t$rYnwxYw|S)aGet fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname from gethostname() is returned. z0.0.0.0rr,)strip gethostname gethostbyaddrinsertr)rhostnamealiasesipaddrss rrrs ::<rsC))V('''''%%%%%%&&&&&&!!!!!!LLLL EEEw"" " % %ge]B// ) *#r#G,,--- <""5))H6HUO5HUO*HUO9HUO;HUO8HUODHUO6HUO6HUO7HUO0HUO+HUO-HUO)HUO0HUO NN:D D D D D W^D D D L,,,, 77>7##%%%% 77L!![&3 ,--tttttr|tttn6+*****(?%)$9$9$9$9$9$9s;AA