added ipv4 cidr and addresses filter
This commit is contained in:
parent
c9ab01c132
commit
a9bfdc9e23
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
#require 'spf/query'
|
||||
require 'ipaddr'
|
||||
|
||||
domain = ARGV[0]
|
||||
|
||||
@ -173,7 +174,30 @@ def getAllSpfIp4(domain)
|
||||
|
||||
base_dom["ipv4"].each { |cidr| ipv4 << cidr }
|
||||
|
||||
return ipv4
|
||||
# filter ipv4 list
|
||||
new_ipv4 = []
|
||||
ipv4.each do |ip|
|
||||
if valid_cidr?(ip) or valid_ip_address?(ip)
|
||||
new_ipv4 << ip
|
||||
end
|
||||
end
|
||||
|
||||
return new_ipv4
|
||||
end
|
||||
|
||||
|
||||
def valid_cidr?(input)
|
||||
IPAddr.new(input)
|
||||
true
|
||||
rescue IPAddr::InvalidAddressError
|
||||
false
|
||||
end
|
||||
|
||||
def valid_ip_address?(input)
|
||||
IPAddr.new(input)
|
||||
true
|
||||
rescue IPAddr::InvalidAddressError
|
||||
false
|
||||
end
|
||||
|
||||
puts getAllSpfIp4(domain)
|
||||
|
Loading…
Reference in New Issue
Block a user