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
|
# http://en.wikipedia.org/wiki/X-Forwarded-For
|
||||||
if forward.find(",") >= 0:
|
if forward.find(",") >= 0:
|
||||||
forward = forward.rsplit(",", 1)[1].strip()
|
forward = forward.rsplit(",", 1)[1].strip()
|
||||||
remote = forward.split(":")
|
|
||||||
if len(remote) < 2:
|
# find host and port on ipv6 address
|
||||||
remote.append('80')
|
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:
|
else:
|
||||||
remote = forward
|
remote = forward
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user