Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
fix: take first ip
Browse files Browse the repository at this point in the history
  • Loading branch information
zac-li committed May 23, 2023
1 parent 9c69055 commit a30d8a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lcserve/backend/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
if scope.get('headers'):
for header in scope['headers']:
if header[0].decode('latin-1') == 'x-forwarded-for':
ip_address = header[1].decode('latin-1')
ip_address = header[1].decode('latin-1').split(",")[0].strip()
break

# Init the request/connection ID
Expand Down Expand Up @@ -1156,7 +1156,7 @@ async def custom_send(message: dict) -> None:
)
elif scope["type"] == "websocket":
self.logger.info(
f"WebSocket connection: {connection_id} - Path: {scope['path']} - Client IP: {ip_address} - Duration: {duration}"
f"WebSocket connection: {connection_id} - Path: {scope['path']} - Client IP: {ip_address} - Duration: {duration} s"
)

else:
Expand Down

0 comments on commit a30d8a3

Please sign in to comment.