parent
6f1e75e097
commit
9148ab4bb2
|
@ -15,21 +15,19 @@ class OptAddressLocal < OptAddress
|
|||
|
||||
def normalize(value)
|
||||
return unless value.kind_of?(String)
|
||||
return value unless interfaces.include?(value)
|
||||
|
||||
if interfaces.include?(value)
|
||||
ip_address = NetworkInterface.addresses(value).values.flatten.map{|x| x['addr']}.select do |addr|
|
||||
begin
|
||||
IPAddr.new(addr).ipv4?
|
||||
rescue IPAddr::InvalidAddressError
|
||||
nil
|
||||
end
|
||||
ip_address = NetworkInterface.addresses(value).values.flatten.map{|x| x['addr']}.select do |addr|
|
||||
begin
|
||||
IPAddr.new(addr).ipv4?
|
||||
rescue IPAddr::InvalidAddressError
|
||||
nil
|
||||
end
|
||||
|
||||
return if ip_address.blank?
|
||||
return ip_address.first
|
||||
end
|
||||
|
||||
value
|
||||
return if ip_address.blank?
|
||||
|
||||
ip_address.first
|
||||
end
|
||||
|
||||
def valid?(value, check_empty: true)
|
||||
|
|
Loading…
Reference in New Issue