class Firewall::Rule
Public Class Methods
new(ip, allowed)
click to toggle source
# File lib/rule.rb, line 4 def initialize(ip, allowed) @ip = IPAddress.parse ip @allowed = allowed end
Public Instance Methods
allowed()
click to toggle source
# File lib/rule.rb, line 13 def allowed @allowed end
ip()
click to toggle source
# File lib/rule.rb, line 9 def ip @ip end
pass?(str_ip)
click to toggle source
# File lib/rule.rb, line 17 def pass? str_ip value = false ip = IPAddress.parse str_ip if @ip.prefix == 32 or ! @ip.network? # single address if @ip.address == ip.address value = @allowed end else # network if @ip.include?(ip) value = @allowed end end if @ip.address == "0.0.0.0" value = @allowed end value end
to_s()
click to toggle source
# File lib/rule.rb, line 38 def to_s "#{@ip.to_string} - #{@allowed}" end