Sha256: 8ed749b9682c9cfaf62d0987b71b420f31d1b31fced4dd9022706f6425e17a56
Contents?: true
Size: 635 Bytes
Versions: 2
Compression:
Stored size: 635 Bytes
Contents
class IpUtils VALID_IPV4_PATTERN = '(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])'.freeze VALID_IPV6_PATTERN = '([0-9a-f]{1,4}:){7}([0-9a-f]){1,4}'.freeze def self.ip_address?(ip_address) return true if IpUtils.VALID_IPV4_PATTERN.match(ip_address) return true if IpUtils.VALID_IPV6_PATTERN.match(ip_address) false end def self.valid_public_ip?(ip_address) ip = IPAddr.new(ip_address) return false if ip.loopback? || ip.private? || ip.link_local? || ip.untrusted? || ip.tainted? true end def self.loop_back?(ip_address) IPAddr.new(ip_address).loopback? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
securenative-0.1.17 | lib/securenative/utils/ip_utils.rb |
securenative-0.1.16 | lib/securenative/utils/ip_utils.rb |