From 4c63dd8bb765c693cfdd79c3da5dc6de22bc4c69 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Sun, 9 Mar 2025 10:23:34 -0300 Subject: [PATCH] start1 --- data/igate_conf.json | 6 ++++- data_embed/index.html | 8 +++--- data_embed/script.js | 2 +- include/configuration.h | 10 ++++++-- include/station_utils.h | 6 +++-- src/LoRa_APRS_iGate.cpp | 5 ++-- src/configuration.cpp | 15 ++++++++--- src/lora_utils.cpp | 2 +- src/station_utils.cpp | 56 ++++++++++++++++++++++++++++------------- src/web_utils.cpp | 2 +- 10 files changed, 78 insertions(+), 34 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index afe41b8..b18bce6 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -84,6 +84,10 @@ "ntp": { "gmtCorrection": 0.0 }, + "remoteManagement": { + "managers": "", + "rfOnly": true + }, "other": { "rememberStationTime": 30, "lowPowerMode": false, @@ -93,5 +97,5 @@ "rebootModeTime": 6 }, "personalNote": "", - "blackList": "" + "blacklist": "" } \ No newline at end of file diff --git a/data_embed/index.html b/data_embed/index.html index cdbb125..e3af7ef 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -596,14 +596,14 @@
Blacklist wifiAPs; WiFi_Auto_AP wifiAutoAP; BEACON beacon; @@ -147,7 +152,8 @@ public: TNC tnc; OTA ota; WEBADMIN webadmin; - NTP ntp; + NTP ntp; + REMOTE_MANAGEMENT remoteManagement; void init(); void writeFile(); diff --git a/include/station_utils.h b/include/station_utils.h index d84d32d..c6d72e8 100644 --- a/include/station_utils.h +++ b/include/station_utils.h @@ -18,8 +18,10 @@ struct LastHeardStation { namespace STATION_Utils { - void loadBlackList(); - bool checkBlackList(const String& callsign); + void loadBlacklist(); + void loadManagers(); + bool isBlacklisted(const String& callsign); + bool isManager(const String& callsign); bool checkObjectTime(const String& packet); void deleteNotHeard(); void updateLastHeard(const String& station); diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index d785f13..feb2ab6 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -48,7 +48,7 @@ ___________________________________________________________________*/ #include "A7670_utils.h" #endif -String versionDate = "2025.03.03"; +String versionDate = "2025.03.09"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS @@ -85,7 +85,8 @@ void setup() { LoRa_Utils::setup(); Utils::validateFreqs(); GPS_Utils::setup(); - STATION_Utils::loadBlackList(); + STATION_Utils::loadBlacklist(); + STATION_Utils::loadManagers(); #ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers displayShow("", " STARTUP DELAY ...", "", "", 0); diff --git a/src/configuration.cpp b/src/configuration.cpp index 1aefb0a..f666f17 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -99,7 +99,7 @@ void Configuration::writeFile() { data["personalNote"] = personalNote; - data["blackList"] = blackList; + data["blacklist"] = blacklist; data["webadmin"]["active"] = webadmin.active; data["webadmin"]["username"] = webadmin.username; @@ -107,6 +107,9 @@ void Configuration::writeFile() { data["ntp"]["gmtCorrection"] = ntp.gmtCorrection; + data["remoteManagement"]["managers"] = remoteManagement.managers; + data["remoteManagement"]["rfOnly"] = remoteManagement.rfOnly; + serializeJson(data, configFile); configFile.close(); @@ -223,7 +226,10 @@ bool Configuration::readFile() { personalNote = data["personalNote"] | "personal note here"; - blackList = data["blackList"] | "station callsign"; + blacklist = data["blacklist"] | "station callsign"; + + remoteManagement.managers = data["remoteManagement"]["managers"] | ""; + remoteManagement.rfOnly = data["remoteManagement"]["rfOnly"] | true; if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP WiFi_AP wifiap; @@ -331,7 +337,7 @@ void Configuration::init() { personalNote = ""; - blackList = ""; + blacklist = ""; webadmin.active = false; webadmin.username = "admin"; @@ -339,6 +345,9 @@ void Configuration::init() { ntp.gmtCorrection = 0.0; + remoteManagement.managers = ""; + remoteManagement.rfOnly = true; + Serial.println("All is Written!"); } diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp index 4c46a8c..261f515 100644 --- a/src/lora_utils.cpp +++ b/src/lora_utils.cpp @@ -185,7 +185,7 @@ namespace LoRa_Utils { if (packet != "") { String sender = packet.substring(3, packet.indexOf(">")); - if (packet.substring(0,3) == "\x3c\xff\x01" && !STATION_Utils::checkBlackList(sender)){ // avoid processing BlackListed stations + if (packet.substring(0,3) == "\x3c\xff\x01" && !STATION_Utils::isBlacklisted(sender)){ // avoid processing BlackListed stations rssi = radio.getRSSI(); snr = radio.getSNR(); freqError = radio.getFrequencyError(); diff --git a/src/station_utils.cpp b/src/station_utils.cpp index a24e9b1..3c523c4 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -16,7 +16,8 @@ uint32_t lastTxTime = millis(); std::vector lastHeardStations; std::vector outputPacketBuffer; std::vector packet25SegBuffer; -std::vector blackList; +std::vector blacklist; +std::vector managers; std::vector lastHeardObjects; bool saveNewDigiEcoModeConfig = false; @@ -24,31 +25,52 @@ bool saveNewDigiEcoModeConfig = false; namespace STATION_Utils { - void loadBlackList() { - if (Config.blackList != "") { - String callsigns = Config.blackList; - int spaceIndex = callsigns.indexOf(" "); + std::vector loadCallSignList(const String& list) { + std::vector loadedList; - while (spaceIndex >= 0) { - blackList.push_back(callsigns.substring(0, spaceIndex)); - callsigns = callsigns.substring(spaceIndex + 1); - spaceIndex = callsigns.indexOf(" "); + String callsigns = list; + callsigns.trim(); + + while (callsigns.length() > 0) { // != "" + int spaceIndex = callsigns.indexOf(" "); + if (spaceIndex == -1) { // No more spaces, add the last part + loadedList.push_back(callsigns); + break; } - callsigns.trim(); - if (callsigns.length() > 0) blackList.push_back(callsigns); // Add the last word if available + loadedList.push_back(callsigns.substring(0, spaceIndex)); + callsigns = callsigns.substring(spaceIndex + 1); + callsigns.trim(); // Trim in case of multiple spaces } + return loadedList; } - bool checkBlackList(const String& callsign) { - for (int i = 0; i < blackList.size(); i++) { - if (blackList[i].indexOf("*") >= 0) { // use wild card - String wildCard = blackList[i].substring(0, blackList[i].indexOf("*")); - if (callsign.startsWith(wildCard))return true; + void loadBlacklist() { + blacklist = loadCallSignList(Config.blacklist); + } + + void loadManagers() { + managers = loadCallSignList(Config.remoteManagement.managers); + } + + bool checkCallsignList(const std::vector& list, const String& callsign) { + for (int i = 0; i < list.size(); i++) { + int wildcardIndex = list[i].indexOf("*"); + if (wildcardIndex >= 0) { + String wildcard = list[i].substring(0, wildcardIndex); + if (callsign.startsWith(wildcard)) return true; } else { - if (blackList[i] == callsign) return true; + if (list[i] == callsign) return true; } } return false; + } + + bool isBlacklisted(const String& callsign) { + return checkCallsignList(blacklist, callsign); + } + + bool isManager(const String& callsign) { + return checkCallsignList(managers, callsign); } void cleanObjectsHeard() { diff --git a/src/web_utils.cpp b/src/web_utils.cpp index ce1838a..9fcd38e 100644 --- a/src/web_utils.cpp +++ b/src/web_utils.cpp @@ -206,7 +206,7 @@ namespace WEB_Utils { Config.personalNote = request->getParam("personalNote", true)->value(); - Config.blackList = request->getParam("blackList", true)->value(); + Config.blacklist = request->getParam("blacklist", true)->value(); Config.webadmin.active = request->hasParam("webadmin.active", true); if (Config.webadmin.active) {