2017-03-03 20:05:50 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "util.hh"
|
2017-03-03 20:28:27 +02:00
|
|
|
#include "sync.hh"
|
2017-03-03 20:05:50 +02:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
|
|
|
class SSHMaster
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2017-03-03 20:28:27 +02:00
|
|
|
const std::string host;
|
2018-08-03 19:12:28 +03:00
|
|
|
bool fakeSSH;
|
2017-03-03 20:28:27 +02:00
|
|
|
const std::string keyFile;
|
2021-02-25 03:52:22 +02:00
|
|
|
const std::string sshPublicHostKey;
|
2017-03-03 20:28:27 +02:00
|
|
|
const bool useMaster;
|
|
|
|
const bool compress;
|
2017-05-02 13:01:46 +03:00
|
|
|
const int logFD;
|
2017-03-03 20:28:27 +02:00
|
|
|
|
|
|
|
struct State
|
|
|
|
{
|
|
|
|
Pid sshMaster;
|
|
|
|
std::unique_ptr<AutoDelete> tmpDir;
|
|
|
|
Path socketPath;
|
|
|
|
};
|
|
|
|
|
|
|
|
Sync<State> state_;
|
2017-03-03 20:05:50 +02:00
|
|
|
|
2017-03-21 15:35:50 +02:00
|
|
|
void addCommonSSHOpts(Strings & args);
|
|
|
|
|
2017-03-03 20:05:50 +02:00
|
|
|
public:
|
|
|
|
|
2021-02-25 03:52:22 +02:00
|
|
|
SSHMaster(const std::string & host, const std::string & keyFile, const std::string & sshPublicHostKey, bool useMaster, bool compress, int logFD = -1);
|
2017-03-03 20:05:50 +02:00
|
|
|
|
|
|
|
struct Connection
|
|
|
|
{
|
|
|
|
Pid sshPid;
|
|
|
|
AutoCloseFD out, in;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr<Connection> startCommand(const std::string & command);
|
|
|
|
|
2017-03-03 20:28:27 +02:00
|
|
|
Path startMaster();
|
2017-03-03 20:05:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|