|
@@ -3,7 +3,7 @@ package Net::OpenSSH::More::Linux;
|
|
use strict;
|
|
use strict;
|
|
use warnings;
|
|
use warnings;
|
|
|
|
|
|
-use parent 'Net::OpenSSH::More::Linux';
|
|
|
|
|
|
+use parent 'Net::OpenSSH::More';
|
|
|
|
|
|
use File::Slurper ();
|
|
use File::Slurper ();
|
|
|
|
|
|
@@ -11,6 +11,28 @@ use File::Slurper ();
|
|
|
|
|
|
This module assumes that both the local and remote machine are some variant of GNU/Linux.
|
|
This module assumes that both the local and remote machine are some variant of GNU/Linux.
|
|
|
|
|
|
|
|
+=cut
|
|
|
|
+
|
|
|
|
+###################
|
|
|
|
+# PRIVATE METHODS #
|
|
|
|
+###################
|
|
|
|
+
|
|
|
|
+my $get_addrs_for_iface = sub {
|
|
|
|
+ my ( $self, $interface, $proto, $use_local ) = @_;
|
|
|
|
+ $interface ||= $self->get_primary_adapter($use_local);
|
|
|
|
+ $self->diag("Attempting to get $proto address for interface $interface");
|
|
|
|
+ my $regex = $proto eq 'inet' ? '[\d\.]+' : '[\da-f:]+'; # Close enough
|
|
|
|
+
|
|
|
|
+ my $cmd = "ip -f $proto addr show $interface scope global dynamic";
|
|
|
|
+ my $ip = $use_local ? `$cmd` : $self->cmd($cmd);
|
|
|
|
+ my @matches = $ip =~ m/$proto\s+($regex)/g;
|
|
|
|
+ return @matches;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+#######################
|
|
|
|
+# END PRIVATE METHODS #
|
|
|
|
+#######################
|
|
|
|
+
|
|
=head2 METHODS
|
|
=head2 METHODS
|
|
|
|
|
|
=head3 B<get_primary_adapter>
|
|
=head3 B<get_primary_adapter>
|
|
@@ -83,24 +105,4 @@ sub get_local_ips {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
-###################
|
|
|
|
-# PRIVATE METHODS #
|
|
|
|
-###################
|
|
|
|
-
|
|
|
|
-my $get_addrs_for_iface = sub {
|
|
|
|
- my ( $self, $interface, $proto, $use_local ) = @_;
|
|
|
|
- $interface ||= $self->get_primary_adapter($use_local);
|
|
|
|
- $self->diag("Attempting to get $proto address for interface $interface");
|
|
|
|
- my $regex = $proto eq 'inet' ? '[\d\.]+' : '[\da-f:]+'; # Close enough
|
|
|
|
-
|
|
|
|
- my $cmd = "ip -f $proto addr show $interface scope global dynamic";
|
|
|
|
- my $ip = $use_local ? `$cmd` : $self->cmd($cmd);
|
|
|
|
- my @matches = $ip =~ m/$proto\s+($regex)/g;
|
|
|
|
- return @matches;
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-#######################
|
|
|
|
-# END PRIVATE METHODS #
|
|
|
|
-#######################
|
|
|
|
-
|
|
|
|
1;
|
|
1;
|