array(), 'selected' => array()); $interfaces = get_configured_interface_with_descr(); $carplist = get_configured_carp_interface_list(); foreach ($carplist as $cif => $carpip) { $interfaces[$cif] = $carpip . " (" . get_vip_descr($carpip) .")"; } $aliaslist = get_configured_ip_aliases_list(); foreach ($aliaslist as $aliasip => $aliasif) { $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; } $size = (count($interfaces) < 10) ? count($interfaces) : 10; foreach ($interfaces as $iface => $ifacename) { if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) { continue; } $iflist['options']['$iface'] = $ifacename; if (in_array($iface, $pconfig['interface'])) { array_push($iflist['selected'], $iface); } } return($iflist); } $closehead = false; $pconfig = &$config['ntpd']; if (empty($pconfig['interface'])) { $pconfig['interface'] = array(); } else { $pconfig['interface'] = explode(",", $pconfig['interface']); } $pgtitle = array(gettext("Services"), gettext("NTP")); $shortcut_section = "ntp"; include("head.inc"); if ($input_errors) print_input_errors($input_errors); if ($savemsg) print_info_box($savemsg, 'success'); $tab_array = array(); $tab_array[] = array(gettext("NTP"), true, "services_ntpd.php"); $tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php"); $tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php"); display_top_tabs($tab_array); require_once('classes/Form.class.php'); $form = new Form; $section = new Form_Section('NTP server configuration'); $iflist = build_interface_list(); $section->addInput(new Form_Select( 'interface', 'Interface', $iflist['selected'], $iflist['options'], true ))->setHelp('Interfaces without an IP address will not be shown.' . '
' . 'Selecting no interfaces will listen on all interfaces with a wildcard.' . '
' . 'Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.'); // NUMTIMESERVERS time servers are always available, but we only display a smaller number of these ($maxrows) // Clicking the 'Add Row' button increments $maxrows so you can see more of time servers $timeservers = explode( ' ', $config['system']['timeservers']); for ($i = $j = 0; $i < NUMTIMESERVERS; $i++) { if($i >= $maxrows) continue; $group = new Form_Group($i == 0 ? 'Time servers':''); $group->add(new Form_Input( 'server' . $i, null, 'text', $timeservers[$i] )); $group->add(new Form_Checkbox( 'servprefer' . $i, null, 'Prefer', isset($config['ntpd']['prefer']) && isset($timeservers[$i]) && substr_count($config['ntpd']['prefer'], $timeservers[$i]) )); $group->add(new Form_Checkbox( 'servselect' . $i, null, 'NoSelect', isset($config['ntpd']['noselect']) && isset($timeservers[$i]) && substr_count($config['ntpd']['noselect'], $timeservers[$i]) )); $section->add($group); } // Show the 'Add Rows' button only if we are currently displaying less than the maximum // number of configured servers if($maxrows < NUMTIMESERVERS) { $btnaddrow = new Form_Button( 'btnaddrow', 'Add Server', 'services_ntpd.php?addrow=' . $maxrows ); $btnaddrow->removeClass('btn-primary')->addClass('btn-success btn-sm'); } else { $btnaddrow = false; } $section->addInput(new Form_StaticText( null, $btnaddrow ))->setHelp('For best results three to five servers should be configured here.' . '
' . 'The prefer option indicates that NTP should favor the use of this server more than all others.' . '
' . 'The noselect option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.'); $section->addInput(new Form_Input( 'ntporphan', 'Orphan mode', 'text', $pconfig['ntporphan'] ))->setHelp('Orphan mode allows the system clock to be used when no other clocks are available. ' . 'The number here specifies the stratum reported during orphan mode and should normally be set to a number high enough ' . 'to insure that any other servers available to clients are preferred over this server. (default: 12).'); $section->addInput(new Form_Checkbox( 'statsgraph', 'NTP Graphs', 'Enable RRD graphs of NTP statistics (default: disabled).', $pconfig['statsgraph'] )); $section->addInput(new Form_Checkbox( 'logpeer', 'Syslog logging', 'Enable logging of peer messages (default: disabled).', $pconfig['logpeer'] )); $section->addInput(new Form_Checkbox( 'logsys', null, 'Enable logging of system messages (default: disabled).', $pconfig['logsys'] ))->setHelp('These options enable additional messages from NTP to be written to the System Log ' . '' . 'Status > System Logs > NTP' . ''); // Statistics logging section $btnadvstats = new Form_Button( 'btnadvstats', 'Advanced' ); $btnadvstats->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'Statistics logging', $btnadvstats ))->setHelp('Warning: These options will create persistent daily log files in /var/log/ntp.'); $section->addInput(new Form_Checkbox( 'clockstats', null, 'Enable logging of reference clock statistics (default: disabled).', $pconfig['clockstats'] )); $section->addInput(new Form_Checkbox( 'loopstats', null, 'Enable logging of clock discipline statistics (default: disabled).', $pconfig['loopstats'] )); $section->addInput(new Form_Checkbox( 'peerstats', null, 'Enable logging of NTP peer statistics (default: disabled).', $pconfig['peerstats'] )); // Access restrictions section $btnadvrestr = new Form_Button( 'btnadvrestr', 'Advanced' ); $btnadvrestr->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'Access Restrictions', $btnadvrestr ))->setHelp('These options control access to NTP from the WAN.'); $section->addInput(new Form_Checkbox( 'kod', null, 'Enable Kiss-o\'-death packets (default: enabled).', $pconfig['kod'] )); $section->addInput(new Form_Checkbox( 'nomodify', null, 'Deny state modifications (i.e. run time configuration) by ntpq and ntpdc (default: enabled).', $pconfig['nomodify'] )); $section->addInput(new Form_Checkbox( 'noquery', null, 'Disable ntpq and ntpdc queries (default: disabled).', $pconfig['noquery'] )); $section->addInput(new Form_Checkbox( 'noserve', null, 'Disable all except ntpq and ntpdc queries (default: disabled).', $pconfig['noserve'] )); $section->addInput(new Form_Checkbox( 'nopeer', null, 'Deny packets that attempt a peer association (default: enabled).', $pconfig['nopeer'] )); $section->addInput(new Form_Checkbox( 'notrap', null, 'Deny mode 6 control message trap service (default: enabled).', $pconfig['notrap'] ))->addClass('advrestrictions'); // Leap seconds section $btnleap = new Form_Button( 'btnleap', 'Advanced' ); $btnleap->removeClass('btn-primary')->addClass('btn-default btn-sm'); $section->addInput(new Form_StaticText( 'Leap seconds', $btnleap ))->setHelp('A leap second file allows NTP to advertize an upcoming leap second addition or subtraction. ' . 'Normally this is only useful if this server is a stratum 1 time server. '); $section->addInput(new Form_Textarea( 'leaptext', null, base64_decode(chunk_split($pconfig['leapsec'])) ))->setHelp('Enter Leap second configuration as text OR select a file to upload'); $section->addInput(new Form_Input( 'leapfile', null, 'file' ))->addClass('btn-default'); $form->add($section); print($form); ?>