mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 04:09:01 +00:00
Let http.lua functions optionally connect via any address family
Sometimes (e.g. when using an external API), a script wants to connect by name to a server and doesn't care whether IPv4 or IPv6 is used. By passing the "any_af" option, the first resolved address of any address family will be used, allowing external-category scripts which used to fail with -6 to succeed.
This commit is contained in:
@@ -55,7 +55,7 @@ end
|
||||
-- No limit on requests. A free registration for an API key is a prerequisite
|
||||
local ipinfodb = function(ip)
|
||||
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
|
||||
local response = http.get("api.ipinfodb.com", 80, "/v3/ip-city/?key="..api_key.."&format=json".."&ip="..ip, nil)
|
||||
local response = http.get("api.ipinfodb.com", 80, "/v3/ip-city/?key="..api_key.."&format=json".."&ip="..ip, {any_af=true})
|
||||
local stat, loc = json.parse(response.body)
|
||||
if not stat then
|
||||
stdnse.debug1("No response, possibly a network problem.")
|
||||
|
||||
Reference in New Issue
Block a user