X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FObject%2FRemote%2FConnector%2FSSH.pm;h=0821c967938c6aadc7c6732a4c29f98e964daf25;hb=a9fdb55e205b30cfca1cee5f61ab0f1107f750d1;hp=5d5797ca076fe2d3678187490d255c15736c8630;hpb=84b04178bd25e342d7f522e8f60c6d695b09576a;p=scpubgit%2FObject-Remote.git diff --git a/lib/Object/Remote/Connector/SSH.pm b/lib/Object/Remote/Connector/SSH.pm index 5d5797c..0821c96 100644 --- a/lib/Object/Remote/Connector/SSH.pm +++ b/lib/Object/Remote/Connector/SSH.pm @@ -1,29 +1,14 @@ package Object::Remote::Connector::SSH; -use Object::Remote::FatNode; use Object::Remote::ModuleSender; -use IPC::Open2; +use Object::Remote::Handle; use Moo; -with 'Object::Remote::Role::Connector'; +with 'Object::Remote::Role::Connector::PerlInterpreter'; -sub _open2_for { - my $self = shift; - my $pid = open2(my $ssh_stdout, my $ssh_stdin, 'ssh', $_[0], 'perl', '-') - or die "Failed to start ssh connection: $!";; - print $ssh_stdin $Object::Remote::FatNode::DATA, "__END__\n"; - return ($ssh_stdin, $ssh_stdout, $pid); -} - -around connect => sub { - my ($orig, $self) = (shift, shift); - my $conn = $self->$orig(@_); - Object::Remote->new( - connection => $conn, - class => 'Object::Remote::ModuleLoader', - args => { module_sender => Object::Remote::ModuleSender->new } - )->disarm_free; - return $conn; +around _perl_command => sub { + my ($orig, $self, $target) = @_; + return 'ssh', $target, $self->$orig($target); }; sub _ssh_object_for { @@ -34,7 +19,7 @@ sub _ssh_object_for { push @Object::Remote::Connection::Guess, sub { for ($_[0]) { # 0-9 a-z _ - first char, those or . subsequent - hostnamish - if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]*/) { + if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) { return __PACKAGE__->new->connect($_[0]); } }