added logging

This commit is contained in:
2021-12-04 13:12:25 -05:00
parent ec7c434ac8
commit a0c7622497

View File

@@ -65,10 +65,13 @@ echo_write_log($randomString, "Name of static WAN Gateway: " . $gatewayName);
$intf_details = legacy_interfaces_details();
$intf = get_real_interface($wanInterface);
echo_write_log($randomString, "Real WAN Interface: " . $intf);
echo_write_log($randomString, "Looping through VIP Carp Interfaces...");
# loop through carp addresses and update the wan ip address
foreach ($config['virtualip']['vip'] as $i => $vip) {
if ($vip['interface'] == $wanInterface) {
echo_write_log($randomString, "VIP Carp WAN Interface and vhid: " . convert_friendly_interface_to_friendly_descr($vip['interface']) . "@{$vip['vhid']}");
$carpStatus = $intf_details[$intf]['carp'][$vip['vhid']]['status'];
echo_write_log($randomString, "VIP Carp WAN Status: " . $carpStatus);
if ($carpStatus == "BACKUP") {
$description = $config['virtualip']['vip'][$i]['descr'];
echo_write_log($randomString, "Description from VIP WAN: " . $description);
@@ -76,21 +79,25 @@ foreach ($config['virtualip']['vip'] as $i => $vip) {
$gatewayIP = trim(substr(explode(":", $description)[1], 0, -1));
echo_write_log($randomString, "CARP Gateway IP from Description: " . $gatewayIP);
if (filter_var($gatewayIP, FILTER_VALIDATE_IP)) {
echo_write_log($randomString, "Looping through Gateways...");
foreach ($config['gateways']['gateway_item'] as $i => $gateway) {
if ($gateway['name'] == $gatewayName) {
echo_write_log($randomString, "Gateway Name: " . $gateway['name']);
echo_write_log($randomString, "Current Gateway IP: " . $gateway['gateway']);
if ($gateway['gateway'] != $gatewayIP) {
echo_write_log($randomString, "Updating Gateway IPs");
$config['gateways']['gateway_item'][$i]['gateway'] = $gatewayIP;
write_config_and_restart_services($wanInterface);
} else {
echo_write_log($randomString, "Gateway IPs are the same, not updating.");
echo_write_log($randomString, "Gateway IPs are the same, not updating");
}
}
}
} else {
echo_write_log($randomString, "Gateway IP is not a valid IP address");
}
} else {
echo_write_log($randomString, "Router is currently carp master, not updating");
echo_write_log($randomString, "Router is currently Carp master, not updating");
}
}
}