1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-20 06:29:02 +00:00

Preserves targetname for connections requested with option any_af.

Relocates option any_af to comm.lua to make it more broadly available.
This commit is contained in:
nnposter
2017-03-05 15:41:46 +00:00
parent b4924eb362
commit 99fa80851c
3 changed files with 14 additions and 7 deletions

View File

@@ -14,6 +14,7 @@
-- * <code>connect_timeout</code> - socket timeout for connection. Default: same as <code>stdnse.get_timeout</code>
-- * <code>request_timeout</code> - additional socket timeout for requests. This is added to the connect_timeout to get a total time for a request to receive a response. Default: 6000ms
-- * <code>recv_before</code> - boolean, receive data before sending first payload
-- * <code>any_af</code> - boolean, allow connecting to any address family, inet or inet6. By default, these functions will only use the same AF as nmap.address_family to resolve names.
--
-- If both <code>"bytes"</code> and <code>"lines"</code> are provided,
-- <code>"lines"</code> takes precedence. If neither are given, the functions
@@ -64,6 +65,13 @@ local setup_connect = function(host, port, opts)
sock:set_timeout(connect_timeout)
if type(host) == "string" and opts.any_af then
local status, addrs = nmap.resolve(host)
if status then
host = {ip = addrs[1], targetname = host}
end
end
local status, err = sock:connect(host, port, opts.proto)
if not status then