16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/firewool/instance_methods.rb', line 16
def ip_allow?(ip)
firewool_config = self.class.firewool_config.yaml_config[Rails.env]
if firewool_config['ip_restriction']
allowed_ranges = firewool_config['allow']
denied_ranges = firewool_config['deny']
if allowed_ranges.include?("0.0.0.0")
access_decision = true
else
access_decision = false
end
client_ip = IPAddress::parse ip
if !allowed_ranges.nil?
if in_range?(allowed_ranges, client_ip)
access_decision = true
end
end
if !denied_ranges.nil?
if in_range?(denied_ranges, client_ip)
access_decision = false
end
end
access_decision
end
end
|