Merge pull request #118 from ForesightCyber/master

Repaired get_ipsecifnum. Working with pre 2.6 and 2.6 pfsense
This commit is contained in:
Riccardo 2022-11-07 23:04:11 +01:00 committed by GitHub
commit f4f092abf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2545 additions and 7 deletions

View File

@ -564,7 +564,6 @@ function pfz_ipsec_discovery_ph1(){
}
function pfz_ipsec_ph1($ikeid,$valuekey){
// Get Value from IPsec Phase 1 Configuration
// If Getting "disabled" value only check item presence in config array
@ -665,12 +664,16 @@ function pfz_ipsec_status($ikeid,$reqid=-1,$valuekey='state'){
$a_phase1 = &$config['ipsec']['phase1'];
$conmap = array();
foreach ($a_phase1 as $ph1ent) {
if (get_ipsecifnum($ph1ent['ikeid'], 0)) {
$cname = "con" . get_ipsecifnum($ph1ent['ikeid'], 0);
} else {
$cname = "con{$ph1ent['ikeid']}00000";
}
$conmap[$cname] = $ph1ent['ikeid'];
if (function_exists('get_ipsecifnum')) {
if (get_ipsecifnum($ph1ent['ikeid'], 0)) {
$cname = "con" . get_ipsecifnum($ph1ent['ikeid'], 0);
} else {
$cname = "con{$ph1ent['ikeid']}00000";
}
$conmap[$cname] = $ph1ent['ikeid'];
} else{
$cname = ipsec_conid($ph1ent);
}
}
$status = ipsec_list_sa();
@ -736,6 +739,42 @@ function pfz_ipsec_status($ikeid,$reqid=-1,$valuekey='state'){
return $value;
}
// Temperature sensors Discovery
function pfz_temperature_sensors_discovery(){
$json_string = '{"data":[';
$sensors = [];
exec("sysctl -a | grep temperature | cut -d ':' -f 1", $sensors, $code);
if ($code != 0) {
echo "";
return;
} else {
foreach ($sensors as $sensor) {
$json_string .= '{"{#SENSORID}":"' . $sensor . '"';
$json_string .= '},';
}
}
$json_string = rtrim($json_string,",");
$json_string .= "]}";
echo $json_string;
}
// Temperature sensor get value
function pfz_get_temperature($sensorid){
exec("sysctl '$sensorid' | cut -d ':' -f 2", $value, $code);
if ($code != 0 or count($value)!=1) {
echo "";
return;
} else {
echo trim($value[0]);
}
}
function pfz_carp_status($echo = true){
@ -1228,6 +1267,9 @@ function pfz_discovery($section){
case "dhcpfailover":
pfz_dhcpfailover_discovery();
break;
case "temperature_sensors":
pfz_temperature_sensors_discovery();
break;
}
}
@ -1295,6 +1337,9 @@ switch (strtolower($argv[1])){
case "cert_date":
pfz_get_cert_date($argv[2]);
break;
case "temperature":
pfz_get_temperature($argv[2]);
break;
default:
pfz_test();
}

File diff suppressed because it is too large Load Diff