chatgui-android: отображение REALITY-линков (TCP+REALITY) в статусе узлов и сокетов

This commit is contained in:
evgeny committed 2026-09-15 12:18:22 +03:00
1 parent 27b591daee
commit 761f64cf76
2 files changed
+12 -9

No files matched your search

@@ -179,8 +179,8 @@ fun MemberWire.toChatMember(): ChatMember = ChatMember(
fun cleanSocketName(raw: String): String =
raw.removePrefix("as_").replace(Regex("_v[46]_(tcp|udp)$"), " $1")
/* ── MEMBER_DETAIL (event 22) link format: 63 bytes per link ── */
private const val MEMBER_DETAIL_LINK_SIZE = 63
/* ── MEMBER_DETAIL (event 22) link format: 64 bytes per link ── */
private const val MEMBER_DETAIL_LINK_SIZE = 64
private fun addrFromBytes(family: Int, bytes: ByteArray): String {
if (family == 4 && bytes.size >= 4)
@@ -214,13 +214,14 @@ fun parseMemberDetail(data: ByteArray): MemberLinks? {
val rp = lbuf.getShort().toInt() and 0xFFFF
val snBytes = ByteArray(20); lbuf.get(snBytes)
val sn = String(snBytes).trimEnd('\u0000').trimEnd()
val isReality = lbuf.get().toInt() != 0
val effState = if (isTcp != 0 && tcpReady != 0) 3 else state
val effStatus = if (isTcp != 0 && tcpReady != 0) 1 else status
links.add(LinkStatus(
localFamily = lf, localAddr = addrFromBytes(lf, la), localPort = lp,
remoteFamily = rf, remoteAddr = addrFromBytes(rf, ra), remotePort = rp,
linkState = effState, linkStatus = effStatus, isServer = isServer != 0,
socketName = sn, protocol = if (isTcp != 0) "TCP" else "UDP"
socketName = sn, protocol = if (isReality) "TCP+REALITY" else if (isTcp != 0) "TCP" else "UDP"
))
offset += MEMBER_DETAIL_LINK_SIZE
}