Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
d082febd
Commit
d082febd
authored
May 26, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) refactor config->interface traversal
parent
fd8c6d46
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
27 additions
and
34 deletions
+27
-34
filter_log.inc
src/etc/inc/filter_log.inc
+1
-1
services.inc
src/etc/inc/services.inc
+1
-1
util.inc
src/etc/inc/util.inc
+5
-9
rc.bootup
src/etc/rc.bootup
+1
-1
rc.newwanip
src/etc/rc.newwanip
+1
-1
firewall_nat_out_edit.php
src/www/firewall_nat_out_edit.php
+2
-2
interfaces_bridge.php
src/www/interfaces_bridge.php
+1
-2
interfaces_gif.php
src/www/interfaces_gif.php
+1
-2
interfaces_gre.php
src/www/interfaces_gre.php
+1
-2
interfaces_ppps.php
src/www/interfaces_ppps.php
+1
-1
interfaces_qinq.php
src/www/interfaces_qinq.php
+1
-1
services_dhcp.php
src/www/services_dhcp.php
+3
-3
services_dhcpv6.php
src/www/services_dhcpv6.php
+2
-2
services_router_advertisements.php
src/www/services_router_advertisements.php
+2
-2
status_dhcp_leases.php
src/www/status_dhcp_leases.php
+1
-1
status_dhcpv6_leases.php
src/www/status_dhcpv6_leases.php
+1
-1
system_routes_edit.php
src/www/system_routes_edit.php
+1
-1
traffic.inc
src/www/widgets/api/plugins/traffic.inc
+1
-1
No files found.
src/etc/inc/filter_log.inc
View file @
d082febd
...
...
@@ -41,7 +41,7 @@ function conv_log_interface_names()
$interface_names
[
'enc0'
]
=
gettext
(
"IPsec"
);
if
(
!
empty
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$intfkey
=>
$interface
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$intfkey
=>
$interface
)
{
$interface_names
[
$interface
[
'if'
]]
=
!
empty
(
$interface
[
'descr'
])
?
$interface
[
'descr'
]
:
$intfkey
;
}
}
...
...
src/etc/inc/services.inc
View file @
d082febd
...
...
@@ -1066,7 +1066,7 @@ function is_dhcpv6_server_enabled()
global
$config
;
if
(
is_array
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$ifcfg
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifcfg
)
{
if
(
isset
(
$ifcfg
[
'enable'
])
&&
!
empty
(
$ifcfg
[
'track6-interface'
]))
{
return
true
;
}
...
...
src/etc/inc/util.inc
View file @
d082febd
...
...
@@ -732,7 +732,7 @@ function get_configured_interface_list($only_opt = false, $withdisabled = false)
/* if list */
if
(
isset
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$ifdetail
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if
=>
$ifdetail
)
{
if
(
$only_opt
&&
(
$if
==
"wan"
||
$if
==
"lan"
))
{
continue
;
}
...
...
@@ -753,7 +753,7 @@ function get_configured_interface_list_by_realif ($only_opt = false, $withdisabl
$iflist
=
array
();
/* if list */
if
(
isset
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$ifdetail
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if
=>
$ifdetail
)
{
if
(
$only_opt
&&
(
$if
==
"wan"
||
$if
==
"lan"
))
{
continue
;
}
...
...
@@ -776,20 +776,16 @@ function get_configured_interface_with_descr($only_opt = false, $withdisabled =
$iflist
=
array
();
/* if list */
if
(
isset
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$ifdetail
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if
=>
$ifdetail
)
{
if
(
$only_opt
&&
(
$if
==
"wan"
||
$if
==
"lan"
))
{
continue
;
}
if
(
isset
(
$ifdetail
[
'enable'
])
||
$withdisabled
==
true
)
{
if
(
empty
(
$ifdetail
[
'descr'
]))
{
$iflist
[
$if
]
=
strtoupper
(
$if
);
}
else
{
$iflist
[
$if
]
=
strtoupper
(
$ifdetail
[
'descr'
]);
}
}
}
}
return
$iflist
;
}
...
...
@@ -925,7 +921,7 @@ function get_interface_list($only_active = false)
);
if
(
isset
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$name
=>
$int
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$name
=>
$int
)
{
if
(
$int
[
'if'
]
==
$ifname
)
{
$toput
[
'friendly'
]
=
$name
;
break
;
...
...
src/etc/rc.bootup
View file @
d082febd
...
...
@@ -55,7 +55,7 @@ function is_interface_mismatch()
$i
=
0
;
if
(
isset
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifcfg
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifname
=>
$ifcfg
)
{
if
(
preg_match
(
"/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i"
,
$ifcfg
[
'if'
]))
{
/* Do not check these interfaces */
$i
++
;
...
...
src/etc/rc.newwanip
View file @
d082febd
...
...
@@ -163,7 +163,7 @@ if (isset($config['interfaces'][$interface]['ipaddrv6'])) {
if
(
isset
(
$config
[
'gifs'
][
'gif'
])
&&
is_array
(
$config
[
'gifs'
][
'gif'
])){
foreach
(
$config
[
'gifs'
][
'gif'
]
as
$gif
)
{
if
(
$gif
[
'if'
]
==
$interface
)
{
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifparent
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifname
=>
$ifparent
)
{
if
((
$ifparent
[
'if'
]
==
$gif
[
'gifif'
])
&&
(
isset
(
$ifparent
[
'enable'
])))
{
$gif
[
'gifif'
]
=
interface_gif_configure
(
$gif
);
$confif
=
convert_real_interface_to_friendly_interface_name
(
$gif
[
'gifif'
]);
...
...
src/www/firewall_nat_out_edit.php
View file @
d082febd
...
...
@@ -38,8 +38,8 @@ require_once("filter.inc");
function
formInterfaces
()
{
global
$config
;
$interfaces
=
array
();
foreach
(
get_configured_interface_with_descr
(
false
,
true
)
as
$if
=>
$ifdesc
)
{
$interfaces
[
$if
]
=
$ifd
esc
;
foreach
(
legacy_config_get_interfaces
()
as
$if
=>
$ifdata
)
{
$interfaces
[
$if
]
=
$ifd
ata
[
'descr'
]
;
}
if
(
isset
(
$config
[
'l2tp'
][
'mode'
])
&&
$config
[
'l2tp'
][
'mode'
]
==
"server"
)
{
...
...
src/www/interfaces_bridge.php
View file @
d082febd
...
...
@@ -39,8 +39,7 @@ if (!isset($config['bridges']['bridged']) || !is_array($config['bridges']['bridg
function
bridge_inuse
(
$bridge_if
)
{
global
$config
;
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
()
as
$if
=>
$intf
)
{
if
(
$intf
[
'if'
]
==
$bridge_if
)
{
return
true
;
}
...
...
src/www/interfaces_gif.php
View file @
d082febd
...
...
@@ -31,8 +31,7 @@ require_once("guiconfig.inc");
require_once
(
"interfaces.inc"
);
function
gif_inuse
(
$gif_intf
)
{
global
$config
;
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
()
as
$if
=>
$intf
)
{
if
(
$intf
[
'if'
]
==
$gif_intf
)
{
return
true
;
}
...
...
src/www/interfaces_gre.php
View file @
d082febd
...
...
@@ -31,8 +31,7 @@ require_once("guiconfig.inc");
require_once
(
"interfaces.inc"
);
function
gre_inuse
(
$gre_intf
)
{
global
$config
;
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
()
as
$if
=>
$intf
)
{
if
(
$intf
[
'if'
]
==
$gre_intf
)
{
return
true
;
}
...
...
src/www/interfaces_ppps.php
View file @
d082febd
...
...
@@ -33,7 +33,7 @@ require_once("interfaces.inc");
function
ppp_inuse
(
$ppp_intf
)
{
global
$config
;
if
(
isset
(
$config
[
'ppps'
][
'ppp'
])
&&
!
is_array
(
$config
[
'ppps'
][
'ppp'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$intf
)
{
if
(
$intf
[
'if'
]
==
$ppp_intf
)
{
return
true
;
}
...
...
src/www/interfaces_qinq.php
View file @
d082febd
...
...
@@ -32,7 +32,7 @@ require_once("interfaces.inc");
function
qinq_inuse
(
$qinq_intf
)
{
global
$config
;
foreach
(
$config
[
'interfaces'
]
as
$if
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if
=>
$intf
)
{
if
(
$intf
[
'if'
]
==
$qinq_intf
)
{
return
true
;
}
...
...
src/www/services_dhcp.php
View file @
d082febd
...
...
@@ -51,7 +51,7 @@ function dhcp_clean_leases()
/* Build list of static MACs */
$staticmacs
=
array
();
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifarr
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifname
=>
$ifarr
)
{
if
(
isset
(
$config
[
'dhcpd'
][
$ifname
][
'staticmap'
]))
{
foreach
(
$config
[
'dhcpd'
][
$ifname
][
'staticmap'
]
as
$static
)
{
$staticmacs
[]
=
$static
[
'mac'
];
...
...
@@ -145,7 +145,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
/* If no interface is provided, choose first one from interfaces */
if
(
!
isset
(
$if
))
{
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
!
empty
(
$intf
[
'enable'
])
&&
is_ipaddrv4
(
$intf
[
'ipaddr'
]))
{
$if
=
$if_id
;
break
;
...
...
@@ -675,7 +675,7 @@ include("head.inc");
<?php
/* active tabs */
$tab_array
=
array
();
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
isset
(
$intf
[
'enable'
])
&&
is_ipaddrv4
(
$intf
[
'ipaddr'
]))
{
$ifname
=
!
empty
(
$intf
[
'descr'
])
?
htmlspecialchars
(
$intf
[
'descr'
])
:
strtoupper
(
$if_id
);
if
(
$if_id
==
$if
)
{
...
...
src/www/services_dhcpv6.php
View file @
d082febd
...
...
@@ -72,7 +72,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
"The DHCPv6 Server can only be enabled on interfaces configured with static "
.
"IP addresses. Only interfaces configured with a static IP will be shown."
);
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
!
empty
(
$intf
[
'enable'
])
&&
isset
(
$intf
[
'ipaddrv6'
])
&&
is_ipaddrv6
(
$intf
[
'ipaddrv6'
])
&&
!
is_linklocal
(
$intf
[
'ipaddrv6'
]))
{
$if
=
$if_id
;
break
;
...
...
@@ -443,7 +443,7 @@ include("head.inc");
<?php
/* active tabs */
$tab_array_main
=
array
();
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
isset
(
$intf
[
'enable'
])
&&
isset
(
$intf
[
'ipaddrv6'
])
&&
is_ipaddrv6
(
$intf
[
'ipaddrv6'
]))
{
$ifname
=
!
empty
(
$intf
[
'descr'
])
?
htmlspecialchars
(
$intf
[
'descr'
])
:
strtoupper
(
$if_id
);
if
(
$if_id
==
$if
)
{
...
...
src/www/services_router_advertisements.php
View file @
d082febd
...
...
@@ -38,7 +38,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
else
{
$savemsg
=
"<p><b>"
.
gettext
(
"The DHCPv6 Server can only be enabled on interfaces configured with static IP addresses"
)
.
".</b></p>"
.
"<p><b>"
.
gettext
(
"Only interfaces configured with a static IP will be shown"
)
.
".</b></p>"
;
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
!
empty
(
$intf
[
'enable'
])
&&
is_ipaddrv6
(
$intf
[
'ipaddrv6'
])
&&
!
is_linklocal
(
$oc
[
'ipaddrv6'
]))
{
$if
=
$if_id
;
break
;
...
...
@@ -173,7 +173,7 @@ include("head.inc");
<?php
/* active tabs */
$tab_array_main
=
array
();
foreach
(
$config
[
'interfaces'
]
as
$if_id
=>
$intf
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if_id
=>
$intf
)
{
if
(
!
empty
(
$intf
[
'enable'
])
&&
is_ipaddrv6
(
$intf
[
'ipaddrv6'
]))
{
$ifname
=
!
empty
(
$intf
[
'descr'
])
?
htmlspecialchars
(
$intf
[
'descr'
])
:
strtoupper
(
$if_id
);
if
(
$if_id
==
$if
)
{
...
...
src/www/status_dhcp_leases.php
View file @
d082febd
...
...
@@ -227,7 +227,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
asort
(
$pools
);
}
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifarr
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifname
=>
$ifarr
)
{
if
(
isset
(
$config
[
'dhcpd'
][
$ifname
][
'staticmap'
]))
{
foreach
(
$config
[
'dhcpd'
][
$ifname
][
'staticmap'
]
as
$static
)
{
$slease
=
array
();
...
...
src/www/status_dhcpv6_leases.php
View file @
d082febd
...
...
@@ -293,7 +293,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
asort
(
$pools
);
}
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifarr
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$ifname
=>
$ifarr
)
{
if
(
isset
(
$config
[
'dhcpdv6'
][
$ifname
][
'staticmap'
]))
{
foreach
(
$config
[
'dhcpdv6'
][
$ifname
][
'staticmap'
]
as
$static
)
{
$slease
=
array
();
...
...
src/www/system_routes_edit.php
View file @
d082febd
...
...
@@ -164,7 +164,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
if
(
is_array
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$if
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$if
)
{
if
(
is_ipaddrv4
(
$pconfig
[
'network'
])
&&
isset
(
$if
[
'ipaddr'
])
&&
isset
(
$if
[
'subnet'
])
&&
is_ipaddrv4
(
$if
[
'ipaddr'
])
&&
is_numeric
(
$if
[
'subnet'
])
...
...
src/www/widgets/api/plugins/traffic.inc
View file @
d082febd
...
...
@@ -33,7 +33,7 @@ function traffic_api()
$temp
=
gettimeofday
();
$result
[
'time'
]
=
(
double
)
$temp
[
"sec"
]
+
(
double
)
$temp
[
"usec"
]
/
1000000.0
;
// collect user friendly interface names
foreach
(
$config
[
'interfaces'
]
as
$interfaceKey
=>
$interfaceData
)
{
foreach
(
legacy_config_get_interfaces
(
array
(
"virtual"
=>
false
))
as
$interfaceKey
=>
$interfaceData
)
{
if
(
array_key_exists
(
$interfaceData
[
'if'
],
$result
[
'interfaces'
]))
{
$result
[
'interfaces'
][
$interfaceData
[
'if'
]][
'name'
]
=
!
empty
(
$interfaceData
[
'descr'
])
?
$interfaceData
[
'descr'
]
:
$interfaceKey
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment