mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
SSH.pm: Print a friendlier message if connecting fails
"got EOF while expecting 8 bytes from remote side" is not very helpful.
This commit is contained in:
parent
087581a642
commit
d436e44ae3
2 changed files with 12 additions and 4 deletions
|
@ -57,6 +57,7 @@ sub copyTo {
|
||||||
if ($@) {
|
if ($@) {
|
||||||
chomp $@;
|
chomp $@;
|
||||||
warn "$@; falling back to old closure copying method\n";
|
warn "$@; falling back to old closure copying method\n";
|
||||||
|
$@ = "";
|
||||||
return oldCopyTo(@_);
|
return oldCopyTo(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package Nix::SSH;
|
package Nix::SSH;
|
||||||
|
|
||||||
|
use utf8;
|
||||||
use strict;
|
use strict;
|
||||||
use File::Temp qw(tempdir);
|
use File::Temp qw(tempdir);
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
|
@ -89,10 +90,16 @@ sub connectToRemoteNix {
|
||||||
my $pid = open2($from, $to, "exec ssh -x -a $sshHost @globalSshOpts @{$sshOpts} nix-store --serve --write $extraFlags");
|
my $pid = open2($from, $to, "exec ssh -x -a $sshHost @globalSshOpts @{$sshOpts} nix-store --serve --write $extraFlags");
|
||||||
|
|
||||||
# Do the handshake.
|
# Do the handshake.
|
||||||
my $SERVE_MAGIC_1 = 0x390c9deb; # FIXME
|
my $magic;
|
||||||
my $clientVersion = 0x200;
|
eval {
|
||||||
syswrite($to, pack("L<x4L<x4", $SERVE_MAGIC_1, $clientVersion)) or die;
|
my $SERVE_MAGIC_1 = 0x390c9deb; # FIXME
|
||||||
die "did not get valid handshake from remote host\n" if readInt($from) != 0x5452eecb;
|
my $clientVersion = 0x200;
|
||||||
|
syswrite($to, pack("L<x4L<x4", $SERVE_MAGIC_1, $clientVersion)) or die;
|
||||||
|
$magic = readInt($from);
|
||||||
|
};
|
||||||
|
die "unable to connect to ‘$sshHost’\n" if $@;
|
||||||
|
die "did not get valid handshake from remote host\n" if $magic != 0x5452eecb;
|
||||||
|
|
||||||
my $serverVersion = readInt($from);
|
my $serverVersion = readInt($from);
|
||||||
die "unsupported server version\n" if $serverVersion < 0x200 || $serverVersion >= 0x300;
|
die "unsupported server version\n" if $serverVersion < 0x200 || $serverVersion >= 0x300;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue