<s> import pyptlib . util <EOL> import obfsproxy . common . log as logging <EOL> import argparse <EOL> log = logging . get_obfslogger ( ) <EOL> """<STR_LIT>""" <EOL> def addrport ( string ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return pyptlib . util . parse_addr_spec ( string , resolve = True ) <EOL> except ValueError , err : <EOL> raise argparse . ArgumentTypeError ( err ) <EOL> class BaseTransport ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . name = "<STR_LIT>" % hex ( id ( self ) ) <EOL> self . circuit = None <EOL> @ classmethod <EOL> def setup ( cls , pt_config ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def get_public_server_options ( cls , transport_options ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> def circuitConnected ( self ) : <EOL> """<STR_LIT>""" <EOL> def circuitDestroyed ( self , reason , side ) : <EOL> """<STR_LIT>""" <EOL> def receivedDownstream ( self , data ) : <EOL> """<STR_LIT>""" <EOL> def receivedUpstream ( self , data ) : <EOL> """<STR_LIT>""" <EOL> def handle_socks_args ( self , args ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def register_external_mode_cli ( cls , subparser ) : <EOL> """<STR_LIT>""" <EOL> subparser . add_argument ( '<STR_LIT>' , choices = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> subparser . add_argument ( '<STR_LIT>' , type = addrport ) <EOL> subparser . add_argument ( '<STR_LIT>' , type = addrport , help = '<STR_LIT>' ) <EOL> subparser . add_argument ( '<STR_LIT>' , type = str , <EOL> help = '<STR_LIT>' ) <EOL> @ classmethod <EOL> def validate_external_mode_cli ( cls , args ) : <EOL> """<STR_LIT>""" <EOL> if ( args . mode != '<STR_LIT>' ) and ( not args . dest ) : <EOL> log . error ( "<STR_LIT>" ) <EOL> return False <EOL> if ( args . mode != '<STR_LIT>' ) and args . ext_cookie_file : <EOL> log . error ( "<STR_LIT>" ) <EOL> return False <EOL> if ( args . mode == '<STR_LIT>' ) and ( not args . ext_cookie_file ) : <EOL> log . error ( "<STR_LIT>" ) <EOL> return False <EOL> return True <EOL> class PluggableTransportError ( Exception ) : pass <EOL> class SOCKSArgsError ( Exception ) : pass <EOL> class TransportSetupFailed ( Exception ) : pass </s>
