Skip to content
Commits on Source (4)
## Unreleased
## 2.1.0
- Drop IPAddr patches !52
## 2.0.1
- Remove vendor directory and copy files into lib/azure !50
......
......@@ -13,8 +13,6 @@
# limitations under the License.
#--------------------------------------------------------------------------
require 'ipaddr'
if RUBY_VERSION.to_f < 2.0
begin
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32|mingw32/
......@@ -192,53 +190,4 @@ class String
end
end
# Code validate private/public IP acceptable ranges.
class IPAddr
PRIVATE_RANGES = [
IPAddr.new('10.0.0.0/8'),
IPAddr.new('172.16.0.0/12'),
IPAddr.new('192.168.0.0/16')
]
def private?
return false unless self.ipv4?
PRIVATE_RANGES.each do |ipr|
return true if ipr.include?(self)
end
false
end
def public?
!private?
end
class << self
def validate_ip_and_prefix(ip, cidr)
if cidr.to_s.empty?
raise "Cidr is missing for IP '#{ip}'."
elsif valid?(ip)
raise "Ip address '#{ip}' is invalid."
elsif !IPAddr.new(ip).private?
raise "Ip Address #{ip} must be private."
end
end
def validate_address_space(ip)
if ip.split('/').size != 2
raise "Cidr is invalid for IP #{ip}."
elsif valid?(ip)
raise "Address space '#{ip}' is invalid."
end
end
def address_prefix(ip, cidr)
ip + '/' + cidr.to_s
end
def valid?(ip)
(IPAddr.new(ip) rescue nil).nil?
end
end
end
Azure::Loggerx = Azure::Core::Logger
......@@ -24,7 +24,6 @@
# THE SOFTWARE.
#--------------------------------------------------------------------------
require "ipaddr"
require "azure/storage/common/core/error"
if RUBY_VERSION.to_f < 2.0
......@@ -210,52 +209,3 @@ class String
end
end
end
# Code validate private/public IP acceptable ranges.
class IPAddr
PRIVATE_RANGES = [
IPAddr.new('10.0.0.0/8'),
IPAddr.new('172.16.0.0/12'),
IPAddr.new('192.168.0.0/16')
]
def private?
return false unless self.ipv4?
PRIVATE_RANGES.each do |ipr|
return true if ipr.include?(self)
end
false
end
def public?
!private?
end
class << self
def validate_ip_and_prefix(ip, cidr)
if cidr.to_s.empty?
raise "Cidr is missing for IP '#{ip}'."
elsif valid?(ip)
raise "Ip address '#{ip}' is invalid."
elsif !IPAddr.new(ip).private?
raise "Ip Address #{ip} must be private."
end
end
def validate_address_space(ip)
if ip.split("/").size != 2
raise "Cidr is invalid for IP #{ip}."
elsif valid?(ip)
raise "Address space '#{ip}' is invalid."
end
end
def address_prefix(ip, cidr)
ip + "/" + cidr.to_s
end
def valid?(ip)
(IPAddr.new(ip) rescue nil).nil?
end
end
end
module Fog
module AzureRM
VERSION = '2.0.1'.freeze
VERSION = '2.1.0'.freeze
end
end