diff --git a/fides b/fides index 8492d6cf2..70657740c 160000 --- a/fides +++ b/fides @@ -1 +1 @@ -Subproject commit 8492d6cf216e0182b9f96d6ed6baffd3a4c41c24 +Subproject commit 70657740ce4daa3225b9f25bed7b1db00efb6b9f diff --git a/modules/p2ptrust/p2ptrust.py b/modules/p2ptrust/p2ptrust.py index 44e6614c9..5711503ba 100644 --- a/modules/p2ptrust/p2ptrust.py +++ b/modules/p2ptrust/p2ptrust.py @@ -27,6 +27,8 @@ Direction, ) +LOCALHOST = "127.0.0.1" + def validate_slips_data(message_data: str) -> (str, int): """ @@ -197,30 +199,23 @@ def _configure(self): f"Did you include it in PATH?. Exiting process." ) return - executable = [self.pigeon_binary] - port_param = ["-port", str(self.port)] - # if '-ip' in sys.argv: - # ip_to_listen_on = sys.argv[sys.argv.index('-ip')+1] - # host_param = ["-host", ip_to_listen_on ] - # print(f"P2P modules is listening on ip {ip_to_listen_on} port: {self.port}, using '-ip' parameter") - # else: - host_param = ["-host", self.host] + + params = { + "-port": str(self.port), + "-host": self.host, + "-key-file": self.pigeon_key_file, + "--redis-db": f"localhost:{self.redis_port}", + "-redis-channel-pygo": self.pygo_channel_raw, + "-redis-channel-gopy": self.gopy_channel_raw, + } self.print( - f"P2p is listening on {self.host} port {self.port} determined " - f"by p2p module" + f"P2P is listening on {self.host} port {self.port} " + f"(determined by p2p module)" ) + executable = [self.pigeon_binary] + [ + item for pair in params.items() for item in pair + ] - keyfile_param = ["-key-file", self.pigeon_key_file] - # rename_with_port_param = ["-rename-with-port", - # str(self.rename_with_port).lower()] - pygo_channel_param = ["-redis-channel-pygo", self.pygo_channel_raw] - gopy_channel_param = ["-redis-channel-gopy", self.gopy_channel_raw] - executable.extend(port_param) - executable.extend(host_param) - executable.extend(keyfile_param) - # executable.extend(rename_with_port_param) - executable.extend(pygo_channel_param) - executable.extend(gopy_channel_param) if self.create_p2p_logfile: outfile = open(self.pigeon_logfile, "+w") else: @@ -649,7 +644,7 @@ def main(self): # give the pigeon time to put the multiaddr in the db time.sleep(2) multiaddr = self.db.get_multiaddr() - self.print(f"You Multiaddress is: {multiaddr}") + self.print(f"You Multiaddress is: {multiaddr}\n") self.mutliaddress_printed = True except Exception: diff --git a/p2p4slips b/p2p4slips index 73597762b..9a9ade5d4 160000 --- a/p2p4slips +++ b/p2p4slips @@ -1 +1 @@ -Subproject commit 73597762b5970524828ba49141b91e6f32b9315e +Subproject commit 9a9ade5d4206362e0e9f4fcc948e9c77d524c498 diff --git a/slips_files/core/database/redis_db/database.py b/slips_files/core/database/redis_db/database.py index ac6f59a95..7c92efc6e 100644 --- a/slips_files/core/database/redis_db/database.py +++ b/slips_files/core/database/redis_db/database.py @@ -31,6 +31,7 @@ ) RUNNING_IN_DOCKER = os.environ.get("IS_IN_A_DOCKER_CONTAINER", False) +LOCALHOST = "127.0.0.1" class RedisDB(IoCHandler, AlertHandler, ProfileHandler, P2PHandler): @@ -330,7 +331,7 @@ def _confirm_redis_is_listening(cls, timeout: float = 5.0) -> (bool, str): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.settimeout(0.2) try: - sock.connect(("127.0.0.1", cls.redis_port)) + sock.connect((LOCALHOST, cls.redis_port)) return True, "" # Redis is up except (ConnectionRefusedError, OSError): time.sleep(0.2) @@ -346,7 +347,7 @@ def _start_a_redis_server(cls) -> bool: cmd = ( f"redis-server {cls._conf_file} " f"--port {cls.redis_port} " - f"--bind 127.0.0.1 " + f"--bind {LOCALHOST} " f"--daemonize yes" ) process = subprocess.Popen( @@ -945,7 +946,7 @@ def should_store_resolution( # don't store this as a valid dns resolution if query != "localhost": for answer in answers: - if answer in ("127.0.0.1", "0.0.0.0"): + if answer in (LOCALHOST, "0.0.0.0"): return False return True @@ -1279,7 +1280,8 @@ def get_ip_identification( def get_multiaddr(self): """ - this is can only be called when p2p is enabled, this value is set by p2p pigeon + this can only be called when p2p is enabled, + this value is set by p2p pigeon in the db """ return self.r.get(self.constants.MULTICAST_ADDRESS)