Commit | Line | Data |
47c83a13 |
1 | package Object::Remote::Connector::SSH; |
2 | |
84b04178 |
3 | use Object::Remote::ModuleSender; |
8ba4f2e3 |
4 | use Object::Remote::Handle; |
47c83a13 |
5 | use Moo; |
6 | |
a9fdb55e |
7 | with 'Object::Remote::Role::Connector::PerlInterpreter'; |
47c83a13 |
8 | |
fbd3b8ec |
9 | has ssh_to => (is => 'ro', required => 1); |
10 | |
498c4ad5 |
11 | has ssh_perl_command => (is => 'lazy'); |
12 | |
6ec765ba |
13 | has ssh_options => (is => 'ro', default => sub { [ '-A' ] }); |
14 | |
15 | has ssh_command => (is => 'ro', default => sub { 'ssh' }); |
16 | |
498c4ad5 |
17 | sub _build_ssh_perl_command { |
18 | my ($self) = @_; |
6ec765ba |
19 | return [ |
20 | do { my $c = $self->ssh_command; ref($c) ? @$c : $c }, |
21 | @{$self->ssh_options}, $self->ssh_to, |
22 | @{$self->perl_command} |
23 | ]; |
498c4ad5 |
24 | } |
25 | |
26 | sub final_perl_command { shift->ssh_perl_command } |
84b04178 |
27 | |
7efea51f |
28 | no warnings 'once'; |
29 | |
84b04178 |
30 | push @Object::Remote::Connection::Guess, sub { |
31 | for ($_[0]) { |
32 | # 0-9 a-z _ - first char, those or . subsequent - hostnamish |
a9fdb55e |
33 | if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) { |
fbd3b8ec |
34 | return __PACKAGE__->new(ssh_to => $_[0]); |
84b04178 |
35 | } |
36 | } |
37 | return; |
38 | }; |
39 | |
47c83a13 |
40 | 1; |