Licensed usage compliance (#6047)

* Prevent psk and legacy admin channel on licensed mode

* Move it

* Consolidate warning strings

* More holes
This commit is contained in:
Ben Meadors
2025-02-15 09:24:37 -06:00
committed by GitHub
parent 919085379e
commit 3f3f89c06e
5 changed files with 49 additions and 6 deletions

View File

@@ -93,6 +93,35 @@ void Channels::initDefaultLoraConfig()
#endif
}
bool Channels::ensureLicensedOperation()
{
if (!owner.is_licensed) {
return false;
}
bool hasEncryptionOrAdmin = false;
for (uint8_t i = 0; i < MAX_NUM_CHANNELS; i++) {
auto channel = channels.getByIndex(i);
if (!channel.has_settings) {
continue;
}
auto &channelSettings = channel.settings;
if (strcasecmp(channelSettings.name, Channels::adminChannel) == 0) {
channel.role = meshtastic_Channel_Role_DISABLED;
channelSettings.psk.bytes[0] = 0;
channelSettings.psk.size = 0;
hasEncryptionOrAdmin = true;
channels.setChannel(channel);
} else if (channelSettings.psk.size > 0) {
channelSettings.psk.bytes[0] = 0;
channelSettings.psk.size = 0;
hasEncryptionOrAdmin = true;
channels.setChannel(channel);
}
}
return hasEncryptionOrAdmin;
}
/**
* Write a default channel to the specified channel index
*/

View File

@@ -92,6 +92,8 @@ class Channels
// Returns true if any of our channels have enabled MQTT uplink or downlink
bool anyMqttEnabled();
bool ensureLicensedOperation();
private:
/** Given a channel index, change to use the crypto key specified by that index
*

View File

@@ -328,6 +328,11 @@ NodeDB::NodeDB()
moduleConfig.neighbor_info.update_interval =
Default::getConfiguredOrMinimumValue(moduleConfig.neighbor_info.update_interval, min_neighbor_info_broadcast_secs);
// Don't let licensed users to rebroadcast encrypted packets
if (owner.is_licensed) {
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY;
}
if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate)))
saveWhat |= SEGMENT_DEVICESTATE;
if (nodeDatabaseCRC != crc32Buffer(&nodeDatabase, sizeof(nodeDatabase)))