diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-06-30 10:10:46 +0500 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-06-30 11:21:37 +0500 |
commit | 6a205122e9c76630b9a0775295d90770f307740b (patch) | |
tree | 1d5398881d5cc6c2db445bcf716a31ff6c26cf24 | |
parent | Makefile: consistent prelude (diff) | |
download | void-6a205122e9c76630b9a0775295d90770f307740b.tar.gz void-6a205122e9c76630b9a0775295d90770f307740b.zip |
log real client IP address
-rwxr-xr-x | server.py | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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) |