mirror of
https://github.com/YunoHost/dynette.git
synced 2024-09-03 20:06:17 +02:00
Multiple allowed ips
This commit is contained in:
parent
d332c6558f
commit
cc70ce072e
1 changed files with 6 additions and 7 deletions
13
dynette.rb
13
dynette.rb
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue