nat: use same-interface STUN mapping as tentative EIM
This commit is contained in:
1 parent
aede36388f
commit
88ac08333e
3 files changed
+26
-12
No files matched your search
@@ -16,6 +16,7 @@
|
||||
#include "etcp_router.h"
|
||||
#include "route_crypto.h"
|
||||
#include "stcp_client.h"
|
||||
#include "stun_nat.h"
|
||||
#include "sock_match.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
@@ -574,7 +575,7 @@ static void clear_profile(struct nat_socket *state, uint8_t reason) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Публикуется только измерение рабочего endpoint; отдельный STUN-порт остаётся диагностикой. */
|
||||
/* Измерение рабочего endpoint приоритетно; STUN того же пути даёт только предварительный EIM?. */
|
||||
static void select_profile(struct nat_socket *state) {
|
||||
const struct address_profile *current = &state->socket->address_profile;
|
||||
struct address_profile selected = state->measured_profile;
|
||||
@@ -586,6 +587,15 @@ static void select_profile(struct nat_socket *state) {
|
||||
if (!selected.mapping && state->observed_address.ss_family) {
|
||||
selected.source = ADDRESS_SOURCE_ETCP; selected_address = state->observed_address;
|
||||
}
|
||||
struct stun_nat_result stun;
|
||||
uint64_t now = get_time_tb();
|
||||
if (!selected.mapping && !stun_nat_get_socket_result(state->detector->instance, state->socket, &stun) &&
|
||||
(stun.status == STUN_NAT_COMPLETE || stun.status == STUN_NAT_PARTIAL) &&
|
||||
stun.measured_at_tb && now >= stun.measured_at_tb && now - stun.measured_at_tb < STUN_NAT_TTL_TB &&
|
||||
stun.server_count == 2 && stun.translated == 1 && (stun.mapping == STUN_MAP_MATCH || stun.mapping == STUN_MAP_EIM) &&
|
||||
(!selected_address.ss_family || route_ping_addr_equal(&selected_address, &stun.mapped[0], 0))) {
|
||||
selected.mapping = ADDRESS_MAP_EIM; selected.inbound = ADDRESS_IN_UNKNOWN; selected.source = ADDRESS_SOURCE_STUN;
|
||||
}
|
||||
int address_changed = selected_address.ss_family != state->socket->nat_addr.ss_family ||
|
||||
(selected_address.ss_family && !route_ping_addr_equal(&selected_address, &state->socket->nat_addr, 1));
|
||||
if (selected.mapping == current->mapping && selected.inbound == current->inbound &&
|
||||
|
||||
Reference in new issue
Block a user