aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-06-30 10:10:46 +0500
committerEgor Tensin <Egor.Tensin@gmail.com>2022-06-30 11:21:37 +0500
commit6a205122e9c76630b9a0775295d90770f307740b (patch)
tree1d5398881d5cc6c2db445bcf716a31ff6c26cf24
parentMakefile: consistent prelude (diff)
downloadvoid-6a205122e9c76630b9a0775295d90770f307740b.tar.gz
void-6a205122e9c76630b9a0775295d90770f307740b.zip
log real client IP address
Diffstat (limited to '')
-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)