App::BCSSH::Message qw(send_message BCSSH_SUCCESS BCSSH_FAILURE BCSSH_COMMAND);
use JSON qw(encode_json decode_json);
use Moo::Role;
has 'agent' => ( is => 'ro', default => sub { $ENV{SSH_AUTH_SOCK}
@_;
my $key = $self->auth_key || '';
my $message = join '|', $self->handler, $key, encode_json(\@args);
my ($rtype, $rmessage) = send_message($self->agent_socket, BCSSH_COMMAND, $message);
unless (defined $rmessage && length $rmessage) {
return;
}
my $response = decode_json($rmessage);
return wantarray ? @$response : 1;
}
1;
__END__
=head1 NAME
App::BCSSH::Client
App::BCSSH::Proxy;
use App::BCSSH::Options;
use App::BCSSH::Util qw(find_mods rc_dir);
use JSON qw(decode_json);
use constant DEBUG => $ENV{BCSSH_DEBUG};
with Options(
permute => 0,
);
with 'App:
rc_dir . '/config'
or return {};
my $raw = do { local $/; <$fh> };
return decode_json($raw);
}
sub run {
my $self = shift;
my $args = $self->args;
my $host = $self->host;
package App::BCSSH::Handler;
use Moo::Role;
use JSON qw(encode_json decode_json);
use App::BCSSH::Message;
use MooX::CaptainHook qw(on_application);
my %handlers;
sub handlers {
return %handlers;
{
my ($self, $args, $send, $socket) = @_;
my $json_send = sub {
my @response = @_;
my $rmessage = @response ? encode_json(\@response) : '';
$send->(BCSSH_SUCCESS, $rme
ssage);
return $socket;
};
my $handler_args = decode_json($args);
$self->handle($json_send, @$handler_args);
return;
}
sub handler {
my $self = shift;
return sub {