aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/server.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-06-30 12:36:35 +0500
committerEgor Tensin <Egor.Tensin@gmail.com>2022-06-30 12:36:35 +0500
commit22a10c01180902eb2d5587aedd80d6c64eef32db (patch)
treee100d3d3244705153b27a9893513f96088313d56 /src/server.py
parentupdate URLs (diff)
downloadlinux-status-22a10c01180902eb2d5587aedd80d6c64eef32db.tar.gz
linux-status-22a10c01180902eb2d5587aedd80d6c64eef32db.zip
log real client IP addressv2.3
Diffstat (limited to '')
-rwxr-xr-xsrc/server.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/server.py b/src/server.py
index a0fa7c4..64b6d47 100755
--- a/src/server.py
+++ b/src/server.py
@@ -32,6 +32,13 @@ def default_html_dir():
class RequestHandler(http.server.SimpleHTTPRequestHandler):
ARGS = 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)