Ë ùÌŽ]÷Πãóª—dZddlZddlZddlZddlZddlZddlZddlmZddl ­ddl ­ddl m Z ddl m Z ejd«ZGd „d e«Zy) zâThis module implements the TFTP Server functionality. Instantiate an instance of the server, and then run the listen() method to listen for client requests. Logging is performed via a standard logging object set in TftpShared.éN)ÚEINTRé)Ú*)ÚTftpPacketFactory)ÚTftpContextServerztftpy.TftpServercó6—eZdZdZ dd„Zdeeefd„Zdd„Z y) Ú TftpServera±This class implements a tftp server object. Run the listen() method to listen for client requests. tftproot is the path to the tftproot directory to serve files from and/or write them to. dyn_file_func is a callable that takes a requested download path that is not present on the file system and must return either a file-like object to read from or None if the path should appear as not found. This permits the serving of dynamic content. upload_open is a callable that is triggered on every upload with the requested destination path and server context. It must either return a file-like object ready for writing or None if the path is invalid.NcóX—d|_d|_d|_tjj |«|_||_||_i|_ tj«|_ d|_ d|_dD]6}t||«}|sŒt!|«rŒt#dj%|««‚tjj'|j «�rFt(j+d|j «tjj-|j «s t#d«‚t(j+d|j z«tj.|j tj0«r#t(j+d|j z«n t#d«‚tj.|j tj2«r#t(j+d |j z«yt(j5d |j z«yt#d «‚) NF)Ú dyn_file_funcÚ upload_openz${} supplied, but it is not callable.ztftproot %s does existz!The tftproot must be a directory.ztftproot %s is a directoryztftproot %s is readablezThe tftproot must be readableztftproot %s is writablezThe tftproot %s is not writablezThe tftproot does not exist.)ÚlistenipÚ listenportÚsockÚosÚpathÚabspathÚrootr r ÚsessionsÚ threadingÚEventÚ is_runningÚshutdown_gracefullyÚshutdown_immediatelyÚgetattrÚcallableÚ TftpExceptionÚformatÚexistsÚlogÚdebugÚisdirÚaccessÚR_OKÚW_OKÚwarning)ÚselfÚtftprootr r ÚnameÚattrs ú5/usr/lib/python3.12/site-packages/tftpy/TftpServer.pyÚ__init__zTftpServer.__init__%s‚€ðˆŒ ؈ŒØˆŒ ä—G‘G—O‘O HÓ-ˆŒ Ø*ˆÔØ&ˆÔðˆŒ ô$Ÿ/™/Ó+ˆŒà#(ˆÔ Ø$)ˆÔ!ã2ˆDܘ4 Ó&ˆDÚœH T�NÜ#Ð$J×$QÑ$QÐRVÓ$WÓXÐXð3ô �7‰7�>‰>˜$Ÿ)™)Õ $Ü �I‰IÐ.°· ± Ô :Ü—7‘7—=‘= §¡Ô+Ü#Ð$GÓHÐHä— ‘ Ð6¸¿¹ÑBÔCÜ—9‘9˜TŸY™Y¬¯©Ô0Ü—I‘IÐ7¸$¿)¹)ÑCÕDä'Ð(GÓHÐHÜ—9‘9˜TŸY™Y¬¯©Ô0Ü—I‘IÐ7¸$¿)¹)ÑCÕDä—K‘KÐ AÀDÇIÁIÑ MÕNäÐ >Ó?Ð ?óÚc ó2—t«}|sd}tjd|›d|›�« tjtjtj «|_|j j||f«|j j«\}|_ |jj«tjd« tjd|jz«tjd|jz«|jr|tj!dt#|j$«z«|j j'«|j$D]}|j$|j)«Œ!g|_�n8|jr=|j$s1tj!d «|j j'«�nïg} | j+|j «|j$D]*}| j+|j$|j «Œ,tjd | « t-j,| gg|«\} } } g} | D�]D}||j k(�rttjd «|j j1t2«\}\}}tjdt#|««|jrtj!d«Œ�|›d|›�}||j$vrutjd|z«t5||||j6|j8|j:|¬«|j$|< |j$|j=|«ntj!d«tjd«tC|j$jE««D]\}}tjd|z«Œ�Œˆ|j$D]™}||j$|j k(sŒ tjd|z« |j$|jG«|j$|jHdk(r&tjd«| j+|«�Œ/tjd«�ŒGtjd«tKjJ«}|j$D]!} |j$|jM|«Œ#tjd«| D�]¤}tjd «tjd!|z«||j$v�rMtjd"«|j$|j)«|j$|jV}|jXd k(rtjd#«nPtjd$|jZ|jXfz«tjd%|j\z«tjd&|j^z«tjd'|j`z«tjd(|z«|j$|=tjd)|j$z«�Œ�tj!d*|z«�Œ§�Œ|jjc«tjd+«d,x|_|_y#tj$r}|‚d}~wwxYw#t,j$r-}|d t.k(rtjd «Yd}~�Œš‚d}~wwxYw#t>$r@}| j+|«tjd|›dtA|«›�«Yd}~�Œd}~wwxYw#t>$r@}| j+|«tjd|›dtA|«›�«Yd}~�Œdd}~wwxYw#tN$�r}tjtA|««|j$|xjPdz c_(|j$|jP|j$|jRk\r7tjd|j$|z«| j+|«nLtjd|j$|z«|j$|jHjU«Yd}~�Œ!d}~wwxYw)-zÌStart a server listening on the supplied interface and port. This defaults to INADDR_ANY (all interfaces) and UDP port 69. You can also supply a different socket timeout value, if desired.z0.0.0.0zServer requested on ip z, port NzStarting receive loop...zshutdown_immediately is %szshutdown_gracefully is %sz$Shutting down now. Session count: %dz4In graceful shutdown mode and all sessions complete.z'Performing select on this inputlist: %srzInterrupted syscall, retryingzData ready on our main socketz Read %d bytesz7Discarding data on main port, in graceful shutdown modeÚ:z0Creating new server context for session key = %s)Úretriesz$Fatal exception thrown from session z: z6received traffic on main socket for existing session??z"Currently handling these sessions:z %szMatched input to session key %szSuccessful transfer.z1Can't find the owner for this packet. Discarding.z-Looping on all sessions to check for timeoutsrz hit max retries on %s, giving upzresending on session %szIterating deletion list.r-zSession %s completez1Gathering up metrics from session before deletingz%Duration too short, rate undeterminedz$Transferred %d bytes in %.2f secondszAverage rate: %.2f kbpsz%.2f bytes in resent dataz%d duplicate packetszDeleting session %szSession list is now %sz/Strange, session %s is not on the deletion listz server returning from while loopF)2rrÚinfoÚsocketÚAF_INETÚ SOCK_DGRAMrÚbindÚ getsocknamerÚerrorrÚsetr rrr%ÚlenrÚcloseÚendÚappendÚselectrÚrecvfromÚ MAX_BLKSIZErrr r ÚstartrÚstrÚlistÚitemsÚcycleÚstateÚtimeÚ checkTimeoutÚ TftpTimeoutÚ retry_countr0Ú resendLastÚmetricsÚdurationÚbytesÚkbpsÚ resent_bytesÚdupcountÚclear)r&r rÚtimeoutr0Ú tftp_factoryÚ_ÚerrÚkeyÚ inputlistÚ readyinputÚ readyoutputÚ readyspecialÚ deletion_listÚ readysockÚbufferÚraddressÚrportÚ session_keyÚsessionÚnowrKs r*ÚlistenzTftpServer.listenOs&€ô )Ó*ˆ ñ I˜Ü �ŠºÁ:ÐNÔOð äŸ ™ ¤f§n¡n´f×6GÑ6GÓHˆDŒIØ �I‰I�N‰N˜H jÐ1Ô 2Ø!%§¡×!6Ñ!6Ó!8Ñ ˆAˆtŒð �‰×ÑÔä �‰Ð+Ô,ØÜ �I‰IÐ2°T×5NÑ5NÑNÔ OÜ �I‰IÐ1°D×4LÑ4LÑLÔ MØ×(Ò(Ü— ‘ ÐBܘTŸ]™]Ó+ñ,ô-à— ‘ —‘Ô!ØŸ=œ=�CØ—M‘M #Ñ&×*Ñ*Õ,ð)à "�” Ùà×)Ò)Ø—}’}Ü—K‘Kð!2ô3à—I‘I—O‘OÔ%ÙðˆIØ × Ñ ˜TŸY™YÔ 'Ø—}”}�Ø× Ñ  §¡¨sÑ!3×!8Ñ!8Õ9ð%ô �I‰IÐ?ÀÔ Kð äŸ ™  i°°R¸ÓAñ6� ˜K¨ðˆMô(� à § ¡ Ó)Ü—I‘IÐ=Ô>Ø04· ± ×0BÑ0BÄ;Ó0OÑ-�FÑ-˜X uä—I‘I˜o¬s°6«{Ô;à×/Ò/ÜŸ ™ ð%=ô>à ò&.©uÐ5�Cà $§-¡-Ñ/ÜŸ ™ ð#8Ø:=ñ#>ô?ä->¸xØ?DØ?FØ?C¿y¹yØ?C×?QÑ?QØ?C×?OÑ?OØGNô .P˜Ÿ ™  cÑ*ðJØ ŸM™M¨#Ñ.×4Ñ4°VÕ<ô Ÿ ™ ð%6ô7ä—H‘HÐAÔBÜ04°T·]±]×5HÑ5HÓ5JÖ0KÑ,˜  WÜŸ™ ¨GÑ!3Õ4ò1Lð $Ÿ}œ}˜Ø$¨¯ © °cÑ(:×(?Ñ(?Ó?ÜŸI™IÐ&GØ"%ñ'&ô'ð =Ø $§ ¡ ¨cÑ 2× 8Ñ 8Ô :Ø#'§=¡=°Ñ#5×#;Ñ#;¸tÒ#CÜ$'§H¡HÐ-CÔ$DØ$1×$8Ñ$8¸Ô$=ò"ð! -ô$Ÿ ™ ð#0ö1ðy(ô~ �I‰IÐEÔ FÜ—)‘)“+ˆCØ—}”}�ð >Ø—M‘M #Ñ&×3Ñ3°CÕ8ð%ô �I‰IÐ0Ô 1Ü$�Ü—‘˜” Ü—‘Ð.°Ñ4Ô5ؘ$Ÿ-™-Ò'Ü—I‘IÐQÔRØ—M‘M #Ñ&×*Ñ*Ô,Ø"Ÿm™m¨CÑ0×8Ñ8�GØ×'Ñ'¨1Ò,ÜŸ™Ð!HÕI䟙Ð!GØ&Ÿ}™}¨g×.>Ñ.>Ð?ñ"@ôA䟙Ð!:¸W¿\¹\Ñ!IÔJÜ—H‘HÐ8¸7×;OÑ;OÑOÔPÜ—H‘HÐ3°g×6FÑ6FÑFÔGÜ—I‘IÐ3°cÑ9Ô:ØŸ ™  cÐ*Ü—I‘IÐ6¸¿¹ÑFÖGä—K‘KØIÈCÑOöQð'%ñsð^ �‰×ÑÔä � ‰ Ð4Ô5Ø?DÐDˆÔ  4Õ#<øôs�|‰|ò àˆIûð ûôJ—<‘<ò Ø�q‘6œU’?ä—I‘IÐ=Ô>Ýàûð  ûôP -òJØ)×0Ñ0°Ô5ÜŸIšIÚ:=¼sÀ3¼xð'I÷JòJûðJûô,$1ò=Ø -× 4Ñ 4°SÔ 9Ü #§ ¢ â-0´#°c´(ð+<÷!=ò!=ûð=ûô"#ó >Ü—I‘Iœc #›hÔ'Ø—M‘M #Ñ&×2Ò2°aÑ7Õ2Ø—}‘} SÑ)×5Ñ5¸¿¹ÀsÑ9K×9SÑ9SÒSÜŸ ™ Ð"DØ ŸM™M¨#Ñ.ñ#/ô0à%×,Ñ,¨SÕ1äŸ ™ Ð";¸d¿m¹mÈCÑ>PÑ"PÔQØŸ ™  cÑ*×0Ñ0×;Ñ;Ô=ÿùð >ús€«A6\É\0Í-]3ÑA^?Ó4` Ü\-Ü&\(Ü(\-Ü0]0Ý!]+Ý*]+Ý+]0Ý3 ^<Ý<5^7Þ7^<Þ? `ß5`à`à dàC6dädcó&—|rd|_yd|_y)a1Stop the server gracefully. Do not take any new transfers, but complete the existing ones. If force is True, drop everything and stop. Note, immediately will not interrupt the select loop, it will happen when the server returns on ready data, or a timeout. ie. SOCK_TIMEOUTTN)rr)r&rbs r*ÚstopzTftpServer.stopús€ñ Ø(,ˆDÕ %à'+ˆDÕ $r,)z /tftpbootNN)F) Ú__name__Ú __module__Ú __qualname__Ú__doc__r+Ú DEF_TFTP_PORTÚ SOCK_TIMEOUTÚDEF_TIMEOUT_RETRIESrcre©r,r*r r s4„ñ Jð &Ø#Ø!ó(@ðT!¨]Ø#Ð-@óiEôV ,r,r )rir2rrFr=rÚloggingÚerrnorÚ TftpSharedÚTftpPacketTypesrÚ TftpContextsrÚ getLoggerrÚ TftpSessionr rmr,r*ÚrusKðñ÷ ÓÛ ÛÛÝÜÜÝ0Ý+à€g×ÑÐ*Ó+€ôn,�õn,r,