mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 01:39:36 +01:00
This patch allows users to specify the connection port
in the store URLS like so:
```
nix store info --store "ssh-ng://localhost:22" --json
```
Previously this failed with: `error: failed to start SSH connection to 'localhost:22'`,
because the code did not distinguish the port from the hostname. This
patch remedies that problem by introducing a ParsedURL::Authority type
for working with parsed authority components of URIs.
Now that the URL parsing code is less ad-hoc we can
add more long-awaited fixes for specifying SSH connection
ports in store URIs.
Builds upon the work from bd1d2d1041.
Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
32 lines
770 B
C++
32 lines
770 B
C++
#include <regex>
|
|
|
|
#include "nix/store/common-ssh-store-config.hh"
|
|
#include "nix/store/ssh.hh"
|
|
|
|
namespace nix {
|
|
|
|
CommonSSHStoreConfig::CommonSSHStoreConfig(std::string_view scheme, std::string_view authority, const Params & params)
|
|
: CommonSSHStoreConfig(scheme, ParsedURL::Authority::parse(authority), params)
|
|
{
|
|
}
|
|
|
|
CommonSSHStoreConfig::CommonSSHStoreConfig(
|
|
std::string_view scheme, const ParsedURL::Authority & authority, const Params & params)
|
|
: StoreConfig(params)
|
|
, authority(authority)
|
|
{
|
|
}
|
|
|
|
SSHMaster CommonSSHStoreConfig::createSSHMaster(bool useMaster, Descriptor logFD) const
|
|
{
|
|
return {
|
|
authority,
|
|
sshKey.get(),
|
|
sshPublicHostKey.get(),
|
|
useMaster,
|
|
compress,
|
|
logFD,
|
|
};
|
|
}
|
|
|
|
} // namespace nix
|