Probe: resolve host names and report the QUIC close cause
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (network) (push) Successful in 9m46s
Foundation / checks (client) (push) Successful in 13m6s
Foundation / checks (tsan) (push) Successful in 8m2s
Foundation / checks (checks) (push) Successful in 32m25s
Foundation / checks (postgres) (push) Successful in 38m45s
Foundation / postgres-tools (push) Successful in 16s
Foundation / image (push) Successful in 2m34s
Foundation / server-image (push) Successful in 4m2s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (network) (push) Successful in 9m46s
Foundation / checks (client) (push) Successful in 13m6s
Foundation / checks (tsan) (push) Successful in 8m2s
Foundation / checks (checks) (push) Successful in 32m25s
Foundation / checks (postgres) (push) Successful in 38m45s
Foundation / postgres-tools (push) Successful in 16s
Foundation / image (push) Successful in 2m34s
Foundation / server-image (push) Successful in 4m2s
evo-session-probe resolves a host name to IPv4 and prints the address DNS answered, and its closed line names why the QUIC connection ended (untrusted: the server answered but failed the pinned check; idle: nothing answered), via the new RegionSessionClient::transport_cause. Records the UDP route reachability check (not yet the authenticated acceptance run). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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 <winsock2.h>
|
||||
// After <winsock2.h>.
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -69,6 +88,49 @@ std::optional<AccountId> 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<std::string> 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<const sockaddr_in*>(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<quic::CloseCause> 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<unsigned>(c.close_reason().value_or(
|
||||
SessionCloseReason::connection_lost)));
|
||||
std::printf("closed %u %s\n",
|
||||
static_cast<unsigned>(
|
||||
c.close_reason().value_or(SessionCloseReason::connection_lost)),
|
||||
cause_name(c.transport_cause()));
|
||||
return 3;
|
||||
}
|
||||
if (c.state() != client::RegionSessionState::established) {
|
||||
|
||||
Reference in New Issue
Block a user