mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix traceback in x-forward-for in cases of localhost
This commit is contained in:
parent
ea802b4567
commit
6c1a77eecc
1 changed files with 9 additions and 8 deletions
|
|
@ -70,14 +70,15 @@ class HTTPChannelWithXForwardedFor(http.HTTPChannel):
|
|||
Check to see if this is a reverse proxied connection.
|
||||
|
||||
"""
|
||||
CLIENT = 0
|
||||
http.HTTPChannel.allHeadersReceived(self)
|
||||
req = self.requests[-1]
|
||||
client_ip, port = self.transport.client
|
||||
proxy_chain = req.getHeader("X-FORWARDED-FOR")
|
||||
if proxy_chain and client_ip in _UPSTREAM_IPS:
|
||||
forwarded = proxy_chain.split(", ", 1)[CLIENT]
|
||||
self.transport.client = (forwarded, port)
|
||||
if self.requests:
|
||||
CLIENT = 0
|
||||
http.HTTPChannel.allHeadersReceived(self)
|
||||
req = self.requests[-1]
|
||||
client_ip, port = self.transport.client
|
||||
proxy_chain = req.getHeader("X-FORWARDED-FOR")
|
||||
if proxy_chain and client_ip in _UPSTREAM_IPS:
|
||||
forwarded = proxy_chain.split(", ", 1)[CLIENT]
|
||||
self.transport.client = (forwarded, port)
|
||||
|
||||
|
||||
# Monkey-patch Twisted to handle X-Forwarded-For.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue