ϪfA dZddlmZddlmZGddej ZGddeZGdd ejZ Gd d eZ Gd d ejZ y)z A simple port forwarder. )protocol)logc&eZdZdZdZdZdZdZy)ProxyTNc||_yN)peer)selfr s ?/usr/lib/python3/dist-packages/twisted/protocols/portforward.pysetPeerz Proxy.setPeers  c|j,|jjjd|_y|jrt j d|yy)NzUnable to connect to peer: )r transportloseConnectionnoisyrmsg)r reasons r connectionLostzProxy.connectionLostsI 99 II   . . 0DI ZZ GG1&: ;r cN|jjj|yr)r rwrite)r datas r dataReceivedzProxy.dataReceiveds !!$'r )__name__ __module__ __qualname__rr r rrr r rr s E D<(r rceZdZdZy) ProxyClientcB|jj||jj|jjd|jjj|jd|jjj y)NT)r r rregisterProducerresumeProducing)r s r connectionMadezProxyClient.connectionMade!sj $ '' (;(;TB ,,T^^TB ++-r N)rrrr"rr r rr s .r rc"eZdZeZdZdZdZy)ProxyClientFactoryc||_yr)server)r r&s r setServerzProxyClientFactory.setServer2s  r ctjj|g|i|}|j|j|Sr)r ClientFactory buildProtocolr r&)r argskwprots r r*z ProxyClientFactory.buildProtocol5s7%%33DF4F2F T[[! r cL|jjjyr)r&rr)r connectorrs r clientConnectionFailedz)ProxyClientFactory.clientConnectionFailed:s ,,.r N)rrrrrr'r*r0rr r r$r$/sH /r r$ceZdZeZdZdZy) ProxyServerNc6|jj|j}|j||j ddlm}||_|jj |jj|jj|y)Nr)reactor) rpauseProducingclientProtocolFactoryr'r4twisted.internet connectTCPfactoryhostport)r clientr4s r r"zProxyServer.connectionMadeBsn %%'++- <<  0"DL  1 14<<3D3DfMr )rrrr$r6r4r"rr r r2r2>s.G Nr r2ceZdZdZeZdZy) ProxyFactoryz% Factory for port forwarder. c ||_||_yr)r:r;)r r:r;s r __init__zProxyFactory.__init__Xs  r N)rrr__doc__r2rr@rr r r>r>QsHr r>N) rAr7rtwisted.pythonrProtocolrrr)r$r2Factoryr>rr r rEsb &(H  (& .% . /// /N%N& 8## r