From 48ccb7a98ed6293168386b0fd4ee833acd91937d Mon Sep 17 00:00:00 2001 From: Philipp Spitzer Date: Tue, 8 Apr 2014 20:21:56 +0200 Subject: [PATCH] Now HTTP_X_FORWARDED_FOR and REMOTE_ADDR are used if ip address is missing. --- cgi-bin/dyndns.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cgi-bin/dyndns.py b/cgi-bin/dyndns.py index 1d3e2d2..417c27a 100755 --- a/cgi-bin/dyndns.py +++ b/cgi-bin/dyndns.py @@ -148,7 +148,13 @@ try: # check IP address if not offline: if myip is None: - raise MyipMissing() + # try HTTP_X_FORWARDED_FOR + myip = os.environ.get('HTTP_X_FORWARDED_FOR') + if not myip: # empty string if not present + # try REMOTE_ADDR + myip = os.environ.get('REMOTE_ADDR') + if not myip: # empty string if not present + raise MyipMissing() try: ip = ipaddr.IPAddress(myip) # throws an exception if the IP address is not valid except ValueError: -- 2.39.5