Better error cards for private messages, neighbor info rendering

This commit is contained in:
Daniel Pupius
2025-06-23 09:47:14 -07:00
parent a83f4feddb
commit dc36070355
9 changed files with 275 additions and 6 deletions

View File

@@ -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,
}

View File

@@ -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