13 lines
344 B
Python
13 lines
344 B
Python
## Unsafe way to get the address behind a proxy in werkzeug.
|
|
|
|
import werkzeug.serving
|
|
|
|
class RequestHandler(werkzeug.serving.WSGIRequestHandler):
|
|
def address_string(self):
|
|
addrs = self.headers['x-forwarded-for']
|
|
if addrs:
|
|
return addrs.split(',')[-1]
|
|
return self.client_address[0]
|
|
|
|
werkzeug.serving.WSGIRequestHandler = RequestHandler
|