Skip to content

Commit

Permalink
verify remote is correctly identified as client or relay
Browse files Browse the repository at this point in the history
the lokinet-specific ALPN logic should be divorced from libquic, but for now
it is working; that can be changed later.
  • Loading branch information
tewinget committed Sep 6, 2023
1 parent 92fc299 commit 2425041
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/008-ed-keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ namespace oxen::quic::test
auto client_endpoint = test_net.endpoint(client_local);

std::promise<bool> key_was_allowed;
bool remote_was_relay{false};
auto f = key_was_allowed.get_future();

auto client_key_allowed_cb = [&](const oxen::quic::gnutls_key& key, bool is_relay) {
remote_was_relay = is_relay;
if (not is_relay)
{
key_was_allowed.set_value(true);
Expand All @@ -91,12 +93,14 @@ namespace oxen::quic::test
return false;
};

auto always_allow_cb = [&](auto&&...) {
auto always_allow_cb = [&](auto, bool is_relay) {
remote_was_relay = is_relay;
key_was_allowed.set_value(true);
return true;
};

auto always_deny_cb = [&](auto&&...) {
auto always_deny_cb = [&](auto, bool is_relay) {
remote_was_relay = is_relay;
key_was_allowed.set_value(false);
return false;
};
Expand All @@ -111,6 +115,7 @@ namespace oxen::quic::test
REQUIRE_NOTHROW(client_endpoint->connect(client_remote, client_tls));

require_future(f);
REQUIRE(not remote_was_relay);
REQUIRE(f.get() == true);
};

Expand All @@ -121,6 +126,7 @@ namespace oxen::quic::test
REQUIRE_NOTHROW(client_endpoint->connect(client_remote, client_tls));

require_future(f);
REQUIRE(not remote_was_relay);
REQUIRE(f.get() == false);
};

Expand All @@ -131,6 +137,7 @@ namespace oxen::quic::test
REQUIRE_NOTHROW(client_endpoint->connect(client_remote, server_tls2));

require_future(f);
REQUIRE(remote_was_relay);
REQUIRE(f.get() == true);
};

Expand All @@ -141,6 +148,7 @@ namespace oxen::quic::test
REQUIRE_NOTHROW(client_endpoint->connect(client_remote, server_tls));

require_future(f);
REQUIRE(remote_was_relay);
REQUIRE(f.get() == false);
};
};
Expand Down

0 comments on commit 2425041

Please sign in to comment.