def establish(self, term="xterm"): self._shell = self.ssh.invoke_shell(term) self._shell.setblocking(0) self._id = self._shell.fileno() IOLoop.instance().register(self) IOLoop.instance().add_future(self.trans_back())
def main(): init_config() options.parse_config_file("/var/www/app/webssh.conf") http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(options.port) IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()
def establish(self, term="xterm"): self.shell = self.ssh.invoke_shell(term) self.shell.setblocking(0) fileno = self.shell.fileno() connection = self.shell websocket = self.websocket IOLoop.instance().register(fileno, connection, websocket)
def main(): init_config() options.parse_config_file("webssh.conf") http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True) http_server.listen(options.port) IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()
def main(): init_config() # options.parse_config_file("webssh.conf") http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(8888) IOLoop.instance().start() welcome(8888) tornado.ioloop.IOLoop.instance().start()
def main(): asyncio.set_event_loop(asyncio.new_event_loop()) init_config() options.parse_config_file("webssh.conf") http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(options.port) IOLoop.instance().start() welcome(options.port) tornado.ioloop.IOLoop.instance().start()
def main(): init_config() options.parse_config_file("webssh.conf") app = tornado.web.Application([ (r"/ws", handlers.WSHandler), ]) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()
def main(): init_config() options.parse_config_file( os.path.join(os.path.dirname(__file__), "webssh.conf")) http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(options.port) IOLoop.instance().start() welcome(options.port) tornado.ioloop.IOLoop.instance().start()
def __init__(self, server_address): self.ssocket = self.setup_server_socket(server_address) host, self.server_port = self.ssocket.getsockname()[:2] self.server_name = socket.getfqdn(host) self.ioloop = IOLoop.instance() self.conn_pool = {}
def _close(self, connect, event=None): fd = connect.fileno() connect.shutdown(socket.SHUT_RDWR) connect.close() ioloop = IOLoop.instance() ioloop.remove_handler(fd) del self.conn_pool[fd]
def _accept(self, ssocket, event): if event & IOLoop.ERROR: self._close(ssocket) connect, addr = ssocket.accept() connect.setblocking(0) ioloop = IOLoop.instance() ioloop.add_handler(connect, self._receive, IOLoop.READ) fd = connect.fileno() connection = Connection(fd) connection.address = addr self.conn_pool[fd] = connection
def add_accept_handler(sock, call_back, io_loop=None): if io_loop is None: io_loop = IOLoop.instance() def accept_handler(fd, events): while True: try: connection, address = sock.accept() except Exception as e: break call_back(connection, address) io_loop.add_handler(sock.fileno(), accept_handler, ioloop._EPOLLIN)
def establish(self, term="xterm"): # data = self.bridges[fd].shell.recv(MAX_DATA_BUFFER) # data = self._ws.recv() if self._type == "os": self._shell = self.ssh.invoke_shell(term) self._shell.setblocking(0) self._id = self._shell.fileno() IOLoop.instance().register(self) IOLoop.instance().add_future(self.trans_back()) else: self._id = self._shell.fileno() self._send_window_resize() IOLoop.instance().register(self) IOLoop.instance().add_future(self.trans_back())
def _receive(self, connect, event): if event & IOLoop.ERROR: self._close(connect) fd = connect.fileno() connection = self.conn_pool[fd] fragment = connect.recv(1024) connection.request_buffer.append(fragment) last_fragment = ''.join(connection.request_buffer[:2]) if EOL2 in last_fragment: ioloop = IOLoop.instance() ioloop.update_handler(fd, IOLoop.WRITE) ioloop.replace_handler(fd, self._send)
def __init__(self, socket, *args, **kwargs): self.io_loop = IOLoop.instance() self.socket = socket self.socket.setblocking(0) self._read_callback = None self.max_buffer_size = 104857600 self.read_chunk_size = 4096 self._read_buffer_size = 0 self._read_buffer = [] self._write_buffer = [] self._state = None self._closed = False
def wrapper(*args, **kwargs): future = func(*args, **kwargs) IOLoop.instance().add_future(future)
def __init__(self, address, port): self.io_loop = IOLoop.instance() self._socket = self.bind_socket(address, port) self.io_loop.add_handler(self._socket.fileno(), self.accept_handler, select.EPOLLIN)
def __init__(self, port=9999): self.__port = port self.__instance = IOLoop.instance() self.init()
def main(): http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(settings['port']) IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()
def __init__(self, *args, **kwargs): _depwarn("CallLater is deprecated; use " "ioloop.IOLoop.instance().call_later() instead") from ioloop import IOLoop IOLoop.instance().call_later(*args, **kwargs)
def __init__(self, *args, **kwargs): _depwarn("CallEvery is deprecated; use " "pyftpdlib.ioloop.IOLoop.instance().call_every() instead") from ioloop import IOLoop IOLoop.instance().call_every(*args, **kwargs)
if not version.startswith('HTTP/'): print('error http version') except: print('on header exception.') raise print(method, uri, version, self._address) remote_ip = self._address[0] self._request = HTTPRequest( connection=self, method=method, uri=uri, version=version, headers=headers, remote_ip=remote_ip) content_length = headers.get('Content-Length') if content_length: content_length = int(content_length) if content_length > self._stream.max_buffer_size(): print('Content-Length too long') raise self._stream.read_bytes(content_length, self._on_request_body) def _on_request_body(self, data): print('request body: %s' % data) self._request.body = data if self._request_callback: self._request_callback(self._request) if __name__ == '__main__': server = HTTPServer(None, io_loop=IOLoop.current()) server.listen(9999) IOLoop.instance().start()
print('on header exception.') raise print(method, uri, version, self._address) remote_ip = self._address[0] self._request = HTTPRequest(connection=self, method=method, uri=uri, version=version, headers=headers, remote_ip=remote_ip) content_length = headers.get('Content-Length') if content_length: content_length = int(content_length) if content_length > self._stream.max_buffer_size(): print('Content-Length too long') raise self._stream.read_bytes(content_length, self._on_request_body) def _on_request_body(self, data): print('request body: %s' % data) self._request.body = data if self._request_callback: self._request_callback(self._request) if __name__ == '__main__': server = HTTPServer(None, io_loop=IOLoop.current()) server.listen(9999) IOLoop.instance().start()
def main(): http_server = tornado.httpserver.HTTPServer(Application()) http_server.listen(options.port) IOLoop.instance().start() tornado.ioloop.IOLoop.instance().start()