fix: UDP packet size and addr_type classification
- etcp_connections.h: add WIRE_OVERHEAD, IP_UDP_OVERHEAD_V4/V6, SC_ENCRYPT_OVERHEAD (properly accounts for v6 IP(40)+UDP(8)+SC(3)+CCM tag(16) = 67 vs old UDP_HDR_SIZE=28) - etcp_connections.c etcp_encrypt_send: use WIRE_OVERHEAD instead of UDP_HDR_SIZE - etcp_connections.c send_init_response: clamp padding to max_data = mtu - WIRE_OVERHEAD - chat_core_priv.h: add addr_type_from_ip() classifier - chat_profile.c, chat_sync.c, member_sync.c: use classified addr_type instead of hardcoded 0 - chat_sync.c: skip zero nat_addr in JOIN, fall back to interface_addr - topo_node_sqlite.c, member_sync.c: remove addr_type=0 filter from SELECT/DELETE - chat_profile.c, member_sync.c: DELETE all addresses (not just addr_type=0)
This commit is contained in:
1 parent
5066cff333
commit
25ebad9f52
8 files changed
+128
-55
No files matched your search
+42
-19
@@ -89,6 +89,7 @@ fun MemberListScreen(
|
||||
MemberDetailCard(
|
||||
detail = detail,
|
||||
memberLinks = memberLinks,
|
||||
isSelf = members.any { it.nodeId == detail.nodeId && it.isSelf },
|
||||
onDismiss = { }
|
||||
)
|
||||
}
|
||||
@@ -140,12 +141,16 @@ private fun MemberListItem(
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(10.dp)
|
||||
.clip(CircleShape)
|
||||
.background(onlineColor)
|
||||
)
|
||||
if (member.isSelf) {
|
||||
Text("✓", fontSize = 12.sp, color = Color(0xFF4CAF50))
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(10.dp)
|
||||
.clip(CircleShape)
|
||||
.background(onlineColor)
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.width(10.dp))
|
||||
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
@@ -161,7 +166,8 @@ private fun MemberListItem(
|
||||
if (member.isAdmin) parts.add("Admin")
|
||||
if (member.isSuper) parts.add("Super")
|
||||
if (member.isStorage) parts.add("Storage")
|
||||
if (member.directUp) parts.add("direct↑")
|
||||
if (member.isSelf) parts.add("self")
|
||||
else if (member.directUp) parts.add("direct↑")
|
||||
else if (member.indirectUp) parts.add("indirect↑")
|
||||
else if (member.directPresence || member.indirectPresence || member.bgpPresence) parts.add("down")
|
||||
if (member.rtt > 0) parts.add("${member.rtt}ms")
|
||||
@@ -170,7 +176,7 @@ private fun MemberListItem(
|
||||
Text(
|
||||
text = parts.joinToString(" "),
|
||||
fontSize = 11.sp,
|
||||
color = if (member.directUp || member.indirectUp)
|
||||
color = if (member.isSelf || member.directUp || member.indirectUp)
|
||||
Color(0xFF4CAF50) else Color.Gray
|
||||
)
|
||||
}
|
||||
@@ -186,6 +192,7 @@ private fun MemberListItem(
|
||||
private fun MemberDetailCard(
|
||||
detail: MemberDetail,
|
||||
memberLinks: MemberLinks,
|
||||
isSelf: Boolean = false,
|
||||
onDismiss: () -> Unit
|
||||
) {
|
||||
fun linkDotColor(addr: MemberAddr): Color {
|
||||
@@ -247,15 +254,7 @@ private fun MemberDetailCard(
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Text("Addresses:", fontSize = 13.sp, fontWeight = FontWeight.Medium)
|
||||
detail.addresses.forEach { a ->
|
||||
val dcol = linkDotColor(a)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.clip(CircleShape)
|
||||
.background(dcol)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
if (isSelf) {
|
||||
Text(
|
||||
text = "${a.protocol} ${a.address}:${a.port}" +
|
||||
(if (a.rtt > 0) " (${a.rtt / 10}ms)" else ""),
|
||||
@@ -263,13 +262,37 @@ private fun MemberDetailCard(
|
||||
fontSize = 11.sp,
|
||||
color = Color.DarkGray
|
||||
)
|
||||
} else {
|
||||
val dcol = linkDotColor(a)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.clip(CircleShape)
|
||||
.background(dcol)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(
|
||||
text = "${a.protocol} ${a.address}:${a.port}" +
|
||||
(if (a.rtt > 0) " (${a.rtt / 10}ms)" else ""),
|
||||
fontFamily = FontFamily.Monospace,
|
||||
fontSize = 11.sp,
|
||||
color = Color.DarkGray
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val rttTypeName = when (detail.rttType) { 0 -> "interface" 1 -> "nat" 2 -> "real" else -> "?" }
|
||||
Spacer(Modifier.height(6.dp))
|
||||
Text("Connection:", fontSize = 13.sp, fontWeight = FontWeight.Medium)
|
||||
if (detail.directPresence) {
|
||||
if (isSelf) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Text("✓", fontSize = 12.sp, color = Color(0xFF4CAF50))
|
||||
Spacer(Modifier.width(4.dp))
|
||||
Text("self (local)", fontSize = 12.sp, color = Color(0xFF4CAF50))
|
||||
}
|
||||
} else if (detail.directPresence) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(Modifier.size(8.dp).clip(CircleShape)
|
||||
.background(if (detail.directUp) Color(0xFF4CAF50) else Color(0xFFE53935)))
|
||||
@@ -295,7 +318,7 @@ private fun MemberDetailCard(
|
||||
Text("BGP: visible", fontSize = 12.sp, color = Color.DarkGray)
|
||||
}
|
||||
}
|
||||
if (!detail.directPresence && !detail.indirectPresence && !detail.bgpPresence) {
|
||||
if (!isSelf && !detail.directPresence && !detail.indirectPresence && !detail.bgpPresence) {
|
||||
Text("offline", fontSize = 12.sp, color = Color.Gray)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user