Retire ipsec_smp_dump_status()

This commit is contained in:
Renato Botelho 2015-11-03 09:22:37 -02:00
parent be7990b9fb
commit 7fcd5ea8bb

View File

@ -426,107 +426,6 @@ function ipsec_phase2_status(&$ipsec_status, &$phase2) {
return false;
}
function ipsec_smp_dump_status() {
global $config, $g, $custom_listtags;
if (isset($config['ipsec']['enable'])) {
if (!file_exists("{$g['varrun_path']}/charon.xml")) {
log_error("IPsec daemon not running or has a problem!");
return;
}
} else {
return;
}
$fd = @fsockopen("unix://{$g['varrun_path']}/charon.xml");
if (!$fd) {
log_error("Could not read status from IPsec");
return;
}
$query = '<?xml version="1.0"?><message xmlns="http://www.strongswan.org/smp/1.0" type="request" id="1">';
$query .= '<query><ikesalist/></query></message>';
@fwrite($fd, $query);
$response = "";
while (!strstr($sread, "</message>")) {
$sread = fgets($fd);
if ($sread === false) {
break;
}
$response .= $sread;
}
fclose($fd);
if ($sread === false) {
log_error("Error during reading of status from IPsec");
return;
}
@file_put_contents("{$g['tmp_path']}/smp_status.xml", $response);
unset($response, $sread);
$custom_listtags = array('ikesa', 'childsa', 'network', 'auth');
$response = parse_xml_config("{$g['tmp_path']}/smp_status.xml", "message");
@unlink("{$g['tmp_path']}/smp_status.xml");
unset($custom_listtags);
return $response;
}
/*
* Return dump of SPD table
*/
function ipsec_dump_spd() {
$fd = @popen("/sbin/setkey -DP", "r");
$spd = array();
if ($fd) {
while (!feof($fd)) {
$line = chop(fgets($fd));
if (!$line) {
continue;
}
if ($line == "No SPD entries.") {
break;
}
if ($line[0] != "\t") {
if (is_array($cursp)) {
$spd[] = $cursp;
}
$cursp = array();
$linea = explode(" ", $line);
$cursp['srcid'] = substr($linea[0], 0, strpos($linea[0], "["));
$cursp['dstid'] = substr($linea[1], 0, strpos($linea[1], "["));
$i = 0;
} else if (is_array($cursp)) {
$line = trim($line, "\t\r\n ");
$linea = explode(" ", $line);
switch ($i) {
case 1:
if ($linea[1] == "none") /* don't show default anti-lockout rule */ {
unset($cursp);
} else {
$cursp['dir'] = $linea[0];
}
break;
case 2:
$upperspec = explode("/", $linea[0]);
$cursp['proto'] = $upperspec[0];
list($cursp['src'], $cursp['dst']) = explode("-", $upperspec[2]);
$cursp['reqid'] = substr($upperspec[3], strpos($upperspec[3], "#")+1);
break;
}
}
$i++;
}
if (is_array($cursp) && count($cursp)) {
$spd[] = $cursp;
}
pclose($fd);
}
return $spd;
}
/*
* Return dump of SAD table
*/