Switch the engineering client to M10 sessions (M10.5c)
Foundation / checks (checks) (push) Successful in 32m47s
Foundation / checks (client) (push) Failing after 10m1s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (network) (push) Successful in 11m18s
Foundation / checks (postgres) (push) Successful in 40m20s
Foundation / checks (tsan) (push) Successful in 7m46s
Foundation / postgres-tools (push) Skipped
Foundation / image (push) Skipped
Foundation / server-image (push) Skipped
Foundation / checks (checks) (push) Successful in 32m47s
Foundation / checks (client) (push) Failing after 10m1s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (network) (push) Successful in 11m18s
Foundation / checks (postgres) (push) Successful in 40m20s
Foundation / checks (tsan) (push) Successful in 7m46s
Foundation / postgres-tools (push) Skipped
Foundation / image (push) Skipped
Foundation / server-image (push) Skipped
evo-client's remote mode now runs over RegionSessionClient (QUIC, session v2): snapshot-fed environment and organism views, the camera following the server's view until the user moves it and then driving the interest, intention records with a simulated state, and reconnects with the next grant of a bundle. The launcher reads 160-byte M10 grants and defaults to the dev route. - quic::resolve_ipv4 shared by the client and evo-session-probe - evo-session-probe grants: owner-only bundles of 1-64 grants - evo-server --m10-max-grant-lifetime (dev only, 60..3600 s) - presets client-network/client-package build QUIC; msquic links the CRT fully static; msquic.dll and msquic/OpenSSL licences in the Windows package - client-remote-session test against a loopback region - ADR-0093/0091/0086 amendments, M10_CLIENT_SESSIONS guide, validation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+104
-60
@@ -3,6 +3,14 @@
|
||||
// evo-session-probe keys --out DIR
|
||||
// Writes a fresh dev issuer key pair: DIR/issuer.key (32-byte P-256 scalar, owner-only)
|
||||
// and DIR/issuer.pub (65-byte public key for evo-server --m10-issuer).
|
||||
// evo-session-probe grants --issuer-key FILE --world N --frame N --region N
|
||||
// --account HEX32 --out FILE [--serial N] [--count 1..64] [--lifetime 60..3600]
|
||||
// M10.5c (ADR-0093): writes COUNT 160-byte grants for one account (the engineering
|
||||
// client's grant bundle), serials SERIAL..SERIAL+COUNT-1, all issued now. Without
|
||||
// --serial the first is 64 x the issue time in seconds, so a later bundle for the same
|
||||
// account supersedes an earlier one without bookkeeping. The file is created new and
|
||||
// owner-only (a credential: never commit or share it); the issuer key stays here.
|
||||
// The region refuses grants longer than its --m10-max-grant-lifetime (default 300).
|
||||
// evo-session-probe run --connect HOST:PORT --server-name NAME --ca FILE --issuer-key FILE
|
||||
// --world N --frame N --region N --account HEX32 --serial N [--lifetime S]
|
||||
// [--intents N] [--actions N --action-base ID] [--query ID]... [--timeout-ms N]
|
||||
@@ -21,22 +29,6 @@
|
||||
// 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>
|
||||
@@ -91,28 +83,6 @@ 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";
|
||||
@@ -134,6 +104,33 @@ const char* cause_name(std::optional<quic::CloseCause> c) {
|
||||
}
|
||||
}
|
||||
|
||||
std::uint64_t now_seconds() {
|
||||
return static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count());
|
||||
}
|
||||
std::optional<GrantSigningKey> issuer(const std::string& path) {
|
||||
const auto scalar = read(path);
|
||||
auto key = GrantSigningKey::import(
|
||||
DeploymentEnvironment::dev, 1,
|
||||
std::span{reinterpret_cast<const std::uint8_t*>(scalar.data()), scalar.size()});
|
||||
if (!key)
|
||||
return std::nullopt;
|
||||
return std::move(*key);
|
||||
}
|
||||
std::optional<SessionGrant> sign(const GrantSigningKey& key, GrantClaims claims) {
|
||||
std::array<std::uint8_t, 8> id{};
|
||||
if (!random_bytes(id))
|
||||
return std::nullopt;
|
||||
for (std::size_t i = 0; i < id.size(); ++i)
|
||||
claims.grant_id |= static_cast<std::uint64_t>(id.at(i)) << (8U * i);
|
||||
claims.grant_id = std::max<std::uint64_t>(claims.grant_id, 1);
|
||||
const auto grant = key.sign(claims);
|
||||
if (!grant)
|
||||
return std::nullopt;
|
||||
return *grant;
|
||||
}
|
||||
|
||||
int keys(const std::filesystem::path& out) {
|
||||
std::filesystem::create_directories(out);
|
||||
for (int attempt = 0; attempt < 8; ++attempt) {
|
||||
@@ -182,42 +179,74 @@ std::optional<SessionInterest> interest_of(std::string_view v) {
|
||||
return SessionInterest{parts[0], parts[1], parts[2], static_cast<std::uint16_t>(parts[3])};
|
||||
}
|
||||
|
||||
int run(const RunOptions& o) {
|
||||
const auto scalar = read(o.issuer_key);
|
||||
const auto key = GrantSigningKey::import(
|
||||
DeploymentEnvironment::dev, 1,
|
||||
std::span{reinterpret_cast<const std::uint8_t*>(scalar.data()), scalar.size()});
|
||||
if (!key) {
|
||||
// Exclusive create, owner-only on POSIX: a bundle is a credential.
|
||||
bool write_new(const std::filesystem::path& path, std::span<const std::uint8_t> bytes) {
|
||||
if (std::filesystem::exists(path))
|
||||
return false;
|
||||
if (!write(path, bytes))
|
||||
return false;
|
||||
std::filesystem::permissions(
|
||||
path, std::filesystem::perms::owner_read | std::filesystem::perms::owner_write,
|
||||
std::filesystem::perm_options::replace);
|
||||
return true;
|
||||
}
|
||||
|
||||
int grants(const RunOptions& o, const std::string& out, std::uint64_t count) {
|
||||
const auto key = issuer(o.issuer_key);
|
||||
if (!key || !o.account) {
|
||||
std::puts("error issuer-key");
|
||||
return 2;
|
||||
}
|
||||
GrantClaims claims;
|
||||
std::array<std::uint8_t, 8> id{};
|
||||
if (!random_bytes(id)) {
|
||||
std::puts("error random");
|
||||
claims.account = *o.account;
|
||||
claims.world = {o.world, o.frame};
|
||||
claims.region = o.region;
|
||||
claims.issued_at = now_seconds();
|
||||
claims.expires_at = claims.issued_at + o.lifetime;
|
||||
const auto first = o.serial != 0 ? o.serial : claims.issued_at * 64;
|
||||
std::vector<std::uint8_t> bundle;
|
||||
for (std::uint64_t i = 0; i < count; ++i) {
|
||||
claims.serial = first + i;
|
||||
const auto grant = sign(*key, claims);
|
||||
if (!grant) {
|
||||
std::puts("error grant");
|
||||
return 2;
|
||||
}
|
||||
bundle.insert(bundle.end(), grant->begin(), grant->end());
|
||||
}
|
||||
if (!write_new(out, bundle)) {
|
||||
std::puts("error out (exists or unwritable)");
|
||||
return 1;
|
||||
}
|
||||
std::printf("wrote %llu grants serial %llu..%llu valid %llu s\n",
|
||||
static_cast<unsigned long long>(count), static_cast<unsigned long long>(first),
|
||||
static_cast<unsigned long long>(first + count - 1),
|
||||
static_cast<unsigned long long>(o.lifetime));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run(const RunOptions& o) {
|
||||
const auto key = issuer(o.issuer_key);
|
||||
if (!key) {
|
||||
std::puts("error issuer-key");
|
||||
return 2;
|
||||
}
|
||||
for (std::size_t i = 0; i < id.size(); ++i)
|
||||
claims.grant_id |= static_cast<std::uint64_t>(id.at(i)) << (8U * i);
|
||||
claims.grant_id = std::max<std::uint64_t>(claims.grant_id, 1);
|
||||
if (!o.account)
|
||||
return 2; // Required at parse time.
|
||||
GrantClaims claims;
|
||||
claims.account = *o.account;
|
||||
claims.serial = o.serial;
|
||||
claims.world = {o.world, o.frame};
|
||||
claims.region = o.region;
|
||||
claims.issued_at =
|
||||
static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count());
|
||||
claims.issued_at = now_seconds();
|
||||
claims.expires_at = claims.issued_at + o.lifetime;
|
||||
const auto grant = key->sign(claims);
|
||||
const auto grant = sign(*key, claims);
|
||||
if (!grant) {
|
||||
std::puts("error grant");
|
||||
return 2;
|
||||
}
|
||||
client::RegionSessionClientConfig config;
|
||||
const auto address = resolve(o.host);
|
||||
const auto address = quic::resolve_ipv4(o.host);
|
||||
if (!address) {
|
||||
std::puts("error resolve");
|
||||
return 2;
|
||||
@@ -340,7 +369,12 @@ int main(int argc, char** argv) {
|
||||
if (args.size() == 3 && args[0] == "keys" && args[1] == "--out")
|
||||
return keys(std::filesystem::path{std::string{args[2]}});
|
||||
RunOptions o;
|
||||
bool ok = !args.empty() && args[0] == "run" && args.size() % 2 == 1;
|
||||
const bool bundle = !args.empty() && args[0] == "grants";
|
||||
std::string out;
|
||||
std::uint64_t count = 1;
|
||||
if (bundle)
|
||||
o.lifetime = 300; // The region's default maximum.
|
||||
bool ok = !args.empty() && (args[0] == "run" || bundle) && args.size() % 2 == 1;
|
||||
for (std::size_t i = 1; ok && i + 1 < args.size(); i += 2) {
|
||||
const auto flag = args[i];
|
||||
const auto value = args[i + 1];
|
||||
@@ -386,12 +420,22 @@ int main(int argc, char** argv) {
|
||||
o.snapshots = *n;
|
||||
else if (flag == "--interest")
|
||||
ok = (o.interest = interest_of(value)).has_value();
|
||||
else if (bundle && flag == "--out")
|
||||
out = value;
|
||||
else if (bundle && n && flag == "--count" && *n >= 1 && *n <= 64)
|
||||
count = *n;
|
||||
else
|
||||
ok = false;
|
||||
}
|
||||
if (!ok || o.host.empty() || o.server_name.empty() || o.ca.empty() || o.issuer_key.empty() ||
|
||||
!o.account || o.world == 0 || o.frame == 0 || o.region == 0 || o.serial == 0) {
|
||||
std::fputs("usage: evo-session-probe keys --out DIR | run --connect HOST:PORT "
|
||||
if (bundle && ok && !o.issuer_key.empty() && o.account && o.world != 0 && o.frame != 0 &&
|
||||
o.region != 0 && !out.empty() && o.lifetime >= 60 && o.host.empty())
|
||||
return grants(o, out, count);
|
||||
if (bundle || !ok || o.host.empty() || o.server_name.empty() || o.ca.empty() ||
|
||||
o.issuer_key.empty() || !o.account || o.world == 0 || o.frame == 0 || o.region == 0 ||
|
||||
o.serial == 0) {
|
||||
std::fputs("usage: evo-session-probe keys --out DIR | grants --issuer-key FILE "
|
||||
"--world N --frame N --region N --account HEX32 --out FILE [--serial N] "
|
||||
"[--count 1..64] [--lifetime 60..3600] | run --connect HOST:PORT "
|
||||
"--server-name NAME --ca FILE --issuer-key FILE --world N --frame N "
|
||||
"--region N --account HEX32 --serial N [--lifetime S] [--intents N] "
|
||||
"[--actions N --action-base ID] [--query ID]... [--timeout-ms N] "
|
||||
|
||||
Reference in New Issue
Block a user