mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 09:42:35 +00:00
Don't use PKC on a non-primary channel unless specifically requested (#4715)
* Don't use PKC on a non-primary channel unless specifically requested * Don't change from channel 0 if we can send a PKC packet.
This commit is contained in:
parent
3a10a27851
commit
ff8baa1c85
@ -185,9 +185,12 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
|
||||
handleReceived(p, src);
|
||||
}
|
||||
|
||||
if (!p->channel) { // don't override if a channel was requested
|
||||
p->channel = nodeDB->getMeshNodeChannel(p->to);
|
||||
LOG_DEBUG("localSend to channel %d\n", p->channel);
|
||||
if (!p->channel && !p->pki_encrypted) { // don't override if a channel was requested
|
||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
|
||||
if (node && node->user.public_key.size == 0) {
|
||||
p->channel = node->channel;
|
||||
LOG_DEBUG("localSend to channel %d\n", p->channel);
|
||||
}
|
||||
}
|
||||
|
||||
return send(p);
|
||||
@ -478,10 +481,20 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||
|
||||
#if !(MESHTASTIC_EXCLUDE_PKI)
|
||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
|
||||
if (!owner.is_licensed && config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr &&
|
||||
node->user.public_key.size > 0 && p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP &&
|
||||
p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP && p->decoded.portnum != meshtastic_PortNum_ROUTING_APP &&
|
||||
p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
|
||||
// We may want to retool things so we can send a PKC packet when the client specifies a key and nodenum, even if the node
|
||||
// is not in the local nodedb
|
||||
if (
|
||||
// Don't use PKC with Ham mode
|
||||
!owner.is_licensed &&
|
||||
// Don't use PKC if it's not explicitly requested and a non-primary channel is requested
|
||||
!(p->pki_encrypted != true && p->channel > 0) &&
|
||||
// Check for valid keys and single node destination
|
||||
config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr &&
|
||||
// Check for a known public key for the destination
|
||||
(node->user.public_key.size == 32) &&
|
||||
// Some portnums either make no sense to send with PKC
|
||||
p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP && p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP &&
|
||||
p->decoded.portnum != meshtastic_PortNum_ROUTING_APP && p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
|
||||
LOG_DEBUG("Using PKI!\n");
|
||||
if (numbytes + 12 > MAX_RHPACKETLEN)
|
||||
return meshtastic_Routing_Error_TOO_LARGE;
|
||||
|
Loading…
Reference in New Issue
Block a user