aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xserver.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/server.py b/server.py
index c0b8fc5..e4ecaef 100755
--- a/server.py
+++ b/server.py
@@ -76,6 +76,13 @@ def setup_signal_handlers(httpd):
class RequestHandler(http.server.SimpleHTTPRequestHandler):
VOID = None
+ def address_string(self):
+ if 'x-forwarded-for' in self.headers:
+ return self.headers['x-forwarded-for'].split(',')[0].strip()
+ if 'x-real-ip' in self.headers:
+ return self.headers['x-real-ip']
+ return super().address_string()
+
def do_GET(self):
try:
request = Request.from_http_path(self.path)