diff options
-rw-r--r-- | etc/inc/util.inc | 12 | ||||
-rwxr-xr-x | usr/local/www/diag_logs_settings.php | 19 |
2 files changed, 20 insertions, 11 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 726446b..420ca0e 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -485,6 +485,18 @@ function is_ipaddrv4($ipaddr) { return false; } +function is_ipaddrwithport($ipport) { + $parts = explode(":", $ipport); + $port = array_pop($parts); + if (count($parts) == 1) { + return is_ipaddrv4($parts[0]) && is_port($port); + } elseif (count($parts) > 1) { + return is_ipaddrv6(implode(":", $parts)) && is_port($port); + } else { + return false; + } +} + /* returns true if $ipaddr is a valid dotted IPv4 address or an alias thereof */ function is_ipaddroralias($ipaddr) { global $config; diff --git a/usr/local/www/diag_logs_settings.php b/usr/local/www/diag_logs_settings.php index 44a682c..b028d5b 100755 --- a/usr/local/www/diag_logs_settings.php +++ b/usr/local/www/diag_logs_settings.php @@ -75,17 +75,14 @@ if ($_POST) { $pconfig = $_POST; /* input validation */ - if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) { - $input_errors[] = gettext("A valid IP address must be specified for remote syslog server #1."); + if ($_POST['enable'] && (!is_ipaddr($_POST['remoteserver']) && !is_ipaddrwithport($_POST['remoteserver']))) { + $input_errors[] = gettext("A valid IP address or IP:Port must be specified for remote syslog server #1."); } - if ($_POST['enable'] && $_POST['remoteserver2'] && !is_ipaddr($_POST['remoteserver2'])) { - $input_errors[] = gettext("A valid IP address must be specified for remote syslog server #2."); + if ($_POST['enable'] && $_POST['remoteserver2'] && (!is_ipaddr($_POST['remoteserver2']) && !is_ipaddrwithport($_POST['remoteserver2']))) { + $input_errors[] = gettext("A valid IP address or IP:Port must be specified for remote syslog server #2."); } - if ($_POST['enable'] && $_POST['remoteserver3'] && !is_ipaddr($_POST['remoteserver3'])) { - $input_errors[] = gettext("A valid IP address must be specified for remote syslog server #3."); - } - if ($_POST['enable'] && !is_ipaddr($_POST['remoteserver'])) { - $input_errors[] = gettext("A valid IP address must be specified."); + if ($_POST['enable'] && $_POST['remoteserver3'] && (!is_ipaddr($_POST['remoteserver3']) && !is_ipaddrwithport($_POST['remoteserver3']))) { + $input_errors[] = gettext("A valid IP address or IP:Port must be specified for remote syslog server #3."); } if (($_POST['nentries'] < 5) || ($_POST['nentries'] > 2000)) { @@ -293,7 +290,7 @@ function check_everything() { </td> <td> - <?=gettext("IP addresses of remote syslog servers");?> + <?=gettext("IP addresses of remote syslog servers, or an IP:port.");?> </td> </table> <input name="system" id="system" type="checkbox" value="yes" onclick="enable_change(false)" <?php if ($pconfig['system']) echo "checked"; ?>> @@ -325,7 +322,7 @@ function check_everything() { <td width="22%" height="53" valign="top"> </td> <td width="78%"><strong><span class="red"><?=gettext("Note:")?></span></strong><br> <?=gettext("syslog sends UDP datagrams to port 514 on the specified " . - "remote syslog server. Be sure to set syslogd on the " . + "remote syslog server, unless another port is specified. Be sure to set syslogd on the " . "remote server to accept syslog messages from");?> <?=$g['product_name']?>. </td> </tr> |