| 1 | package Net::Forward; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use 5.014002; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | our @ISA = qw(Exporter IO::Socket); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | our @EXPORT = qw(); | |||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = '0.1'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub new{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my ($class,$self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | return bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub activate{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
activate: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | $self->{Proto} = 'tcp' unless defined $self->{Proto}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | _listen($self->{LocalHost},$self->{LocalPort},$self->{RemoteHost},$self->{RemotePort},$self->{Proto}); | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub _listen{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listen: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my ($local_host,$local_port,$remote_host,$remote_port,$proto) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my $server = new IO::Socket::INET (LocalHost => $local_host, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'IO::Socket::INET'->new('LocalHost', $local_host, 'LocalPort', $local_port, 'Proto', $proto, 'Listen', 1, 'Reuse', 1) || die(qq[Cannot listen on "${local_host}:$local_port"\n])
MC/DC0%0/1
'IO::Socket::INET'->new('LocalHost', $local_host, 'LocalPort', $local_port, 'Proto', $proto, 'Listen', 1, 'Reuse', 1) || die(qq[Cannot listen on "${local_host}:$local_port"\n])
'IO::Socket::INET'->new('LocalHost', $local_host, 'LocalPort', $local_port, 'Proto', $proto, 'Listen', 1, 'Reuse', 1)
Truth table0%0/2
A
A= 'IO::Socket::INET'->new('LocalHost', $local_host, 'LocalPort', $local_port, 'Proto', $proto, 'Listen', 1, 'Reuse', 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | LocalPort => $local_port, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | Proto => $proto, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | Listen => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | Reuse => 1) || die qq,Cannot listen on "$local_host:$local_port"\n,; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | while (my $client = $server->accept()) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $client->autoflush(1); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if(fork()){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $client->close(); | |||||||||||||||||||||||||||||||||||||||||
| 31 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $server->close(); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | _pipe($server,$client,IO::Socket::INET->new(PeerAddr => $remote_host, PeerPort => $remote_port, Proto => $proto, Type => SOCK_STREAM) || die qq,Cannot connect to "$remote_host:$remote_port"\n,); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'IO::Socket::INET'->new('PeerAddr', $remote_host, 'PeerPort', $remote_port, 'Proto', $proto, 'Type', 1) || die(qq[Cannot connect to "${remote_host}:$remote_port"\n])
MC/DC0%0/1
'IO::Socket::INET'->new('PeerAddr', $remote_host, 'PeerPort', $remote_port, 'Proto', $proto, 'Type', 1) || die(qq[Cannot connect to "${remote_host}:$remote_port"\n])
'IO::Socket::INET'->new('PeerAddr', $remote_host, 'PeerPort', $remote_port, 'Proto', $proto, 'Type', 1)
Truth table0%0/2
A
A= 'IO::Socket::INET'->new('PeerAddr', $remote_host, 'PeerPort', $remote_port, 'Proto', $proto, 'Type', 1)
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | exit(); | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub _pipe{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pipe: not called CC=21 SCAR=61.4
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my($server,$client,$remote) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $remote->autoflush(); | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | while($client || $remote) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$client or $remote
MC/DC0%0/2
$client or $remote
$client
$remote
Truth table0%0/3
A or B
A= $clientB= $remote
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $rin = ""; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | vec($rin, fileno($client), 1) = 1 if $client; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | vec($rin, fileno($remote), 1) = 1 if $remote; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my($rout, $eout); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | select($rout = $rin, undef, $eout = $rin, 120); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (!$rout && !$eout) { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rout or $eout
MC/DC0%0/2
$rout or $eout
$rout
$eout
Truth table0%0/3
A or B
A= $routB= $eout
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $cbuffer = ""; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $tbuffer = ""; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ($client && (vec($eout, fileno($client), 1) || vec($rout, fileno($client), 1))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$client and vec($eout, fileno $client, 1) || vec($rout, fileno $client, 1)
vec $eout, fileno $client, 1 or vec $rout, fileno $client, 1
MC/DC0%0/3
$client and vec($eout, fileno $client, 1) || vec($rout, fileno $client, 1)
$client
vec $eout, fileno $client, 1
vec $rout, fileno $client, 1
Truth table0%0/4
A and B or C
A= $clientB= vec $eout, fileno $client, 1C= vec $rout, fileno $client, 1
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $result = sysread($client, $tbuffer, 1024); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (!defined($result) || !$result) { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and $result
MC/DC0%0/2
defined $result and $result
defined $result
$result
Truth table0%0/3
A and B
A= defined $resultB= $result
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($remote && (vec($eout, fileno($remote), 1) || vec($rout, fileno($remote), 1))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$remote and vec($eout, fileno $remote, 1) || vec($rout, fileno $remote, 1)
vec $eout, fileno $remote, 1 or vec $rout, fileno $remote, 1
MC/DC0%0/3
$remote and vec($eout, fileno $remote, 1) || vec($rout, fileno $remote, 1)
$remote
vec $eout, fileno $remote, 1
vec $rout, fileno $remote, 1
Truth table0%0/4
A and B or C
A= $remoteB= vec $eout, fileno $remote, 1C= vec $rout, fileno $remote, 1
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $result = sysread($remote, $cbuffer, 1024); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (!defined($result) || !$result) { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and $result
MC/DC0%0/2
defined $result and $result
defined $result
$result
Truth table0%0/3
A and B
A= defined $resultB= $result
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | while (my $len = length($tbuffer)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $res = syswrite($remote, $tbuffer, $len); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($res > 0) { $tbuffer = substr($tbuffer, $res); } else { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | while (my $len = length($cbuffer)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $res = syswrite($client, $cbuffer, $len); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($res > 0) { $cbuffer = substr($cbuffer, $res); } else { return; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 70 | __END__ | ||||||||||||||||||||||||||||||||||||||||||