line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::CLI::Interact::Transport::Wrapper::Net_Telnet; |
2
|
|
|
|
|
|
|
{ $Net::CLI::Interact::Transport::Wrapper::Net_Telnet::VERSION = '2.400000' } |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
7066
|
use Moo; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
312
|
use Sub::Quote; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
6
|
1
|
|
|
1
|
|
7
|
use MooX::Types::MooseLike::Base qw(Str InstanceOf); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
118
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Net::CLI::Interact::Transport::Wrapper::Base'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
{ |
11
|
|
|
|
|
|
|
package # hide from pause |
12
|
|
|
|
|
|
|
Net::CLI::Interact::Transport::Wrapper::Options; |
13
|
1
|
|
|
1
|
|
8
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
extends 'Net::CLI::Interact::Transport::Wrapper::Base::Options'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub put { (shift)->wrapper->put( join '', @_ ) } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '_buffer' => ( |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
default => quote_sub(q{''}), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub buffer { |
26
|
4
|
|
|
4
|
0
|
6
|
my $self = shift; |
27
|
4
|
100
|
|
|
|
44
|
return $self->_buffer if scalar(@_) == 0; |
28
|
2
|
|
|
|
|
35
|
return $self->_buffer(shift); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub pump { |
32
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# try to read all blocks of already available data first |
35
|
0
|
|
|
|
|
|
my $pump_buffer; |
36
|
0
|
|
|
|
|
|
my $available_content = ''; |
37
|
0
|
|
|
|
|
|
while (defined $available_content) { |
38
|
0
|
|
|
|
|
|
$available_content = $self->wrapper->get(Errmode => 'return', Timeout => 0); |
39
|
0
|
0
|
|
|
|
|
if (defined $available_content) { |
40
|
0
|
|
|
|
|
|
$self->logger->log('transport', 'debug', 'read one block of data, appending to pump buffer'); |
41
|
0
|
|
|
|
|
|
$pump_buffer .= $available_content; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
0
|
|
|
|
|
|
$self->logger->log('transport', 'debug', 'no block of data available'); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# only try harder if no content was already available |
49
|
0
|
0
|
|
|
|
|
if (not defined $pump_buffer) { |
50
|
|
|
|
|
|
|
# this either returns data or throws an exception because of Net::Telnets default Errmode die |
51
|
0
|
|
|
|
|
|
my $content = $self->wrapper->get(Timeout => $self->timeout); |
52
|
0
|
0
|
|
|
|
|
if (defined $content) { |
53
|
0
|
|
|
|
|
|
$self->logger->log('transport', 'debug', 'read one block of data while waiting for timeout, appending to pump buffer'); |
54
|
0
|
|
|
|
|
|
$pump_buffer .= $content; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
0
|
|
|
|
|
|
$self->logger->log('transport', 'debug', 'no block of data available waiting for timeout'); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
0
|
0
|
|
|
|
|
$self->_buffer($self->_buffer . $pump_buffer) |
61
|
|
|
|
|
|
|
if defined $pump_buffer; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has '+timeout' => ( |
65
|
|
|
|
|
|
|
trigger => 1, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _trigger_timeout { |
69
|
0
|
|
|
0
|
|
|
my $self = shift; |
70
|
0
|
0
|
|
|
|
|
if (scalar @_) { |
71
|
0
|
|
|
|
|
|
my $timeout = shift; |
72
|
0
|
0
|
|
|
|
|
if ($self->connect_ready) { |
73
|
0
|
|
|
|
|
|
$self->wrapper->timeout($timeout); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has '+wrapper' => ( |
79
|
|
|
|
|
|
|
isa => InstanceOf['Net::Telnet'], |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
around '_build_wrapper' => sub { |
83
|
|
|
|
|
|
|
my ($orig, $self) = (shift, shift); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$self->logger->log('transport', 'notice', 'creating Net::Telnet wrapper for', $self->app); |
86
|
|
|
|
|
|
|
$self->$orig(@_); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$SIG{CHLD} = 'IGNORE' |
89
|
|
|
|
|
|
|
if not $self->connect_options->reap; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
with 'Net::CLI::Interact::Transport::Role::ConnectCore'; |
92
|
|
|
|
|
|
|
return $self->connect_core($self->app, $self->runtime_options); |
93
|
|
|
|
|
|
|
}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
after 'disconnect' => sub { |
96
|
|
|
|
|
|
|
delete $SIG{CHLD}; |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |