android: fix key regeneration, Clear DB, uasync eventfd, udp log from config
- jni_on_event: fix JNI_EDETACHED — AttachCurrentThread/DetachCurrentThread - u_async.c: pipe→eventfd for reliable cross-thread wakeup add process_posted_tasks in poll() path, fix EINTR (saved_errno) - bridge_debug_hook: keep udp_log_write, remove mutex from udp_log - memory_pool.c: alloc/free logs INFO→DEBUG (reduce spam) - instance_lite.c: chat_event_set_handler before ensure_keys, KEYS_GENERATED events, fchmod 0600 on keys.conf, UDP log from config [log_udp] section, regenerate_trampoline - config_parser: parse [log_udp] ip/port - NativeLib.kt: remove callbacksSet, simplify init/stop/destroy - ChatViewModel.kt: unified event callback in init, pubKey StateFlow, requestRegenerateKeys, clearState fix - SettingsScreen.kt: pubKey.collectAsState(), Clear DB via restart() - HeadlessService.kt: remove setUdpLogTarget (now from config) - android_udp_log.c: simplified — no mutex, buffer+send+timer in one thread - utun_instance.c: NULL-check tcp_connections before destroy - chat_event.h: +CHAT_EVT_KEYS_GENERATED 11, -NODE_CHANGED - logreceiver: UDP log receiver tool
This commit is contained in:
1 parent
d0cca27edd
commit
064bed06f2
68 files changed
+5090
-291
No files matched your search
@@ -2,6 +2,8 @@
|
||||
#include "utun_node.h"
|
||||
#include <cinttypes>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
#include <csignal>
|
||||
#include "../../lib/socket_compat.h"
|
||||
|
||||
@@ -146,8 +148,28 @@ bool UtunNode::ntpEnabled() const {
|
||||
QList<NodeAddr> UtunNode::getInviteAddresses(DbManager* db) {
|
||||
(void)db;
|
||||
QList<NodeAddr> addrs;
|
||||
QMap<QPair<QByteArray, quint16>, uint8_t> addrProto; // key=(addr,port) → proto bits
|
||||
|
||||
auto add_addr = [&](const QByteArray& addr, quint16 port, int family,
|
||||
int sockId, uint8_t proto) {
|
||||
QPair<QByteArray, quint16> key(addr, port);
|
||||
uint8_t existing = addrProto.value(key, 0);
|
||||
addrProto[key] = existing | proto;
|
||||
// Store sockId/family for serialization (overwrite is fine — same port)
|
||||
};
|
||||
|
||||
auto append_from_addr_proto = [&](const QByteArray& addr, quint16 port,
|
||||
int family, int sockId, uint8_t proto) {
|
||||
NodeAddr a;
|
||||
a.family = family;
|
||||
a.address = addr;
|
||||
a.port = port;
|
||||
a.socketId = sockId;
|
||||
a.protocol = proto;
|
||||
addrs.append(a);
|
||||
};
|
||||
if (m_instance) {
|
||||
/* 1) UDP from active ETCP links */
|
||||
struct ll_entry* entry = m_instance->connections->head;
|
||||
while (entry) {
|
||||
struct conn_queue_entry* ce = (struct conn_queue_entry*)entry->data;
|
||||
@@ -156,56 +178,74 @@ QList<NodeAddr> UtunNode::getInviteAddresses(DbManager* db) {
|
||||
struct ETCP_LINK* link = conn->links;
|
||||
while (link) {
|
||||
if (link->link_state == 3 && link->nat_type == NAT_TYPE_DIRECT) {
|
||||
NodeAddr a;
|
||||
a.socketId = link->conn ? (int)link->conn->sock_id : 0;
|
||||
a.protocol = INVITE_PROTO_UDP;
|
||||
struct sockaddr_storage* sa = &link->remote_addr;
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in* sin = (struct sockaddr_in*)sa;
|
||||
a.family = 4;
|
||||
a.address = QByteArray((const char*)&sin->sin_addr, 4);
|
||||
a.port = ntohs(sin->sin_port);
|
||||
QByteArray addr((const char*)&sin->sin_addr, 4);
|
||||
add_addr(addr, ntohs(sin->sin_port), 4,
|
||||
link->conn ? (int)link->conn->sock_id : 0, INVITE_PROTO_UDP);
|
||||
} else {
|
||||
struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;
|
||||
a.family = 6;
|
||||
a.address = QByteArray((const char*)&sin6->sin6_addr, 16);
|
||||
a.port = ntohs(sin6->sin6_port);
|
||||
QByteArray addr((const char*)&sin6->sin6_addr, 16);
|
||||
add_addr(addr, ntohs(sin6->sin6_port), 6,
|
||||
link->conn ? (int)link->conn->sock_id : 0, INVITE_PROTO_UDP);
|
||||
}
|
||||
addrs.append(a);
|
||||
}
|
||||
link = link->next;
|
||||
}
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (addrs.isEmpty() && m_instance) {
|
||||
struct ETCP_SOCKET* sock = m_instance->etcp_sockets;
|
||||
while (sock) {
|
||||
struct sockaddr_storage* sa;
|
||||
if (sock->nat_addr.ss_family != 0)
|
||||
sa = &sock->nat_addr;
|
||||
else if (sock->interface_addr.ss_family != 0)
|
||||
sa = &sock->interface_addr;
|
||||
else { sock = sock->next; continue; }
|
||||
|
||||
NodeAddr a;
|
||||
a.socketId = (int)sock->sock_id;
|
||||
a.protocol = INVITE_PROTO_UDP;
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in* sin = (struct sockaddr_in*)sa;
|
||||
a.family = 4;
|
||||
a.address = QByteArray((const char*)&sin->sin_addr, 4);
|
||||
a.port = ntohs(sin->sin_port);
|
||||
} else {
|
||||
struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;
|
||||
a.family = 6;
|
||||
a.address = QByteArray((const char*)&sin6->sin6_addr, 16);
|
||||
a.port = ntohs(sin6->sin6_port);
|
||||
/* 2) UDP from local ETCP sockets (fallback) */
|
||||
{
|
||||
struct ETCP_SOCKET* sock = m_instance->etcp_sockets;
|
||||
while (sock) {
|
||||
struct sockaddr_storage* sa = NULL;
|
||||
if (sock->nat_addr.ss_family != 0)
|
||||
sa = &sock->nat_addr;
|
||||
else if (sock->interface_addr.ss_family != 0)
|
||||
sa = &sock->interface_addr;
|
||||
if (sa) {
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in* sin = (struct sockaddr_in*)sa;
|
||||
QByteArray addr((const char*)&sin->sin_addr, 4);
|
||||
add_addr(addr, ntohs(sin->sin_port), 4, (int)sock->sock_id, INVITE_PROTO_UDP);
|
||||
} else {
|
||||
struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;
|
||||
QByteArray addr((const char*)&sin6->sin6_addr, 16);
|
||||
add_addr(addr, ntohs(sin6->sin6_port), 6, (int)sock->sock_id, INVITE_PROTO_UDP);
|
||||
}
|
||||
}
|
||||
sock = sock->next;
|
||||
}
|
||||
addrs.append(a);
|
||||
sock = sock->next;
|
||||
}
|
||||
|
||||
/* 3) TCP from local TCP sockets */
|
||||
{
|
||||
struct TCP_SOCKET* ts = m_instance->tcp_sockets;
|
||||
while (ts) {
|
||||
struct sockaddr_storage* sa = &ts->interface_addr;
|
||||
if (sa->ss_family == AF_INET) {
|
||||
struct sockaddr_in* sin = (struct sockaddr_in*)sa;
|
||||
QByteArray addr((const char*)&sin->sin_addr, 4);
|
||||
add_addr(addr, ntohs(sin->sin_port), 4, (int)ts->sock_id, INVITE_PROTO_TCP);
|
||||
} else if (sa->ss_family == AF_INET6) {
|
||||
struct sockaddr_in6* sin6 = (struct sockaddr_in6*)sa;
|
||||
QByteArray addr((const char*)&sin6->sin6_addr, 16);
|
||||
add_addr(addr, ntohs(sin6->sin6_port), 6, (int)ts->sock_id, INVITE_PROTO_TCP);
|
||||
}
|
||||
ts = ts->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* 4) Merge: dedup by (addr,port), write result with merged proto */
|
||||
for (auto it = addrProto.begin(); it != addrProto.end(); ++it) {
|
||||
QByteArray addr = it.key().first;
|
||||
quint16 port = it.key().second;
|
||||
uint8_t proto = it.value();
|
||||
int family = (addr.size() == 16) ? 6 : 4;
|
||||
append_from_addr_proto(addr, port, family, 0, proto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user