def handle_proxy_request(socket, request): try: tunnel = Tunnel.get_by_proxy_request(request) except RuntimeError, e: protocol.send_message(socket, protocol.error_reply('notavailable')) socket.close() return
def handle_proxy(socket, request): try: tunnel = Tunnel.get_by_proxy_request(request) except RuntimeError, e: protocol.send_message(socket, protocol.error_reply('notavailable')) socket.close() return
while True: eventlet.sleep(HEARTBEAT_INTERVAL) protocol.send_message(socket, protocol.control_ping()) with Timeout(HEARTBEAT_INTERVAL): message = protocol.recv_message(socket) assert message == protocol.control_pong() except (IOError, AssertionError, Timeout): logging.debug("expiring tunnel:\"{0}\"".format(tunnel.name)) tunnel.destroy() @metrics.time_calls(name='proxy_conn') def handle_proxy_request(socket, request): try: tunnel = Tunnel.get_by_proxy_request(request) except RuntimeError, e: protocol.send_message(socket, protocol.error_reply('notavailable')) socket.close() return if not tunnel: protocol.send_message(socket, protocol.error_reply('expired')) socket.close() return try: proxy_used = tunnel.add_proxy_conn(socket) logging.debug("added connection:\"{0}\" by client:\"{1}\"".format( tunnel.name, tunnel.client)) pool = proxy_used.wait() pool.waitall() except ValueError, e: logging.debug(str(e))
message = protocol.recv_message(socket) assert message == protocol.control_pong() except (IOError, AssertionError, Timeout): logging.debug("expiring tunnel:\"{0}\"".format(tunnel.name)) tunnel.destroy() def handle_proxy(socket, request): try: tunnel = Tunnel.get_by_proxy_request(request) except RuntimeError, e: protocol.send_message(socket, protocol.error_reply('notavailable')) socket.close() return if not tunnel: protocol.send_message(socket, protocol.error_reply('expired')) socket.close() return try: tunnel.add_proxy_backend(socket) logging.debug("added backend:\"{0}\" by client:\"{1}\"".format( tunnel.name, tunnel.client)) util.leave_socket_open() except ValueError, e: logging.debug(str(e)) def frontend_handler(socket, address): hostname = '' hostheader = re.compile('host: ([^\(\);:,<>]+)', re.I) # Peek up to 512 bytes into data for the Host header
protocol.send_message(socket, protocol.control_ping()) with Timeout(HEARTBEAT_INTERVAL): message = protocol.recv_message(socket) assert message == protocol.control_pong() except (IOError, AssertionError, Timeout): logging.debug('expiring tunnel:"{0}"'.format(tunnel.name)) tunnel.destroy() @metrics.time_calls(name="proxy_conn") def handle_proxy_request(socket, request): try: tunnel = Tunnel.get_by_proxy_request(request) except RuntimeError, e: protocol.send_message(socket, protocol.error_reply("notavailable")) socket.close() return if not tunnel: protocol.send_message(socket, protocol.error_reply("expired")) socket.close() return try: proxy_used = tunnel.add_proxy_conn(socket) logging.debug('added connection:"{0}" by client:"{1}"'.format(tunnel.name, tunnel.client)) pool = proxy_used.wait() pool.waitall() except ValueError, e: protocol.send_message(socket, protocol.error_reply(e)) socket.close() logging.debug(str(e))