tunnel bugs fix
This commit is contained in:
parent
e739b8104d
commit
cc32b369b4
|
@ -8,6 +8,7 @@ class TransportProxyBase(Thread):
|
|||
self.dest_port = dest_port
|
||||
self._stopped = False
|
||||
super(TransportProxyBase, self).__init__()
|
||||
self.daemon = True
|
||||
|
||||
def stop(self):
|
||||
self._stopped = True
|
|
@ -18,7 +18,8 @@ class SocketsPipe(Thread):
|
|||
self.dest = dest
|
||||
self.timeout = timeout
|
||||
self._keep_connection = True
|
||||
super(SocketsPipe, self).__init__()
|
||||
super(SocketsPipe, self).__init__()
|
||||
self.daemon = True
|
||||
|
||||
def run(self):
|
||||
sockets = [self.source, self.dest]
|
||||
|
|
|
@ -37,21 +37,31 @@ def find_tunnel(attempts=3, timeout=DEFAULT_TIMEOUT):
|
|||
for attempt in range(0, attempts):
|
||||
try:
|
||||
sock.sendto("?", (MCAST_GROUP, MCAST_PORT))
|
||||
answer, address = sock.recvfrom(BUFFER_READ)
|
||||
tunnels = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
answer, address = sock.recvfrom(BUFFER_READ)
|
||||
if not answer in ['?', '+', '-']:
|
||||
tunnels.append(answer)
|
||||
except socket.timeout:
|
||||
break
|
||||
|
||||
while answer in ['?', '+', '-']:
|
||||
answer, address = sock.recvfrom(BUFFER_READ)
|
||||
for tunnel in tunnels:
|
||||
if tunnel.find(':') != -1:
|
||||
address, port = tunnel.split(':', 1)
|
||||
if address in l_ips:
|
||||
continue
|
||||
|
||||
LOG.debug("Checking tunnel %s:%d" % (address, port))
|
||||
is_open,_ = check_port_tcp(address, int(port))
|
||||
if not is_open:
|
||||
LOG.debug("Could not connect to %s:%d" % (address, port))
|
||||
continue
|
||||
|
||||
if answer.find(':') != -1:
|
||||
address, port = answer.split(':', 1)
|
||||
if address in l_ips:
|
||||
continue
|
||||
if not check_port_tcp(address, int(port)):
|
||||
continue
|
||||
|
||||
sock.sendto("+", (address, MCAST_PORT))
|
||||
sock.close()
|
||||
return (address, port)
|
||||
sock.sendto("+", (address, MCAST_PORT))
|
||||
sock.close()
|
||||
return (address, port)
|
||||
except:
|
||||
continue
|
||||
|
||||
|
@ -78,6 +88,7 @@ class MonkeyTunnel(Thread):
|
|||
self._stopped = False
|
||||
self._clients = []
|
||||
super(MonkeyTunnel, self).__init__()
|
||||
self.daemon = True
|
||||
|
||||
def run(self):
|
||||
self._broad_sock = _set_multicast_socket(self._timeout)
|
||||
|
|
Loading…
Reference in New Issue