I'm trying to create an array of IP addresses so that when the application is ran Rack-Attack can identify from the set of IP addresses that are allowed to access the application. So what I have done is as followed:
a = "127.0.0.1"
Rack::Attack.blacklist('allow from localhost') do |req|
p "#{'127.0.0.1' == req.ip} "
a != req.ip
end
The above works, so localhost can access the application but I have tried the following below which seems to not work what so ever:
a = "127.0.0.1", "1.2.3.4"
Rack::Attack.blacklist('allow from localhost') do |req|
a.select{|x| x != req.ip}.join("")
end
Can someone explain what the correct way would be to do this. You can see that I create an array. I want Rack::Attack
to detect whether the IP address in the array has access or not.
to_set
triggered one of the key points the guy mentioned in the rails conf 2014 video: youtube.com/… but he doesBANNED_IPS = Set.new['1.2.3.4', '5.6.7.8']
But thank you – Embarkation