mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-18 08:07:17 +02:00
Name the protocol version types
This makes the code clearer, and will help us replace them with proper structs and get rid of the macros later.
This commit is contained in:
parent
e92cac789f
commit
ff68426095
6 changed files with 22 additions and 8 deletions
|
@ -45,9 +45,9 @@ struct TunnelLogger : public Logger
|
||||||
|
|
||||||
Sync<State> state_;
|
Sync<State> state_;
|
||||||
|
|
||||||
unsigned int clientVersion;
|
WorkerProto::Version clientVersion;
|
||||||
|
|
||||||
TunnelLogger(FdSink & to, unsigned int clientVersion)
|
TunnelLogger(FdSink & to, WorkerProto::Version clientVersion)
|
||||||
: to(to), clientVersion(clientVersion) { }
|
: to(to), clientVersion(clientVersion) { }
|
||||||
|
|
||||||
void enqueueMsg(const std::string & s)
|
void enqueueMsg(const std::string & s)
|
||||||
|
@ -261,7 +261,7 @@ struct ClientSettings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<DerivedPath> readDerivedPaths(Store & store, unsigned int clientVersion, WorkerProto::ReadConn conn)
|
static std::vector<DerivedPath> readDerivedPaths(Store & store, WorkerProto::Version clientVersion, WorkerProto::ReadConn conn)
|
||||||
{
|
{
|
||||||
std::vector<DerivedPath> reqs;
|
std::vector<DerivedPath> reqs;
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 30) {
|
if (GET_PROTOCOL_MINOR(clientVersion) >= 30) {
|
||||||
|
@ -274,7 +274,7 @@ static std::vector<DerivedPath> readDerivedPaths(Store & store, unsigned int cli
|
||||||
}
|
}
|
||||||
|
|
||||||
static void performOp(TunnelLogger * logger, ref<Store> store,
|
static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
TrustedFlag trusted, RecursiveFlag recursive, unsigned int clientVersion,
|
TrustedFlag trusted, RecursiveFlag recursive, WorkerProto::Version clientVersion,
|
||||||
Source & from, BufferedSink & to, WorkerProto::Op op)
|
Source & from, BufferedSink & to, WorkerProto::Op op)
|
||||||
{
|
{
|
||||||
WorkerProto::ReadConn rconn { .from = from };
|
WorkerProto::ReadConn rconn { .from = from };
|
||||||
|
@ -1017,7 +1017,7 @@ void processConnection(
|
||||||
if (magic != WORKER_MAGIC_1) throw Error("protocol mismatch");
|
if (magic != WORKER_MAGIC_1) throw Error("protocol mismatch");
|
||||||
to << WORKER_MAGIC_2 << PROTOCOL_VERSION;
|
to << WORKER_MAGIC_2 << PROTOCOL_VERSION;
|
||||||
to.flush();
|
to.flush();
|
||||||
unsigned int clientVersion = readInt(from);
|
WorkerProto::Version clientVersion = readInt(from);
|
||||||
|
|
||||||
if (clientVersion < 0x10a)
|
if (clientVersion < 0x10a)
|
||||||
throw Error("the Nix client version is too old");
|
throw Error("the Nix client version is too old");
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
|
||||||
std::unique_ptr<SSHMaster::Connection> sshConn;
|
std::unique_ptr<SSHMaster::Connection> sshConn;
|
||||||
FdSink to;
|
FdSink to;
|
||||||
FdSource from;
|
FdSource from;
|
||||||
int remoteVersion;
|
ServeProto::Version remoteVersion;
|
||||||
bool good = true;
|
bool good = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct RemoteStore::Connection
|
||||||
* sides support. (If the maximum doesn't exist, we would fail to
|
* sides support. (If the maximum doesn't exist, we would fail to
|
||||||
* establish a connection and produce a value of this type.)
|
* establish a connection and produce a value of this type.)
|
||||||
*/
|
*/
|
||||||
unsigned int daemonVersion;
|
WorkerProto::Version daemonVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the remote side trusts us or not.
|
* Whether the remote side trusts us or not.
|
||||||
|
|
|
@ -30,6 +30,13 @@ struct ServeProto
|
||||||
*/
|
*/
|
||||||
enum struct Command : uint64_t;
|
enum struct Command : uint64_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version type for the protocol.
|
||||||
|
*
|
||||||
|
* @todo Convert to struct with separate major vs minor fields.
|
||||||
|
*/
|
||||||
|
using Version = unsigned int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unidirectional read connection, to be used by the read half of the
|
* A unidirectional read connection, to be used by the read half of the
|
||||||
* canonical serializers below.
|
* canonical serializers below.
|
||||||
|
|
|
@ -47,6 +47,13 @@ struct WorkerProto
|
||||||
*/
|
*/
|
||||||
enum struct Op : uint64_t;
|
enum struct Op : uint64_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version type for the protocol.
|
||||||
|
*
|
||||||
|
* @todo Convert to struct with separate major vs minor fields.
|
||||||
|
*/
|
||||||
|
using Version = unsigned int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unidirectional read connection, to be used by the read half of the
|
* A unidirectional read connection, to be used by the read half of the
|
||||||
* canonical serializers below.
|
* canonical serializers below.
|
||||||
|
|
|
@ -818,7 +818,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
if (magic != SERVE_MAGIC_1) throw Error("protocol mismatch");
|
if (magic != SERVE_MAGIC_1) throw Error("protocol mismatch");
|
||||||
out << SERVE_MAGIC_2 << SERVE_PROTOCOL_VERSION;
|
out << SERVE_MAGIC_2 << SERVE_PROTOCOL_VERSION;
|
||||||
out.flush();
|
out.flush();
|
||||||
unsigned int clientVersion = readInt(in);
|
ServeProto::Version clientVersion = readInt(in);
|
||||||
|
|
||||||
ServeProto::ReadConn rconn { .from = in };
|
ServeProto::ReadConn rconn { .from = in };
|
||||||
ServeProto::WriteConn wconn { .to = out };
|
ServeProto::WriteConn wconn { .to = out };
|
||||||
|
|
Loading…
Add table
Reference in a new issue