Skip to content

Commit

Permalink
small changes to get things hopefully fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
JustRedTTG committed Mar 18, 2024
1 parent a01c23b commit fd70411
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions common/security_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SecurityWrapper:
def __init__(self, host: str, port: int):
self.host = '0.0.0.0' if host is None else '127.0.0.1' if host == 'localhost' else host
self.host = '0.0.0.0' if host is None else '0.0.0.0' if host == 'localhost' else host
self.port = port

self.socket = socket(AF_INET, SOCK_DGRAM)
Expand Down Expand Up @@ -63,4 +63,6 @@ def send(self, data: bytes, addr: tuple, delay: float = 0.0):
else:
self.socket.sendto(self.public_key, addr)
self.connected_clients.append(addr)
threading.Thread(target=self.send, args=(data, addr, .1), daemon=False).start()
thread = threading.Thread(target=self.send, args=(data, addr, .1), daemon=True)
thread.start()
thread.join()
4 changes: 3 additions & 1 deletion server/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
from logging import info

os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.join(os.getcwd(), '..'))
Expand All @@ -13,10 +14,11 @@ def __init__(self):
self.clients = {}

super().__init__('0.0.0.0', 9024)
print(f'Server: {self.host}:{self.port}')
info(f'Server running on: {self.host}:{self.port}')

def _receive(self, data, addr):
if data == b'echo':
info(f'Received an echo request from {addr}')
self.send(b'Hello from server!', addr)


Expand Down

0 comments on commit fd70411

Please sign in to comment.