|
|
|
@ -270,8 +270,7 @@ static int ncd_create_links(struct ncd_entry* entry, struct TOPO_NODE* ni, |
|
|
|
if (mm->id == a->socket_id) { m = mm; break; } |
|
|
|
if (mm->id == a->socket_id) { m = mm; break; } |
|
|
|
uint8_t tcfg = m ? m->config_type : CFG_SERVER_TYPE_UNKNOWN; |
|
|
|
uint8_t tcfg = m ? m->config_type : CFG_SERVER_TYPE_UNKNOWN; |
|
|
|
const struct address_profile *profile = m ? &m->address_profile : NULL; |
|
|
|
const struct address_profile *profile = m ? &m->address_profile : NULL; |
|
|
|
uint8_t target_class = sock_target_class(a->type, tcfg, profile, ip_is_public(tip), |
|
|
|
uint8_t target_class = sock_target_class(a->type, tcfg, profile, ip_is_public(tip)); |
|
|
|
nviews ? views[0].now_us : (uint64_t)ntp_time_get_us(inst)); |
|
|
|
|
|
|
|
if (target_class == SOCK_TC_UNREACH) { v4_skip++; continue; } |
|
|
|
if (target_class == SOCK_TC_UNREACH) { v4_skip++; continue; } |
|
|
|
|
|
|
|
|
|
|
|
if (a->protocol & TOPO_PROTO_TCP) { |
|
|
|
if (a->protocol & TOPO_PROTO_TCP) { |
|
|
|
@ -321,9 +320,8 @@ static int ncd_create_links(struct ncd_entry* entry, struct TOPO_NODE* ni, |
|
|
|
const struct TOPO_SOCKMETA6 *metadata = ni->v6_sock_meta; |
|
|
|
const struct TOPO_SOCKMETA6 *metadata = ni->v6_sock_meta; |
|
|
|
while (metadata && metadata->id != a->socket_id) metadata = metadata->next; |
|
|
|
while (metadata && metadata->id != a->socket_id) metadata = metadata->next; |
|
|
|
int global = (a->addr[0] & 0xe0) == 0x20; |
|
|
|
int global = (a->addr[0] & 0xe0) == 0x20; |
|
|
|
int64_t current = ntp_time_get_us(inst); |
|
|
|
|
|
|
|
uint8_t target_class = sock_target_class(a->type, metadata ? metadata->config_type : CFG_SERVER_TYPE_UNKNOWN, |
|
|
|
uint8_t target_class = sock_target_class(a->type, metadata ? metadata->config_type : CFG_SERVER_TYPE_UNKNOWN, |
|
|
|
metadata ? &metadata->address_profile : NULL, global, current > 0 ? (uint64_t)current : 0); |
|
|
|
metadata ? &metadata->address_profile : NULL, global); |
|
|
|
if (target_class == SOCK_TC_UNREACH) { v6_skip++; continue; } |
|
|
|
if (target_class == SOCK_TC_UNREACH) { v6_skip++; continue; } |
|
|
|
struct sockaddr_in6 sin6; memset(&sin6, 0, sizeof(sin6)); sin6.sin6_family = AF_INET6; |
|
|
|
struct sockaddr_in6 sin6; memset(&sin6, 0, sizeof(sin6)); sin6.sin6_family = AF_INET6; |
|
|
|
memcpy(&sin6.sin6_addr, a->addr, 16); sin6.sin6_port = htons(a->port); |
|
|
|
memcpy(&sin6.sin6_addr, a->addr, 16); sin6.sin6_port = htons(a->port); |
|
|
|
@ -390,8 +388,6 @@ int node_conn_direct_compatible(struct UTUN_INSTANCE* inst, uint64_t node_id) { |
|
|
|
* Это возможность попытки, не подтверждение маршрута/работоспособности скрытых сокетов пира. */ |
|
|
|
* Это возможность попытки, не подтверждение маршрута/работоспособности скрытых сокетов пира. */ |
|
|
|
const struct TOPO_NODE* self = topo_node_registry_find(inst->topo_groups, inst->node_id); |
|
|
|
const struct TOPO_NODE* self = topo_node_registry_find(inst->topo_groups, inst->node_id); |
|
|
|
if (!self) return 0; |
|
|
|
if (!self) return 0; |
|
|
|
int64_t current = ntp_time_get_us(inst); |
|
|
|
|
|
|
|
uint64_t now_us = current > 0 ? (uint64_t)current : 0; |
|
|
|
|
|
|
|
for (const struct TOPO_ADDR4* a = self->v4_addrs; a; a = a->next) { |
|
|
|
for (const struct TOPO_ADDR4* a = self->v4_addrs; a; a = a->next) { |
|
|
|
uint32_t ip; memcpy(&ip, a->addr, 4); |
|
|
|
uint32_t ip; memcpy(&ip, a->addr, 4); |
|
|
|
if (!ip || !a->port) continue; |
|
|
|
if (!ip || !a->port) continue; |
|
|
|
@ -399,7 +395,7 @@ int node_conn_direct_compatible(struct UTUN_INSTANCE* inst, uint64_t node_id) { |
|
|
|
while (meta && meta->id != a->socket_id) meta = meta->next; |
|
|
|
while (meta && meta->id != a->socket_id) meta = meta->next; |
|
|
|
uint8_t cfg = meta ? meta->config_type : CFG_SERVER_TYPE_UNKNOWN; |
|
|
|
uint8_t cfg = meta ? meta->config_type : CFG_SERVER_TYPE_UNKNOWN; |
|
|
|
const struct address_profile *profile = meta ? &meta->address_profile : NULL; |
|
|
|
const struct address_profile *profile = meta ? &meta->address_profile : NULL; |
|
|
|
uint8_t target_class = sock_target_class(a->type, cfg, profile, ip_is_public(ip), now_us); |
|
|
|
uint8_t target_class = sock_target_class(a->type, cfg, profile, ip_is_public(ip)); |
|
|
|
if (target_class == SOCK_TC_PRIV || target_class == SOCK_TC_UNREACH) continue; |
|
|
|
if (target_class == SOCK_TC_PRIV || target_class == SOCK_TC_UNREACH) continue; |
|
|
|
if ((a->protocol & TOPO_PROTO_REALITY) && !topo_node_find_reality_sock(self, a->socket_id)) continue; |
|
|
|
if ((a->protocol & TOPO_PROTO_REALITY) && !topo_node_find_reality_sock(self, a->socket_id)) continue; |
|
|
|
if (a->protocol & TOPO_PROTO_TCP) return 1; |
|
|
|
if (a->protocol & TOPO_PROTO_TCP) return 1; |
|
|
|
@ -408,7 +404,7 @@ int node_conn_direct_compatible(struct UTUN_INSTANCE* inst, uint64_t node_id) { |
|
|
|
if (!(remote->protocol & TOPO_PROTO_UDP)) continue; |
|
|
|
if (!(remote->protocol & TOPO_PROTO_UDP)) continue; |
|
|
|
const struct TOPO_SOCKMETA4* rm = node->v4_sock_meta; |
|
|
|
const struct TOPO_SOCKMETA4* rm = node->v4_sock_meta; |
|
|
|
while (rm && rm->id != remote->socket_id) rm = rm->next; |
|
|
|
while (rm && rm->id != remote->socket_id) rm = rm->next; |
|
|
|
struct sock_view view = {.has_inet = 1, .now_us = now_us}; |
|
|
|
struct sock_view view = {.has_inet = 1}; |
|
|
|
if (rm) view.address_profile = rm->address_profile; |
|
|
|
if (rm) view.address_profile = rm->address_profile; |
|
|
|
for (const struct TOPO_ADDR4* ra = node->v4_addrs; ra; ra = ra->next) |
|
|
|
for (const struct TOPO_ADDR4* ra = node->v4_addrs; ra; ra = ra->next) |
|
|
|
if (ra->socket_id == remote->socket_id && ra->type == TOPO_ADDR_NAT) memcpy(&view.public_ip4, ra->addr, 4); |
|
|
|
if (ra->socket_id == remote->socket_id && ra->type == TOPO_ADDR_NAT) memcpy(&view.public_ip4, ra->addr, 4); |
|
|
|
|