Mon, 04 Jan 2016 17:08:27 +0000
geoip: Use IP from X-Forwarded-For if it exists
geoip.lua | file | annotate | diff | comparison | revisions |
--- a/geoip.lua Mon Jan 04 17:08:12 2016 +0000 +++ b/geoip.lua Mon Jan 04 17:08:27 2016 +0000 @@ -12,8 +12,7 @@ log("debug", "Loaded geoip database successfully"); events.add_handler("new-client", function (info) - local ip = info.conn:ip(); - local location = city_db:query_by_addr(ip); + local ip = info.request.headers.x_forwarded_for or info.conn:ip(); log("debug", "GeoIP query for %s", tostring(ip)); local location, err = city_db:query_by_addr(ip); if location then