Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fides
Submodule fides updated from 8492d6 to 706577
39 changes: 17 additions & 22 deletions modules/p2ptrust/p2ptrust.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
Direction,
)

LOCALHOST = "127.0.0.1"


def validate_slips_data(message_data: str) -> (str, int):
"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion p2p4slips
Submodule p2p4slips updated 1 files
+1 −1 main.go
10 changes: 6 additions & 4 deletions slips_files/core/database/redis_db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading