diff --git a/CMakeLists.txt b/CMakeLists.txt index 804e9d3..d697d9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,9 @@ if(EVO_BUILD_QUIC) # M10.4c headless session client (development and test only; ADR-0092). add_executable(evo-session-probe apps/evo-session-probe/main.cpp) target_link_libraries(evo-session-probe PRIVATE evo_session_client evo_network_tls) + if(WIN32) + target_link_libraries(evo-session-probe PRIVATE ws2_32) # Host name lookup. + endif() evo_owned_target(evo-session-probe) evo_msquic_runtime(evo-session-probe) if(BUILD_TESTING) diff --git a/apps/evo-session-probe/main.cpp b/apps/evo-session-probe/main.cpp index b0b4ebf..6136bc7 100644 --- a/apps/evo-session-probe/main.cpp +++ b/apps/evo-session-probe/main.cpp @@ -10,11 +10,30 @@ // (one per tick, two ticks ahead) and N probe actions (three ticks ahead), queries the // given action ids, and prints one line per answer: // welcome SESSION EPOCH TICK | intention SEQ STATUS | simulated SEQ TICK -// receipt ID STATUS TICK | outcome ID RESULT TICK COMMIT | closed REASON | done +// receipt ID STATUS TICK | outcome ID RESULT TICK COMMIT | done +// resolved HOST ADDRESS (a host name was looked up; IPv4) +// closed REASON TRANSPORT (TRANSPORT names why QUIC ended: untrusted means the server +// answered but failed the pinned CA/name check; idle means nothing answered) // Statuses, results and reasons are the session-v1 wire values. Exits 0 once every // action is final and every query answered, 1 on timeout, 3 when the server closes. // The issuer key is a development credential: the probe refuses any environment but dev. #include "evo/client/region_session.hpp" +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +// After . +#include +#else +#include +#include +#include +#include +#endif #include "evo/network/session_grant.hpp" #include #include @@ -69,6 +88,49 @@ std::optional account_of(std::string_view hex) { return id.valid() ? std::optional{id} : std::nullopt; } +// The QUIC endpoint takes a numeric address (the server name is verified separately): +// look a host name up once, IPv4, and print what DNS answered. +std::optional resolve(const std::string& host) { +#ifdef _WIN32 + WSADATA data{}; + if (WSAStartup(MAKEWORD(2, 2), &data) != 0) + return std::nullopt; +#endif + addrinfo hints{}; + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; + addrinfo* found = nullptr; + if (getaddrinfo(host.c_str(), nullptr, &hints, &found) != 0 || found == nullptr) + return std::nullopt; + char text[INET_ADDRSTRLEN] = {}; + const auto* address = reinterpret_cast(found->ai_addr); + const bool ok = inet_ntop(AF_INET, &address->sin_addr, text, sizeof text) != nullptr; + freeaddrinfo(found); + if (!ok) + return std::nullopt; + return std::string{text}; +} +const char* cause_name(std::optional c) { + if (!c) + return "none"; + switch (*c) { + case quic::CloseCause::local: + return "local"; + case quic::CloseCause::peer: + return "peer"; + case quic::CloseCause::idle: + return "idle"; + case quic::CloseCause::untrusted: + return "untrusted"; + case quic::CloseCause::overloaded: + return "overloaded"; + case quic::CloseCause::protocol: + return "protocol"; + default: + return "transport"; + } +} + int keys(const std::filesystem::path& out) { std::filesystem::create_directories(out); for (int attempt = 0; attempt < 8; ++attempt) { @@ -135,7 +197,14 @@ int run(const RunOptions& o) { return 2; } client::RegionSessionClientConfig config; - config.transport.server_address = o.host; + const auto address = resolve(o.host); + if (!address) { + std::puts("error resolve"); + return 2; + } + if (*address != o.host) + std::printf("resolved %s %s\n", o.host.c_str(), address->c_str()); + config.transport.server_address = *address; config.transport.port = o.port; config.transport.server_name = o.server_name; config.transport.authority_pem = read(o.ca); @@ -156,8 +225,10 @@ int run(const RunOptions& o) { while (Clock::now() < deadline) { c.poll(Clock::now()); if (c.state() == client::RegionSessionState::closed) { - std::printf("closed %u\n", static_cast(c.close_reason().value_or( - SessionCloseReason::connection_lost))); + std::printf("closed %u %s\n", + static_cast( + c.close_reason().value_or(SessionCloseReason::connection_lost)), + cause_name(c.transport_cause())); return 3; } if (c.state() != client::RegionSessionState::established) { diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index dc0bd28..5c6f631 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -4328,3 +4328,22 @@ port `session` UDP 7400; no other Service exposes 7400. Not done (needs the maintainer): Argo sync of this change; the edge firewall rule; internal DNS to 172.10.1.202; retrieving the dev CA and issuer key (no cluster credentials on the workstation); the end-to-end probe through the VIP. The route is not verified. + +## 2026-10-05 — Dev session route reachability over UDP (not yet acceptance) + +After the maintainer synced the UDP route and set internal DNS, from workstation +172.10.1.169 (inside 172.10.1.0/24): `void.aeternalisgames.com` resolves to the VIP +172.10.1.202 (earlier answers of 172.10.1.160 were cached). `evo-session-probe` with a +throwaway CA and issuer key (generated locally; cannot authenticate) against +`172.10.1.202:7400` and `void.aeternalisgames.com:7400` ended with transport cause +`untrusted` after 62-67 ms: a QUIC server answered with its certificate, which the pinned +throwaway CA refused. Control: `172.10.1.202:7401` ended after the 5 s Welcome deadline with +no transport event (nothing answered). This shows UDP 7400 reaches the M10 listener through +DNS, the MetalLB VIP, the Service and the NetworkPolicy from the same subnet. It is not the +acceptance run: that needs the dev CA and issuer key from the cluster Secret (no cluster +credentials on the workstation yet), and a client on the same subnet does not cross the +edge firewall. +Probe changes: host names are resolved (IPv4) and printed (`resolved HOST ADDRESS`), and +`closed` lines name the QUIC transport cause (`RegionSessionClient::transport_cause`). +Executed: Windows MSVC preset `quic` build; Linux GCC preset `quic` CTest 4/4; clang-tidy 19 +on the client, probe and evo-server sources. diff --git a/include/evo/client/region_session.hpp b/include/evo/client/region_session.hpp index 1474ee2..c06be8b 100644 --- a/include/evo/client/region_session.hpp +++ b/include/evo/client/region_session.hpp @@ -60,6 +60,9 @@ class RegionSessionClient { [[nodiscard]] RegionSessionState state() const noexcept; [[nodiscard]] const std::optional& welcome() const noexcept; [[nodiscard]] std::optional close_reason() const noexcept; + // Why the QUIC connection itself ended (e.g. `untrusted`: the server answered but its + // certificate failed the pinned check), when it ended without a session Close. + [[nodiscard]] std::optional transport_cause() const noexcept; private: struct Impl; diff --git a/src/client/session/region_session.cpp b/src/client/session/region_session.cpp index b244d38..0d654e1 100644 --- a/src/client/session/region_session.cpp +++ b/src/client/session/region_session.cpp @@ -16,6 +16,7 @@ struct RegionSessionClient::Impl { network::quic::ConnectionId connection{}; std::optional welcome; std::optional reason; + std::optional transport_cause; std::optional refresh_result; std::uint64_t next_sequence{1}, server_tick{}; std::optional simulated; @@ -136,6 +137,7 @@ void RegionSessionClient::poll(Clock::time_point now) { } else if (e.kind == EventKind::datagram) { m.datagram(e.bytes); } else if (e.kind == EventKind::closed) { + m.transport_cause = e.cause; m.connection = 0; // Already gone; nothing to close or send. m.end(SessionCloseReason::connection_lost, false); } @@ -212,6 +214,10 @@ const std::optional& RegionSessionClient::welcome() con return impl_->welcome; } +std::optional RegionSessionClient::transport_cause() const noexcept { + return impl_->transport_cause; +} + std::optional RegionSessionClient::close_reason() const noexcept { return impl_->reason; }