1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 17:39:03 +00:00

Re-indent some scripts. Whitespace-only commit

https://secwiki.org/w/Nmap/Code_Standards
This commit is contained in:
dmiller
2014-01-31 13:02:29 +00:00
parent 64fb5b3482
commit d36c08dcf5
137 changed files with 3977 additions and 3977 deletions

View File

@@ -34,54 +34,54 @@ categories = {"discovery","external","safe"}
hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err )
return false
elseif is_private then
stdnse.print_debug("%s not running: Private IP address of target: %s", SCRIPT_NAME, host.ip)
return false
end
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err )
return false
elseif is_private then
stdnse.print_debug("%s not running: Private IP address of target: %s", SCRIPT_NAME, host.ip)
return false
end
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
if not (type(api_key)=="string") then
stdnse.print_debug("%s not running: No IPInfoDB API key specified.", SCRIPT_NAME)
return false
end
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
if not (type(api_key)=="string") then
stdnse.print_debug("%s not running: No IPInfoDB API key specified.", SCRIPT_NAME)
return false
end
return true
return true
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 stat, loc = json.parse(response.body)
if not stat then
stdnse.print_debug("No response, possibly a network problem.")
return nil
end
if loc.statusMessage and loc.statusMessage == "Invalid API key." then
stdnse.print_debug(loc.statusMessage)
return nil
end
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 stat, loc = json.parse(response.body)
if not stat then
stdnse.print_debug("No response, possibly a network problem.")
return nil
end
if loc.statusMessage and loc.statusMessage == "Invalid API key." then
stdnse.print_debug(loc.statusMessage)
return nil
end
local output = {}
table.insert(output, "coordinates (lat,lon): "..loc.latitude..","..loc.longitude)
table.insert(output,"city: ".. loc.cityName..", ".. loc.regionName..", ".. loc.countryName)
local output = {}
table.insert(output, "coordinates (lat,lon): "..loc.latitude..","..loc.longitude)
table.insert(output,"city: ".. loc.cityName..", ".. loc.regionName..", ".. loc.countryName)
return output
return output
end
action = function(host,port)
local output = ipinfodb(host.ip)
local output = ipinfodb(host.ip)
if(#output~=0) then
output.name = host.ip
if host.targetname then
output.name = output.name.." ("..host.targetname..")"
end
end
if(#output~=0) then
output.name = host.ip
if host.targetname then
output.name = output.name.." ("..host.targetname..")"
end
end
return stdnse.format_output(true,output)
return stdnse.format_output(true,output)
end