mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-03 01:10:10 +00:00
Removed lagegy code and moved to vue
This commit is contained in:
parent
10f699af39
commit
8440f1a9d4
1 changed files with 1 additions and 575 deletions
|
|
@ -324,581 +324,7 @@ page_utils.print_navbar(i18n("hosts"), base_url .. "?", {{
|
|||
url = ntop.getHttpPrefix() .. "/lua/as_overview.lua?asn=" .. (asn or 0)
|
||||
}})
|
||||
|
||||
-- added not to use new table, remove not to use old table (in case of errors)
|
||||
if page == 'active_hosts' and not ntop.isnEdge() then
|
||||
page_utils.print_page_title(getPageTitle(protocol_name, traffic_type_title, device_ip_title, network_name, cidr,
|
||||
ipver_title, os_title, country_title, asninfo, mac_title, pool_title, vlan_title, vlan_alias))
|
||||
|
||||
if (_GET["page"] ~= "historical") then
|
||||
if (asn ~= nil) then
|
||||
print [[
|
||||
<div class='card'><div class='card-header'>
|
||||
<ul class="nav nav-tabs card-header-tabs">
|
||||
<li class="nav-item" class="active"><a class="nav-link active" data-bs-toggle="tab" href="#home">]]
|
||||
print(i18n("hosts_stats.hosts"))
|
||||
print [[</a></li>
|
||||
]]
|
||||
|
||||
if (asn ~= "0") then
|
||||
print [[
|
||||
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#asinfo">]]
|
||||
print(i18n("hosts_stats.as_info"))
|
||||
print [[</a></li>
|
||||
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#aspath">]]
|
||||
print(i18n("hosts_stats.as_path"))
|
||||
print [[</a></li>
|
||||
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#prefix">]]
|
||||
print(i18n("hosts_stats.as_prefixes"))
|
||||
print [[</a></li>
|
||||
<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" href="#bgp">]]
|
||||
print(i18n("hosts_stats.bgp_updates"))
|
||||
print [[</a></li>
|
||||
]]
|
||||
end
|
||||
end
|
||||
|
||||
print("</ul>") -- close .card-header
|
||||
|
||||
if (asn ~= nil) then
|
||||
print("</div>")
|
||||
end
|
||||
|
||||
if (asn ~= nil) then
|
||||
print [[
|
||||
<div class='card-body'>
|
||||
<div class="tab-content">
|
||||
<div id="home" class="tab-pane in active">
|
||||
]]
|
||||
end
|
||||
|
||||
-- build the current filter url
|
||||
page_params["os"] = os_
|
||||
page_params["asn"] = asn
|
||||
page_params["community"] = community
|
||||
page_params["vlan"] = vlan
|
||||
page_params["country"] = country
|
||||
page_params["mac"] = mac
|
||||
page_params["pool"] = pool
|
||||
page_params["network_cidr"] = cidr
|
||||
|
||||
if (protocol ~= nil) then
|
||||
-- Example HTTP.Facebook
|
||||
dot = string.find(protocol, '%.')
|
||||
if (dot ~= nil) then
|
||||
protocol = string.sub(protocol, dot + 1)
|
||||
end
|
||||
|
||||
page_params["protocol"] = protocol
|
||||
end
|
||||
|
||||
if (network ~= nil) then
|
||||
page_params["network"] = network
|
||||
local network_key = ntop.getNetworkNameById(tonumber(network))
|
||||
|
||||
if not isEmptyString(network_name) then
|
||||
local charts_available = areInterfaceTimeseriesEnabled(ifstats.id)
|
||||
|
||||
charts_icon = " <small><a href='" .. ntop.getHttpPrefix() .. "/lua/network_details.lua?network=" ..
|
||||
network .. "&page=config'><i class='fas fa-sm fa-cog'></i></a>"
|
||||
|
||||
if charts_available then
|
||||
charts_icon = charts_icon .. " <a href='" .. ntop.getHttpPrefix() ..
|
||||
"/lua/network_details.lua?network=" .. network ..
|
||||
"&page=historical'><i class='fas fa-sm fa-chart-area'></i></a>"
|
||||
end
|
||||
|
||||
charts_icon = charts_icon .. "</small>"
|
||||
end
|
||||
end
|
||||
|
||||
if not isEmptyString(ipversion) then
|
||||
page_params["version"] = ipversion
|
||||
end
|
||||
|
||||
custom_column_utils.updateCustomColumn()
|
||||
local custom_name, custom_key, custom_align = custom_column_utils.getCustomColumnName()
|
||||
|
||||
print [[
|
||||
<div id="table-hosts"></div>
|
||||
<script>
|
||||
var url_update = "]]
|
||||
print(getPageUrl(ntop.getHttpPrefix() .. "/lua/get_hosts_data.lua", page_params))
|
||||
print [[";]]
|
||||
|
||||
ntop.dumpFile(dirs.installdir .. "/httpdocs/inc/hosts_stats_id.inc")
|
||||
|
||||
if ((ifstats.vlan)) then
|
||||
show_vlan = true
|
||||
else
|
||||
show_vlan = false
|
||||
end
|
||||
|
||||
if (show_vlan) then
|
||||
print('host_rows_option["vlan"] = true;\n')
|
||||
end
|
||||
|
||||
if ((custom_key == "") or (custom_key == nil)) then
|
||||
custom_key = "score"
|
||||
end
|
||||
|
||||
print [[
|
||||
host_rows_option["ip"] = true;
|
||||
host_rows_option["custom_column"] = "]]
|
||||
print(custom_key)
|
||||
print [[";
|
||||
$("#table-hosts").datatable({
|
||||
title: "]]
|
||||
print(i18n("hosts_stats.hosts_list"))
|
||||
print [[",
|
||||
url: url_update ,
|
||||
]]
|
||||
|
||||
if (protocol == nil) then
|
||||
protocol = ""
|
||||
end
|
||||
|
||||
if not isEmptyString(protocol_name) then
|
||||
local iface_ts_id = getIfacenDPITsName()
|
||||
charts_icon = " <a href='" .. ntop.getHttpPrefix() .. "/lua/if_stats.lua?ifid=" .. ifstats.id ..
|
||||
"&page=historical&ts_schema=" .. iface_ts_id .. "&protocol=" .. protocol_name ..
|
||||
"'><i class='fas fa-sm fa-chart-area'></i></a>"
|
||||
end
|
||||
|
||||
print('title: "",\n')
|
||||
print('rowCallback: function ( row ) { return host_table_setID(row); },')
|
||||
|
||||
print [[
|
||||
tableCallback: function() { $("#dt-bottom-details > .float-left > p").first().append('. ]]
|
||||
print(i18n('hosts_stats.idle_hosts_not_listed'))
|
||||
print [['); },
|
||||
]]
|
||||
|
||||
-- Set the preference table
|
||||
preference = tablePreferences("rows_number", _GET["perPage"])
|
||||
if (preference ~= "") then
|
||||
print('perPage: ' .. preference .. ",\n")
|
||||
end
|
||||
|
||||
-- Automatic default sorted. NB: the column must exist.
|
||||
print('sort: [ ["' .. getDefaultTableSort("hosts") .. '","' .. getDefaultTableSortOrder("hosts") .. '"] ],')
|
||||
|
||||
print [[ showPagination: true, ]]
|
||||
|
||||
print('buttons: [ ')
|
||||
|
||||
-- IP version selector
|
||||
print [['<div class="btn-group float-right">]]
|
||||
custom_column_utils.printCustomColumnDropdown(base_url, page_params)
|
||||
print [[</div>']]
|
||||
|
||||
-- IP version selector
|
||||
print [[, '<div class="btn-group float-right">]]
|
||||
printIpVersionDropdown(base_url, page_params)
|
||||
print [[</div>']]
|
||||
|
||||
-- VLAN selector
|
||||
if ifstats.vlan then
|
||||
print [[, '<div class="btn-group float-right">]]
|
||||
printVLANFilterDropdown(base_url, page_params)
|
||||
print [[</div>']]
|
||||
end
|
||||
|
||||
print [[, '<div class="btn-group float-right">]]
|
||||
printTrafficTypeFilterDropdown(base_url, page_params)
|
||||
print [[</div>']]
|
||||
|
||||
-- Hosts filter
|
||||
-- table.clone needed to modify some parameters while keeping the original unchanged
|
||||
local hosts_filter_params = table.clone(page_params)
|
||||
|
||||
print(', \'<div class="btn-group"><button class="btn btn-link dropdown-toggle" data-bs-toggle="dropdown">' ..
|
||||
i18n("hosts_stats.filter_hosts") .. hosts_filter ..
|
||||
'<span class="caret"></span></button> <ul class="dropdown-menu scrollable-dropdown" role="menu" style="min-width: 90px;"><li"><a class="dropdown-item" href="')
|
||||
|
||||
hosts_filter_params.mode = nil
|
||||
hosts_filter_params.pool = nil
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.all_hosts") .. '</a></li>')
|
||||
|
||||
|
||||
hosts_filter_params.mode = "blacklisted"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "blacklisted", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.blacklisted_hosts_only") .. '</a></li>')
|
||||
|
||||
if interface.isPacketInterface() and not interface.isPcapDumpInterface() then
|
||||
|
||||
hosts_filter_params.mode = "broadcast_domain"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "broadcast_domain", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.broadcast_domain_hosts_only") .. '</a></li>')
|
||||
end
|
||||
|
||||
hosts_filter_params.mode = "broadcast_multicast"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "broadcast_multicast", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.broadcast_and_multicast") .. '</a></li>')
|
||||
|
||||
if interface.isPacketInterface() and not interface.isPcapDumpInterface() then
|
||||
hosts_filter_params.mode = "dhcp"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "dhcp", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("mac_stats.dhcp_only") .. '</a></li>')
|
||||
end
|
||||
|
||||
-- Host pools
|
||||
if (not ifstats.isView) then
|
||||
hosts_filter_params.mode = nil
|
||||
hosts_filter_params.pool = nil
|
||||
local pools = host_pools_instance:get_all_pools()
|
||||
if (table.len(pools) > 2) then
|
||||
-- Not only the default and jailed (host pools or nEdge users)
|
||||
print('<li role="separator" class="divider"></li>')
|
||||
for _, _pool in ipairs(pools) do
|
||||
hosts_filter_params.pool = _pool.pool_id
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary((tonumber(pool) == _pool.pool_id), 'active', '') .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params) .. '">' ..
|
||||
i18n(ternary(have_nedge, "hosts_stats.user", "hosts_stats.host_pool"), {
|
||||
pool_name = string.gsub(_pool.name, "'", "\\'")
|
||||
}) .. '</li>')
|
||||
end
|
||||
hosts_filter_params.pool = nil
|
||||
end
|
||||
end
|
||||
|
||||
hosts_filter_params.mode = "local"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "local", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.local_hosts_only") .. '</a></li>')
|
||||
|
||||
hosts_filter_params.mode = "local_no_tx"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "local_no_tx", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.local_no_tx") .. '</a></li>')
|
||||
|
||||
hosts_filter_params.mode = "local_no_tcp_tx"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "local_no_tcp_tx", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.local_no_tcp_tx") .. '</a></li>')
|
||||
|
||||
hosts_filter_params.mode = "remote"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "remote", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.remote_hosts_only") .. '</a></li>')
|
||||
|
||||
hosts_filter_params.mode = "remote_no_tx"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "remote_no_tx", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.remote_no_tx") .. '</a></li>')
|
||||
|
||||
hosts_filter_params.mode = "remote_no_tcp_tx"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "remote_no_tcp_tx", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.remote_no_tcp_tx") .. '</a></li>')
|
||||
|
||||
if isBridgeInterface(ifstats) then
|
||||
hosts_filter_params.mode = "filtered"
|
||||
print('<li ')
|
||||
print('"><a class="dropdown-item ' .. ternary(mode == "filtered", "active", "") .. '" href="')
|
||||
print(getPageUrl(base_url, hosts_filter_params))
|
||||
print('">' .. i18n("hosts_stats.filtered_hosts_only") .. '</a></li>')
|
||||
end
|
||||
|
||||
print('</ul></div>\'')
|
||||
local alignment_c_info = 'center'
|
||||
if (ntop.isnEdge()) then
|
||||
alignment_c_info = 'nowrap'
|
||||
end
|
||||
print(' ],')
|
||||
|
||||
print [[
|
||||
columns: [
|
||||
{
|
||||
title: "Key",
|
||||
field: "key",
|
||||
hidden: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},{
|
||||
title: "",
|
||||
field: "column_info",
|
||||
sortable: false,
|
||||
css: {
|
||||
textAlign: ']]print(alignment_c_info)print[[',
|
||||
whiteSpace: 'nowrap'
|
||||
|
||||
}
|
||||
},{
|
||||
title: "]]
|
||||
print(i18n("ip_address"))
|
||||
print [[",
|
||||
field: "column_ip",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'left'
|
||||
}
|
||||
},
|
||||
]]
|
||||
|
||||
if (show_vlan) then
|
||||
print('{ title: "' .. i18n("vlan") .. '",\n')
|
||||
print [[
|
||||
field: "column_vlan",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
|
||||
},
|
||||
]]
|
||||
end
|
||||
|
||||
print [[
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("flows"))
|
||||
print [[",
|
||||
field: "column_num_flows",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("hosts_stats.page_scan_hosts.title_hosts_page") )
|
||||
print [[",
|
||||
field: "column_num_vulnerabilities",
|
||||
sortable: false,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
},
|
||||
hidden: ]]
|
||||
local scan_modules = vs_utils.list_scan_modules()
|
||||
print(#scan_modules == 0)
|
||||
print [[
|
||||
|
||||
}, {
|
||||
title: "]]
|
||||
print(i18n("if_stats_overview.blocked_flows"))
|
||||
print [[",
|
||||
field: "column_num_dropped_flows",
|
||||
sortable: true,
|
||||
hidden: ]]
|
||||
if isBridgeInterface(ifstats) then
|
||||
print("false")
|
||||
else
|
||||
print("true")
|
||||
end
|
||||
print [[,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
|
||||
}, {
|
||||
title: "]]
|
||||
-- tprint({custom_name = custom_name, custom_key = custom_key, custom_align = custom_align})
|
||||
print(custom_name)
|
||||
print [[",
|
||||
field: "column_]]
|
||||
print(custom_key)
|
||||
print [[",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: ']]
|
||||
print(custom_align)
|
||||
print [['
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("name"))
|
||||
print [[",
|
||||
field: "column_name",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'left'
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("seen_since"))
|
||||
print [[",
|
||||
field: "column_since",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
}, {
|
||||
title: "]]
|
||||
print(i18n("score"))
|
||||
print [[",
|
||||
field: "column_score",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
}, {
|
||||
title: "]]
|
||||
print(i18n("breakdown"))
|
||||
print [[",
|
||||
field: "column_breakdown",
|
||||
sortable: false,
|
||||
css: {
|
||||
textAlign: 'center'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("throughput"))
|
||||
print [[",
|
||||
field: "column_thpt",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'right'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "]]
|
||||
print(i18n("flows_page.total_bytes"))
|
||||
print [[",
|
||||
field: "column_traffic",
|
||||
sortable: true,
|
||||
css: {
|
||||
textAlign: 'right'
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
]]
|
||||
|
||||
if (have_nedge) then
|
||||
print [[
|
||||
<script>
|
||||
const block_host_csrf = "]]
|
||||
print(ntop.getRandomCSRFValue())
|
||||
print [[";
|
||||
|
||||
function block_host(host_key, host_url) {
|
||||
var url = "]]
|
||||
print(ntop.getHttpPrefix())
|
||||
print [[/lua/pro/nedge/toggle_block_host.lua?" + host_url;
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url,
|
||||
cache: false,
|
||||
data: {
|
||||
csrf: block_host_csrf
|
||||
},
|
||||
success: function(content) {
|
||||
var data = jQuery.parseJSON(content);
|
||||
if (data.status == "BLOCKED") {
|
||||
$('#'+host_key+'_info').find('.block-badge')
|
||||
.removeClass('btn-secondary').addClass('btn-danger');
|
||||
$('#'+host_key+'_ip').find('a').css("text-decoration", "line-through");
|
||||
} else if (data.status == "UNBLOCKED") {
|
||||
$('#'+host_key+'_info').find('.block-badge')
|
||||
.removeClass('btn-danger').addClass('btn-secondary');
|
||||
$('#'+host_key+'_ip').find('a').css("text-decoration", "none");
|
||||
}
|
||||
},
|
||||
error: function(content) {
|
||||
console.log("error");
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
]]
|
||||
end
|
||||
|
||||
if (asn ~= nil) then
|
||||
print [[
|
||||
</div>
|
||||
<script>
|
||||
let STAT_WIDGET_API_URL = 'https://stat.ripe.net/widgets/';
|
||||
let STAT_DATA_API_URL = 'https://stat.ripe.net/data/';
|
||||
let STAT_OTHER_API_URL = 'https://stat.ripe.net/api/';
|
||||
let STAT_HOME = "https://stat.ripe.net/";
|
||||
// DOM class for auto linking to div element
|
||||
let STAT_DOM_CLASS_NAME = 'statwdgtauto';
|
||||
// how many seconds to wait for scripts to load
|
||||
// 0 ... disables the timeout
|
||||
let STAT_REQUIRE_TIMEOUT = 120;
|
||||
</script>
|
||||
<script src="https://stat.ripe.net/widget-api-config"></script>
|
||||
<script src="https://stat.ripe.net/widgets/js/version.js"></script>
|
||||
<script src="https://stat.ripe.net/widgets/js/widget_api_main.js"></script>
|
||||
|
||||
<div id="asinfo" class="tab-pane"></div>
|
||||
<div id="aspath" class="tab-pane"></div>
|
||||
<div id="prefix" class="tab-pane"></div>
|
||||
<div id="bgp" class="tab-pane"></div>
|
||||
]]
|
||||
|
||||
if (asn ~= nil) then
|
||||
print("</div>")
|
||||
print("</div>")
|
||||
print("</div>")
|
||||
end
|
||||
|
||||
print [[
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var tab_id_to_widget = {
|
||||
"#asinfo": "iana-registry-info",
|
||||
"#aspath": "as-path-length",
|
||||
"#prefix": "announced-prefixes",
|
||||
"#bgp": "bgp-update-activity",
|
||||
};
|
||||
var loaded_widgets = {};
|
||||
|
||||
function load_widget(tab_id) {
|
||||
var widget = tab_id_to_widget[tab_id];
|
||||
|
||||
if((typeof(widget) === "undefined") || loaded_widgets[widget])
|
||||
return;
|
||||
|
||||
var tab = $(tab_id);
|
||||
var script = $("<script>")
|
||||
var div = $('<div class="statwdgtauto"></div>');
|
||||
script.text('ripestat.init("' + widget + '",{"resource":"AS]]
|
||||
print(asn)
|
||||
print [["},null,{"disable":["controls"]});');
|
||||
script.appendTo(div);
|
||||
div.appendTo(tab);
|
||||
|
||||
loaded_widgets[widget] = true;
|
||||
}
|
||||
|
||||
$('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
var target = $(e.target).attr("href") // activated tab
|
||||
load_widget(target);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
]]
|
||||
end -- if(asn ~= nil)
|
||||
end
|
||||
elseif page == "active_hosts" then
|
||||
if page == "active_hosts" then
|
||||
local json = require "dkjson"
|
||||
local vlans = interface.getVLANsList()
|
||||
local json_context = json.encode({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue