Module: Roda::RodaPlugins::IpShield
- Defined in:
- lib/ip_shield.rb
Defined Under Namespace
Modules: RequestMethods Classes: InvalidIP, UnauthorisedIP
Class Method Summary collapse
-
.configure(app, *ip_addrs) ⇒ Object
Auto configure
ip_shieldplugin.
Class Method Details
.configure(app, *ip_addrs) ⇒ Object
Note:
Auto configure ip_shield plugin. Set IPs when the plugin is loaded. The provided IP will be authorize automatically as long as they as are valid IPv4 or IPv6. There are two ways to set IP.
-
As a string. Ex; ‘0.0.0.0’
-
As an array of low and high boundaries. Ex; [‘0.0.0.0’, ‘0.0.0.7’]
boundaries should be an array with two string elements - IP. The first element must be low IP and the second should be high.
32 33 34 35 |
# File 'lib/ip_shield.rb', line 32 def self.configure(app, *ip_addrs) ip_addrs = app.opts[:ip_shield] || ip_addrs ip_addrs.each { |ip_addr| IPValidator.instance.add_ip(ip_addr) } unless ip_addrs.nil? || ip_addrs.empty? end |