Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch clog to cat in status_tinc.php #691

Merged
merged 9 commits into from
Nov 6, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions security/pfSense-pkg-tinc/files/usr/local/www/status_tinc.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,37 @@
require("guiconfig.inc");

function tinc_status_usr($usr) {
global $g;
exec("/usr/local/sbin/tincd --config=/usr/local/etc/tinc -k{$usr}");
usleep(500000);
$result = array();
$logfile = "/var/log/tinc.log";
$clog_path = "/usr/local/sbin/clog";
$firmware = host_firmware_version();

if ($firmware['kernel']['version'] >= 12.0) {
exec(system_log_get_cat() . ' ' . sort_related_log_files($logfile, true, true) . "| /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
if (pfs_version_compare(false, 2.4, $g['product_version'])) {
exec(system_log_get_cat() . ' ' . sort_related_log_files($logfile, true, true) . "| /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
} else {
exec("{$clog_path} {$logfile} | /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
exec("{$clog_path} {$logfile} | /usr/bin/sed -e 's/.*tinc\[.*\]: //'", $result);
}

$i = 0;
if ($usr == 'USR1') {
foreach ($result as $line) {
if (preg_match("/Connections:/", $line)) {
$begin = $i;
}
if (preg_match("/End of connections./", $line)) {
$end = $i;
}
$i++;
}
} else {
foreach ($result as $line) {
if (preg_match("/Statistics for Generic BSD (tun|tap) device/",$line)) {
$begin = $i;
}
if (preg_match("/End of subnet list./",$line)) {
$end = $i;
}
$i++;
foreach ($result as $line) {
jim-p marked this conversation as resolved.
Show resolved Hide resolved
if ($usr == 'USR1') {
if (preg_match("/Connections:/", $line)) {
$begin = $i;
}
if (preg_match("/End of connections./", $line)) {
$end = $i;
}
} else {
if (preg_match("/Statistics for Generic BSD (tun|tap) device/",$line)) {
$begin = $i;
}
if (preg_match("/End of subnet list./",$line)) {
$end = $i;
}
}
$i++;
}

$output = "";
Expand Down