Skip to content

Instantly share code, notes, and snippets.

@FreekingDean
Last active July 27, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreekingDean/84a5348ccb84f3c544c7ec0ea8d8f702 to your computer and use it in GitHub Desktop.
Save FreekingDean/84a5348ccb84f3c544c7ec0ea8d8f702 to your computer and use it in GitHub Desktop.
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