Project

General

Profile

Feature #11496 » 458 (2).diff

Viktor Gurov, 11/13/2021 08:35 AM

View differences:

src/etc/inc/system.inc
1621 1621
global $ntp_poll_min_default_gps, $ntp_poll_max_default_gps;
1622 1622
global $ntp_poll_min_default_pps, $ntp_poll_max_default_pps;
1623 1623
global $ntp_poll_min_default, $ntp_poll_max_default;
1624
global $ntp_auth_halgos;
1624
global $ntp_auth_halgos, $ntp_server_types;
1625 1625
$ntp_poll_min_value = 4;
1626 1626
$ntp_poll_max_value = 17;
1627 1627
$ntp_poll_min_default_gps = 4;
......
1635 1635
	'sha1' => 'SHA1',
1636 1636
	'sha256' => 'SHA256'
1637 1637
);
1638
$ntp_server_types = array(
1639
	'server' => 'Server',
1640
	'pool' => 'Pool',
1641
	'peer' => 'Peer'
1642
);
1638 1643

  
1639 1644
function system_ntp_poll_values() {
1640 1645
	global $ntp_poll_min_value, $ntp_poll_max_value;
......
1996 2001
			$ntpcfg .= 'pool ';
1997 2002
			$have_pools = true;
1998 2003
		} else {
1999
			$ntpcfg .= 'server ';
2004
			if (substr_count($config['ntpd']['ispeer'], $ts)) {
2005
				$ntpcfg .= 'peer ';
2006
			} else {
2007
				$ntpcfg .= 'server ';
2008
			}
2000 2009
			if ($config['ntpd']['dnsresolv'] == 'inet') {
2001 2010
				$ntpcfg .= '-4 ';
2002 2011
			} elseif ($config['ntpd']['dnsresolv'] == 'inet6') {
......
2004 2013
			}
2005 2014
		}
2006 2015

  
2007
		$ntpcfg .= "{$ts} iburst";
2016
		$ntpcfg .= "{$ts}";
2017
		if (!substr_count($config['ntpd']['ispeer'], $ts)) {
2018
			$ntpcfg .= " iburst";
2019
		}
2008 2020

  
2009 2021
		$ntpcfg .= system_ntp_fixup_poll_value('minpoll', $config['ntpd']['ntpminpoll'], $ntp_poll_min_default);
2010 2022
		$ntpcfg .= system_ntp_fixup_poll_value('maxpoll', $config['ntpd']['ntpmaxpoll'], $ntp_poll_max_default);
src/usr/local/www/services_ntpd.php
34 34
require_once('rrd.inc');
35 35
require_once("shaper.inc");
36 36

  
37
global $ntp_poll_min_default, $ntp_poll_max_default;
37
global $ntp_poll_min_default, $ntp_poll_max_default, $ntp_server_types;
38 38
$ntp_poll_values = system_ntp_poll_values();
39 39
$auto_pool_suffix = "pool.ntp.org";
40 40
$max_candidate_peers = 25;
......
79 79
	}
80 80

  
81 81
	for ($i = 0; $i < NUMTIMESERVERS; $i++) {
82
		if (isset($pconfig["servselect{$i}"]) && (isset($pconfig["servispool{$i}"]) || 
82
		if (isset($pconfig["servselect{$i}"]) && (($pconfig["servistype{$i}"] == 'pool') || 
83 83
		    (substr_compare($pconfig["server{$i}"], $auto_pool_suffix, strlen($pconfig["server{$i}"]) - strlen($auto_pool_suffix), strlen($auto_pool_suffix)) === 0))) {
84 84
			$input_errors[] = gettext("It is not possible to use 'No Select' for pools.");
85 85
		}
......
121 121
		unset($config['ntpd']['prefer']);
122 122
		unset($config['ntpd']['noselect']);
123 123
		unset($config['ntpd']['ispool']);
124
		unset($config['ntpd']['ispeer']);
124 125
		$timeservers = '';
125 126

  
126 127
		for ($i = 0; $i < NUMTIMESERVERS; $i++) {
......
133 134
				if (isset($_POST["servselect{$i}"])) {
134 135
					$config['ntpd']['noselect'] .= "{$tserver} ";
135 136
				}
136
				if (isset($_POST["servispool{$i}"])) {
137
				if ($_POST["servistype{$i}"] == 'pool') {
137 138
					$config['ntpd']['ispool'] .= "{$tserver} ";
139
				} elseif ($_POST["servistype{$i}"] == 'peer') {
140
					$config['ntpd']['ispeer'] .= "{$tserver} ";
138 141
				}
139 142
			}
140 143
		}
......
329 332
		isset($config['ntpd']['noselect']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['noselect'], $timeservers[$counter])
330 333
	 ))->sethelp('No Select');
331 334

  
332
	$group->add(new Form_Checkbox(
333
		'servispool' . $counter,
334
		null,
335
	if ((substr_compare($timeservers[$counter], $auto_pool_suffix, strlen($timeservers[$counter]) - strlen($auto_pool_suffix), strlen($auto_pool_suffix)) === 0) || (isset($config['ntpd']['ispool']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['ispool'], $timeservers[$counter]))) {
336
		$servertype = 'pool';
337
	} elseif (isset($config['ntpd']['ispeer']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['ispeer'], $timeservers[$counter])) {
338
		$servertype = 'peer';
339
	} else {
340
		$servertype = 'server';
341
	}
342

  
343
	$group->add(new Form_Select(
344
		'servistype' . $counter,
335 345
		null,
336
		(substr_compare($timeservers[$counter], $auto_pool_suffix, strlen($timeservers[$counter]) - strlen($auto_pool_suffix), strlen($auto_pool_suffix)) === 0)
337
		 || (isset($config['ntpd']['ispool']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['ispool'], $timeservers[$counter]))
338
	 ))->sethelp('Is a Pool');
346
		$servertype,
347
		$ntp_server_types
348
	 ))->sethelp('Type')->setWidth(2);
339 349

  
340 350
	$group->add(new Form_Button(
341 351
		'deleterow' . $counter,
......
363 373
	'are configured and they disagree, %2$sneither%3$s will be believed. Options:%1$s' .
364 374
	'%2$sPrefer%3$s - NTP should favor the use of this server more than all others.%1$s' .
365 375
	'%2$sNo Select%3$s - NTP should not use this server for time, but stats for this server will be collected and displayed.%1$s' .
366
	'%2$sIs a Pool%3$s - this entry is a pool of NTP servers and not a single address. This is assumed for *.pool.ntp.org.',
376
	'%2$sType%3$s - Server, Peer or a Pool of NTP servers and not a single address. This is assumed for *.pool.ntp.org.',
367 377
	'<br />',
368 378
	'<b>',
369 379
	'</b>',
(4-4/4)