Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rex/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions spec/rex/socket_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down