Skip to content

Commit

Permalink
try to get real IP from websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Foroxon committed Dec 16, 2024
1 parent 2dadb7d commit 27d20cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions deploy/websocket_server/websocket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def bin_sort(bin):


async def alerts_data(websocket, client, shared_data, alert_version):
client_ip, client_port = websocket.remote_address
client_ip = websocket.headers.get("X-Real-IP")
while True:
if client["firmware"] == "unknown":
await asyncio.sleep(0.1)
Expand Down Expand Up @@ -194,7 +194,9 @@ def send_google_stat(tracker, event):


async def echo(websocket, path):
client_ip, client_port = websocket.remote_address
nginx_ip, client_port = websocket.remote_address
# get real header from websocket
client_ip = websocket.headers.get("X-Real-IP")
logger.debug(f"{client_ip}:{client_port} >>> new client")

if client_ip in shared_data.blocked_ips:
Expand Down

0 comments on commit 27d20cd

Please sign in to comment.