Skip to content

Commit

Permalink
Hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gorane7 committed Apr 25, 2024
1 parent 7049480 commit 297b856
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
16 changes: 9 additions & 7 deletions taky/cot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,15 @@ def feed(self, data):
continue

# Drop sea locations, love you RT
if evt.point.lat <= 55 or evt.point.lat >= 59.5:
print(f"Dropping message because out of land box {data.decode()}")
continue

if evt.point.lon <= -35.5 or evt.point.lon >= -19.6:
print(f"Dropping message because out of land box {data.decode()}")
continue
message_uid = evt.uid
if message_uid[:7] != "bridge-":
if evt.point.lat <= 55 or evt.point.lat >= 59.5:
print(f"Dropping message because out of land box {data.decode()}")
continue

if evt.point.lon <= -35.5 or evt.point.lon >= -19.6:
print(f"Dropping message because out of land box {data.decode()}")
continue

if evt.etype.startswith("a"):
self.handle_atom(evt)
Expand Down
15 changes: 14 additions & 1 deletion taky/cot/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def route(self, src, evt):
# print(f"Routing {evt} from {src}")

try:
# Removed this
{}[0]
client_ip = src.sock.getpeername()[0]
message_uid = evt.uid
if message_uid[:7] != "bridge-":
Expand All @@ -172,17 +174,28 @@ def route(self, src, evt):
client_ip = src.sock.getpeername()[0]
message_uid = evt.uid
print(f"Message from {client_ip} had uid {message_uid}")
allowed = False
for l in self.allowed_connections:
#print(l)
if l[0] != message_uid:
continue
print(f"Found that uid {l[0]} is limited")
#print(f"Found that uid {l[0]} is limited")
if l[1][0] == "all":
print(f"Message with uid {message_uid} is allowed from all IPs")
allowed = True
continue
if client_ip in l[1]:
print(f"{client_ip} is allowed to send under {message_uid}")
allowed = True
continue
else:
print(f"{client_ip} is not allowed to send under {message_uid}")
print()
return
if not allowed:
print(f"Message uid {message_uid} is unknown, blocking")
print()
return
#print(f"Checking if ip {client_ip} is allowed to send under uid {message_uid}")
except:
pass
Expand Down

0 comments on commit 297b856

Please sign in to comment.