]> git.ipfire.org Git - ipfire.org.git/commitdiff
geoip: Fix getting the ip address if user has a proxy which sends headers.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Jan 2011 17:36:03 +0000 (18:36 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 14 Jan 2011 17:36:03 +0000 (18:36 +0100)
www/webapp/backend/geoip.py

index b2cdc09cc319174202eda90738a0cd4c307d7d45..b7f3e999b3df4038fef736f766cb89e36e0f7c7d 100644 (file)
@@ -11,6 +11,11 @@ class GeoIP(object):
                return Databases().geoip
 
        def __encode_ip(self, addr):
+               # We get a tuple if there were proxy headers.
+               addr = addr.split(", ")
+               if addr:
+                       addr = addr[-1]
+
                # ip is calculated as described in http://ipinfodb.com/ip_database.php
                a1, a2, a3, a4 = addr.split(".")