Created
October 5, 2015 05:02
-
-
Save yseto/5c8b68caffa05b66777a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CountryDeniedViaGeoIP | |
@@geoip = nil | |
def call(env) | |
if @@geoip == nil | |
@@geoip = GeoIP.new("/usr/share/GeoIP/GeoIPCity.dat") | |
end | |
@@geoip.record_by_addr env["REMOTE_ADDR"] | |
ret = [399, {}, []] | |
if @@geoip.country_code != "JP" | |
ret = [403, {'content-type' => 'text/plain'}, [ "forbidden" ]] | |
end | |
# geoip.close | |
return ret | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment