Beispiel #1
0
 def _process_frontend(self, frontend):
     conn_id, tunnel = self.frontends[frontend]
     try:
         data = frontend.recv()
     except Exception as e:
         msg = "unknown error: " + str(e)
         error(msg, 'frontend', tunnel.address)
         tunnel.reset_connection(conn_id)
         self._close_frontend(frontend)
         return
     if data:
         tunnel.send_packet(conn_id, data)
     elif data is None:
         tunnel.close_connection(conn_id)
         self._close_frontend(frontend)
Beispiel #2
0
 def _process_frontend(self, frontend):
     conn_id, tunnel = self.frontends[frontend]
     try:
         data = frontend.recv()
     except Exception as e:
         msg = "unknown error: " + str(e)
         error(msg, 'frontend', tunnel.address)
         tunnel.reset_connection(conn_id)
         self._close_frontend(frontend)
         return
     if data:
         tunnel.send_packet(conn_id, data)
     elif data is None:
         tunnel.close_connection(conn_id)
         self._close_frontend(frontend)
Beispiel #3
0
 def _process_tunnel_packet(self, tunnel, conn_id, control, data):
     frontends = self.tunnels[tunnel]
     # RST flag is set
     if control & StatusControl.rst:
         self._close_frontend(frontends[conn_id], True)
     # SYN flag is set
     if control & StatusControl.syn:
         if conn_id in frontends:
             self._close_frontend(frontends[conn_id], True)
         try:
             frontend = self.new_frontend()
         except FrontendUnavailableError:
             error("unavailable", 'frontend', tunnel.address)
             tunnel.reset_connection(conn_id)
             return
         frontends[conn_id] = frontend
         self.frontends[frontend] = conn_id, tunnel
     # DAT flag is set
     if control & StatusControl.dat:
         frontends[conn_id].send(data)
     # FIN flag is set
     if control & StatusControl.fin:
         self._close_frontend(frontends[conn_id])
Beispiel #4
0
 def _process_tunnel_packet(self, tunnel, conn_id, control, data):
     frontends = self.tunnels[tunnel]
     # RST flag is set
     if control & StatusControl.rst:
         self._close_frontend(frontends[conn_id], True)
     # SYN flag is set
     if control & StatusControl.syn:
         if conn_id in frontends:
             self._close_frontend(frontends[conn_id], True)
         try:
             frontend = self.new_frontend()
         except FrontendUnavailableError:
             error("unavailable", 'frontend', tunnel.address)
             tunnel.reset_connection(conn_id)
             return
         frontends[conn_id] = frontend
         self.frontends[frontend] = conn_id, tunnel
     # DAT flag is set
     if control & StatusControl.dat:
         frontends[conn_id].send(data)
     # FIN flag is set
     if control & StatusControl.fin:
         self._close_frontend(frontends[conn_id])