1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-31 20:09: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

@@ -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