Skip to content

Commit

Permalink
fix: remote admin backward compatibility
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
andrekir committed Oct 8, 2024
1 parent 3473ef3 commit 23f05c1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/src/main/java/com/geeksville/mesh/service/MeshService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 23f05c1

Please sign in to comment.