1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 11:36:03 +01:00

Introduce MINIMUM_PROTOCOL_VERSION constant

This commit is contained in:
Eelco Dolstra 2025-10-27 15:11:16 +01:00
parent 1af5a98955
commit 91cd42511e
3 changed files with 3 additions and 2 deletions

View file

@ -1031,7 +1031,7 @@ void processConnection(ref<Store> store, FdSource && from, FdSink && to, Trusted
auto [protoVersion, features] = auto [protoVersion, features] =
WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures); WorkerProto::BasicServerConnection::handshake(to, from, PROTOCOL_VERSION, WorkerProto::allFeatures);
if (protoVersion < 256 + 18) if (protoVersion < MINIMUM_PROTOCOL_VERSION)
throw Error("the Nix client version is too old"); throw Error("the Nix client version is too old");
WorkerProto::BasicServerConnection conn; WorkerProto::BasicServerConnection conn;

View file

@ -13,6 +13,7 @@ namespace nix {
/* Note: you generally shouldn't change the protocol version. Define a /* Note: you generally shouldn't change the protocol version. Define a
new `WorkerProto::Feature` instead. */ new `WorkerProto::Feature` instead. */
#define PROTOCOL_VERSION (1 << 8 | 38) #define PROTOCOL_VERSION (1 << 8 | 38)
#define MINIMUM_PROTOCOL_VERSION (1 << 8 | 18)
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)

View file

@ -73,7 +73,7 @@ void RemoteStore::initConnection(Connection & conn)
try { try {
auto [protoVersion, features] = auto [protoVersion, features] =
WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures); WorkerProto::BasicClientConnection::handshake(conn.to, tee, PROTOCOL_VERSION, WorkerProto::allFeatures);
if (protoVersion < 256 + 18) if (protoVersion < MINIMUM_PROTOCOL_VERSION)
throw Error("the Nix daemon version is too old"); throw Error("the Nix daemon version is too old");
conn.protoVersion = protoVersion; conn.protoVersion = protoVersion;
conn.features = features; conn.features = features;