Skip to content

Commit

Permalink
wsgi: Fixed incorrect parsing of ipv6 addresses in access log
Browse files Browse the repository at this point in the history
Granian is setting REMOTE_ADDR values using SocketAddr::to_string() which uses
the format <host>:<port> and ipv6 addresses are delimited internally by colons,
so the port that needs to be stripped must be taken from the right and there
must only be one split done to avoid splitting the ipv6 address.
  • Loading branch information
jyelloz committed Dec 28, 2024
1 parent 9aff0ca commit 79fb677
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion granian/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def access_log(t, scope, resp_code):
logger(
t,
{
'addr_remote': scope['REMOTE_ADDR'].split(':')[0],
'addr_remote': scope['REMOTE_ADDR'].rsplit(':', 1)[0],
'protocol': scope['SERVER_PROTOCOL'],
'path': scope['PATH_INFO'],
'qs': scope['QUERY_STRING'],
Expand Down

0 comments on commit 79fb677

Please sign in to comment.