kopia lustrzana https://github.com/meshtastic/firmware
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.pull/4726/head
rodzic
3a10a27851
commit
ff8baa1c85
|
@ -185,9 +185,12 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src)
|
||||||
handleReceived(p, src);
|
handleReceived(p, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p->channel) { // don't override if a channel was requested
|
if (!p->channel && !p->pki_encrypted) { // don't override if a channel was requested
|
||||||
p->channel = nodeDB->getMeshNodeChannel(p->to);
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
|
||||||
LOG_DEBUG("localSend to channel %d\n", p->channel);
|
if (node && node->user.public_key.size == 0) {
|
||||||
|
p->channel = node->channel;
|
||||||
|
LOG_DEBUG("localSend to channel %d\n", p->channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return send(p);
|
return send(p);
|
||||||
|
@ -478,10 +481,20 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p)
|
||||||
|
|
||||||
#if !(MESHTASTIC_EXCLUDE_PKI)
|
#if !(MESHTASTIC_EXCLUDE_PKI)
|
||||||
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
|
meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(p->to);
|
||||||
if (!owner.is_licensed && config.security.private_key.size == 32 && p->to != NODENUM_BROADCAST && node != nullptr &&
|
// 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
|
||||||
node->user.public_key.size > 0 && p->decoded.portnum != meshtastic_PortNum_TRACEROUTE_APP &&
|
// is not in the local nodedb
|
||||||
p->decoded.portnum != meshtastic_PortNum_NODEINFO_APP && p->decoded.portnum != meshtastic_PortNum_ROUTING_APP &&
|
if (
|
||||||
p->decoded.portnum != meshtastic_PortNum_POSITION_APP) {
|
// 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");
|
LOG_DEBUG("Using PKI!\n");
|
||||||
if (numbytes + 12 > MAX_RHPACKETLEN)
|
if (numbytes + 12 > MAX_RHPACKETLEN)
|
||||||
return meshtastic_Routing_Error_TOO_LARGE;
|
return meshtastic_Routing_Error_TOO_LARGE;
|
||||||
|
|
Ładowanie…
Reference in New Issue