diff --git a/chaos_monkey/network/info.py b/chaos_monkey/network/info.py index 189991d1a..22c340979 100644 --- a/chaos_monkey/network/info.py +++ b/chaos_monkey/network/info.py @@ -1,8 +1,9 @@ import os import sys +import array import socket import struct -import array +import psutil import ipaddress from random import randint diff --git a/chaos_monkey/tunnel.py b/chaos_monkey/tunnel.py index d26713087..e8ba530a6 100644 --- a/chaos_monkey/tunnel.py +++ b/chaos_monkey/tunnel.py @@ -153,6 +153,10 @@ class MonkeyTunnel(Thread): def set_tunnel_for_host(self, host): assert isinstance(host, VictimHost) + + if not self.local_port: + return + ip_match = get_close_matches(host.ip_addr, local_ips()) or self.l_ips host.default_tunnel = '%s:%d' % (ip_match[0], self.local_port)