Skip to content

Commit

Permalink
Fix unit tests on Ruby 3.2 because IPAddr =~ fails
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Feb 8, 2024
1 parent 56d2dfa commit 1b2a2af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rex/proto/dns/static_hostnames.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get(hostname, type = Dnsruby::Types::A)
# @param [IPAddr, String] ip_address The IP address that is being defined for the hostname. If this value is a
# string, it will be converted to an IPAddr instance.
def add(hostname, ip_address)
ip_address = IPAddr.new(ip_address) if Rex::Socket.is_ip_addr?(ip_address)
ip_address = IPAddr.new(ip_address) if ip_address.is_a?(String) && Rex::Socket.is_ip_addr?(ip_address)

hostname = hostname.downcase
this_host = @hostnames.fetch(hostname, {})
Expand All @@ -100,7 +100,7 @@ def add(hostname, ip_address)
# @param [IPAddr, String] ip_address The IP address that is being undefined. If this value is a string, it will be
# converted to an IPAddr instance.
def delete(hostname, ip_address)
ip_address = IPAddr.new(ip_address) if Rex::Socket.is_ip_addr?(ip_address)
ip_address = IPAddr.new(ip_address) if ip_address.is_a?(String) && Rex::Socket.is_ip_addr?(ip_address)
if ip_address.family == ::Socket::AF_INET
type = Dnsruby::Types::A
else
Expand Down

0 comments on commit 1b2a2af

Please sign in to comment.