Skip to content

Commit

Permalink
implement fix suggested in samm-git#12
Browse files Browse the repository at this point in the history
  • Loading branch information
irobertson committed Nov 17, 2016
1 parent 062847f commit 5f15b66
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions jvpn.pl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@
"\nConnected to $dhost, press CTRL+C to exit\n";
# disabling cursor
print "\e[?25l";
my $lastTx = 0;
my $lastRx = 0;
while ( 1 ) {
#stat query
$data="\0\0\0\0\0\0\0\x69\x01\0\0\0\x01\0\0\0\0\0\0\0";
Expand All @@ -554,11 +556,26 @@
}
hdump($data) if $debug;
my $now = time - $start_t;
# printing RX/TX. This packet also contains encription type,
# compression and transport info, but length seems to be variable
printf("Duration: %02d:%02d:%02d Sent: %s\tReceived: %s",
int($now / 3600), int(($now % 3600) / 60), int($now % 60),
format_bytes(unpack('x[78]N',$data)), format_bytes(unpack('x[68]N',$data)));
eval {
my $hours = int($now / 3600);
my $minutes = int(($now % 3600) / 60);
my $seconds = int($now % 60);
my $tx = unpack('x[78]N', $data);
my $rx = unpack('x[68]N', $data);
printf(
"Duration: %02d:%02d:%02d Sent: %10s %10s Received: %10s %10s\e[K",
$hours, $minutes, $seconds,
format_bytes($tx), "(" . format_bytes($tx - $lastTx) . ")",
format_bytes($rx), "(" . format_bytes($rx - $lastRx) . ")");
$lastTx = $tx;
$lastRx = $rx;
1;
}
or do {
print("Something went wrong: $@\n");
hdump($data);
print("$data\n");
};
sleep(1);
}

Expand Down

0 comments on commit 5f15b66

Please sign in to comment.