mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
network time: take IPv6 addresses into account; closes #7934
Adhere to standard binding behaviour of other components: Use the address read to get all addresses and binding ok instead of using the arcane "interface name" bind option. CARP VIPs are ignored although allowed to be selected... something we should just remove since interfaces_addresses() will load all aliases as well. We also will not get tentative or otherwise unusable addresses. Next stop for this code is probaby MVC conversion.
This commit is contained in:
parent
e628c48968
commit
c6e700fbae
@ -3846,7 +3846,7 @@ function ip_in_interface_alias_subnet($interface, $ipalias)
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_interface_ip($interface = 'wan', $ifconfig_details = null)
|
||||
function get_interface_ip($interface, $ifconfig_details = null)
|
||||
{
|
||||
if (is_ipaddrv4($interface)) {
|
||||
return $interface;
|
||||
@ -3867,7 +3867,7 @@ function get_interface_ip($interface = 'wan', $ifconfig_details = null)
|
||||
return $ip;
|
||||
}
|
||||
|
||||
function get_interface_ipv6($interface = 'wan', $ifconfig_details = null, $mode = 'primary')
|
||||
function get_interface_ipv6($interface, $ifconfig_details = null, $mode = 'primary')
|
||||
{
|
||||
if (is_ipaddrv6($interface)) {
|
||||
return $interface;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2022 Franco Fichtner <franco@opnsense.org>
|
||||
* Copyright (C) 2016-2024 Franco Fichtner <franco@opnsense.org>
|
||||
* Copyright (C) 2004-2007 Scott Ullrich <sullrich@gmail.com>
|
||||
* Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
|
||||
* All rights reserved.
|
||||
@ -424,21 +424,33 @@ function ntpd_configure_do($verbose = false)
|
||||
$ntpcfg .= "leapfile /var/db/leap-seconds\n";
|
||||
}
|
||||
|
||||
$interfaces = [];
|
||||
if (isset($config['ntpd']['interface'])) {
|
||||
$interfaces = explode(',', $config['ntpd']['interface']);
|
||||
}
|
||||
/* only bind to given interfaces or IP aliases */
|
||||
if (!empty($config['ntpd']['interface'])) {
|
||||
$ntpifs = ['lo0'];
|
||||
$ntpaddrs = [];
|
||||
|
||||
foreach (explode(',', $config['ntpd']['interface']) as $interface) {
|
||||
if (!is_ipaddr($interface)) {
|
||||
$ntpifs[] = $interface;
|
||||
} else {
|
||||
$ntpaddrs[] = $interface;
|
||||
}
|
||||
/* XXX _vip constructs have always been ignored */
|
||||
}
|
||||
|
||||
foreach (interfaces_addresses($ntpifs) as $tmpaddr => $info) {
|
||||
if (!$info['bind']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ntpaddrs[] = $tmpaddr;
|
||||
}
|
||||
|
||||
if (is_array($interfaces) && count($interfaces)) {
|
||||
$ntpcfg .= "interface ignore all\n";
|
||||
$ntpcfg .= "interface ignore wildcard\n";
|
||||
foreach ($interfaces as $interface) {
|
||||
if (!is_ipaddr($interface)) {
|
||||
$interface = get_real_interface($interface);
|
||||
}
|
||||
if (!empty($interface)) {
|
||||
$ntpcfg .= "interface listen {$interface}\n";
|
||||
}
|
||||
|
||||
foreach ($ntpaddrs as $addr) {
|
||||
$ntpcfg .= "interface listen {$addr}\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -334,7 +334,7 @@ include("head.inc");
|
||||
<select id="interface" name="interface[]" multiple="multiple" class="selectpicker" title="<?= html_safe(gettext('All (recommended)')) ?>">
|
||||
<?php
|
||||
foreach ($interfaces as $iface => $ifacename):
|
||||
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) {
|
||||
if (!is_ipaddr($iface) && !is_ipaddrv4(get_interface_ip($iface)) && !is_ipaddrv6(get_interface_ipv6($iface))) {
|
||||
continue;
|
||||
}?>
|
||||
<option value="<?=$iface;?>" <?= !empty($pconfig['interface']) && in_array($iface, $pconfig['interface']) ? 'selected="selected"' : '' ?>>
|
||||
|
||||
@ -161,7 +161,7 @@ require_once("interfaces.inc");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) {
|
||||
if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && isset($gps_ok)) {
|
||||
//GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board
|
||||
$gpsport = fopen("/dev/gps0", "r+");
|
||||
while ($gpsport) {
|
||||
@ -237,7 +237,7 @@ include("head.inc");
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
if ($gps_ok):
|
||||
if (isset($gps_ok)):
|
||||
$gps_goo_lnk = 2; ?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user