lib/rack/geo_locale.rb in rack-geo-locale-0.0.5 vs lib/rack/geo_locale.rb in rack-geo-locale-0.0.6
- old
+ new
@@ -23,12 +23,16 @@
private
def parse_country(env)
if database?
if remote_addr = env["REMOTE_ADDR"]
+ remote_addr = env["HTTP_X_FORWARDED_FOR"] if env["HTTP_X_FORWARDED_FOR"]
+
result = geoip.country(remote_addr).country_code2
return result if result != "--"
+ else
+ puts "WARNING: Didn't find env['REMOTE_ADDR']"
end
else
puts "WARNING: Didn't find geoip database."
end