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