mirror of
https://github.com/nmap/nmap.git
synced 2025-12-20 14:39:02 +00:00
Provides a common function, url.get_default_port(), for obtaining
the default port number for a given scheme. Fixes #781
This commit is contained in:
@@ -175,10 +175,8 @@ local function url_build_defaults (host, port, parsed)
|
||||
local parts = tcopy(parsed or {})
|
||||
parts.host = parts.host or stdnse.get_hostname(host, port)
|
||||
parts.scheme = parts.scheme or shortport.ssl(host, port) and "https" or "http"
|
||||
local pn = parts.port or port.number
|
||||
if not (parts.scheme == "http" and pn == 80
|
||||
or parts.scheme == "https" and pn == 443) then
|
||||
parts.port = pn
|
||||
if not parts.port and port.number ~= url.get_default_port(parts.scheme) then
|
||||
parts.port = port.number
|
||||
end
|
||||
return parts
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user