Last active
July 27, 2016 15:39
-
-
Save FreekingDean/84a5348ccb84f3c544c7ec0ea8d8f702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cidr_conflicts | |
ipa = get_ip_address | |
if permission | |
rules = user.rules.denied | |
else | |
rules = user.rules.allowed | |
end | |
conflicts_array = [] | |
rules.each do |rule| | |
rule_ipa = get_ip_address(rule.cidr) | |
next unless rule_ipa.present? | |
if rule_ipa.include?(ipa) || ipa.include?(rule_ipa) | |
conflicts_array << rule_ipa.to_string | |
end | |
end | |
conflicts_array | |
end | |
def cidr_conflicts | |
opposing_rules = self.permission? ? user.rules.denied : user.rules.allowed | |
our_ip_addresses(self.cidr) | |
opposing_rules.select { |rule| get_ip_address(rule.cidr) & our_ip_addresses } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment