Default to pkiEncrypted always on for admin messages

This commit is contained in:
Ian McEwen
2024-09-28 11:13:04 -07:00
parent d875a574b6
commit 27729995d2
2 changed files with 13 additions and 2 deletions

View File

@@ -394,6 +394,8 @@ class MeshInterface: # pylint: disable=R0902
onResponseAckPermitted: bool=False,
channelIndex: int=0,
hopLimit: Optional[int]=None,
pkiEncrypted: Optional[bool]=False,
publicKey: Optional[bytes]=None,
):
"""Send a data packet to some other node
@@ -449,7 +451,7 @@ class MeshInterface: # pylint: disable=R0902
if onResponse is not None:
logging.debug(f"Setting a response handler for requestId {meshPacket.id}")
self._addResponseHandler(meshPacket.id, onResponse, ackPermitted=onResponseAckPermitted)
p = self._sendPacket(meshPacket, destinationId, wantAck=wantAck, hopLimit=hopLimit)
p = self._sendPacket(meshPacket, destinationId, wantAck=wantAck, hopLimit=hopLimit, pkiEncrypted=pkiEncrypted, publicKey=publicKey)
return p
def sendPosition(
@@ -689,7 +691,9 @@ class MeshInterface: # pylint: disable=R0902
meshPacket: mesh_pb2.MeshPacket,
destinationId: Union[int,str]=BROADCAST_ADDR,
wantAck: bool=False,
hopLimit: Optional[int]=None
hopLimit: Optional[int]=None,
pkiEncrypted: Optional[bool]=False,
publicKey: Optional[bytes]=None,
):
"""Send a MeshPacket to the specified node (or if unspecified, broadcast).
You probably don't want this - use sendData instead.
@@ -738,6 +742,12 @@ class MeshInterface: # pylint: disable=R0902
loraConfig = getattr(self.localNode.localConfig, "lora")
meshPacket.hop_limit = getattr(loraConfig, "hop_limit")
if pkiEncrypted:
meshPacket.pki_encrypted = True
if publicKey is not None:
meshPacket.public_key = publicKey
# if the user hasn't set an ID for this packet (likely and recommended),
# we should pick a new unique ID so the message can be tracked.
if meshPacket.id == 0:

View File

@@ -894,6 +894,7 @@ class Node:
wantResponse=wantResponse,
onResponse=onResponse,
channelIndex=adminIndex,
pkiEncrypted=True,
)
def ensureSessionKey(self):