display Regions in received Messages and allow reply to same region.

This commit is contained in:
ericz committed 2026-09-21 17:52:33 +02:00
1 parent d5f54dfa11
commit 20e01145e6
9 files changed
+177 -15

No files matched your search

+23 -3
View File
@@ -1040,9 +1040,29 @@ Uint8List buildSetFloodScopeFrame(String region) {
return Uint8List.fromList([cmdSetFloodScope, 0]);
}
final name = region.startsWith('#') ? region : '#$region';
final hash = crypto.sha256.convert(utf8.encode(name)).bytes;
final scope = Uint8List.fromList(hash.sublist(0, 16));
final scope = floodScopeKeyForRegion(region);
return Uint8List.fromList([cmdSetFloodScope, 0, ...scope]);
}
Uint8List floodScopeKeyForRegion(String region) {
final name = region.startsWith('#') ? region : '#$region';
final hash = crypto.sha256.convert(utf8.encode(name)).bytes;
return Uint8List.fromList(hash.sublist(0, 16));
}
Uint8List floodTransportCode({
required Uint8List scopeKey,
required int payloadType,
required Uint8List payload,
}) {
final input = Uint8List(1 + payload.length)
..[0] = payloadType
..setRange(1, 1 + payload.length, payload);
final code = crypto.Hmac(crypto.sha256, scopeKey).convert(input).bytes;
if (code[0] == 0 && code[1] == 0) return Uint8List.fromList([1, 0]);
if (code[0] == 0xFF && code[1] == 0xFF) {
return Uint8List.fromList([0xFE, 0xFF]);
}
return Uint8List.fromList(code.sublist(0, 2));
}