Example #1
0
 def dispatch(client):
     supported = {'pty', 'x11', 'forward-agent'}
     chan_type = client.request.type
     kind = client.request.kind
     if kind == 'session' and chan_type in supported:
         logger.info("Request type `{}:{}`, dispatch to interactive mode".format(kind, chan_type))
         try:
             InteractiveServer(client).interact()
         except Exception as e:
             logger.error("Unexpected error occur: {}".format(e))
         connection = Connection.get_connection(client.connection_id)
         connection.remove_client(client.id)
     elif chan_type == 'subsystem':
         pass
     else:
         msg = "Request type `{}:{}` not support now".format(kind, chan_type)
         logger.info(msg)
         client.send(msg)
Example #2
0
 def dispatch(client):
     supported = {'pty', 'x11', 'forward-agent'}
     chan_type = client.request.type
     kind = client.request.kind
     try:
         if kind == 'session' and chan_type in supported:
             logger.info("Dispatch client to interactive mode")
             try:
                 InteractiveServer(client).interact()
             except IndexError as e:
                 logger.error("Unexpected error occur: {}".format(e))
         elif chan_type == 'subsystem':
             while not client.closed:
                 time.sleep(5)
             logger.debug("SFTP session finished")
         else:
             msg = "Request type `{}:{}` not support now".format(kind, chan_type)
             logger.error(msg)
             client.send_unicode(msg)
     finally:
         connection = Connection.get_connection(client.connection_id)
         if connection:
             connection.remove_client(client.id)