Respect SOCKS policy and report LAN lookup failures precisely

This commit is contained in:
evgeny committed 2026-10-25 17:55:34 +01:00
1 parent d5aa5926dd
commit 910c1624b7
3 files changed
+10 -3

No files matched your search

+4 -2
View File
@@ -991,8 +991,10 @@ int topo_node_sqlite_get_ed25519_pubkey(sqlite3* db, uint64_t node_id, uint8_t p
}
int final_rc = sqlite3_finalize(stmt);
if (final_rc != SQLITE_OK) rc = -1;
if (rc) DEBUG_WARN(DEBUG_CATEGORY_ROUTING, "get_ed25519_pubkey: unavailable node=%016llx sql=%d finalize=%d: %s",
(unsigned long long)node_id, sql_rc, final_rc, sqlite3_errmsg(db));
if (rc && sql_rc == SQLITE_DONE && final_rc == SQLITE_OK)
DEBUG_DEBUG(DEBUG_CATEGORY_ROUTING, "get_ed25519_pubkey: unknown node=%016llx", (unsigned long long)node_id);
else if (rc) DEBUG_WARN(DEBUG_CATEGORY_ROUTING, "get_ed25519_pubkey: unavailable node=%016llx sql=%d finalize=%d: %s",
(unsigned long long)node_id, sql_rc, final_rc, sqlite3_errmsg(db));
return rc;
}
+5 -1
View File
@@ -315,6 +315,10 @@ static int ncd_create_lan_links(struct ncd_entry* entry, const struct TOPO_NODE*
int count = 0;
struct local_route route;
for (size_t i = 0; local_transport_route(inst->local_transport, id, i, &route); i++) {
if ((route.socket.protocol & LOCAL_ROUTE_TCP) && inst->config && inst->config->global.socks_enabled) {
DEBUG_DEBUG(DEBUG_CATEGORY_NCD, "[ncd] LAN TCP skipped node=%016llx socket=%u reason=global SOCKS policy",
(unsigned long long)id, route.socket.socket_id); continue;
}
const struct TOPO_REALITY_SOCK* reality = NULL;
if (route.socket.protocol & LOCAL_ROUTE_REALITY) {
reality = topo_node_find_reality_sock(ni, route.socket.socket_id);
@@ -585,7 +589,7 @@ int node_conn_direct_update_local(struct UTUN_INSTANCE* inst, uint64_t node_id)
struct TOPO_NODE* known = ncd_lookup_node(inst, node_id);
struct TOPO_NODE* copy = known ? ncd_copy_node(inst, known) : NULL;
if (known) topo_node_registry_unref(inst->topo_groups, node_id);
int result = copy ? ncd_create_lan_links(entry, copy, NULL, NULL) : 0;
int result = copy ? ncd_create_lan_links(entry, copy, NULL, NULL) : known ? -1 : 0;
if (!copy) ncd_prune_lan(entry, 0);
topo_node_destroy(inst->topo_groups, copy);
entry->active_calls--; ncd_collect(entry); etcp_conn_ref_free(conn);
+1
View File
@@ -51,6 +51,7 @@ struct NODE_CONN_DIRECT;
* Без линков/handles/таймеров/проб. Исходящие пары — тот же обход, что open; reverse — sock_match/публикуемые адреса.
* Учитывает IPv6 и исходящий TCP fallback; 1 — кандидат есть, 0 — нет/ошибка. SQLite не загружает.
* Для подтверждённого LAN-кандидата может прочитать идентичность из SQLite без регистрации.
* LAN TCP соблюдает глобальную SOCKS-политику: при включённом SOCKS прямые LAN TCP-пробы не создаются.
* Возможность попытки не доказывает достижимость и не подтверждает готовность группы. */
int node_conn_direct_compatible(struct UTUN_INSTANCE* inst, uint64_t node_id);