From 23f05c109b45ec9f7ae4512adbe364ec47e9085b Mon Sep 17 00:00:00 2001 From: andrekir Date: Tue, 8 Oct 2024 07:47:25 -0300 Subject: [PATCH] fix: remote admin backward compatibility - only use PKC encryption when the remote node has a public key (2.5 -> 2.5) - fall back to legacy admin if public key is not available (2.5 -> 2.4) --- .../java/com/geeksville/mesh/service/MeshService.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index a2cdab6c..0ef5fe59 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -476,11 +476,13 @@ class MeshService : Service(), Logging { private val myNodeID get() = toNodeID(myNodeNum) /// Admin channel index - private val adminChannelIndex: Int - get() = if (nodeDBbyNodeNum[myNodeNum]?.hasPKC == true) { // TODO use meta.hasPKC - DataPacket.PKC_CHANNEL_INDEX - } else { - channelSet.settingsList + private val MeshPacket.Builder.adminChannelIndex: Int + get() = when { + myNodeNum == to -> 0 + nodeDBbyNodeNum[myNodeNum]?.hasPKC == true && nodeDBbyNodeNum[to]?.hasPKC == true -> + DataPacket.PKC_CHANNEL_INDEX + + else -> channelSet.settingsList .indexOfFirst { it.name.equals("admin", ignoreCase = true) } .coerceAtLeast(0) }