Enable authenticated primitive life sessions
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m59s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 6m2s
Foundation / checks (network) (push) Canceled after 3m53s
Foundation / checks (client) (push) Canceled after 6m8s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m59s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 6m2s
Foundation / checks (network) (push) Canceled after 3m53s
Foundation / checks (client) (push) Canceled after 6m8s
This commit is contained in:
@@ -256,6 +256,14 @@ PrimitiveHostReply PrimitiveRegionHost::query(const persistence::Uuid& account,
|
||||
return reply(PrimitiveHostReplyKind::pending, value.reservation);
|
||||
}
|
||||
|
||||
PrimitiveHostReply PrimitiveRegionHost::query_life(const persistence::Uuid& account,
|
||||
std::uint64_t generation,
|
||||
std::uint64_t request) {
|
||||
if (!status_.ready || !authority_.may_begin_commit(LeaseClock::now()))
|
||||
return reply(PrimitiveHostReplyKind::unavailable, {});
|
||||
return query(account, generation, request);
|
||||
}
|
||||
|
||||
PrimitiveHostReply PrimitiveRegionHost::new_life(const persistence::Uuid& account,
|
||||
std::uint64_t generation, std::uint64_t request,
|
||||
std::uint32_t rules) {
|
||||
|
||||
@@ -72,6 +72,7 @@ struct RegionSessions::Impl {
|
||||
network::quic::ConnectionId id{};
|
||||
State state{State::hello};
|
||||
std::uint64_t session{};
|
||||
std::uint16_t protocol_version{network::session_protocol_version};
|
||||
std::string account;
|
||||
Clock::time_point deadline; // Hello, pending (Welcome due) or close flush.
|
||||
bool close_requested{};
|
||||
@@ -128,7 +129,8 @@ struct RegionSessions::Impl {
|
||||
}
|
||||
void send(const Connection& c, const network::SessionMessage& m) {
|
||||
// A refused send (budget) leaves the peer to observe the transport close instead.
|
||||
(void)endpoint->send_message(c.id, network::encode_session(m)).has_value();
|
||||
(void)endpoint->send_message(c.id, network::encode_session(m, c.protocol_version))
|
||||
.has_value();
|
||||
}
|
||||
// Realtime answers: a refused datagram is dropped; cumulative watermarks cover it.
|
||||
void send_datagram(const Connection& c, const network::SessionMessage& m) {
|
||||
@@ -537,10 +539,15 @@ struct RegionSessions::Impl {
|
||||
? SessionCloseReason::unsupported_version
|
||||
: SessionCloseReason::protocol,
|
||||
now);
|
||||
// v5 has a codec and schema, but per-connection negotiation and life handling
|
||||
// land in the following server gate. Do not silently accept v5 and answer v4.
|
||||
if (wire_version != network::session_protocol_version)
|
||||
if (c.state == State::hello) {
|
||||
c.protocol_version = wire_version;
|
||||
const bool primitive_v5 = static_cast<bool>(config.create_primitive_life);
|
||||
if ((primitive_v5 && wire_version != network::session_protocol_v5) ||
|
||||
(wire_version == network::session_protocol_v5 && !primitive_v5))
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
} else if (wire_version != c.protocol_version) {
|
||||
return close(c, SessionCloseReason::unsupported_version, now);
|
||||
}
|
||||
if (c.state == State::hello) {
|
||||
if (const auto* m = std::get_if<network::SessionHello>(&*decoded))
|
||||
return hello(c, *m, now_seconds, now);
|
||||
@@ -566,6 +573,23 @@ struct RegionSessions::Impl {
|
||||
c.deadline = now; // Nothing left to flush to a peer that is leaving.
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::PrimitiveLifeRequest>(&*decoded)) {
|
||||
const auto status = m->session != c.session ? network::AdmitStatus::unknown_session
|
||||
: m->epoch != control.epoch() ? network::AdmitStatus::stale_epoch
|
||||
: !facts.ready || c.generation == 0
|
||||
? network::AdmitStatus::not_ready
|
||||
: network::AdmitStatus::admitted;
|
||||
send(c, network::PrimitiveLifeReceipt{m->request_id, status, facts.simulated_tick});
|
||||
if (status == network::AdmitStatus::admitted)
|
||||
send(c, config.create_primitive_life(c.account_id, c.generation, m->request_id));
|
||||
return;
|
||||
}
|
||||
if (const auto* m = std::get_if<network::PrimitiveLifeQuery>(&*decoded)) {
|
||||
if (c.generation == 0)
|
||||
return send(c, network::PrimitiveLifeOutcome{
|
||||
m->request_id, network::PrimitiveLifeResult::unknown, 0, 0});
|
||||
return send(c, config.query_primitive_life(c.account_id, c.generation, m->request_id));
|
||||
}
|
||||
close(c, SessionCloseReason::protocol, now);
|
||||
}
|
||||
};
|
||||
@@ -579,6 +603,8 @@ RegionSessions::create(RegionSessionsConfig config) {
|
||||
if (config.issuer_keys.empty() || (config.handoff != nullptr && config.ledger == nullptr) ||
|
||||
(config.handoff_key != nullptr && config.probes == nullptr) ||
|
||||
config.ticket_lifetime == 0 || config.ticket_lifetime > network::max_ticket_lifetime ||
|
||||
((config.create_primitive_life || config.query_primitive_life) &&
|
||||
(!config.create_primitive_life || !config.query_primitive_life || !config.ledger)) ||
|
||||
config.transport.limits.max_connections < config.control.max_sessions ||
|
||||
config.hello_deadline.count() <= 0 || config.close_flush.count() <= 0 ||
|
||||
config.renew_interval.count() <= 0 || config.safety_margin.count() <= 0 ||
|
||||
|
||||
Reference in New Issue
Block a user