Adapt STUN diagnostics to endpoint profiles and helper sockets
This commit is contained in:
1 parent
fff3fa62ab
commit
4b2e540798
2 files changed
+18
-2
No files matched your search
@@ -656,7 +656,7 @@ static void restart_probe(struct stun_probe* p) {
|
||||
static void scan_sources(struct STUN_NAT* mod) {
|
||||
for (struct stun_probe* p = mod->probes; p; p = p->next) p->seen = 0;
|
||||
for (struct ETCP_SOCKET* sock = mod->inst->etcp_sockets; sock; sock = sock->next) {
|
||||
if (sock->is_tcp) continue;
|
||||
if (sock->is_tcp || sock->probe_only) continue;
|
||||
struct stun_source source;
|
||||
if (source_snapshot(sock, &source) < 0) continue;
|
||||
struct stun_probe** slot = &mod->probes;
|
||||
|
||||
+17
-1
@@ -157,7 +157,10 @@ static void fixture_init(struct fixture* f) {
|
||||
assert(!getsockname(f->source.fd, (struct sockaddr*)&f->source.local_addr, &size));
|
||||
f->source.interface_addr = f->source.local_addr;
|
||||
f->source.instance = &f->inst;
|
||||
f->source.nat_type = NAT_VERIFIED_STRICT;
|
||||
f->source.address_profile.mapping = ADDRESS_MAP_DEPENDENT;
|
||||
f->source.address_profile.inbound = ADDRESS_IN_CONTACT;
|
||||
f->source.address_profile.evidence_id = 1;
|
||||
f->source.address_profile.checked_at = 1;
|
||||
f->source.nat_addr = f->source.local_addr;
|
||||
snprintf(f->source.name, sizeof(f->source.name), "source");
|
||||
f->inst.etcp_sockets = &f->source;
|
||||
@@ -307,6 +310,19 @@ int main(void) {
|
||||
run_case("unstable mapping", &unstable, STUN_MAP_UNKNOWN, STUN_FILTER_UNKNOWN);
|
||||
struct fixture direct = { .rfc = 1, .direct = 1, .mapping = STUN_MAP_EIM, .filtering = STUN_FILTER_EIF };
|
||||
run_case("no translation", &direct, STUN_MAP_EIM, STUN_FILTER_EIF);
|
||||
struct fixture helpers = { .mapping = STUN_MAP_EIM };
|
||||
fixture_init(&helpers);
|
||||
struct ETCP_SOCKET auxiliary = helpers.source;
|
||||
auxiliary.probe_only = 1;
|
||||
snprintf(auxiliary.name, sizeof(auxiliary.name), "nat-helper");
|
||||
auxiliary.next = &helpers.source;
|
||||
helpers.inst.etcp_sockets = &auxiliary;
|
||||
fixture_start(&helpers, 0, 0, 0);
|
||||
struct stun_nat_result helper_result = wait_result(&helpers);
|
||||
assert(helper_result.mapping == STUN_MAP_MATCH);
|
||||
assert(stun_nat_get_result(&helpers.inst, "nat-helper", &helper_result) < 0);
|
||||
fixture_destroy(&helpers);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_NAT, "PASS STUN skips auxiliary NAT helper sockets");
|
||||
struct fixture duplicate = { .mapping = STUN_MAP_EIM };
|
||||
fixture_init(&duplicate);
|
||||
fixture_start(&duplicate, 0, 0, 1);
|
||||
|
||||
Reference in new issue
Block a user