]> ToastFreeware Gitweb - toast/tdyndns.git/blobdiff - cgi-bin/dyndns.py
Now HTTP_X_FORWARDED_FOR and REMOTE_ADDR are used if ip address is missing.
[toast/tdyndns.git] / cgi-bin / dyndns.py
index 1d3e2d2567c0637ee1f37f45ceee88ee42f36e9c..417c27a2c9981681117659a5ee8c214afaa52d63 100755 (executable)
@@ -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: