mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Add ntopng Host Address prefs under User Interface settings
This commit is contained in:
parent
6187ee30b8
commit
615cb2544a
5 changed files with 48 additions and 11 deletions
|
|
@ -1210,18 +1210,35 @@ function getHttpHost()
|
|||
local ntopng_info = ntop.getInfo()
|
||||
local ntopng_host_info = ntop.getHostInformation()
|
||||
|
||||
local ntopng_host_ip = ntopng_host_info.ip or '127.0.0.1'
|
||||
|
||||
local ntopng_protocol = "http://"
|
||||
local ntopng_port = ntopng_info.http_port
|
||||
|
||||
if not ntop.isnEdge()
|
||||
and ntopng_info.https_port and tonumber(ntopng_info.https_port) ~= 0 then
|
||||
ntopng_protocol = "https://"
|
||||
ntopng_port = ntopng_info.https_port
|
||||
-- Read configured ntopng host name or IP
|
||||
local ntopng_host_ip = ntop.getPref("ntopng.prefs.ntopng_host_address")
|
||||
if isEmptyString(ntopng_host_ip) then
|
||||
-- fallback: managegemt IP
|
||||
ntopng_host_ip = ntopng_host_info.ip
|
||||
end
|
||||
if isEmptyString(ntopng_host_ip) then
|
||||
-- last resort: dummy IP
|
||||
ntopng_host_ip = '127.0.0.1'
|
||||
end
|
||||
|
||||
return ntopng_protocol .. ntopng_host_ip .. ":" .. ntopng_port
|
||||
local http_host
|
||||
if starts(ntopng_host_ip, 'http') then
|
||||
http_host = ntopng_host_ip
|
||||
else
|
||||
-- Computing URL adding protocol and port
|
||||
local ntopng_protocol = "http://"
|
||||
local ntopng_port = ntopng_info.http_port
|
||||
|
||||
if not ntop.isnEdge()
|
||||
and ntopng_info.https_port and tonumber(ntopng_info.https_port) ~= 0 then
|
||||
ntopng_protocol = "https://"
|
||||
ntopng_port = ntopng_info.https_port
|
||||
end
|
||||
|
||||
http_host = ntopng_protocol .. ntopng_host_ip .. ":" .. ntopng_port
|
||||
end
|
||||
|
||||
return http_host
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue