forked from p15670423/monkey
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
|
|
@ -19,6 +19,7 @@ class SocketsPipe(Thread):
|
|||
self.timeout = timeout
|
||||
self._keep_connection = True
|
||||
super(SocketsPipe, self).__init__()
|
||||
self.daemon = True
|
||||
|
||||
def run(self):
|
||||
sockets = [self.source, self.dest]
|
||||
|
|
|
@ -37,16 +37,26 @@ 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 answer in ['?', '+', '-']:
|
||||
while True:
|
||||
try:
|
||||
answer, address = sock.recvfrom(BUFFER_READ)
|
||||
if not answer in ['?', '+', '-']:
|
||||
tunnels.append(answer)
|
||||
except socket.timeout:
|
||||
break
|
||||
|
||||
if answer.find(':') != -1:
|
||||
address, port = answer.split(':', 1)
|
||||
for tunnel in tunnels:
|
||||
if tunnel.find(':') != -1:
|
||||
address, port = tunnel.split(':', 1)
|
||||
if address in l_ips:
|
||||
continue
|
||||
if not check_port_tcp(address, int(port)):
|
||||
|
||||
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
|
||||
|
||||
sock.sendto("+", (address, MCAST_PORT))
|
||||
|
@ -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