Current Path : /usr/lib/python2.7/dist-packages/twisted/protocols/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyc |
ó [³XMc @ sã d Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l m Z d e j f d „ ƒ YZ d e j f d „ ƒ YZ d e j f d „ ƒ YZ d e j f d „ ƒ YZ d e j f d „ ƒ YZ d S( s) Implementation of the SOCKSv4 protocol. iÿÿÿÿN( t reactort protocolt defer( t logt SOCKSv4Outgoingc B s5 e Z d „ Z d „ Z d „ Z d „ Z d „ Z RS( c C s | | _ d S( N( t socks( t selfR ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyt __init__ s c C sD | j j ƒ } | j j d d d | j d | j ƒ| | j _ d S( NiZ i t portt ip( t transportt getPeerR t makeReplyR t hostt otherConn( R t peer( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyt connectionMade s %c C s | j j j ƒ d S( N( R R t loseConnection( R t reason( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyt connectionLost s c C s | j j | ƒ d S( N( R t write( R t data( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyt dataReceived! s c C s' | j j | | ƒ | j j | ƒ d S( N( R R R R ( R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR $ s ( t __name__t __module__R R R R R ( ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR s t SOCKSv4Incomingc B s, e Z d „ Z d „ Z d „ Z d „ Z RS( c C s | | _ | | j _ d S( N( R R ( R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR , s c C s | j j j ƒ d S( N( R R R ( R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR 0 s c C s | j j | ƒ d S( N( R R ( R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR 3 s c C s' | j j | | ƒ | j j | ƒ d S( N( R R R R ( R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR 6 s ( R R R R R R ( ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR * s t SOCKSv4c B s€ e Z d Z d e d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d d d d „ Z d „ Z d „ Z RS( sË An implementation of the SOCKSv4 protocol. @type logging: C{str} or C{None} @ivar logging: If not C{None}, the name of the logfile to which connection information will be written. @type reactor: object providing L{twisted.internet.interfaces.IReactorTCP} @ivar reactor: The reactor used to create connections. @type buf: C{str} @ivar buf: Part of a SOCKSv4 connection request. @type otherConn: C{SOCKSv4Incoming}, C{SOCKSv4Outgoing} or C{None} @ivar otherConn: Until the connection has been established, C{otherConn} is C{None}. After that, it is the proxy-to-destination protocol instance along which the client's connection is being forwarded. c C s | | _ | | _ d S( N( t loggingR ( R R R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR N s c C s d | _ d | _ d S( Nt ( t buft NoneR ( R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR R s c C s| | j r | j j | ƒ d S| j | | _ | j } d | j d k rx| j d | j d } | _ t j d | d ƒ \ } } } | j j d d ƒ \ } | _ | d d !d k rF| d d k rFd | j k rã | | _ d S| j j d d ƒ \ } | _ | j j | ƒ } | j | j | | | | ƒ | j | d „ ƒ d St j | d d !ƒ } | j | | | | | ƒ n d S( s… Called whenever data is received. @type data: C{str} @param data: Part or all of a SOCKSv4 packet. Nt i s !BBHi i i t c S s | j d ƒ S( Ni[ ( R ( t resultR ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyt <lambda>r s ( R R R t structt unpackt splitR t resolvet addCallbackt _dataReceived2t addErrbackt sockett inet_ntoa( R R t completeBuffert headt versiont codeR t usert servert d( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR V s* # c C sò | d k s t d | ƒ ‚ | j | | | | ƒ sE | j d ƒ d S| d k r | j | | t | ƒ } | j | d „ ƒ nG | d k r¹ | j d t | | ƒ } | j | d „ ƒ n t d | ‚ | j d k sî t d t | j ƒ ƒ ‚ d S( s3 The second half of the SOCKS connection setup. For a SOCKSv4 packet this is after the server address has been extracted from the header. For a SOCKSv4a packet this is after the host name has been resolved. @type server: C{str} @param server: The IP address of the destination, represented as a dotted quad. @type user: C{str} @param user: The username associated with the connection. @type version: C{int} @param version: The SOCKS protocol version number. @type code: C{int} @param code: The comand code. 1 means establish a TCP/IP stream connection, and 2 means establish a TCP/IP port binding. @type port: C{int} @param port: The port number associated with the connection. i s Bad version code: %si[ Ni c S s | j d ƒ S( Ni[ ( R ( R! R ( ( s; /usr/lib/python2.7/dist-packages/twisted/protocols/socks.pyR"