From fb6af1c99ec69247a1b0b97374bda4447e092268 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 17 Jul 2024 00:39:17 +0200 Subject: [PATCH] No longer hardcode localhost as bandwidth exception, instead auto-config local network exceptions when no exceptions are configured yet --- src/controller/controller_statistics.cpp | 15 --------------- src/controller/controller_storage.cpp | 8 ++++++++ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index d9a9fabc..f64d829d 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -169,21 +169,6 @@ void Controller::updateBandwidthConfig(){ } } } - //Localhost is always excepted from counts - { - std::string newbins = Socket::getBinForms("::1"); - if (offset + newbins.size() < 1700){ - memcpy(noBWCountMatches + offset, newbins.data(), newbins.size()); - offset += newbins.size(); - } - } - { - std::string newbins = Socket::getBinForms("127.0.0.1/8"); - if (offset + newbins.size() < 1700){ - memcpy(noBWCountMatches + offset, newbins.data(), newbins.size()); - offset += newbins.size(); - } - } } /// This function is ran whenever a stream becomes active. diff --git a/src/controller/controller_storage.cpp b/src/controller/controller_storage.cpp index e15bdba3..18ea726d 100644 --- a/src/controller/controller_storage.cpp +++ b/src/controller/controller_storage.cpp @@ -395,6 +395,14 @@ namespace Controller{ if (!Controller::Storage["config"].isMember("tknMode")){ Controller::Storage["config"]["tknMode"] = SESS_TKN_DEFAULT_MODE; } + if (!Controller::Storage.isMember("bandwidth") || !Controller::Storage["bandwidth"].isMember("exceptions") || !Controller::Storage["bandwidth"]["exceptions"].size()){ + Controller::Log("CONF", "Adding default bandwidth exception ranges (local networks) because nothing is configured"); + Controller::Storage["bandwidth"]["exceptions"].append("::1"); + Controller::Storage["bandwidth"]["exceptions"].append("127.0.0.0/8"); + Controller::Storage["bandwidth"]["exceptions"].append("10.0.0.0/8"); + Controller::Storage["bandwidth"]["exceptions"].append("192.168.0.0/16"); + Controller::Storage["bandwidth"]["exceptions"].append("172.16.0.0/12"); + } Controller::prometheus = Controller::Storage["config"]["prometheus"].asStringRef(); Controller::accesslog = Controller::Storage["config"]["accesslog"].asStringRef();