Skip to content

Commit

Permalink
Added display of license limits
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed May 10, 2024
1 parent d152660 commit 8489c19
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions scripts/locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ local lang = {
["licence_expires_in"] = "License expires in %{time}",
["licence_generation"] = "Click on the above URL to generate your ntopng license, or purchase a license at <a class='ntopng-external-link' href=\"%{purchase_url}\"> ntop shop <i class=\"fas fa-external-link-alt\"></i></a>.<br>If you are no-profit, research or an education institution please read <a class='ntopng-external-link' href=\"%{universities_url}\">this page <i class=\"fas fa-external-link-alt\"></i></a>.",
["licence_save_path"] = "Please generate your license and save it on /etc/ntopng.license (or /usr/local/etc on BSD-based platforms) and restart ntopng.",
["licence_limits"] = "License Limits",
["licence_status"] = "License",
["maintenance"] = "Maintenance",
["maintenance_expired"] = "%{product} maintenance expired",
Expand Down
6 changes: 6 additions & 0 deletions scripts/lua/about.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ print("</td></tr>\n")
end
print("<tr><th><a class='ntopng-external-link' href=\"http://d3js.org\" target=\"_blank\">Data-Driven Documents (d3js) <i class='fas fa-external-link-alt'></i></A></th><td colspan=2>2.9.1 / 3.0</td></tr>\n")

print("<tr><th>".. i18n("about.licence_limits") .."</th><td colspan=2><table width=100% class=\"table table-bordered table-striped\">"
.. "<tr><th>Pools</th><td align=right>"..info["constants.max_num_host_pools"].."</td></tr>"
.. "<tr><th>Pool Members</th><td align=right>"..info["constants.max_num_pool_members"].."</td></tr>"
.. "<tr><th>Profiles</th><td align=right>"..info["constants.max_num_profiles"].."</td></tr>\n"
.. "<td></tr>\n"
)


print("</table>\n")
Expand Down
21 changes: 9 additions & 12 deletions src/HostPools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,17 @@ void HostPools::reloadPool(u_int16_t _pool_id, VLANAddressTree *new_tree, HostPo
if ((num_members = redis->smembers(kname, &pool_members)) > 0) {
// NOTE: the auto-assigned host_pool must not be limited as it receives
// devices assigments automatically
actual_num_members =
min_val((u_int32_t)num_members,
((_pool_id == ntop->getPrefs()->get_auto_assigned_pool_id())
? MAX_NUM_INTERFACE_HOSTS
: MAX_NUM_POOL_MEMBERS));
actual_num_members = min_val((u_int32_t)num_members,
((_pool_id == ntop->getPrefs()->get_auto_assigned_pool_id())
? MAX_NUM_INTERFACE_HOSTS : MAX_NUM_POOL_MEMBERS));

if (actual_num_members < num_members) {
ntop->getTrace()->traceEvent(
TRACE_WARNING,
"Too many members [pool id: %2d][pool members: %d]. "
"Maximum number of pool members for this license is %u, so %u pool "
"members will be ignored.",
_pool_id, num_members, actual_num_members,
num_members - actual_num_members, actual_num_members);
ntop->getTrace()->traceEvent(TRACE_WARNING,
"Too many members [pool id: %2d][pool members: %d]. "
"Maximum number of pool members for this license is %u, so %u pool "
"members will be ignored.",
_pool_id, num_members, actual_num_members,
num_members - actual_num_members, actual_num_members);
}

for (int k = 0; k < actual_num_members; k++) {
Expand Down
5 changes: 2 additions & 3 deletions src/LuaEngineNtop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4003,9 +4003,8 @@ static int ntop_get_info(lua_State *vm) {
ntop->getPro()->get_encoded_license());
lua_push_bool_table_entry(vm, "pro.has_valid_license",
ntop->getPro()->has_valid_license());
lua_push_str_table_entry(
vm, "pro.license_type",
ntop->getPro()->get_license_type(buf, sizeof(buf)));
lua_push_str_table_entry(vm, "pro.license_type",
ntop->getPro()->get_license_type(buf, sizeof(buf)));
lua_push_bool_table_entry(vm, "pro.forced_community",
ntop->getPro()->is_forced_community());
lua_push_bool_table_entry(vm, "pro.out_of_maintenance",
Expand Down

0 comments on commit 8489c19

Please sign in to comment.