misc/python/proxy-ip.py

13 lines
344 B
Python
Raw Normal View History

2018-08-05 18:53:07 +02:00
## 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