mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 03:56:01 +01:00
Remove support for serve protocol < 5
This was introduced in August 2018 (2825e05d21).
This commit is contained in:
parent
8c789db05b
commit
fa048e4383
7 changed files with 17 additions and 60 deletions
Binary file not shown.
|
|
@ -20,9 +20,9 @@ struct ServeProtoTest : VersionedProtoTest<ServeProto, serveProtoDir>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* For serializers that don't care about the minimum version, we
|
* For serializers that don't care about the minimum version, we
|
||||||
* used the oldest one: 1.0.
|
* used the oldest one: 2.5.
|
||||||
*/
|
*/
|
||||||
ServeProto::Version defaultVersion = 2 << 8 | 0;
|
ServeProto::Version defaultVersion = 2 << 8 | 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST(
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,6 @@ struct ServeProto::BasicClientConnection
|
||||||
BuildResult getBuildDerivationResponse(const StoreDirConfig & store);
|
BuildResult getBuildDerivationResponse(const StoreDirConfig & store);
|
||||||
|
|
||||||
void narFromPath(const StoreDirConfig & store, const StorePath & path, std::function<void(Source &)> fun);
|
void narFromPath(const StoreDirConfig & store, const StorePath & path, std::function<void(Source &)> fun);
|
||||||
|
|
||||||
void importPaths(const StoreDirConfig & store, std::function<void(Sink &)> fun);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ServeProto::BasicServerConnection
|
struct ServeProto::BasicServerConnection
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ enum struct ServeProto::Command : uint64_t {
|
||||||
QueryValidPaths = 1,
|
QueryValidPaths = 1,
|
||||||
QueryPathInfos = 2,
|
QueryPathInfos = 2,
|
||||||
DumpStorePath = 3,
|
DumpStorePath = 3,
|
||||||
ImportPaths = 4,
|
|
||||||
ExportPaths = 5,
|
ExportPaths = 5,
|
||||||
BuildPaths = 6,
|
BuildPaths = 6,
|
||||||
QueryClosure = 7,
|
QueryClosure = 7,
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,6 @@ std::map<StorePath, UnkeyedValidPathInfo> LegacySSHStore::queryPathInfosUncached
|
||||||
{
|
{
|
||||||
auto conn(connections->get());
|
auto conn(connections->get());
|
||||||
|
|
||||||
/* No longer support missing NAR hash */
|
|
||||||
assert(GET_PROTOCOL_MINOR(conn->remoteVersion) >= 4);
|
|
||||||
|
|
||||||
debug(
|
debug(
|
||||||
"querying remote host '%s' for info on '%s'",
|
"querying remote host '%s' for info on '%s'",
|
||||||
config->authority.host,
|
config->authority.host,
|
||||||
|
|
@ -152,40 +149,21 @@ void LegacySSHStore::addToStore(const ValidPathInfo & info, Source & source, Rep
|
||||||
|
|
||||||
auto conn(connections->get());
|
auto conn(connections->get());
|
||||||
|
|
||||||
if (GET_PROTOCOL_MINOR(conn->remoteVersion) >= 5) {
|
conn->to << ServeProto::Command::AddToStoreNar << printStorePath(info.path)
|
||||||
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
conn->to << ServeProto::Command::AddToStoreNar << printStorePath(info.path)
|
<< info.narHash.to_string(HashFormat::Base16, false);
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
ServeProto::write(*this, *conn, info.references);
|
||||||
<< info.narHash.to_string(HashFormat::Base16, false);
|
conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs << renderContentAddress(info.ca);
|
||||||
ServeProto::write(*this, *conn, info.references);
|
try {
|
||||||
conn->to << info.registrationTime << info.narSize << info.ultimate << info.sigs
|
copyNAR(source, conn->to);
|
||||||
<< renderContentAddress(info.ca);
|
} catch (...) {
|
||||||
try {
|
conn->good = false;
|
||||||
copyNAR(source, conn->to);
|
throw;
|
||||||
} catch (...) {
|
|
||||||
conn->good = false;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
conn->to.flush();
|
|
||||||
|
|
||||||
if (readInt(conn->from) != 1)
|
|
||||||
throw Error(
|
|
||||||
"failed to add path '%s' to remote host '%s'", printStorePath(info.path), config->authority.host);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
conn->importPaths(*this, [&](Sink & sink) {
|
|
||||||
try {
|
|
||||||
copyNAR(source, sink);
|
|
||||||
} catch (...) {
|
|
||||||
conn->good = false;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
sink << exportMagic << printStorePath(info.path);
|
|
||||||
ServeProto::write(*this, *conn, info.references);
|
|
||||||
sink << (info.deriver ? printStorePath(*info.deriver) : "") << 0 << 0;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
conn->to.flush();
|
||||||
|
|
||||||
|
if (readInt(conn->from) != 1)
|
||||||
|
throw Error("failed to add path '%s' to remote host '%s'", printStorePath(info.path), config->authority.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LegacySSHStore::narFromPath(const StorePath & path, Sink & sink)
|
void LegacySSHStore::narFromPath(const StorePath & path, Sink & sink)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ ServeProto::Version ServeProto::BasicClientConnection::handshake(
|
||||||
if (magic != SERVE_MAGIC_2)
|
if (magic != SERVE_MAGIC_2)
|
||||||
throw Error("'nix-store --serve' protocol mismatch from '%s'", host);
|
throw Error("'nix-store --serve' protocol mismatch from '%s'", host);
|
||||||
auto remoteVersion = readInt(from);
|
auto remoteVersion = readInt(from);
|
||||||
if (GET_PROTOCOL_MAJOR(remoteVersion) != 0x200)
|
if (GET_PROTOCOL_MAJOR(remoteVersion) != 0x200 || GET_PROTOCOL_MINOR(remoteVersion) < 5)
|
||||||
throw Error("unsupported 'nix-store --serve' protocol version on '%s'", host);
|
throw Error("unsupported 'nix-store --serve' protocol version on '%s'", host);
|
||||||
return std::min(remoteVersion, localVersion);
|
return std::min(remoteVersion, localVersion);
|
||||||
}
|
}
|
||||||
|
|
@ -93,14 +93,4 @@ void ServeProto::BasicClientConnection::narFromPath(
|
||||||
fun(from);
|
fun(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServeProto::BasicClientConnection::importPaths(const StoreDirConfig & store, std::function<void(Sink &)> fun)
|
|
||||||
{
|
|
||||||
to << ServeProto::Command::ImportPaths;
|
|
||||||
fun(to);
|
|
||||||
to.flush();
|
|
||||||
|
|
||||||
if (readInt(from) != 1)
|
|
||||||
throw Error("remote machine failed to import closure");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
|
|
@ -985,14 +985,6 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
store->narFromPath(store->parseStorePath(readString(in)), out);
|
store->narFromPath(store->parseStorePath(readString(in)), out);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ServeProto::Command::ImportPaths: {
|
|
||||||
if (!writeAllowed)
|
|
||||||
throw Error("importing paths is not allowed");
|
|
||||||
store->importPaths(in, NoCheckSigs); // FIXME: should we skip sig checking?
|
|
||||||
out << 1; // indicate success
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ServeProto::Command::ExportPaths: {
|
case ServeProto::Command::ExportPaths: {
|
||||||
readInt(in); // obsolete
|
readInt(in); // obsolete
|
||||||
store->exportPaths(ServeProto::Serialise<StorePathSet>::read(*store, rconn), out);
|
store->exportPaths(ServeProto::Serialise<StorePathSet>::read(*store, rconn), out);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue