Multiple allowed ips

This commit is contained in:
Kload 2013-07-07 08:03:15 +00:00
parent d332c6558f
commit cc70ce072e

View file

@ -7,8 +7,7 @@ require 'json'
DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://postgres:yayaya@localhost/dynette") DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://postgres:yayaya@localhost/dynette")
DOMAINS = ["nohost.me", "noho.st"] DOMAINS = ["nohost.me", "noho.st"]
ALLOWED_IP = "82.196.13.142" ALLOWED_IP = ["82.196.13.142", "192.241.138.212", "127.0.0.1"]
#ALLOWED_IP = "127.0.0.1"
class Entry class Entry
include DataMapper::Resource include DataMapper::Resource
@ -154,7 +153,7 @@ delete '/key/:public_key' do
end end
get '/all' do get '/all' do
unless request.ip == ALLOWED_IP unless ALLOWED_IP.include? request.ip
status 403 status 403
return "Access denied" return "Access denied"
end end
@ -162,7 +161,7 @@ get '/all' do
end end
get '/all/:domain' do get '/all/:domain' do
unless request.ip == ALLOWED_IP unless ALLOWED_IP.include? request.ip
status 403 status 403
return "Access denied" return "Access denied"
end end
@ -174,7 +173,7 @@ get '/all/:domain' do
end end
get '/ips/:public_key' do get '/ips/:public_key' do
unless request.ip == ALLOWED_IP unless ALLOWED_IP.include? request.ip
status 403 status 403
return "Access denied" return "Access denied"
end end
@ -186,7 +185,7 @@ get '/ips/:public_key' do
end end
get '/ban/:ip' do get '/ban/:ip' do
unless request.ip == ALLOWED_IP unless ALLOWED_IP.include? request.ip
status 403 status 403
return "Access denied" return "Access denied"
end end
@ -195,7 +194,7 @@ get '/ban/:ip' do
end end
get '/unban/:ip' do get '/unban/:ip' do
unless request.ip == ALLOWED_IP unless ALLOWED_IP.include? request.ip
status 403 status 403
return "Access denied" return "Access denied"
end end