diff --git a/lib/rex/socket.rb b/lib/rex/socket.rb index cee793e..97bc776 100644 --- a/lib/rex/socket.rb +++ b/lib/rex/socket.rb @@ -133,7 +133,7 @@ def self.support_ipv6? # Determine whether this is a valid DNS name without trying to resolve it # def self.is_name?(name) - return false if name.length > 253 + return false if name.length > 253 || name =~ MATCH_IPV4 || name =~ MATCH_IPV6 name.delete_suffix('.') =~ MATCH_DNS_NAME ? (name =~ /\s/).nil? : false end diff --git a/spec/rex/socket_spec.rb b/spec/rex/socket_spec.rb index 12137b2..6c047b6 100644 --- a/spec/rex/socket_spec.rb +++ b/spec/rex/socket_spec.rb @@ -370,6 +370,13 @@ described_class.is_name?(try) end + context 'with an ip address' do + let(:try) { '192.168.1.1' } + it 'should return false' do + expect(name).to eq false + end + end + context 'with a hostname' do let(:try) { "localhost" } it "should return true" do