module Fog::Proxmox::IpHelper
module IpHelper
mixins
Constants
- CIDRv4_PREFIX
- CIDRv4_PREFIX_REGEXP
- CIDRv4_REGEXP
- CIDRv6_PREFIX
- CIDRv6_PREFIX_REGEXP
- CIDRv6_REGEXP
- IPv4_SRC
- IPv6_SRC
Public Class Methods
cidr6?(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 40 def self.cidr6?(ip) CIDRv6_REGEXP.match?(ip) end
cidr6_prefix?(prefix)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 68 def self.cidr6_prefix?(prefix) CIDRv6_PREFIX_REGEXP.match?(prefix) && prefix.to_i >= 0 && prefix.to_i <= 128 end
cidr?(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 36 def self.cidr?(ip) CIDRv4_REGEXP.match?(ip) end
cidr_prefix?(prefix)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 64 def self.cidr_prefix?(prefix) CIDRv4_PREFIX_REGEXP.match?(prefix) end
ip(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 72 def self.ip(ip) return unless cidr = CIDRv4_REGEXP.match(ip) cidr[1] end
ip6(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 78 def self.ip6(ip) return unless cidr = CIDRv6_REGEXP.match(ip) cidr[1] end
ip6?(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 60 def self.ip6?(ip) Resolv::IPv6::Regex.match?(ip) end
ip?(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 56 def self.ip?(ip) Resolv::IPv4::Regex.match?(ip) end
prefix(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 44 def self.prefix(ip) return unless cidr = CIDRv4_REGEXP.match(ip) cidr[7] end
prefix6(ip)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 50 def self.prefix6(ip) return unless cidr = CIDRv6_REGEXP.match(ip) cidr[3] end
to_cidr(ip, prefix = nil)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 84 def self.to_cidr(ip, prefix = nil) return nil unless ip?(ip) && (!prefix || cidr_prefix?(prefix)) cidr = "#{ip}" cidr += "/#{prefix}" if cidr_prefix?(prefix) cidr end
to_cidr6(ip, prefix = nil)
click to toggle source
# File lib/fog/proxmox/helpers/ip_helper.rb, line 92 def self.to_cidr6(ip, prefix = nil) return nil unless ip6?(ip) && (!prefix || cidr6_prefix?(prefix)) cidr = "#{ip}" cidr += "/#{prefix}" if cidr6_prefix?(prefix) cidr end