mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
src: more style updates
This commit is contained in:
parent
a09d4592a8
commit
bb35688f0e
@ -235,7 +235,7 @@ function interface_vlan_configure(&$vlan)
|
||||
legacy_interface_flags($member, $tag);
|
||||
}
|
||||
} elseif (in_array($tag, $selected_opts)) {
|
||||
legacy_interface_flags($member, '-'.$tag);
|
||||
legacy_interface_flags($member, '-' . $tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1399,9 +1399,9 @@ EOD;
|
||||
}
|
||||
if ($ppp['type'] == "pppoe" && $mtus[$pid] > 1500) {
|
||||
// use pppoe max-payload if mtu we're about to set > 1492
|
||||
$mpdconf_arr[] = "set pppoe max-payload " . ($mtus[$pid]-8);
|
||||
$mpdconf_arr[] = "set pppoe max-payload " . ($mtus[$pid] - 8);
|
||||
} else {
|
||||
$mpdconf_arr[] = "set link mtu " . ($mtus[$pid]-8);
|
||||
$mpdconf_arr[] = "set link mtu " . ($mtus[$pid] - 8);
|
||||
}
|
||||
$mrus = !empty($ppp['mtu']) ? explode(',', $ppp['mru']) : null;
|
||||
if (!empty($mrus[$pid])) {
|
||||
@ -1678,7 +1678,7 @@ function interface_ipalias_configure(&$vip)
|
||||
$vhid = !empty($vip['vhid']) ? 'vhid ' . escapeshellarg($vip['vhid']) : '';
|
||||
$gateway = !empty($vip['gateway']) ? escapeshellarg($vip['gateway']) . ' ' : '';
|
||||
|
||||
mwexec("/sbin/ifconfig " . $if ." {$af} ". escapeshellarg($vip['subnet']) ."/" . escapeshellarg($vip['subnet_bits']) . " alias ".$gateway. $vhid);
|
||||
mwexec("/sbin/ifconfig " . $if . " {$af} " . escapeshellarg($vip['subnet']) . "/" . escapeshellarg($vip['subnet_bits']) . " alias " . $gateway . $vhid);
|
||||
}
|
||||
|
||||
function interface_carp_configure(&$vip)
|
||||
@ -2261,7 +2261,8 @@ EOD;
|
||||
*/
|
||||
if ($clone_if != $if) {
|
||||
$friendly_if = convert_real_interface_to_friendly_interface_name($clone_if);
|
||||
if (!empty($friendly_if)
|
||||
if (
|
||||
!empty($friendly_if)
|
||||
&& $config['interfaces'][$friendly_if]['wireless']['mode'] == "bss"
|
||||
&& isset($config['interfaces'][$friendly_if]['wireless']['wpa']['enable'])
|
||||
) {
|
||||
@ -3115,15 +3116,18 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif)
|
||||
}
|
||||
$id_assoc_statement_address .= " {\n";
|
||||
|
||||
if (($wancfg['adv_dhcp6_id_assoc_statement_address'] != '') &&
|
||||
if (
|
||||
($wancfg['adv_dhcp6_id_assoc_statement_address'] != '') &&
|
||||
(is_numeric($wancfg['adv_dhcp6_id_assoc_statement_address_pltime']) ||
|
||||
$wancfg['adv_dhcp6_id_assoc_statement_address_pltime'] == 'infinity')
|
||||
) {
|
||||
) {
|
||||
$id_assoc_statement_address .= " address";
|
||||
$id_assoc_statement_address .= " {$wancfg['adv_dhcp6_id_assoc_statement_address']}";
|
||||
$id_assoc_statement_address .= " {$wancfg['adv_dhcp6_id_assoc_statement_address_pltime']}";
|
||||
if (is_numeric($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']) ||
|
||||
$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] == 'infinity' ) {
|
||||
if (
|
||||
is_numeric($wancfg['adv_dhcp6_id_assoc_statement_address_vltime']) ||
|
||||
$wancfg['adv_dhcp6_id_assoc_statement_address_vltime'] == 'infinity'
|
||||
) {
|
||||
$id_assoc_statement_address .= " {$wancfg['adv_dhcp6_id_assoc_statement_address_vltime']}";
|
||||
}
|
||||
$id_assoc_statement_address .= ";\n";
|
||||
@ -3142,15 +3146,18 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif)
|
||||
}
|
||||
$id_assoc_statement_prefix .= " {\n";
|
||||
|
||||
if (($wancfg['adv_dhcp6_id_assoc_statement_prefix'] != '') &&
|
||||
if (
|
||||
($wancfg['adv_dhcp6_id_assoc_statement_prefix'] != '') &&
|
||||
(is_numeric($wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']) ||
|
||||
$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime'] == 'infinity')
|
||||
) {
|
||||
) {
|
||||
$id_assoc_statement_prefix .= " prefix";
|
||||
$id_assoc_statement_prefix .= " {$wancfg['adv_dhcp6_id_assoc_statement_prefix']}";
|
||||
$id_assoc_statement_prefix .= " {$wancfg['adv_dhcp6_id_assoc_statement_prefix_pltime']}";
|
||||
if ((is_numeric($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'])) ||
|
||||
($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] == 'infinity') ) {
|
||||
if (
|
||||
(is_numeric($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'])) ||
|
||||
($wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime'] == 'infinity')
|
||||
) {
|
||||
$id_assoc_statement_prefix .= " {$wancfg['adv_dhcp6_id_assoc_statement_prefix_vltime']}";
|
||||
}
|
||||
$id_assoc_statement_prefix .= ";\n";
|
||||
@ -3161,7 +3168,8 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif)
|
||||
$trackifv6 = get_real_interface($friendly, 'inet6');
|
||||
$id_assoc_statement_prefix .= " prefix-interface {$trackifv6} {\n";
|
||||
$id_assoc_statement_prefix .= " sla-id {$ifcfg['track6-prefix-id']};\n";
|
||||
if (($wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] >= 0) &&
|
||||
if (
|
||||
($wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] >= 0) &&
|
||||
($wancfg['adv_dhcp6_prefix_interface_statement_sla_len'] <= 128)
|
||||
) {
|
||||
$id_assoc_statement_prefix .= " sla-len {$wancfg['adv_dhcp6_prefix_interface_statement_sla_len']};\n";
|
||||
@ -3174,8 +3182,10 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif)
|
||||
}
|
||||
|
||||
$authentication_statement = "";
|
||||
if (($wancfg['adv_dhcp6_authentication_statement_authname'] != '') &&
|
||||
($wancfg['adv_dhcp6_authentication_statement_protocol'] == 'delayed') ) {
|
||||
if (
|
||||
($wancfg['adv_dhcp6_authentication_statement_authname'] != '') &&
|
||||
($wancfg['adv_dhcp6_authentication_statement_protocol'] == 'delayed')
|
||||
) {
|
||||
$authentication_statement .= "authentication {$wancfg['adv_dhcp6_authentication_statement_authname']} {\n";
|
||||
$authentication_statement .= " protocol {$wancfg['adv_dhcp6_authentication_statement_protocol']};\n";
|
||||
if (preg_match("/(hmac(-)?md5)||(HMAC(-)?MD5)/", $wancfg['adv_dhcp6_authentication_statement_algorithm'])) {
|
||||
@ -3188,10 +3198,12 @@ function DHCP6_Config_File_Advanced($interface, $wancfg, $wanif)
|
||||
}
|
||||
|
||||
$key_info_statement = "";
|
||||
if (($wancfg['adv_dhcp6_key_info_statement_keyname'] != '') &&
|
||||
if (
|
||||
($wancfg['adv_dhcp6_key_info_statement_keyname'] != '') &&
|
||||
($wancfg['adv_dhcp6_key_info_statement_realm'] != '') &&
|
||||
(is_numeric($wancfg['adv_dhcp6_key_info_statement_keyid'])) &&
|
||||
($wancfg['adv_dhcp6_key_info_statement_secret'] != '') ) {
|
||||
($wancfg['adv_dhcp6_key_info_statement_secret'] != '')
|
||||
) {
|
||||
$key_info_statement .= "keyinfo {$wancfg['adv_dhcp6_key_info_statement_keyname']} {\n";
|
||||
$key_info_statement .= " realm \"{$wancfg['adv_dhcp6_key_info_statement_realm']}\";\n";
|
||||
$key_info_statement .= " keyid {$wancfg['adv_dhcp6_key_info_statement_keyid']};\n";
|
||||
@ -3416,7 +3428,7 @@ function DHCP_Config_File_Substitutions($wancfg, $wanif, $dhclientconf)
|
||||
$dhcpclientconf_mac_hex = "";
|
||||
$delimiter = "";
|
||||
for ($i = 0; $i < strlen($dhcpclientconf_mac); $i++) {
|
||||
$dhcpclientconf_mac_hex .= $delimiter. bin2hex($dhcpclientconf_mac[$i]);
|
||||
$dhcpclientconf_mac_hex .= $delimiter . bin2hex($dhcpclientconf_mac[$i]);
|
||||
$delimiter = ":";
|
||||
}
|
||||
$dhcpclientconf_mac = $dhcpclientconf_mac_hex;
|
||||
@ -4130,8 +4142,10 @@ function get_interfaces_info()
|
||||
$ifinfo['if'] = get_real_interface($ifdescr);
|
||||
$ifinfo['status'] = (is_array($ifup) && in_array($ifinfo['if'], $ifup)) ? 'up' : 'down';
|
||||
if (!empty($all_intf_details[$ifinfo['if']])) {
|
||||
if (isset($all_intf_details[$ifinfo['if']]['status']) &&
|
||||
in_array($all_intf_details[$ifinfo['if']]['status'], array('active', 'running'))) {
|
||||
if (
|
||||
isset($all_intf_details[$ifinfo['if']]['status']) &&
|
||||
in_array($all_intf_details[$ifinfo['if']]['status'], array('active', 'running'))
|
||||
) {
|
||||
$all_intf_details[$ifinfo['if']]['status'] = $ifinfo['status'];
|
||||
}
|
||||
$ifinfo = array_merge($ifinfo, $all_intf_details[$ifinfo['if']]);
|
||||
@ -4291,13 +4305,13 @@ function get_interfaces_info()
|
||||
|
||||
function convert_seconds_to_hms($sec)
|
||||
{
|
||||
$min=$hrs=0;
|
||||
$min = $hrs = 0;
|
||||
if ($sec != 0) {
|
||||
$min = floor($sec/60);
|
||||
$min = floor($sec / 60);
|
||||
$sec %= 60;
|
||||
}
|
||||
if ($min != 0) {
|
||||
$hrs = floor($min/60);
|
||||
$hrs = floor($min / 60);
|
||||
$min %= 60;
|
||||
}
|
||||
if ($sec < 10) {
|
||||
@ -4309,7 +4323,7 @@ function convert_seconds_to_hms($sec)
|
||||
if ($hrs < 10) {
|
||||
$hrs = "0" . $hrs;
|
||||
}
|
||||
$result = $hrs.":".$min.":".$sec;
|
||||
$result = $hrs . ":" . $min . ":" . $sec;
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -4423,7 +4437,7 @@ function get_ppp_uptime($port)
|
||||
if (file_exists("/conf/{$port}.log")) {
|
||||
$saved_time = file_get_contents("/conf/{$port}.log");
|
||||
$uptime_data = explode("\n", $saved_time);
|
||||
$sec=0;
|
||||
$sec = 0;
|
||||
foreach ($uptime_data as $upt) {
|
||||
$sec += substr($upt, 1 + strpos($upt, " "));
|
||||
}
|
||||
|
||||
@ -489,22 +489,22 @@ function ip_range_size($startip, $endip)
|
||||
function find_smallest_cidr($number)
|
||||
{
|
||||
$smallest = 1;
|
||||
for ($b=32; $b > 0; $b--) {
|
||||
for ($b = 32; $b > 0; $b--) {
|
||||
$smallest = ($number <= pow(2, $b)) ? $b : $smallest;
|
||||
}
|
||||
return (32-$smallest);
|
||||
return (32 - $smallest);
|
||||
}
|
||||
|
||||
/* Return the previous IP address before the given address */
|
||||
function ip_before($ip)
|
||||
{
|
||||
return long2ip32(ip2long($ip)-1);
|
||||
return long2ip32(ip2long($ip) - 1);
|
||||
}
|
||||
|
||||
/* Return the next IP address after the given address */
|
||||
function ip_after($ip)
|
||||
{
|
||||
return long2ip32(ip2long($ip)+1);
|
||||
return long2ip32(ip2long($ip) + 1);
|
||||
}
|
||||
|
||||
/* Return true if the first IP is 'before' the second */
|
||||
@ -758,7 +758,7 @@ function is_domain($domain)
|
||||
function is_macaddr($macaddr, $partial = false)
|
||||
{
|
||||
$repeat = ($partial) ? '1,5' : '5';
|
||||
return preg_match('/^[0-9A-F]{2}(?:[:][0-9A-F]{2}){'.$repeat.'}$/i', $macaddr) == 1 ? true : false;
|
||||
return preg_match('/^[0-9A-F]{2}(?:[:][0-9A-F]{2}){' . $repeat . '}$/i', $macaddr) == 1 ? true : false;
|
||||
}
|
||||
|
||||
/* returns true if $name is a valid name for an alias
|
||||
@ -1217,7 +1217,7 @@ function ip_in_subnet($addr, $subnet)
|
||||
function is_private_ip($iptocheck)
|
||||
{
|
||||
foreach (array("10.0.0.0/8", "100.64.0.0/10", "172.16.0.0/12", "192.168.0.0/16") as $private) {
|
||||
if (ip_in_subnet($iptocheck, $private)==true) {
|
||||
if (ip_in_subnet($iptocheck, $private) == true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1510,8 +1510,10 @@ function get_dyndns_ip($int, $ipver = 4)
|
||||
* check cannot work. Avoid the long wait for the external check
|
||||
* to timeout.
|
||||
*/
|
||||
if (!empty($gateways_status[$config['interfaces'][$int]['gateway']]['status']) &&
|
||||
stristr($gateways_status[$config['interfaces'][$int]['gateway']]['status'], 'down')) {
|
||||
if (
|
||||
!empty($gateways_status[$config['interfaces'][$int]['gateway']]['status']) &&
|
||||
stristr($gateways_status[$config['interfaces'][$int]['gateway']]['status'], 'down')
|
||||
) {
|
||||
log_error("Aborted IPv{$ipver} detection: gateway down for {$int}");
|
||||
return 'down';
|
||||
}
|
||||
|
||||
@ -209,14 +209,16 @@ function dump_xml_config_sub($arr, $indent)
|
||||
$xmlconfig .= str_repeat("\t", $indent);
|
||||
if ((is_bool($cval) && $cval == true) || ($cval === "")) {
|
||||
$xmlconfig .= "<$ent/>\n";
|
||||
} elseif ((substr($ent, 0, 5) == "descr")
|
||||
|| (substr($ent, 0, 6) == "detail")
|
||||
|| (substr($ent, 0, 12) == "login_banner")
|
||||
|| (substr($ent, 0, 9) == "ldap_attr")
|
||||
|| (substr($ent, 0, 9) == "ldap_bind")
|
||||
|| (substr($ent, 0, 11) == "ldap_basedn")
|
||||
|| (substr($ent, 0, 18) == "ldap_authcn")
|
||||
|| (substr($ent, 0, 19) == "ldap_extended_query")) {
|
||||
} elseif (
|
||||
(substr($ent, 0, 5) == "descr")
|
||||
|| (substr($ent, 0, 6) == "detail")
|
||||
|| (substr($ent, 0, 12) == "login_banner")
|
||||
|| (substr($ent, 0, 9) == "ldap_attr")
|
||||
|| (substr($ent, 0, 9) == "ldap_bind")
|
||||
|| (substr($ent, 0, 11) == "ldap_basedn")
|
||||
|| (substr($ent, 0, 18) == "ldap_authcn")
|
||||
|| (substr($ent, 0, 19) == "ldap_extended_query")
|
||||
) {
|
||||
$xmlconfig .= "<$ent><![CDATA[" . htmlentities($cval) . "]]></$ent>\n";
|
||||
} else {
|
||||
$xmlconfig .= "<$ent>" . htmlentities($cval) . "</$ent>\n";
|
||||
@ -240,14 +242,16 @@ function dump_xml_config_sub($arr, $indent)
|
||||
$xmlconfig .= "<$ent/>\n";
|
||||
} elseif (!is_bool($val)) {
|
||||
$xmlconfig .= str_repeat("\t", $indent);
|
||||
if ((substr($ent, 0, 5) == "descr")
|
||||
|| (substr($ent, 0, 6) == "detail")
|
||||
|| (substr($ent, 0, 12) == "login_banner")
|
||||
|| (substr($ent, 0, 9) == "ldap_attr")
|
||||
|| (substr($ent, 0, 9) == "ldap_bind")
|
||||
|| (substr($ent, 0, 11) == "ldap_basedn")
|
||||
|| (substr($ent, 0, 18) == "ldap_authcn")
|
||||
|| (substr($ent, 0, 19) == "ldap_extended_query")) {
|
||||
if (
|
||||
(substr($ent, 0, 5) == "descr")
|
||||
|| (substr($ent, 0, 6) == "detail")
|
||||
|| (substr($ent, 0, 12) == "login_banner")
|
||||
|| (substr($ent, 0, 9) == "ldap_attr")
|
||||
|| (substr($ent, 0, 9) == "ldap_bind")
|
||||
|| (substr($ent, 0, 11) == "ldap_basedn")
|
||||
|| (substr($ent, 0, 18) == "ldap_authcn")
|
||||
|| (substr($ent, 0, 19) == "ldap_extended_query")
|
||||
) {
|
||||
$xmlconfig .= "<$ent><![CDATA[" . htmlentities($val) . "]]></$ent>\n";
|
||||
} else {
|
||||
$xmlconfig .= "<$ent>" . htmlentities($val) . "</$ent>\n";
|
||||
|
||||
@ -1,31 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2019 Deciso B.V.
|
||||
/*
|
||||
* Copyright (C) 2019 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* All rights reserved.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Diagnostics;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
{#
|
||||
#
|
||||
# Copyright (c) 2019 Deciso B.V.
|
||||
# All rights reserved.
|
||||
#
|
||||
@ -13,7 +12,7 @@
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
|
||||
@ -88,7 +88,6 @@ parameters: --destination %s --gateway %s
|
||||
message: Remove route %s %s
|
||||
type: script_output
|
||||
|
||||
|
||||
[gateways.list]
|
||||
command:/usr/local/opnsense/scripts/routes/gateways.php
|
||||
type:script_output
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user