mirror of
https://github.com/dpup/meshstream.git
synced 2026-03-28 17:42:37 +01:00
Better error cards for private messages, neighbor info rendering
This commit is contained in:
@@ -308,7 +308,12 @@ func decodeEncryptedPayload(data *meshtreampb.Data, encrypted []byte, channelId
|
||||
TextMessage: string(decrypted),
|
||||
}
|
||||
} else {
|
||||
data.DecodeError = fmt.Sprintf("failed to parse decrypted data: %v", err)
|
||||
// Check if this channel is configured - if not, likely a private message
|
||||
if !IsChannelConfigured(channelId) {
|
||||
data.DecodeError = fmt.Sprintf("PRIVATE_CHANNEL: failed to parse decrypted data on unconfigured channel '%s': %v", channelId, err)
|
||||
} else {
|
||||
data.DecodeError = fmt.Sprintf("PARSE_ERROR: failed to parse decrypted data: %v", err)
|
||||
}
|
||||
data.Payload = &meshtreampb.Data_BinaryData{
|
||||
BinaryData: decrypted,
|
||||
}
|
||||
|
||||
@@ -72,6 +72,15 @@ func RemoveChannelKey(channelId string) {
|
||||
delete(channelKeys, channelId)
|
||||
}
|
||||
|
||||
// IsChannelConfigured checks if a channel has a specific key configured
|
||||
func IsChannelConfigured(channelId string) bool {
|
||||
channelKeysMutex.RLock()
|
||||
defer channelKeysMutex.RUnlock()
|
||||
|
||||
_, ok := channelKeys[channelId]
|
||||
return ok
|
||||
}
|
||||
|
||||
// PadKey ensures the key is properly padded to be a valid AES key length (16, 24, or 32 bytes)
|
||||
func PadKey(key []byte) []byte {
|
||||
// If key length is already valid, return as is
|
||||
|
||||
Reference in New Issue
Block a user