Skip to content

Commit

Permalink
Ignore the hosts file if it can't be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Mar 25, 2024
1 parent 0e3e7b5 commit 4c83554
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rex/proto/dns/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,15 @@ def initialize(config = {})
raise ResolverArgumentError, "Option #{key} not valid"
end
end

self.static_hostnames = StaticHostnames.new(hostnames: static_hosts)
self.static_hostnames.parse_hosts_file
begin
self.static_hostnames.parse_hosts_file
rescue StandardError => e
@logger.error 'Failed to parse the hosts file, ignoring it'
# if the hosts file is corrupted, just use a default instance with any specified hostnames
self.static_hostnames = StaticHostnames.new(hostnames: static_hosts)
end
end
#
# Provides current proxy setting if configured
Expand Down

0 comments on commit 4c83554

Please sign in to comment.