block creation or sending of duplicate channels. (#3913)

This commit is contained in:
Dane Evans 2025-12-06 23:47:33 +11:00 committed by GitHub
parent 499ed58311
commit 7db7f61386
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 108 additions and 9 deletions

View file

@ -89,3 +89,21 @@ fun ChannelSet.qrCode(shouldAdd: Boolean): Bitmap? = try {
Timber.e("URL was too complex to render as barcode")
null
}
/**
* Check if the ChannelSet contains any duplicate PSKs.
*
* @return true if there are duplicate PSKs, false otherwise
*/
fun ChannelSet.hasDuplicateKeys(): Boolean {
val pskList = mutableListOf<ByteArray>()
for (setting in settingsList) {
val channel = Channel(setting, loraConfig)
val pskBytes = channel.psk.toByteArray()
if (pskList.any { it contentEquals pskBytes }) {
return true
}
pskList.add(pskBytes)
}
return false
}