mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix ipv6 address parsing in forward address. Spotted 3 weeks ago by
Jonathan Leroy.
This commit is contained in:
parent
cdd58014a7
commit
0bd86f7729
@ -77,9 +77,22 @@ def create(req, sock, client, server, cfg):
|
||||
# http://en.wikipedia.org/wiki/X-Forwarded-For
|
||||
if forward.find(",") >= 0:
|
||||
forward = forward.rsplit(",", 1)[1].strip()
|
||||
remote = forward.split(":")
|
||||
if len(remote) < 2:
|
||||
remote.append('80')
|
||||
|
||||
# find host and port on ipv6 address
|
||||
if '[' in forward and ']' in forward:
|
||||
host = forward.split(']')[0][1:].lower()
|
||||
elif ":" in forward:
|
||||
host = forward.split(":")[0].lower()
|
||||
else:
|
||||
host = fowerd
|
||||
|
||||
forward = forward.split(']')[-1]
|
||||
if ":" in forward:
|
||||
port = forward.split(':', 1)[1]
|
||||
else:
|
||||
port = 80
|
||||
|
||||
remote = (host, port)
|
||||
else:
|
||||
remote = forward
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user