refactor: separate NAT detection from topology into standalone nat_detection module
- Extract NAT detection logic (~250 lines) from topo_group.c into new nat_detection.c - NAT_DETECTION struct owns ping_pending, next_ping_req_id, allow_nat_check_local (removed from TOPO_GROUP) - route_ping.* signatures changed: TOPO_GROUP* -> NAT_DETECTION* (+ TOPO_GROUP* where needed) - topo_group.c now only dispatches BGP subcommands to nat_detection_* handlers - UTUN_INSTANCE gets struct NAT_DETECTION* nat_det field (init/destroy in topo_groups_init/destroy) - External callers (etcp_connections, etcp, control_server) call nat_detection_* directly - nat_detection_cancel_for_conn / nat_detection_send_nat_info / nat_detection_link_ready / nat_detection_request_check_all - route_ping_destroy_pending properly implemented (was dead code) - TOPO_SUBCMD_PING_REQ/RESP moved from route_ping.h to topo_group.h (all BGP subcommands in one place) - Tests updated: test_nat_detection, test_route_ping - both PASSED - Build: auto(CORE_SOURCES+libutun) and cmake(chatgui/libutun)
This commit is contained in:
1 parent
8180676120
commit
910cac8dce
31 files changed
+1166
-288
No files matched your search
@@ -273,9 +273,9 @@ QByteArray DbManager::getNodeEdPub(quint64 nodeId) const {
|
||||
QList<NodeAddr> DbManager::getOnlinePeerAddresses(quint64 excludeNodeId) const {
|
||||
QList<NodeAddr> list;
|
||||
sqlite3_stmt* stmt = prepareOrNull(
|
||||
"SELECT na.node_id, na.family, na.protocol, na.address, na.port, na.rtt, na.is_nat"
|
||||
"SELECT na.node_id, na.family, na.protocol, na.address, na.port, na.rtt, na.addr_type"
|
||||
" FROM node_addresses na JOIN nodes n ON na.node_id = n.node_id"
|
||||
" WHERE na.is_nat=0 AND na.node_id != ?"
|
||||
" WHERE na.addr_type=0 AND na.node_id != ?"
|
||||
" ORDER BY RANDOM()");
|
||||
if (!stmt) return list;
|
||||
sqlite3_bind_int64(stmt, 1, (sqlite3_int64)excludeNodeId);
|
||||
@@ -287,7 +287,7 @@ QList<NodeAddr> DbManager::getOnlinePeerAddresses(quint64 excludeNodeId) const {
|
||||
a.address = colBlob(stmt, 3);
|
||||
a.port = (quint16)sqlite3_column_int(stmt, 4);
|
||||
a.rtt = sqlite3_column_int(stmt, 5);
|
||||
a.isNat = sqlite3_column_int(stmt, 6) != 0;
|
||||
a.addrType = sqlite3_column_int(stmt, 6);
|
||||
list.append(a);
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
Reference in new issue
Block a user