From: Matt S Trout Date: Fri, 26 Aug 2016 13:17:16 +0000 (+0000) Subject: INET connector X-Git-Tag: v0.004000~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=commitdiff_plain;h=bef36e73e4257b2ba8e59eb55661ffc51d8a620a INET connector --- diff --git a/Changes b/Changes index bec886e..352c461 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - Add INET connector - Make strictures dep explicit 0.003006 - 2016-01-10 diff --git a/lib/Object/Remote/Connection.pm b/lib/Object/Remote/Connection.pm index d64a8dd..bb1b260 100644 --- a/lib/Object/Remote/Connection.pm +++ b/lib/Object/Remote/Connection.pm @@ -234,6 +234,7 @@ BEGIN { Object::Remote::Connector::LocalSudo Object::Remote::Connector::SSH Object::Remote::Connector::UNIX + Object::Remote::Connector::INET ); } diff --git a/lib/Object/Remote/Connector/INET.pm b/lib/Object/Remote/Connector/INET.pm new file mode 100644 index 0000000..eb0f188 --- /dev/null +++ b/lib/Object/Remote/Connector/INET.pm @@ -0,0 +1,30 @@ +package Object::Remote::Connector::INET; + +use IO::Socket::INET; +use Moo; + +with 'Object::Remote::Role::Connector'; + +has socket_path => (is => 'ro', required => 1); + +sub _open2_for { + my ($self) = @_; + my $path = $self->socket_path; + my $sock = IO::Socket::INET->new($path) + or die "Couldn't open socket ${path}: $!"; + ($sock, $sock, undef); +} + +no warnings 'once'; + +push @Object::Remote::Connection::Guess, sub { + for ($_[0]) { + if (defined and !ref and /^.+:\d+$/) { + my $socket = shift(@_); + return __PACKAGE__->new(@_, socket_path => $socket); + } + } + return; +}; + +1;