1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-30 01:59:02 +00:00

o Update the HTTP library to use the new timing_level functionality to

set connection and response timeouts. An error preventing the new
  timing_level feature from working was also fixed.  [Jah]
This commit is contained in:
fyodor
2008-06-18 00:15:27 +00:00
parent a4ed2549a4
commit 92e39aa66f
3 changed files with 27 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
# Nmap Changelog ($Id$); -*-text-*-
o Update the HTTP library to use the new timing_level functionality to
set connection and response timeouts. An error preventing the new
timing_level feature from working was also fixed. [Jah]
o Added a new timing_level() function to NSE which reports the Nmap
timing level from 0 to 5, as set by the Nmap -T option. The default
is 3. [Thomas Buchanan]

View File

@@ -99,6 +99,7 @@ int luaopen_nmap (lua_State *L)
{"debugging", l_get_debugging},
{"have_ssl", l_get_have_ssl},
{"fetchfile", l_fetchfile},
{"timing_level", l_get_timing_level},
{NULL, NULL}
};

View File

@@ -85,12 +85,19 @@ request = function( host, port, data, options )
local result = {status=nil,header={},body=""}
local socket = nmap.new_socket()
local default_timeout = {}
if options.timeout then
socket:set_timeout( options.timeout )
else
default_timeout = get_default_timeout( nmap.timing_level() )
socket:set_timeout( default_timeout.connect )
end
if not socket:connect( host, port, protocol ) then
return result
end
if not options.timeout then
socket:set_timeout( default_timeout.request )
end
if not socket:send( data ) then
return result
end
@@ -147,3 +154,18 @@ request = function( host, port, data, options )
end
get_default_timeout = function( nmap_timing )
local timeout = {}
if nmap_timing >= 0 and nmap_timing <= 3 then
timeout.connect = 10000
timeout.request = 15000
end
if nmap_timing >= 4 then
timeout.connect = 5000
timeout.request = 10000
end
if nmap_timing >= 5 then
timeout.request = 7000
end
return timeout
end