Skip to content

Commit

Permalink
fixed None encode
Browse files Browse the repository at this point in the history
  • Loading branch information
v00g100skr committed Jan 7, 2025
1 parent 49c6d6e commit 7d626fe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deploy/websocket_server/websocket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ async def echo(websocket, path):
return

country = websocket.request_headers.get("cf-ipcountry", None)
region = websocket.request_headers.get("cf-region", None).encode("utf-8", "ignore").decode("utf-8")
city = websocket.request_headers.get("cf-ipcity", None).encode("utf-8", "ignore").decode("utf-8")
region = websocket.request_headers.get("cf-region", None)
city = websocket.request_headers.get("cf-ipcity", None)
timezone = websocket.request_headers.get("cf-timezone", None)

if not country or not region or not city or not timezone:
Expand All @@ -255,6 +255,10 @@ async def echo(websocket, path):
country = country or "not-found"
timezone = timezone or "not-found"

country = country.encode("utf-8", "ignore").decode("utf-8")
region = region.encode("utf-8", "ignore").decode("utf-8")
city = city.encode("utf-8", "ignore").decode("utf-8")

# if response.country.iso_code != 'UA' and response.continent.code != 'EU':
# shared_data.blocked_ips.append(client_ip)
# logger.warning(f"{client_ip}_{client_port} !!! BLOCKED")
Expand Down

0 comments on commit 7d626fe

Please sign in to comment.