mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-24 03:31:14 +00:00
Event mode: Enforce reliable hop limit and disallow default public MQTT (#4343)
* Event mode: Enforce reliable hop limit * Event mode: Short circuit wantsLink on MQTT for default broker address * Just enforce at channels level since everything uses this * For events never forward packets with excessive hop_limit * In EVENT_MODE, don't respond with hop_limit set more then the configured max. * Correct hop_start when correcting hop_limit in event mode. * Make EVENT_MODE work from userPrefs.h * Event mode: Disallow Router or Repeater roles --------- Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
@@ -400,6 +400,13 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
|
||||
requiresReboot = true;
|
||||
}
|
||||
}
|
||||
#if EVENT_MODE
|
||||
// If we're in event mode, nobody is a Router or Repeater
|
||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||
config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) {
|
||||
config.device.role = meshtastic_Config_DeviceConfig_Role_CLIENT;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case meshtastic_Config_position_tag:
|
||||
LOG_INFO("Setting config: Position\n");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "RoutingModule.h"
|
||||
#include "Default.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "Router.h"
|
||||
@@ -50,12 +51,15 @@ uint8_t RoutingModule::getHopLimitForResponse(uint8_t hopStart, uint8_t hopLimit
|
||||
// Hops used by the request. If somebody in between running modified firmware modified it, ignore it
|
||||
uint8_t hopsUsed = hopStart < hopLimit ? config.lora.hop_limit : hopStart - hopLimit;
|
||||
if (hopsUsed > config.lora.hop_limit) {
|
||||
// In event mode, we never want to send packets with more than our default 3 hops.
|
||||
#if !(EVENTMODE) // This falls through to the default.
|
||||
return hopsUsed; // If the request used more hops than the limit, use the same amount of hops
|
||||
#endif
|
||||
} else if ((uint8_t)(hopsUsed + 2) < config.lora.hop_limit) {
|
||||
return hopsUsed + 2; // Use only the amount of hops needed with some margin as the way back may be different
|
||||
}
|
||||
}
|
||||
return config.lora.hop_limit; // Use the default hop limit
|
||||
return Default::getConfiguredOrDefaultHopLimit(config.lora.hop_limit); // Use the default hop limit
|
||||
}
|
||||
|
||||
RoutingModule::RoutingModule() : ProtobufModule("routing", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg)
|
||||
|
||||
Reference in New Issue
Block a user