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
691021eb
Commit
691021eb
authored
Feb 08, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Feb 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) spaces and curly brances in services.inc
(cherry picked from commit
8a13c8a7
)
parent
ba2cdee6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2485 additions
and
2365 deletions
+2485
-2365
services.inc
src/etc/inc/services.inc
+2485
-2365
No files found.
src/etc/inc/services.inc
View file @
691021eb
...
...
@@ -32,15 +32,17 @@ require_once('dyndns.class');
require_once
(
'unbound.inc'
);
require_once
(
'miniupnpd.inc'
);
function
generate_ipv6_from_mac
(
$mac
)
{
function
generate_ipv6_from_mac
(
$mac
)
{
$elements
=
explode
(
":"
,
$mac
);
if
(
count
(
$elements
)
<>
6
)
if
(
count
(
$elements
)
<>
6
)
{
return
false
;
}
$i
=
0
;
$ipv6
=
"fe80::"
;
foreach
(
$elements
as
$byte
)
{
if
(
$i
==
0
)
{
if
(
$i
==
0
)
{
$hexadecimal
=
substr
(
$byte
,
1
,
2
);
$bitmap
=
base_convert
(
$hexadecimal
,
16
,
2
);
$bitmap
=
str_pad
(
$bitmap
,
4
,
"0"
,
STR_PAD_LEFT
);
...
...
@@ -48,13 +50,13 @@ function generate_ipv6_from_mac($mac) {
$byte
=
substr
(
$byte
,
0
,
1
)
.
base_convert
(
$bitmap
,
2
,
16
);
}
$ipv6
.=
$byte
;
if
(
$i
==
1
)
{
if
(
$i
==
1
)
{
$ipv6
.=
":"
;
}
if
(
$i
==
3
)
{
if
(
$i
==
3
)
{
$ipv6
.=
":"
;
}
if
(
$i
==
2
)
{
if
(
$i
==
2
)
{
$ipv6
.=
"ff:fe"
;
}
...
...
@@ -63,19 +65,20 @@ function generate_ipv6_from_mac($mac) {
return
$ipv6
;
}
function
get_pppoes_child_interfaces
(
$ifpattern
)
{
function
get_pppoes_child_interfaces
(
$ifpattern
)
{
$if_arr
=
array
();
if
(
$ifpattern
==
""
)
if
(
$ifpattern
==
""
)
{
return
;
}
exec
(
"ifconfig"
,
$out
,
$ret
);
foreach
(
$out
as
$line
)
{
if
(
preg_match
(
"/^(
{
$ifpattern
}
[0-9]+):/i"
,
$line
,
$match
))
{
if
(
preg_match
(
"/^(
{
$ifpattern
}
[0-9]+):/i"
,
$line
,
$match
))
{
$if_arr
[]
=
$match
[
1
];
}
}
return
$if_arr
;
}
function
get_configured_pppoe_server_interfaces
()
...
...
@@ -91,7 +94,6 @@ function get_configured_pppoe_server_interfaces()
}
}
}
return
$iflist
;
}
...
...
@@ -115,23 +117,26 @@ function services_radvd_configure($blacklist = array())
/* handle manually configured DHCP6 server settings first */
foreach
(
$config
[
'dhcpdv6'
]
as
$dhcpv6if
=>
$dhcpv6ifconf
)
{
if
(
!
is_array
(
$config
[
'interfaces'
][
$dhcpv6if
]))
if
(
!
is_array
(
$config
[
'interfaces'
][
$dhcpv6if
]))
{
continue
;
if
(
!
isset
(
$config
[
'interfaces'
][
$dhcpv6if
][
'enable'
]))
}
elseif
(
!
isset
(
$config
[
'interfaces'
][
$dhcpv6if
][
'enable'
]))
{
continue
;
}
elseif
(
isset
(
$blacklist
[
$dhcpv6if
]))
{
/* Do not put in the config an interface which is down */
if
(
isset
(
$blacklist
[
$dhcpv6if
]))
continue
;
if
(
!
isset
(
$dhcpv6ifconf
[
'ramode'
]))
}
if
(
!
isset
(
$dhcpv6ifconf
[
'ramode'
]))
{
$dhcpv6ifconf
[
'ramode'
]
=
$dhcpv6ifconf
[
'mode'
];
}
/* are router advertisements enabled? */
if
(
$dhcpv6ifconf
[
'ramode'
]
==
"disabled"
)
if
(
$dhcpv6ifconf
[
'ramode'
]
==
"disabled"
)
{
continue
;
}
if
(
!
isset
(
$dhcpv6ifconf
[
'rapriority'
]))
if
(
!
isset
(
$dhcpv6ifconf
[
'rapriority'
]))
{
$dhcpv6ifconf
[
'rapriority'
]
=
"medium"
;
}
/* always start with the real parent, we override with the carp if later */
$carpif
=
false
;
...
...
@@ -144,12 +149,14 @@ function services_radvd_configure($blacklist = array())
}
$realif
=
get_real_interface
(
$dhcpv6if
,
"inet6"
);
if
(
isset
(
$radvdifs
[
$realif
]))
if
(
isset
(
$radvdifs
[
$realif
]))
{
continue
;
}
$ifcfgipv6
=
get_interface_ipv6
(
$dhcpv6if
);
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
continue
;
}
$ifcfgsnv6
=
get_interface_subnetv6
(
$dhcpv6if
);
$subnetv6
=
gen_subnetv6
(
$ifcfgipv6
,
$ifcfgsnv6
);
...
...
@@ -161,11 +168,12 @@ function services_radvd_configure($blacklist = array())
$radvdconf
.=
"
\t
MinRtrAdvInterval 5;
\n
"
;
$radvdconf
.=
"
\t
MaxRtrAdvInterval 20;
\n
"
;
$mtu
=
legacy_interface_stats
(
$realif
)[
'mtu'
];
if
(
is_numeric
(
$mtu
))
if
(
is_numeric
(
$mtu
))
{
$radvdconf
.=
"
\t
AdvLinkMTU
{
$mtu
}
;
\n
"
;
else
}
else
{
$radvdconf
.=
"
\t
AdvLinkMTU 1280;
\n
"
;
// $radvdconf .= "\tDeprecatePrefix on;\n";
}
switch
(
$dhcpv6ifconf
[
'rapriority'
])
{
case
"low"
:
$radvdconf
.=
"
\t
AdvDefaultPreference low;
\n
"
;
...
...
@@ -185,7 +193,7 @@ function services_radvd_configure($blacklist = array())
break
;
}
$radvdconf
.=
"
\t
prefix
{
$subnetv6
}
/
{
$ifcfgsnv6
}
{\n"
;
if
(
$carpif
==
true
)
{
if
(
$carpif
==
true
)
{
$radvdconf
.=
"
\t\t
DeprecatePrefix off;
\n
"
;
}
else
{
$radvdconf
.=
"
\t\t
DeprecatePrefix on;
\n
"
;
...
...
@@ -214,7 +222,7 @@ function services_radvd_configure($blacklist = array())
}
$radvdconf
.=
"
\t
};
\n
"
;
if
(
$carpif
===
true
)
{
if
(
$carpif
===
true
)
{
$radvdconf
.=
"
\t
route ::/0 {\n"
;
$radvdconf
.=
"
\t\t
RemoveRoute off;
\n
"
;
$radvdconf
.=
"
\t
};
\n
"
;
...
...
@@ -227,26 +235,32 @@ function services_radvd_configure($blacklist = array())
/* add DNS servers */
$dnslist
=
array
();
if
(
isset
(
$dhcpv6ifconf
[
'rasamednsasdhcp6'
])
&&
is_array
(
$dhcpv6ifconf
[
'dnsserver'
])
&&
!
empty
(
$dhcpv6ifconf
[
'dnsserver'
]))
{
foreach
(
$dhcpv6ifconf
[
'dnsserver'
]
as
$server
)
if
(
is_ipaddrv6
(
$server
))
foreach
(
$dhcpv6ifconf
[
'dnsserver'
]
as
$server
)
{
if
(
is_ipaddrv6
(
$server
))
{
$dnslist
[]
=
$server
;
}
}
}
elseif
(
!
isset
(
$dhcpv6ifconf
[
'rasamednsasdhcp6'
])
&&
isset
(
$dhcpv6ifconf
[
'radnsserver'
])
&&
is_array
(
$dhcpv6ifconf
[
'radnsserver'
]))
{
foreach
(
$dhcpv6ifconf
[
'radnsserver'
]
as
$server
)
if
(
is_ipaddrv6
(
$server
))
foreach
(
$dhcpv6ifconf
[
'radnsserver'
]
as
$server
)
{
if
(
is_ipaddrv6
(
$server
))
{
$dnslist
[]
=
$server
;
}
}
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
$dnslist
[]
=
get_interface_ipv6
(
$realif
);
}
elseif
(
is_array
(
$config
[
'system'
][
'dnsserver'
])
&&
!
empty
(
$config
[
'system'
][
'dnsserver'
]))
{
foreach
(
$config
[
'system'
][
'dnsserver'
]
as
$server
)
{
if
(
is_ipaddrv6
(
$server
))
if
(
is_ipaddrv6
(
$server
))
{
$dnslist
[]
=
$server
;
}
}
}
if
(
count
(
$dnslist
)
>
0
)
{
$dnsstring
=
implode
(
" "
,
$dnslist
);
if
(
$dnsstring
<>
""
)
if
(
$dnsstring
<>
""
)
{
$radvdconf
.=
"
\t
RDNSS
{
$dnsstring
}
{ };
\n
"
;
}
}
if
(
!
empty
(
$dhcpv6ifconf
[
'domain'
]))
{
$radvdconf
.=
"
\t
DNSSL
{
$dhcpv6ifconf
[
'domain'
]
}
{ };
\n
"
;
}
elseif
(
!
empty
(
$config
[
'system'
][
'domain'
]))
{
...
...
@@ -257,24 +271,27 @@ function services_radvd_configure($blacklist = array())
/* handle DHCP-PD prefixes and 6RD dynamic interfaces */
foreach
(
$Iflist
as
$if
=>
$ifdescr
)
{
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'track6-interface'
]))
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'track6-interface'
]))
{
continue
;
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'enable'
]))
}
elseif
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'enable'
]))
{
continue
;
}
elseif
(
isset
(
$blacklist
[
$if
]))
{
/* Do not put in the config an interface which is down */
if
(
isset
(
$blacklist
[
$if
]))
continue
;
}
$trackif
=
$config
[
'interfaces'
][
$if
][
'track6-interface'
];
if
(
empty
(
$config
[
'interfaces'
][
$trackif
]))
if
(
empty
(
$config
[
'interfaces'
][
$trackif
]))
{
continue
;
}
$realif
=
get_real_interface
(
$if
,
"inet6"
);
/* prevent duplicate entries, manual overrides */
if
(
isset
(
$radvdifs
[
$realif
]))
if
(
isset
(
$radvdifs
[
$realif
]))
{
continue
;
}
$ifcfgipv6
=
get_interface_ipv6
(
$if
);
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
$subnetv6
=
"::"
;
$ifcfgsnv6
=
"64"
;
}
else
{
...
...
@@ -293,10 +310,11 @@ function services_radvd_configure($blacklist = array())
$radvdconf
.=
"
\t
MinRtrAdvInterval 3;
\n
"
;
$radvdconf
.=
"
\t
MaxRtrAdvInterval 10;
\n
"
;
$mtu
=
legacy_interface_stats
(
$realif
)[
'mtu'
];
if
(
is_numeric
(
$mtu
))
if
(
is_numeric
(
$mtu
))
{
$radvdconf
.=
"
\t
AdvLinkMTU
{
$mtu
}
;
\n
"
;
else
}
else
{
$radvdconf
.=
"
\t
AdvLinkMTU 1280;
\n
"
;
}
$radvdconf
.=
"
\t
AdvOtherConfigFlag on;
\n
"
;
$radvdconf
.=
"
\t\t
prefix
{
$subnetv6
}
/
{
$ifcfgsnv6
}
{\n"
;
$radvdconf
.=
"
\t\t
AdvOnLink on;
\n
"
;
...
...
@@ -310,15 +328,17 @@ function services_radvd_configure($blacklist = array())
$dnslist
[]
=
$ifcfgipv6
;
}
elseif
(
is_array
(
$config
[
'system'
][
'dnsserver'
])
&&
!
empty
(
$config
[
'system'
][
'dnsserver'
]))
{
foreach
(
$config
[
'system'
][
'dnsserver'
]
as
$server
)
{
if
(
is_ipaddrv6
(
$server
))
if
(
is_ipaddrv6
(
$server
))
{
$dnslist
[]
=
$server
;
}
}
}
if
(
count
(
$dnslist
)
>
0
)
{
$dnsstring
=
implode
(
" "
,
$dnslist
);
if
(
!
empty
(
$dnsstring
))
if
(
!
empty
(
$dnsstring
))
{
$radvdconf
.=
"
\t
RDNSS
{
$dnsstring
}
{ };
\n
"
;
}
}
if
(
!
empty
(
$config
[
'system'
][
'domain'
]))
{
$radvdconf
.=
"
\t
DNSSL
{
$config
[
'system'
][
'domain'
]
}
{ };
\n
"
;
}
...
...
@@ -328,9 +348,10 @@ function services_radvd_configure($blacklist = array())
/* write radvd.conf */
if
(
!@
file_put_contents
(
"/var/etc/radvd.conf"
,
$radvdconf
))
{
log_error
(
"Error: cannot open radvd.conf in services_radvd_configure().
\n
"
);
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
printf
(
"Error: cannot open radvd.conf in services_radvd_configure().
\n
"
);
}
}
unset
(
$radvdconf
);
if
(
count
(
$radvdifs
)
>
0
)
{
...
...
@@ -411,8 +432,9 @@ function services_dhcpdv4_configure()
killbypid
(
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/run/dhcpd.pid"
);
/* DHCP enabled on any interfaces? */
if
(
!
is_dhcp_server_enabled
())
if
(
!
is_dhcp_server_enabled
())
{
return
0
;
}
if
(
file_exists
(
"/var/run/booting"
))
{
/* restore the leases, if we have them */
...
...
@@ -421,15 +443,16 @@ function services_dhcpdv4_configure()
$dhcpreturn
=
''
;
exec
(
'cd /;LANG=C /usr/bin/tar -xzf /conf/dhcpleases.tgz 2>&1'
,
$dhcprestore
,
$dhcpreturn
);
$dhcprestore
=
implode
(
' '
,
$dhcprestore
);
if
(
$dhcpreturn
<>
0
)
{
if
(
$dhcpreturn
<>
0
)
{
log_error
(
sprintf
(
gettext
(
'DHCP leases restore failed exited with %s, the error is: %s'
),
$dhcpreturn
,
$dhcprestore
));
}
}
}
$syscfg
=
$config
[
'system'
];
if
(
!
is_array
(
$config
[
'dhcpd'
]))
if
(
!
is_array
(
$config
[
'dhcpd'
]))
{
$config
[
'dhcpd'
]
=
array
();
}
$dhcpdcfg
=
$config
[
'dhcpd'
];
$Iflist
=
get_configured_interface_list
();
...
...
@@ -443,24 +466,25 @@ function services_dhcpdv4_configure()
}
}
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DHCP service..."
);
else
}
else
{
sleep
(
1
);
}
$custoptions
=
""
;
foreach
(
$dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
if
(
isset
(
$dhcpifconf
[
'numberoptions'
][
'item'
]))
{
foreach
(
$dhcpifconf
[
'numberoptions'
][
'item'
]
as
$itemidx
=>
$item
)
{
if
(
!
empty
(
$item
[
'type'
]))
if
(
!
empty
(
$item
[
'type'
]))
{
$itemtype
=
$item
[
'type'
];
else
}
else
{
$itemtype
=
"text"
;
}
$custoptions
.=
"option custom-
{
$dhcpif
}
-
{
$itemidx
}
code
{
$item
[
'number'
]
}
=
{
$itemtype
}
;
\n
"
;
}
}
}
$dhcpdconf
=
<<<EOD
option domain-name "{$syscfg['domain']}";
...
...
@@ -478,11 +502,13 @@ update-conflict-detection false;
EOD;
if
(
!
isset
(
$dhcpifconf
[
'disableauthoritative'
]))
if
(
!
isset
(
$dhcpifconf
[
'disableauthoritative'
]))
{
$dhcpdconf
.=
"authoritative;
\n
"
;
}
if
(
isset
(
$dhcpifconf
[
'alwaysbroadcast'
]))
if
(
isset
(
$dhcpifconf
[
'alwaysbroadcast'
]))
{
$dhcpdconf
.=
"always-broadcast on
\n
"
;
}
$dhcpdifs
=
array
();
$add_routers
=
false
;
...
...
@@ -490,7 +516,7 @@ EOD;
/* only add a routers line if the system has any IPv4 gateway at all */
/* a static route has a gateway, manually overriding this field always works */
foreach
(
$gateways_arr
as
$gwitem
)
{
if
(
$gwitem
[
'ipprotocol'
]
==
"inet"
)
{
if
(
$gwitem
[
'ipprotocol'
]
==
"inet"
)
{
$add_routers
=
true
;
break
;
}
...
...
@@ -500,26 +526,25 @@ EOD;
* failover peer "bleh" entries
*/
foreach
(
$dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
interfaces_staticarp_configure
(
$dhcpif
);
if
(
!
isset
(
$dhcpifconf
[
'enable'
]))
if
(
!
isset
(
$dhcpifconf
[
'enable'
]))
{
continue
;
}
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
$intip
=
get_interface_ip
(
$dhcpif
);
/*
* yep, failover peer is defined.
* does it match up to a defined vip?
*/
$skew
=
110
;
if
(
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
if
(
is_array
(
$config
[
'virtualip'
][
'vip'
]))
{
foreach
(
$config
[
'virtualip'
][
'vip'
]
as
$vipent
)
{
if
(
$vipent
[
'interface'
]
==
$dhcpif
)
{
if
(
$vipent
[
'interface'
]
==
$dhcpif
)
{
$carp_nw
=
gen_subnet
(
$vipent
[
'subnet'
],
$vipent
[
'subnet_bits'
]);
if
(
ip_in_subnet
(
$dhcpifconf
[
'failover_peerip'
],
"
{
$carp_nw
}
/
{
$vipent
[
'subnet_bits'
]
}
"
))
{
/* this is the interface! */
if
(
is_numeric
(
$vipent
[
'advskew'
])
&&
(
intval
(
$vipent
[
'advskew'
])
<
20
))
{
if
(
is_numeric
(
$vipent
[
'advskew'
])
&&
(
intval
(
$vipent
[
'advskew'
])
<
20
))
{
$skew
=
0
;
break
;
}
...
...
@@ -529,7 +554,7 @@ EOD;
}
else
{
log_error
(
gettext
(
"Warning! DHCP Failover setup and no CARP virtual IPs defined!"
));
}
if
(
$skew
>
10
)
{
if
(
$skew
>
10
)
{
$type
=
"secondary"
;
$my_port
=
"520"
;
$peer_port
=
"519"
;
...
...
@@ -561,19 +586,20 @@ EOPP;
}
foreach
(
$dhcpdcfg
as
$dhcpif
=>
$dhcpifconf
)
{
$newzone
=
array
();
$ifcfg
=
$config
[
'interfaces'
][
$dhcpif
];
if
(
!
isset
(
$dhcpifconf
[
'enable'
])
||
!
isset
(
$Iflist
[
$dhcpif
]))
if
(
!
isset
(
$dhcpifconf
[
'enable'
])
||
!
isset
(
$Iflist
[
$dhcpif
]))
{
continue
;
}
$ifcfgip
=
get_interface_ip
(
$dhcpif
);
$ifcfgsn
=
get_interface_subnet
(
$dhcpif
);
$subnet
=
gen_subnet
(
$ifcfgip
,
$ifcfgsn
);
$subnetmask
=
gen_subnet_mask
(
$ifcfgsn
);
if
(
!
is_ipaddr
(
$subnet
))
if
(
!
is_ipaddr
(
$subnet
))
{
continue
;
}
$all_pools
=
array
();
$all_pools
[]
=
$dhcpifconf
;
...
...
@@ -587,14 +613,14 @@ EOPP;
$dnscfg
.=
" option domain-name
\"
{
$dhcpifconf
[
'domain'
]
}
\"
;
\n
"
;
}
if
(
$dhcpifconf
[
'domainsearchlist'
]
<>
""
)
{
if
(
$dhcpifconf
[
'domainsearchlist'
]
<>
""
)
{
$dnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$dhcpifconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
}
if
(
isset
(
$dhcpifconf
[
'ddnsupdate'
]))
{
$need_ddns_updates
=
true
;
$newzone
=
array
();
if
(
$dhcpifconf
[
'ddnsdomain'
]
<>
""
)
{
if
(
$dhcpifconf
[
'ddnsdomain'
]
<>
""
)
{
$newzone
[
'domain-name'
]
=
$dhcpifconf
[
'ddnsdomain'
];
$dnscfg
.=
" ddns-domainname
\"
{
$dhcpifconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
else
{
...
...
@@ -612,17 +638,20 @@ EOPP;
if
(
is_array
(
$dhcpifconf
[
'dnsserver'
])
&&
(
$dhcpifconf
[
'dnsserver'
][
0
]))
{
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dhcpifconf
[
'dnsserver'
])
.
";"
;
if
(
$newzone
[
'domain-name'
])
if
(
$newzone
[
'domain-name'
])
{
$newzone
[
'dns-servers'
]
=
$dhcpifconf
[
'dnsserver'
];
}
else
if
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
}
}
elseif
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
$dnscfg
.=
" option domain-name-servers
{
$ifcfgip
}
;"
;
if
(
$newzone
[
'domain-name'
]
&&
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
if
(
$newzone
[
'domain-name'
]
&&
is_array
(
$syscfg
[
'dnsserver'
])
&&
(
$syscfg
[
'dnsserver'
][
0
]))
{
$newzone
[
'dns-servers'
]
=
$syscfg
[
'dnsserver'
];
}
else
if
(
!
empty
(
$dns_arrv4
))
{
}
}
elseif
(
!
empty
(
$dns_arrv4
))
{
$dnscfg
.=
" option domain-name-servers "
.
join
(
","
,
$dns_arrv4
)
.
";"
;
if
(
$newzone
[
'domain-name'
])
if
(
$newzone
[
'domain-name'
])
{
$newzone
[
'dns-servers'
]
=
$dns_arrv4
;
}
}
/* Create classes - These all contain comma separated lists. Join them into one
big comma separated string then split them all up. */
...
...
@@ -637,8 +666,9 @@ EOPP;
$all_mac_strings
[]
=
$dhcpifconf
[
'mac_deny'
];
$all_mac_list
=
array_unique
(
explode
(
','
,
implode
(
','
,
$all_mac_strings
)));
foreach
(
$all_mac_list
as
$mac
)
{
if
(
empty
(
$mac
))
if
(
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
'class "'
.
str_replace
(
':'
,
''
,
$mac
)
.
'" {'
.
"
\n
"
;
// Skip the first octet of the MAC address - for media type, typically Ethernet ("01") and match the rest.
$dhcpdconf
.=
' match if substring (hardware, 1, '
.
(
substr_count
(
$mac
,
':'
)
+
1
)
.
') = '
.
$mac
.
';'
.
"
\n
"
;
...
...
@@ -647,41 +677,47 @@ EOPP;
$dhcpdconf
.=
"subnet
{
$subnet
}
netmask
{
$subnetmask
}
{\n"
;
// Setup pool options
// Setup pool options
foreach
(
$all_pools
as
$poolconf
)
{
$dhcpdconf
.=
" pool {\n"
;
/* is failover dns setup? */
if
(
is_array
(
$poolconf
[
'dnsserver'
])
&&
$poolconf
[
'dnsserver'
][
0
]
<>
""
)
{
$dhcpdconf
.=
" option domain-name-servers
{
$poolconf
[
'dnsserver'
][
0
]
}
"
;
if
(
$poolconf
[
'dnsserver'
][
1
]
<>
""
)
if
(
$poolconf
[
'dnsserver'
][
1
]
<>
""
)
{
$dhcpdconf
.=
",
{
$poolconf
[
'dnsserver'
][
1
]
}
"
;
}
$dhcpdconf
.=
";
\n
"
;
}
/* allow/deny MACs */
$mac_allow_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_allow'
]));
foreach
(
$mac_allow_list
as
$mac
)
{
if
(
empty
(
$mac
))
if
(
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
" allow members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
}
$mac_deny_list
=
array_unique
(
explode
(
','
,
$poolconf
[
'mac_deny'
]));
foreach
(
$mac_deny_list
as
$mac
)
{
if
(
empty
(
$mac
))
if
(
empty
(
$mac
))
{
continue
;
}
$dhcpdconf
.=
" deny members of
\"
"
.
str_replace
(
':'
,
''
,
$mac
)
.
"
\"
;
\n
"
;
}
if
(
$poolconf
[
'failover_peerip'
]
<>
""
)
if
(
$poolconf
[
'failover_peerip'
]
<>
""
)
{
$dhcpdconf
.=
" deny dynamic bootp clients;
\n
"
;
}
if
(
isset
(
$poolconf
[
'denyunknown'
]))
if
(
isset
(
$poolconf
[
'denyunknown'
]))
{
$dhcpdconf
.=
" deny unknown-clients;
\n
"
;
}
if
(
$poolconf
[
'gateway'
]
&&
$poolconf
[
'gateway'
]
!=
"none"
&&
(
$poolconf
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
if
(
$poolconf
[
'gateway'
]
&&
$poolconf
[
'gateway'
]
!=
"none"
&&
(
$poolconf
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
{
$dhcpdconf
.=
" option routers
{
$poolconf
[
'gateway'
]
}
;
\n
"
;
}
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
if
(
$dhcpifconf
[
'failover_peerip'
]
<>
""
)
{
$dhcpdconf
.=
" failover peer
\"
dhcp_
{
$dhcpif
}
\"
;
\n
"
;
}
...
...
@@ -691,13 +727,14 @@ EOPP;
$pdnscfg
.=
" option domain-name
\"
{
$poolconf
[
'domain'
]
}
\"
;
\n
"
;
}
if
(
!
empty
(
$poolconf
[
'domainsearchlist'
])
&&
(
$poolconf
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
if
(
!
empty
(
$poolconf
[
'domainsearchlist'
])
&&
(
$poolconf
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
$pdnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$poolconf
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
}
if
(
isset
(
$poolconf
[
'ddnsupdate'
]))
{
if
((
$poolconf
[
'ddnsdomain'
]
<>
""
)
&&
(
$poolconf
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
if
((
$poolconf
[
'ddnsdomain'
]
<>
""
)
&&
(
$poolconf
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
{
$pdnscfg
.=
" ddns-domainname
\"
{
$poolconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
}
...
...
@@ -707,12 +744,14 @@ EOPP;
$dhcpdconf
.=
"
{
$pdnscfg
}
"
;
// default-lease-time
if
(
$poolconf
[
'defaultleasetime'
]
&&
(
$poolconf
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
if
(
$poolconf
[
'defaultleasetime'
]
&&
(
$poolconf
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
$dhcpdconf
.=
" default-lease-time
{
$poolconf
[
'defaultleasetime'
]
}
;
\n
"
;
}
// max-lease-time
if
(
$poolconf
[
'maxleasetime'
]
&&
(
$poolconf
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
if
(
$poolconf
[
'maxleasetime'
]
&&
(
$poolconf
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
$dhcpdconf
.=
" max-lease-time
{
$poolconf
[
'maxleasetime'
]
}
;
\n
"
;
}
// netbios-name*
if
(
is_array
(
$poolconf
[
'winsserver'
])
&&
$poolconf
[
'winsserver'
][
0
]
&&
(
$poolconf
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
...
...
@@ -721,19 +760,22 @@ EOPP;
}
// ntp-servers
if
(
is_array
(
$poolconf
[
'ntpserver'
])
&&
$poolconf
[
'ntpserver'
][
0
]
&&
(
$poolconf
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
if
(
is_array
(
$poolconf
[
'ntpserver'
])
&&
$poolconf
[
'ntpserver'
][
0
]
&&
(
$poolconf
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$poolconf
[
'ntpserver'
])
.
";
\n
"
;
}
// tftp-server-name
if
(
!
empty
(
$poolconf
[
'tftp'
])
&&
(
$poolconf
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
if
(
!
empty
(
$poolconf
[
'tftp'
])
&&
(
$poolconf
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
{
$dhcpdconf
.=
" option tftp-server-name
\"
{
$poolconf
[
'tftp'
]
}
\"
;
\n
"
;
}
// ldap-server
if
(
!
empty
(
$poolconf
[
'ldap'
])
&&
(
$poolconf
[
'ldap'
]
!=
$dhcpifconf
[
'ldap'
]))
if
(
!
empty
(
$poolconf
[
'ldap'
])
&&
(
$poolconf
[
'ldap'
]
!=
$dhcpifconf
[
'ldap'
]))
{
$dhcpdconf
.=
" option ldap-server
\"
{
$poolconf
[
'ldap'
]
}
\"
;
\n
"
;
}
// net boot information
if
(
isset
(
$poolconf
[
'netboot'
]))
{
if
(
isset
(
$poolconf
[
'netboot'
]))
{
if
(
!
empty
(
$poolconf
[
'nextserver'
])
&&
(
$poolconf
[
'nextserver'
]
!=
$dhcpifconf
[
'nextserver'
]))
{
$dhcpdconf
.=
" next-server
{
$poolconf
[
'nextserver'
]
}
;
\n
"
;
}
...
...
@@ -747,7 +789,7 @@ EOPP;
$dhcpdconf
.=
" range
{
$poolconf
[
'range'
][
'from'
]
}
{
$poolconf
[
'range'
][
'to'
]
}
;
\n
"
;
$dhcpdconf
.=
" }
\n\n
"
;
}
// End of settings inside pools
// End of settings inside pools
if
(
$dhcpifconf
[
'gateway'
]
&&
$dhcpifconf
[
'gateway'
]
!=
"none"
)
{
$routers
=
$dhcpifconf
[
'gateway'
];
...
...
@@ -757,20 +799,23 @@ EOPP;
}
else
{
$routers
=
$ifcfgip
;
}
if
(
$add_routers
)
if
(
$add_routers
)
{
$dhcpdconf
.=
" option routers
{
$routers
}
;
\n
"
;
}
$dhcpdconf
.=
<<<EOD
$dnscfg
EOD;
// default-lease-time
if
(
$dhcpifconf
[
'defaultleasetime'
])
if
(
$dhcpifconf
[
'defaultleasetime'
])
{
$dhcpdconf
.=
" default-lease-time
{
$dhcpifconf
[
'defaultleasetime'
]
}
;
\n
"
;
}
// max-lease-time
if
(
$dhcpifconf
[
'maxleasetime'
])
if
(
$dhcpifconf
[
'maxleasetime'
])
{
$dhcpdconf
.=
" max-lease-time
{
$dhcpifconf
[
'maxleasetime'
]
}
;
\n
"
;
}
// netbios-name*
if
(
is_array
(
$dhcpifconf
[
'winsserver'
])
&&
$dhcpifconf
[
'winsserver'
][
0
])
{
...
...
@@ -779,30 +824,34 @@ EOD;
}
// ntp-servers
if
(
is_array
(
$dhcpifconf
[
'ntpserver'
])
&&
$dhcpifconf
[
'ntpserver'
][
0
])
if
(
is_array
(
$dhcpifconf
[
'ntpserver'
])
&&
$dhcpifconf
[
'ntpserver'
][
0
])
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$dhcpifconf
[
'ntpserver'
])
.
";
\n
"
;
}
// tftp-server-name
if
(
$dhcpifconf
[
'tftp'
]
<>
""
)
if
(
$dhcpifconf
[
'tftp'
]
<>
""
)
{
$dhcpdconf
.=
" option tftp-server-name
\"
{
$dhcpifconf
[
'tftp'
]
}
\"
;
\n
"
;
}
// Handle option, number rowhelper values
$dhcpdconf
.=
"
\n
"
;
if
(
isset
(
$dhcpifconf
[
'numberoptions'
][
'item'
]))
{
foreach
(
$dhcpifconf
[
'numberoptions'
][
'item'
]
as
$itemidx
=>
$item
)
{
if
(
empty
(
$item
[
'type'
])
||
$item
[
'type'
]
==
"text"
)
if
(
empty
(
$item
[
'type'
])
||
$item
[
'type'
]
==
"text"
)
{
$dhcpdconf
.=
" option custom-
{
$dhcpif
}
-
{
$itemidx
}
\"
{
$item
[
'value'
]
}
\"
;
\n
"
;
else
}
else
{
$dhcpdconf
.=
" option custom-
{
$dhcpif
}
-
{
$itemidx
}
{
$item
[
'value'
]
}
;
\n
"
;
}
}
}
// ldap-server
if
(
$dhcpifconf
[
'ldap'
]
<>
""
)
if
(
$dhcpifconf
[
'ldap'
]
<>
""
)
{
$dhcpdconf
.=
" option ldap-server
\"
{
$dhcpifconf
[
'ldap'
]
}
\"
;
\n
"
;
}
// net boot information
if
(
isset
(
$dhcpifconf
[
'netboot'
]))
{
if
(
isset
(
$dhcpifconf
[
'netboot'
]))
{
if
(
$dhcpifconf
[
'nextserver'
]
<>
""
)
{
$dhcpdconf
.=
" next-server
{
$dhcpifconf
[
'nextserver'
]
}
;
\n
"
;
}
...
...
@@ -829,47 +878,51 @@ EOD;
/* add static mappings */
if
(
is_array
(
$dhcpifconf
[
'staticmap'
]))
{
$i
=
0
;
foreach
(
$dhcpifconf
[
'staticmap'
]
as
$sm
)
{
$dhcpdconf
.=
"host s_
{
$dhcpif
}
_
{
$i
}
{\n"
;
if
(
$sm
[
'mac'
])
if
(
$sm
[
'mac'
])
{
$dhcpdconf
.=
" hardware ethernet
{
$sm
[
'mac'
]
}
;
\n
"
;
}
if
(
$sm
[
'cid'
])
if
(
$sm
[
'cid'
])
{
$dhcpdconf
.=
" option dhcp-client-identifier
\"
{
$sm
[
'cid'
]
}
\"
;
\n
"
;
}
if
(
$sm
[
'ipaddr'
])
if
(
$sm
[
'ipaddr'
])
{
$dhcpdconf
.=
" fixed-address
{
$sm
[
'ipaddr'
]
}
;
\n
"
;
}
if
(
$sm
[
'hostname'
])
{
$dhhostname
=
str_replace
(
" "
,
"_"
,
$sm
[
'hostname'
]);
$dhhostname
=
str_replace
(
"."
,
"_"
,
$dhhostname
);
$dhcpdconf
.=
" option host-name
\"
{
$dhhostname
}
\"
;
\n
"
;
}
if
(
$sm
[
'filename'
])
if
(
$sm
[
'filename'
])
{
$dhcpdconf
.=
" filename
\"
{
$sm
[
'filename'
]
}
\"
;
\n
"
;
}
if
(
$sm
[
'rootpath'
])
if
(
$sm
[
'rootpath'
])
{
$dhcpdconf
.=
" option root-path
\"
{
$sm
[
'rootpath'
]
}
\"
;
\n
"
;
}
if
(
$sm
[
'gateway'
]
&&
(
$sm
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
if
(
$sm
[
'gateway'
]
&&
(
$sm
[
'gateway'
]
!=
$dhcpifconf
[
'gateway'
]))
{
$dhcpdconf
.=
" option routers
{
$sm
[
'gateway'
]
}
;
\n
"
;
}
$smdnscfg
=
""
;
if
(
$sm
[
'domain'
]
&&
(
$sm
[
'domain'
]
!=
$dhcpifconf
[
'domain'
]))
{
$smdnscfg
.=
" option domain-name
\"
{
$sm
[
'domain'
]
}
\"
;
\n
"
;
}
if
(
!
empty
(
$sm
[
'domainsearchlist'
])
&&
(
$sm
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
if
(
!
empty
(
$sm
[
'domainsearchlist'
])
&&
(
$sm
[
'domainsearchlist'
]
!=
$dhcpifconf
[
'domainsearchlist'
]))
{
$smdnscfg
.=
" option domain-search
\"
"
.
join
(
"
\"
,
\"
"
,
preg_split
(
"/[ ;]+/"
,
$sm
[
'domainsearchlist'
]))
.
"
\"
;
\n
"
;
}
if
(
isset
(
$sm
[
'ddnsupdate'
]))
{
if
((
$sm
[
'ddnsdomain'
]
<>
""
)
&&
(
$sm
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
if
((
$sm
[
'ddnsdomain'
]
<>
""
)
&&
(
$sm
[
'ddnsdomain'
]
!=
$dhcpifconf
[
'ddnsdomain'
]))
{
$pdnscfg
.=
" ddns-domainname
\"
{
$sm
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
$pdnscfg
.=
" ddns-update-style interim;
\n
"
;
}
...
...
@@ -879,12 +932,14 @@ EOD;
$dhcpdconf
.=
"
{
$smdnscfg
}
"
;
// default-lease-time
if
(
$sm
[
'defaultleasetime'
]
&&
(
$sm
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
if
(
$sm
[
'defaultleasetime'
]
&&
(
$sm
[
'defaultleasetime'
]
!=
$dhcpifconf
[
'defaultleasetime'
]))
{
$dhcpdconf
.=
" default-lease-time
{
$sm
[
'defaultleasetime'
]
}
;
\n
"
;
}
// max-lease-time
if
(
$sm
[
'maxleasetime'
]
&&
(
$sm
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
if
(
$sm
[
'maxleasetime'
]
&&
(
$sm
[
'maxleasetime'
]
!=
$dhcpifconf
[
'maxleasetime'
]))
{
$dhcpdconf
.=
" max-lease-time
{
$sm
[
'maxleasetime'
]
}
;
\n
"
;
}
// netbios-name*
if
(
is_array
(
$sm
[
'winsserver'
])
&&
$sm
[
'winsserver'
][
0
]
&&
(
$sm
[
'winsserver'
][
0
]
!=
$dhcpifconf
[
'winsserver'
][
0
]))
{
...
...
@@ -893,12 +948,14 @@ EOD;
}
// ntp-servers
if
(
is_array
(
$sm
[
'ntpserver'
])
&&
$sm
[
'ntpserver'
][
0
]
&&
(
$sm
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
if
(
is_array
(
$sm
[
'ntpserver'
])
&&
$sm
[
'ntpserver'
][
0
]
&&
(
$sm
[
'ntpserver'
][
0
]
!=
$dhcpifconf
[
'ntpserver'
][
0
]))
{
$dhcpdconf
.=
" option ntp-servers "
.
join
(
","
,
$sm
[
'ntpserver'
])
.
";
\n
"
;
}
// tftp-server-name
if
(
!
empty
(
$sm
[
'tftp'
])
&&
(
$sm
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
if
(
!
empty
(
$sm
[
'tftp'
])
&&
(
$sm
[
'tftp'
]
!=
$dhcpifconf
[
'tftp'
]))
{
$dhcpdconf
.=
" option tftp-server-name
\"
{
$sm
[
'tftp'
]
}
\"
;
\n
"
;
}
$dhcpdconf
.=
"}
\n
"
;
$i
++
;
...
...
@@ -906,10 +963,8 @@ EOD;
}
$dhcpdifs
[]
=
get_real_interface
(
$dhcpif
);
if
(
$newzone
[
'domain-name'
])
{
if
(
$need_ddns_updates
)
{
if
(
$newzone
[
'domain-name'
])
{
if
(
$need_ddns_updates
)
{
$newzone
[
'dns-servers'
]
=
array
(
$dhcpifconf
[
'ddnsdomainprimary'
]);
}
$ddns_zones
[]
=
$newzone
;
...
...
@@ -919,7 +974,6 @@ EOD;
if
(
$need_ddns_updates
)
{
$dhcpdconf
.=
"ddns-update-style interim;
\n
"
;
$dhcpdconf
.=
"update-static-leases on;
\n
"
;
$dhcpdconf
.=
dhcpdkey
(
$dhcpifconf
);
$dhcpdconf
.=
dhcpdzones
(
$ddns_zones
,
$dhcpifconf
);
}
...
...
@@ -941,12 +995,12 @@ EOD;
/* fire up dhcpd in a chroot */
if
(
count
(
$dhcpdifs
)
>
0
)
{
mwexec
(
"/usr/local/sbin/dhcpd -user dhcpd -group dhcpd -chroot
{
$g
[
'dhcpd_chroot_path'
]
}
-cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid "
.
join
(
" "
,
$dhcpdifs
));
mwexec
(
"/usr/local/sbin/dhcpd -user dhcpd -group dhcpd -chroot
{
$g
[
'dhcpd_chroot_path'
]
}
-cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid "
.
join
(
" "
,
$dhcpdifs
));
}
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
print
"done.
\n
"
;
}
return
0
;
}
...
...
@@ -954,8 +1008,7 @@ EOD;
function
dhcpdkey
(
$dhcpifconf
)
{
$dhcpdconf
=
""
;
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
{
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
{
$dhcpdconf
.=
"key
{
$dhcpifconf
[
'ddnsdomainkeyname'
]
}
{\n"
;
$dhcpdconf
.=
" algorithm hmac-md5;
\n
"
;
$dhcpdconf
.=
" secret
{
$dhcpifconf
[
'ddnsdomainkey'
]
}
;
\n
"
;
...
...
@@ -972,8 +1025,9 @@ function dhcpdzones($ddns_zones, $dhcpifconf)
if
(
is_array
(
$ddns_zones
))
{
$added_zones
=
array
();
foreach
(
$ddns_zones
as
$zone
)
{
if
(
!
is_array
(
$zone
)
||
empty
(
$zone
)
||
!
is_array
(
$zone
[
'dns-servers'
]))
if
(
!
is_array
(
$zone
)
||
empty
(
$zone
)
||
!
is_array
(
$zone
[
'dns-servers'
]))
{
continue
;
}
$primary
=
$zone
[
'dns-servers'
][
0
];
$secondary
=
empty
(
$zone
[
'dns-servers'
][
1
])
?
""
:
$zone
[
'dns-servers'
][
1
];
...
...
@@ -991,20 +1045,24 @@ function dhcpdzones($ddns_zones, $dhcpifconf)
if
(
$zone
[
'domain-name'
]
&&
!
in_array
(
$zone
[
'domain-name'
],
$added_zones
))
{
$dhcpdconf
.=
"zone
{
$zone
[
'domain-name'
]
}
. {\n"
;
$dhcpdconf
.=
" primary
{
$primary
}
;
\n
"
;
if
(
is_ipaddrv4
(
$secondary
))
if
(
is_ipaddrv4
(
$secondary
))
{
$dhcpdconf
.=
" secondary
{
$secondary
}
;
\n
"
;
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
}
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
{
$dhcpdconf
.=
" key
{
$dhcpifconf
[
'ddnsdomainkeyname'
]
}
;
\n
"
;
}
$dhcpdconf
.=
"}
\n
"
;
$added_zones
[]
=
$zone
[
'domain-name'
];
}
if
(
$zone
[
'ptr-domain'
]
&&
!
in_array
(
$zone
[
'ptr-domain'
],
$added_zones
))
{
$dhcpdconf
.=
"zone
{
$zone
[
'ptr-domain'
]
}
{\n"
;
$dhcpdconf
.=
" primary
{
$primary
}
;
\n
"
;
if
(
is_ipaddrv4
(
$secondary
))
if
(
is_ipaddrv4
(
$secondary
))
{
$dhcpdconf
.=
" secondary
{
$secondary
}
;
\n
"
;
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
}
if
(
$dhcpifconf
[
'ddnsdomainkeyname'
]
<>
""
&&
$dhcpifconf
[
'ddnsdomainkey'
]
<>
""
)
{
$dhcpdconf
.=
" key
{
$dhcpifconf
[
'ddnsdomainkeyname'
]
}
;
\n
"
;
}
$dhcpdconf
.=
"}
\n
"
;
$added_zones
[]
=
$zone
[
'ptr-domain'
];
}
...
...
@@ -1069,13 +1127,15 @@ function services_dhcpdv6_configure($blacklist = array())
/* we add a fake entry for interfaces that are set to track6 another WAN */
foreach
(
$Iflist
as
$ifname
)
{
/* Do not put in the config an interface which is down */
if
(
isset
(
$blacklist
[
$ifname
]))
if
(
isset
(
$blacklist
[
$ifname
]))
{
continue
;
}
if
(
!
empty
(
$config
[
'interfaces'
][
$ifname
][
'track6-interface'
]))
{
$realif
=
get_real_interface
(
$ifname
,
"inet6"
);
$ifcfgipv6
=
get_interface_ipv6
(
$ifname
);
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
continue
;
}
$ifcfgipv6
=
Net_IPv6
::
getNetmask
(
$ifcfgipv6
,
64
);
$trackifname
=
$config
[
'interfaces'
][
$ifname
][
'track6-interface'
];
$trackcfg
=
$config
[
'interfaces'
][
$trackifname
];
...
...
@@ -1090,7 +1150,7 @@ function services_dhcpdv6_configure($blacklist = array())
$ifcfgipv6arr
[
7
]
=
"2000"
;
$dhcpdv6cfg
[
$ifname
][
'range'
][
'to'
]
=
Net_IPv6
::
compress
(
implode
(
":"
,
$ifcfgipv6arr
));
/* prefix length > 0? We can add dhcp6 prefix delegation server */
if
(
$pdlen
>
2
)
{
if
(
$pdlen
>
2
)
{
$pdlenmax
=
$pdlen
;
$pdlenhalf
=
$pdlenmax
-
1
;
$pdlenmin
=
(
64
-
ceil
(
$pdlenhalf
/
4
));
...
...
@@ -1114,15 +1174,16 @@ function services_dhcpdv6_configure($blacklist = array())
$custoptionsv6
=
""
;
foreach
(
$dhcpdv6cfg
as
$dhcpv6if
=>
$dhcpv6ifconf
)
{
if
(
isset
(
$dhcpv6ifconf
[
'numberoptions'
][
'item'
]))
{
if
(
isset
(
$dhcpv6ifconf
[
'numberoptions'
][
'item'
]))
{
foreach
(
$dhcpv6ifconf
[
'numberoptions'
][
'item'
]
as
$itemv6idx
=>
$itemv6
)
{
$custoptionsv6
.=
"option custom-
{
$dhcpv6if
}
-
{
$itemv6idx
}
code
{
$itemv6
[
'number'
]
}
= text;
\n
"
;
}
}
}
if
(
isset
(
$dhcpv6ifconf
[
'netboot'
])
&&
!
empty
(
$dhcpv6ifconf
[
'bootfile_url'
]))
if
(
isset
(
$dhcpv6ifconf
[
'netboot'
])
&&
!
empty
(
$dhcpv6ifconf
[
'bootfile_url'
]))
{
$custoptionsv6
.=
"option dhcp6.bootfile-url code 59 = string;
\n
"
;
}
$dhcpdv6conf
=
<<<EOD
...
...
@@ -1140,25 +1201,26 @@ update-conflict-detection false;
EOD;
if
(
!
isset
(
$dhcpv6ifconf
[
'disableauthoritative'
]))
if
(
!
isset
(
$dhcpv6ifconf
[
'disableauthoritative'
]))
{
$dhcpdv6conf
.=
"authoritative;
\n
"
;
}
if
(
isset
(
$dhcpv6ifconf
[
'alwaysbroadcast'
]))
if
(
isset
(
$dhcpv6ifconf
[
'alwaysbroadcast'
]))
{
$dhcpdv6conf
.=
"always-broadcast on
\n
"
;
}
$dhcpdv6ifs
=
array
();
$dhcpv6num
=
0
;
$nsupdate
=
false
;
foreach
(
$dhcpdv6cfg
as
$dhcpv6if
=>
$dhcpv6ifconf
)
{
$ddns_zones
=
array
();
$ifcfgv6
=
$config
[
'interfaces'
][
$dhcpv6if
];
if
(
!
isset
(
$dhcpv6ifconf
[
'enable'
])
||
!
isset
(
$Iflist
[
$dhcpv6if
]))
if
(
!
isset
(
$dhcpv6ifconf
[
'enable'
])
||
!
isset
(
$Iflist
[
$dhcpv6if
]))
{
continue
;
}
$ifcfgipv6
=
get_interface_ipv6
(
$dhcpv6if
);
$ifcfgsnv6
=
get_interface_subnetv6
(
$dhcpv6if
);
$subnetv6
=
gen_subnetv6
(
$ifcfgipv6
,
$ifcfgsnv6
);
...
...
@@ -1175,7 +1237,7 @@ EOD;
}
if
(
isset
(
$dhcpv6ifconf
[
'ddnsupdate'
]))
{
if
(
$dhcpv6ifconf
[
'ddnsdomain'
]
<>
""
)
{
if
(
$dhcpv6ifconf
[
'ddnsdomain'
]
<>
""
)
{
$dnscfgv6
.=
" ddns-domainname
\"
{
$dhcpv6ifconf
[
'ddnsdomain'
]
}
\"
;
\n
"
;
}
$dnscfgv6
.=
" ddns-update-style interim;
\n
"
;
...
...
@@ -1193,9 +1255,10 @@ EOD;
$dns_arrv6
[]
=
$dnsserver
;
}
}
if
(
!
empty
(
$dns_arrv6
))
if
(
!
empty
(
$dns_arrv6
))
{
$dnscfgv6
.=
" option dhcp6.name-servers "
.
join
(
","
,
$dns_arrv6
)
.
";"
;
}
}
if
(
!
empty
(
$dhcpv6ifconf
[
'domain'
]))
{
$newzone
=
array
();
...
...
@@ -1225,23 +1288,27 @@ EOD;
$dhcpdv6conf
.=
" option dhcp6.name-servers
{
$dhcpv6ifconf
[
'dns6ip'
]
}
;
\n
"
;
}
// default-lease-time
if
(
!
empty
(
$dhcpv6ifconf
[
'defaultleasetime'
]))
if
(
!
empty
(
$dhcpv6ifconf
[
'defaultleasetime'
]))
{
$dhcpdv6conf
.=
" default-lease-time
{
$dhcpv6ifconf
[
'defaultleasetime'
]
}
;
\n
"
;
}
// max-lease-time
if
(
!
empty
(
$dhcpv6ifconf
[
'maxleasetime'
]))
if
(
!
empty
(
$dhcpv6ifconf
[
'maxleasetime'
]))
{
$dhcpdv6conf
.=
" max-lease-time
{
$dhcpv6ifconf
[
'maxleasetime'
]
}
;
\n
"
;
}
// ntp-servers
if
(
isset
(
$dhcpv6ifconf
[
'ntpserver'
][
0
]))
{
$ntpservers
=
array
();
foreach
(
$dhcpv6ifconf
[
'ntpserver'
]
as
$ntpserver
)
{
if
(
is_ipaddrv6
(
$ntpserver
))
if
(
is_ipaddrv6
(
$ntpserver
))
{
$ntpservers
[]
=
$ntpserver
;
}
if
(
count
(
$ntpservers
)
>
0
)
}
if
(
count
(
$ntpservers
)
>
0
)
{
$dhcpdv6conf
.=
" option dhcp6.sntp-servers "
.
join
(
","
,
$dhcpv6ifconf
[
'ntpserver'
])
.
";
\n
"
;
}
}
// tftp-server-name
/* Needs ISC DHCPD support
if ($dhcpv6ifconf['tftp'] <> "")
...
...
@@ -1257,11 +1324,12 @@ EOD;
}
// ldap-server
if
(
!
empty
(
$dhcpv6ifconf
[
'ldap'
]))
if
(
!
empty
(
$dhcpv6ifconf
[
'ldap'
]))
{
$dhcpdv6conf
.=
" option ldap-server
\"
{
$dhcpv6ifconf
[
'ldap'
]
}
\"
;
\n
"
;
}
// net boot information
if
(
isset
(
$dhcpv6ifconf
[
'netboot'
]))
{
if
(
isset
(
$dhcpv6ifconf
[
'netboot'
]))
{
if
(
!
empty
(
$dhcpv6ifconf
[
'bootfile_url'
]))
{
$dhcpdv6conf
.=
" option dhcp6.bootfile-url
\"
{
$dhcpv6ifconf
[
'bootfile_url'
]
}
\"
;
\n
"
;
}
...
...
@@ -1279,33 +1347,35 @@ host s_{$dhcpv6if}_{$i} {
host-identifier option dhcp6.client-id {$sm['duid']};
EOD;
if
(
$sm
[
'ipaddrv6'
])
if
(
$sm
[
'ipaddrv6'
])
{
$dhcpdv6conf
.=
" fixed-address6
{
$sm
[
'ipaddrv6'
]
}
;
\n
"
;
}
if
(
$sm
[
'hostname'
])
{
$dhhostname
=
str_replace
(
" "
,
"_"
,
$sm
[
'hostname'
]);
$dhhostname
=
str_replace
(
"."
,
"_"
,
$dhhostname
);
$dhcpdv6conf
.=
" option host-name
{
$dhhostname
}
;
\n
"
;
}
if
(
$sm
[
'filename'
])
if
(
$sm
[
'filename'
])
{
$dhcpdv6conf
.=
" filename
\"
{
$sm
[
'filename'
]
}
\"
;
\n
"
;
}
if
(
$sm
[
'rootpath'
])
if
(
$sm
[
'rootpath'
])
{
$dhcpdv6conf
.=
" option root-path
\"
{
$sm
[
'rootpath'
]
}
\"
;
\n
"
;
}
$dhcpdv6conf
.=
"}
\n
"
;
$i
++
;
}
}
if
(
!
empty
(
$dhcpv6ifconf
[
'domain'
]))
{
if
(
!
empty
(
$dhcpv6ifconf
[
'domain'
]))
{
$dhcpdv6conf
.=
dhcpdkey
(
$dhcpv6ifconf
);
$dhcpdv6conf
.=
dhcpdzones
(
$ddns_zones
,
$dhcpv6ifconf
);
}
if
(
isset
(
$config
[
'dhcpdv6'
][
$dhcpv6if
][
'ramode'
])
&&
$config
[
'dhcpdv6'
][
$dhcpv6if
][
'ramode'
]
<>
"unmanaged"
)
{
if
(
preg_match
(
"/poes/si"
,
$dhcpv6if
))
{
if
(
preg_match
(
"/poes/si"
,
$dhcpv6if
))
{
/* magic here */
$dhcpdv6ifs
=
array_merge
(
$dhcpdv6ifs
,
get_pppoes_child_interfaces
(
$dhcpv6if
));
}
else
{
...
...
@@ -1322,28 +1392,27 @@ EOD;
}
}
if
(
$nsupdate
)
{
if
(
$nsupdate
)
{
$dhcpdv6conf
.=
"ddns-update-style interim;
\n
"
;
}
else
{
}
else
{
$dhcpdv6conf
.=
"ddns-update-style none;
\n
"
;
}
/* write dhcpdv6.conf */
if
(
!@
file_put_contents
(
"
{
$g
[
'dhcpd_chroot_path'
]
}
/etc/dhcpdv6.conf"
,
$dhcpdv6conf
))
{
log_error
(
"Error: cannot open
{
$g
[
'dhcpd_chroot_path'
]
}
/etc/dhcpdv6.conf in services_dhcpdv6_configure().
\n
"
);
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
printf
(
"Error: cannot open
{
$g
[
'dhcpd_chroot_path'
]
}
/etc/dhcpdv6.conf in services_dhcpdv6_configure().
\n
"
);
}
unset
(
$dhcpdv6conf
);
return
1
;
}
unset
(
$dhcpdv6conf
);
/* create an empty leases v6 database */
if
(
!
file_exists
(
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/db/dhcpd6.leases"
))
if
(
!
file_exists
(
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/db/dhcpd6.leases"
))
{
@
touch
(
"
{
$g
[
'dhcpd_chroot_path'
]
}
/var/db/dhcpd6.leases"
);
}
/* make sure there isn't a stale dhcpdv6.pid file, which may make dhcpdv6 fail to start. */
/* if we get here, dhcpdv6 has been killed and is not started yet */
...
...
@@ -1355,8 +1424,9 @@ EOD;
join
(
" "
,
$dhcpdv6ifs
));
mwexec
(
"/usr/local/sbin/dhcpleases6 -c
\"
/usr/local/bin/php -f /usr/local/sbin/prefixes.php|/bin/sh
\"
-l
{
$g
[
'dhcpd_chroot_path'
]
}
/var/db/dhcpd6.leases"
);
}
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
print
gettext
(
"done."
)
.
"
\n
"
;
}
return
0
;
}
...
...
@@ -1368,8 +1438,9 @@ function services_igmpproxy_configure()
/* kill any running igmpproxy */
killbyname
(
"igmpproxy"
);
if
(
!
isset
(
$config
[
'igmpproxy'
][
'igmpentry'
])
||
!
is_array
(
$config
[
'igmpproxy'
][
'igmpentry'
])
||
(
count
(
$config
[
'igmpproxy'
][
'igmpentry'
])
==
0
))
if
(
!
isset
(
$config
[
'igmpproxy'
][
'igmpentry'
])
||
!
is_array
(
$config
[
'igmpproxy'
][
'igmpentry'
])
||
(
count
(
$config
[
'igmpproxy'
][
'igmpentry'
])
==
0
))
{
return
1
;
}
$iflist
=
get_configured_interface_list
();
...
...
@@ -1385,17 +1456,19 @@ EOD;
foreach
(
$config
[
'igmpproxy'
][
'igmpentry'
]
as
$igmpcf
)
{
unset
(
$iflist
[
$igmpcf
[
'ifname'
]]);
$realif
=
get_real_interface
(
$igmpcf
[
'ifname'
]);
if
(
empty
(
$igmpcf
[
'threshold'
]))
if
(
empty
(
$igmpcf
[
'threshold'
]))
{
$threshld
=
1
;
else
}
else
{
$threshld
=
$igmpcf
[
'threshold'
];
}
$igmpconf
.=
"phyint
{
$realif
}
{
$igmpcf
[
'type'
]
}
ratelimit 0 threshold
{
$threshld
}
\n
"
;
if
(
$igmpcf
[
'address'
]
<>
""
)
{
$item
=
explode
(
" "
,
$igmpcf
[
'address'
]);
foreach
(
$item
as
$iww
)
foreach
(
$item
as
$iww
)
{
$igmpconf
.=
"altnet
{
$iww
}
\n
"
;
}
}
$igmpconf
.=
"
\n
"
;
}
foreach
(
$iflist
as
$ifn
)
{
...
...
@@ -1432,22 +1505,23 @@ function services_dhcrelay_configure()
if
(
!
isset
(
$dhcrelaycfg
[
'enable'
]))
return
0
;
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DHCP relay service..."
);
else
}
else
{
sleep
(
1
);
}
$iflist
=
get_configured_interface_list
();
$dhcifaces
=
explode
(
","
,
$dhcrelaycfg
[
'interface'
]);
foreach
(
$dhcifaces
as
$dhcrelayif
)
{
if
(
!
isset
(
$iflist
[
$dhcrelayif
])
||
link_interface_to_bridge
(
$dhcrelayif
))
if
(
!
isset
(
$iflist
[
$dhcrelayif
])
||
link_interface_to_bridge
(
$dhcrelayif
))
{
continue
;
}
if
(
is_ipaddr
(
get_interface_ip
(
$dhcrelayif
)))
if
(
is_ipaddr
(
get_interface_ip
(
$dhcrelayif
)))
{
$dhcrelayifs
[]
=
get_real_interface
(
$dhcrelayif
);
}
}
/*
* In order for the relay to work, it needs to be active
...
...
@@ -1458,8 +1532,9 @@ function services_dhcrelay_configure()
unset
(
$destif
);
foreach
(
$iflist
as
$ifname
)
{
$subnet
=
get_interface_ip
(
$ifname
);
if
(
!
is_ipaddr
(
$subnet
))
if
(
!
is_ipaddr
(
$subnet
))
{
continue
;
}
$subnet
.=
"/"
.
get_interface_subnet
(
$ifname
);
if
(
ip_in_subnet
(
$srvip
,
$subnet
))
{
$destif
=
get_real_interface
(
$ifname
);
...
...
@@ -1513,9 +1588,10 @@ function services_dhcrelay_configure()
$destif
=
get_real_interface
(
"wan"
);
}
if
(
!
empty
(
$destif
))
if
(
!
empty
(
$destif
))
{
$dhcrelayifs
[]
=
$destif
;
}
}
$dhcrelayifs
=
array_unique
(
$dhcrelayifs
);
/* fire up dhcrelay */
...
...
@@ -1526,8 +1602,9 @@ function services_dhcrelay_configure()
$cmd
=
"/usr/local/sbin/dhcrelay -i "
.
implode
(
" -i "
,
$dhcrelayifs
);
if
(
isset
(
$dhcrelaycfg
[
'agentoption'
]))
if
(
isset
(
$dhcrelaycfg
[
'agentoption'
]))
{
$cmd
.=
" -a -m replace"
;
}
$cmd
.=
" "
.
implode
(
" "
,
$srvips
);
mwexec
(
$cmd
);
...
...
@@ -1546,25 +1623,27 @@ function services_dhcrelay6_configure()
$dhcrelaycfg
=&
$config
[
'dhcrelay6'
];
/* DHCPv6 Relay enabled on any interfaces? */
if
(
!
isset
(
$dhcrelaycfg
[
'enable'
]))
if
(
!
isset
(
$dhcrelaycfg
[
'enable'
]))
{
return
0
;
}
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DHCPv6 relay service..."
);
else
}
else
{
sleep
(
1
);
}
$iflist
=
get_configured_interface_list
();
$dhcifaces
=
explode
(
","
,
$dhcrelaycfg
[
'interface'
]);
foreach
(
$dhcifaces
as
$dhcrelayif
)
{
if
(
!
isset
(
$iflist
[
$dhcrelayif
])
||
link_interface_to_bridge
(
$dhcrelayif
))
if
(
!
isset
(
$iflist
[
$dhcrelayif
])
||
link_interface_to_bridge
(
$dhcrelayif
))
{
continue
;
}
if
(
is_ipaddrv6
(
get_interface_ipv6
(
$dhcrelayif
)))
if
(
is_ipaddrv6
(
get_interface_ipv6
(
$dhcrelayif
)))
{
$dhcrelayifs
[]
=
get_real_interface
(
$dhcrelayif
);
}
}
$dhcrelayifs
=
array_unique
(
$dhcrelayifs
);
/*
...
...
@@ -1577,8 +1656,9 @@ function services_dhcrelay6_configure()
unset
(
$destif
);
foreach
(
$iflist
as
$ifname
)
{
$subnet
=
get_interface_ipv6
(
$ifname
);
if
(
!
is_ipaddrv6
(
$subnet
))
if
(
!
is_ipaddrv6
(
$subnet
))
{
continue
;
}
$subnet
.=
"/"
.
get_interface_subnetv6
(
$ifname
);
if
(
ip_in_subnet
(
$srvip
,
$subnet
))
{
$destif
=
get_real_interface
(
$ifname
);
...
...
@@ -1622,9 +1702,10 @@ function services_dhcrelay6_configure()
break
;
}
}
}
else
}
else
{
$destif
=
get_real_interface
(
"wan"
);
}
}
if
(
!
empty
(
$destif
))
{
$srvifaces
[]
=
"
{
$srvip
}
%
{
$destif
}
"
;
...
...
@@ -1687,8 +1768,9 @@ function services_dyndns_list()
function
services_dyndns_configure_client
(
$conf
)
{
if
(
!
isset
(
$conf
[
'enable'
]))
if
(
!
isset
(
$conf
[
'enable'
]))
{
return
;
}
$dns
=
new
updatedns
(
$dnsService
=
$conf
[
'type'
],
$dnsHost
=
$conf
[
'host'
],
...
...
@@ -1709,7 +1791,8 @@ function services_dyndns_configure_client($conf) {
$dnsID
=
"
{
$conf
[
'id'
]
}
"
,
$dnsVerboseLog
=
$conf
[
'verboselog'
],
$curlIpresolveV4
=
$conf
[
'curl_ipresolve_v4'
],
$curlSslVerifypeer
=
$conf
[
'curl_ssl_verifypeer'
]);
$curlSslVerifypeer
=
$conf
[
'curl_ssl_verifypeer'
]
);
}
function
services_dyndns_configure
(
$int
=
''
)
...
...
@@ -1718,11 +1801,11 @@ function services_dyndns_configure($int = '')
if
(
isset
(
$config
[
'dyndnses'
][
'dyndns'
]))
{
$dyndnscfg
=
$config
[
'dyndnses'
][
'dyndns'
];
$gwgroups
=
return_gateway_groups_array
();
if
(
is_array
(
$dyndnscfg
))
{
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting dynamic DNS clients..."
);
}
foreach
(
$dyndnscfg
as
$dyndns
)
{
if
((
empty
(
$int
))
||
(
$int
==
$dyndns
[
'interface'
])
||
(
is_array
(
$gwgroups
[
$dyndns
[
'interface'
]])))
{
...
...
@@ -1734,10 +1817,11 @@ function services_dyndns_configure($int = '')
}
}
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"done."
)
.
"
\n
"
;
}
}
}
return
0
;
}
...
...
@@ -1752,8 +1836,9 @@ function dyndnsCheckIP($int)
$gateways_status
=
return_gateways_status
(
true
);
// If the gateway for this interface is down, then the external check cannot work.
// Avoid the long wait for the external check to timeout.
if
(
stristr
(
$gateways_status
[
$config
[
'interfaces'
][
$int
][
'gateway'
]][
'status'
],
"down"
))
if
(
stristr
(
$gateways_status
[
$config
[
'interfaces'
][
$int
][
'gateway'
]][
'status'
],
"down"
))
{
return
"down"
;
}
$hosttocheck
=
"http://checkip.dyndns.org"
;
$ip_ch
=
curl_init
(
$hosttocheck
);
curl_setopt
(
$ip_ch
,
CURLOPT_RETURNTRANSFER
,
1
);
...
...
@@ -1787,11 +1872,11 @@ function services_dnsmasq_configure()
killbypid
(
'/var/run/dnsmasq.pid'
);
if
(
isset
(
$config
[
'dnsmasq'
][
'enable'
]))
{
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DNS forwarder..."
);
else
}
else
{
sleep
(
1
);
}
$args
=
""
;
...
...
@@ -1805,12 +1890,12 @@ function services_dnsmasq_configure()
}
$listen_addresses
=
""
;
if
(
isset
(
$config
[
'dnsmasq'
][
'interface'
]))
{
if
(
isset
(
$config
[
'dnsmasq'
][
'interface'
]))
{
$interfaces
=
explode
(
","
,
$config
[
'dnsmasq'
][
'interface'
]);
foreach
(
$interfaces
as
$interface
)
{
if
(
is_ipaddrv4
(
$interface
))
{
$listen_addresses
.=
" --listen-address=
{
$interface
}
"
;
}
else
if
(
is_ipaddrv6
(
$interface
))
{
}
else
if
(
is_ipaddrv6
(
$interface
))
{
/*
* XXX: Since dnsmasq does not support link-local address
* with scope specified. These checks are being done.
...
...
@@ -1818,14 +1903,16 @@ function services_dnsmasq_configure()
if
(
is_linklocal
(
$interface
)
&&
strstr
(
$interface
,
"%"
))
{
$tmpaddrll6
=
explode
(
"%"
,
$interface
);
$listen_addresses
.=
" --listen-address=
{
$tmpaddrll6
[
0
]
}
"
;
}
else
}
else
{
$listen_addresses
.=
" --listen-address=
{
$interface
}
"
;
}
}
else
{
$if
=
get_real_interface
(
$interface
);
if
(
does_interface_exist
(
$if
))
{
$laddr
=
find_interface_ip
(
$if
);
if
(
is_ipaddrv4
(
$laddr
))
if
(
is_ipaddrv4
(
$laddr
))
{
$listen_addresses
.=
" --listen-address=
{
$laddr
}
"
;
}
$laddr6
=
find_interface_ipv6
(
$if
);
if
(
is_ipaddrv6
(
$laddr6
)
&&
!
isset
(
$config
[
'dnsmasq'
][
'strictbind'
]))
{
/*
...
...
@@ -1835,18 +1922,20 @@ function services_dnsmasq_configure()
if
(
is_linklocal
(
$laddr6
)
&&
strstr
(
$laddr6
,
"%"
))
{
$tmpaddrll6
=
explode
(
"%"
,
$laddr6
);
$listen_addresses
.=
" --listen-address=
{
$tmpaddrll6
[
0
]
}
"
;
}
else
}
else
{
$listen_addresses
.=
" --listen-address=
{
$laddr6
}
"
;
}
}
}
}
}
if
(
!
empty
(
$listen_addresses
))
{
$args
.=
"
{
$listen_addresses
}
"
;
if
(
isset
(
$config
[
'dnsmasq'
][
'strictbind'
]))
if
(
isset
(
$config
[
'dnsmasq'
][
'strictbind'
]))
{
$args
.=
" --bind-interfaces "
;
}
}
}
/* If selected, then first forward reverse lookups for private IPv4 addresses to nowhere. */
/* If any of these are duplicated by a user-specified domain override (e.g. 10.in-addr.arpa) then */
...
...
@@ -1874,15 +1963,16 @@ function services_dnsmasq_configure()
/* Allow DNS Rebind for forwarded domains */
if
(
isset
(
$config
[
'dnsmasq'
][
'domainoverrides'
])
&&
is_array
(
$config
[
'dnsmasq'
][
'domainoverrides'
]))
{
if
(
!
isset
(
$config
[
'system'
][
'webgui'
][
'nodnsrebindcheck'
]))
{
if
(
!
isset
(
$config
[
'system'
][
'webgui'
][
'nodnsrebindcheck'
]))
{
foreach
(
$config
[
'dnsmasq'
][
'domainoverrides'
]
as
$override
)
{
$args
.=
' --rebind-domain-ok=/'
.
$override
[
'domain'
]
.
'/ '
;
}
}
}
if
(
!
isset
(
$config
[
'system'
][
'webgui'
][
'nodnsrebindcheck'
]))
if
(
!
isset
(
$config
[
'system'
][
'webgui'
][
'nodnsrebindcheck'
]))
{
$dns_rebind
=
"--rebind-localhost-ok --stop-dns-rebind"
;
}
if
(
isset
(
$config
[
'dnsmasq'
][
'strict_order'
]))
{
$args
.=
" --strict-order "
;
...
...
@@ -1896,10 +1986,11 @@ function services_dnsmasq_configure()
foreach
(
preg_split
(
'/\s+/'
,
$config
[
'dnsmasq'
][
'custom_options'
])
as
$c
)
{
$args
.=
" "
.
escapeshellarg
(
"--
{
$c
}
"
);
$p
=
explode
(
'='
,
$c
);
if
(
array_key_exists
(
$p
[
0
],
$standard_args
))
if
(
array_key_exists
(
$p
[
0
],
$standard_args
))
{
unset
(
$standard_args
[
$p
[
0
]]);
}
}
}
$args
.=
' '
.
implode
(
' '
,
array_values
(
$standard_args
));
/* run dnsmasq */
...
...
@@ -1909,14 +2000,16 @@ function services_dnsmasq_configure()
system_dhcpleases_configure
();
unset
(
$args
);
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"done."
)
.
"
\n
"
;
}
}
if
(
!
file_exists
(
"/var/run/booting"
))
{
if
(
services_dhcpd_configure
()
!=
0
)
if
(
services_dhcpd_configure
()
!=
0
)
{
$return
=
1
;
}
}
return
$return
;
}
...
...
@@ -1930,21 +2023,24 @@ function services_unbound_configure()
killbypid
(
'/var/run/unbound.pid'
);
if
(
isset
(
$config
[
'unbound'
][
'enable'
]))
{
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting DNS Resolver..."
);
else
}
else
{
sleep
(
1
);
}
sync_unbound_service
();
system_dhcpleases_configure
();
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"done."
)
.
"
\n
"
;
}
}
if
(
!
file_exists
(
"/var/run/booting"
))
{
if
(
services_dhcpd_configure
()
!=
0
)
if
(
services_dhcpd_configure
()
!=
0
)
{
$return
=
1
;
}
}
return
$return
;
}
...
...
@@ -1962,9 +2058,9 @@ function services_snmpd_configure()
}
if
(
isset
(
$config
[
'snmpd'
][
'enable'
]))
{
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Starting SNMP daemon... "
);
}
/* generate snmpd.conf */
$fd
=
fopen
(
"/var/etc/snmpd.conf"
,
"w"
);
...
...
@@ -1992,7 +2088,7 @@ EOD;
*/
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
$snmpdconf
.=
<<<EOD
# SNMP Trap support.
traphost := {$config['snmpd']['trapserver']}
...
...
@@ -2029,7 +2125,7 @@ EOD;
*/
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
if
(
isset
(
$config
[
'snmpd'
][
'trapenable'
])
&&
preg_match
(
'/^\S+$/'
,
$config
[
'snmpd'
][
'trapserver'
])){
$snmpdconf
.=
<<<EOD
begemotTrapSinkStatus.[$(traphost)].$(trapport) = 4
begemotTrapSinkVersion.[$(traphost)].$(trapport) = 2
...
...
@@ -2049,17 +2145,18 @@ EOD;
unset
(
$config
[
'snmpd'
][
'bindlan'
]);
}
$bind_to_ip
=
"0.0.0.0"
;
if
(
isset
(
$config
[
'snmpd'
][
'bindip'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'bindip'
]))
{
if
(
is_ipaddr
(
$config
[
'snmpd'
][
'bindip'
]))
{
$bind_to_ip
=
$config
[
'snmpd'
][
'bindip'
];
}
else
{
$if
=
get_real_interface
(
$config
[
'snmpd'
][
'bindip'
]);
if
(
does_interface_exist
(
$if
))
if
(
does_interface_exist
(
$if
))
{
$bind_to_ip
=
find_interface_ip
(
$if
);
}
}
}
if
(
is_port
(
$config
[
'snmpd'
][
'pollport'
]
))
{
if
(
is_port
(
$config
[
'snmpd'
][
'pollport'
]
))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdPortStatus.{$bind_to_ip}.{$config['snmpd']['pollport']} = 1
...
...
@@ -2081,14 +2178,14 @@ snmpEnableAuthenTraps = 2
EOD;
if
(
is_array
(
$config
[
'snmpd'
][
'modules'
]
))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'mibii'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'mibii'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'netgraph'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'netgraph'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."netgraph" = "/usr/lib/snmp_netgraph.so"
%netgraph
...
...
@@ -2097,33 +2194,33 @@ begemotNgControlNodeName = "snmpd"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'pf'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'pf'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'hostres'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'hostres'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."hostres" = "/usr/lib/snmp_hostres.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'bridge'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'bridge'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."bridge" = "/usr/lib/snmp_bridge.so"
# config must end with blank line
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'ucd'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'ucd'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."ucd" = "/usr/local/lib/snmp_ucd.so"
EOD;
}
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'regex'
]))
{
if
(
isset
(
$config
[
'snmpd'
][
'modules'
][
'regex'
]))
{
$snmpdconf
.=
<<<EOD
begemotSnmpdModulePath."regex" = "/usr/local/lib/snmp_regex.so"
...
...
@@ -2143,9 +2240,10 @@ EOD;
mwexec
(
"/usr/sbin/bsnmpd -c /var/etc/snmpd.conf"
.
"
{
$bindlan
}
-p /var/run/snmpd.pid"
);
if
(
file_exists
(
"/var/run/booting"
))
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"done."
)
.
"
\n
"
;
}
}
return
0
;
}
...
...
@@ -2158,20 +2256,22 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
if
(
isset
(
$config
[
'dnsupdates'
][
'dnsupdate'
])
&&
is_array
(
$config
[
'dnsupdates'
][
'dnsupdate'
]))
{
$notify_text
=
""
;
foreach
(
$config
[
'dnsupdates'
][
'dnsupdate'
]
as
$i
=>
$dnsupdate
)
{
if
(
!
isset
(
$dnsupdate
[
'enable'
]))
if
(
!
isset
(
$dnsupdate
[
'enable'
]))
{
continue
;
if
(
!
empty
(
$int
)
&&
$int
!=
$dnsupdate
[
'interface'
])
}
elseif
(
!
empty
(
$int
)
&&
$int
!=
$dnsupdate
[
'interface'
])
{
continue
;
if
(
!
empty
(
$updatehost
)
&&
(
$updatehost
!=
$dnsupdate
[
'host'
]))
}
elseif
(
!
empty
(
$updatehost
)
&&
(
$updatehost
!=
$dnsupdate
[
'host'
]))
{
continue
;
}
/* determine interface name */
$if
=
get_real_interface
(
$dnsupdate
[
'interface'
]);
if
(
isset
(
$dnsupdate
[
'usepublicip'
]))
if
(
isset
(
$dnsupdate
[
'usepublicip'
]))
{
$wanip
=
dyndnsCheckIP
(
$dnsupdate
[
'interface'
]);
else
}
else
{
$wanip
=
get_interface_ip
(
$dnsupdate
[
'interface'
]);
}
$wanipv6
=
get_interface_ipv6
(
$dnsupdate
[
'interface'
]);
$cacheFile
=
"/conf/dyndns_
{
$dnsupdate
[
'interface'
]
}
_rfc2136_"
.
escapeshellarg
(
$dnsupdate
[
'host'
])
.
"_
{
$dnsupdate
[
'server'
]
}
.cache"
;
...
...
@@ -2180,13 +2280,15 @@ function services_dnsupdate_process($int = '', $updatehost = '', $forced = false
if
(
$wanip
||
$wanipv6
)
{
$keyname
=
$dnsupdate
[
'keyname'
];
/* trailing dot */
if
(
substr
(
$keyname
,
-
1
)
!=
"."
)
if
(
substr
(
$keyname
,
-
1
)
!=
"."
)
{
$keyname
.=
"."
;
}
$hostname
=
$dnsupdate
[
'host'
];
/* trailing dot */
if
(
substr
(
$hostname
,
-
1
)
!=
"."
)
if
(
substr
(
$hostname
,
-
1
)
!=
"."
)
{
$hostname
.=
"."
;
}
/* write private key file
this is dumb - public and private keys are the same for HMAC-MD5,
...
...
@@ -2219,8 +2321,9 @@ EOD;
/* generate update instructions */
$upinst
=
""
;
if
(
!
empty
(
$dnsupdate
[
'server'
]))
if
(
!
empty
(
$dnsupdate
[
'server'
]))
{
$upinst
.=
"server
{
$dnsupdate
[
'server'
]
}
\n
"
;
}
if
(
file_exists
(
$cacheFile
))
{
list
(
$cachedipv4
,
$cacheTimev4
)
=
explode
(
"|"
,
file_get_contents
(
$cacheFile
));
...
...
@@ -2245,8 +2348,9 @@ EOD;
}
else
{
log_error
(
"Dynamic DNS: Not updating
{
$dnsupdate
[
'host'
]
}
A record because the IP address has not changed."
);
}
}
else
}
else
{
@
unlink
(
$cacheFile
);
}
/* Update IPv6 if we have it. */
if
(
is_ipaddrv6
(
$wanipv6
))
{
...
...
@@ -2260,8 +2364,9 @@ EOD;
}
else
{
log_error
(
"Dynamic DNS: Not updating
{
$dnsupdate
[
'host'
]
}
AAAA record because the IPv6 address has not changed."
);
}
}
else
}
else
{
@
unlink
(
"
{
$cacheFile
}
.ipv6"
);
}
$upinst
.=
"
\n
"
;
/* mind that trailing newline! */
...
...
@@ -2347,8 +2452,9 @@ function upnp_action($action)
break
;
case
"stop"
:
killbypid
(
'/var/run/miniupnpd.pid'
);
while
((
int
)
exec
(
"/bin/pgrep -a miniupnpd | wc -l"
)
>
0
)
while
((
int
)
exec
(
"/bin/pgrep -a miniupnpd | wc -l"
)
>
0
)
{
mwexec
(
'killall miniupnpd 2>/dev/null'
,
true
);
}
mwexec
(
'/sbin/pfctl -aminiupnpd -Fr 2>&1 >/dev/null'
);
mwexec
(
'/sbin/pfctl -aminiupnpd -Fn 2>&1 >/dev/null'
);
break
;
...
...
@@ -2376,21 +2482,23 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
$is_installed
=
false
;
if
(
!
is_array
(
$config
[
'cron'
]))
if
(
!
is_array
(
$config
[
'cron'
]))
{
$config
[
'cron'
]
=
array
();
if
(
!
is_array
(
$config
[
'cron'
][
'item'
]))
}
if
(
!
is_array
(
$config
[
'cron'
][
'item'
]))
{
$config
[
'cron'
][
'item'
]
=
array
();
}
$x
=
0
;
foreach
(
$config
[
'cron'
][
'item'
]
as
$item
)
{
if
(
strstr
(
$item
[
'command'
],
$command
))
{
if
(
strstr
(
$item
[
'command'
],
$command
))
{
$is_installed
=
true
;
break
;
}
$x
++
;
}
if
(
$active
)
{
if
(
$active
)
{
$cron_item
=
array
();
$cron_item
[
'minute'
]
=
$minute
;
$cron_item
[
'hour'
]
=
$hour
;
...
...
@@ -2399,7 +2507,7 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
$cron_item
[
'wday'
]
=
$weekday
;
$cron_item
[
'who'
]
=
$who
;
$cron_item
[
'command'
]
=
$command
;
if
(
!
$is_installed
)
{
if
(
!
$is_installed
)
{
$config
[
'cron'
][
'item'
][]
=
$cron_item
;
write_config
(
sprintf
(
gettext
(
"Installed cron job for %s"
),
$command
));
}
else
{
...
...
@@ -2407,7 +2515,7 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
write_config
(
sprintf
(
gettext
(
"Updated cron job for %s"
),
$command
));
}
}
else
{
if
(
$is_installed
==
true
)
{
if
(
$is_installed
==
true
)
{
unset
(
$config
[
'cron'
][
'item'
][
$x
]);
write_config
(
sprintf
(
gettext
(
"Removed cron job for %s"
),
$command
));
}
...
...
@@ -2474,9 +2582,10 @@ function get_services() {
$ifdescrs
=
get_configured_interface_list
();
foreach
(
$ifdescrs
as
$if
)
{
$oc
=
$config
[
'interfaces'
][
$if
];
if
(
$oc
[
'if'
]
&&
(
!
link_interface_to_bridge
(
$if
)))
if
(
$oc
[
'if'
]
&&
(
!
link_interface_to_bridge
(
$if
)))
{
$iflist
[
$if
]
=
$if
;
}
}
if
(
isset
(
$config
[
'dhcrelay'
][
'enable'
]))
{
$pconfig
=
array
();
...
...
@@ -2577,16 +2686,19 @@ function get_services() {
function
find_service_by_openvpn_vpnid
(
$vpnid
)
{
$services
=
get_services
();
foreach
(
$services
as
$service
)
if
((
$service
[
"name"
]
==
"openvpn"
)
&&
isset
(
$service
[
"vpnid"
])
&&
(
$service
[
"vpnid"
]
==
$vpnid
))
foreach
(
$services
as
$service
)
{
if
((
$service
[
"name"
]
==
"openvpn"
)
&&
isset
(
$service
[
"vpnid"
])
&&
(
$service
[
"vpnid"
]
==
$vpnid
))
{
return
$service
;
}
}
return
array
();
}
function
service_name_compare
(
$a
,
$b
)
{
if
(
strtolower
(
$a
[
'name'
])
==
strtolower
(
$b
[
'name'
]))
if
(
strtolower
(
$a
[
'name'
])
==
strtolower
(
$b
[
'name'
]))
{
return
0
;
}
return
(
strtolower
(
$a
[
'name'
])
<
strtolower
(
$b
[
'name'
]))
?
-
1
:
1
;
}
...
...
@@ -2618,7 +2730,7 @@ function get_service_status($service)
function
get_service_status_icon
(
$service
,
$withtext
=
true
,
$smallicon
=
false
)
{
$output
=
""
;
if
(
get_service_status
(
$service
))
{
if
(
get_service_status
(
$service
))
{
$statustext
=
gettext
(
"Running"
);
$output
.=
'<span class="btn btn-success"><span class="glyphicon glyphicon-play" title="'
.
sprintf
(
gettext
(
'%s Service is'
),
$service
[
'name'
])
.
' '
.
$statustext
.
'" data-toggle="tooltip" data-placement="bottom" ></span></span> '
;
}
else
{
...
...
@@ -2632,7 +2744,7 @@ function get_service_control_links($service, $addname = false)
{
$output
=
""
;
$stitle
=
(
$addname
)
?
$service
[
'name'
]
.
" "
:
""
;
if
(
get_service_status
(
$service
))
{
if
(
get_service_status
(
$service
))
{
switch
(
$service
[
'name'
])
{
case
"openvpn"
:
$output
.=
"<a href='status_services.php?mode=restartservice&service=
{
$service
[
'name'
]
}
&vpnmode=
{
$service
[
'mode'
]
}
&id=
{
$service
[
'vpnid'
]
}
' class=
\"
btn btn-default
\"
>"
;
...
...
@@ -2678,38 +2790,46 @@ function is_radvd_enabled() {
/* handle manually configured DHCP6 server settings first */
foreach
(
$dhcpdv6cfg
as
$dhcpv6if
=>
$dhcpv6ifconf
)
{
if
(
!
isset
(
$config
[
'interfaces'
][
$dhcpv6if
][
'enable'
]))
if
(
!
isset
(
$config
[
'interfaces'
][
$dhcpv6if
][
'enable'
]))
{
continue
;
}
if
(
!
isset
(
$dhcpv6ifconf
[
'ramode'
]))
if
(
!
isset
(
$dhcpv6ifconf
[
'ramode'
]))
{
$dhcpv6ifconf
[
'ramode'
]
=
$dhcpv6ifconf
[
'mode'
];
}
if
(
$dhcpv6ifconf
[
'ramode'
]
==
"disabled"
)
if
(
$dhcpv6ifconf
[
'ramode'
]
==
"disabled"
)
{
continue
;
}
$ifcfgipv6
=
get_interface_ipv6
(
$dhcpv6if
);
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
continue
;
}
return
true
;
}
/* handle DHCP-PD prefixes and 6RD dynamic interfaces */
foreach
(
$Iflist
as
$if
=>
$ifdescr
)
{
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'track6-interface'
]))
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'track6-interface'
]))
{
continue
;
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'enable'
]))
}
if
(
!
isset
(
$config
[
'interfaces'
][
$if
][
'enable'
]))
{
continue
;
}
$ifcfgipv6
=
get_interface_ipv6
(
$if
);
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
if
(
!
is_ipaddrv6
(
$ifcfgipv6
))
{
continue
;
}
$ifcfgsnv6
=
get_interface_subnetv6
(
$if
);
$subnetv6
=
gen_subnetv6
(
$ifcfgipv6
,
$ifcfgsnv6
);
if
(
!
is_ipaddrv6
(
$subnetv6
))
if
(
!
is_ipaddrv6
(
$subnetv6
))
{
continue
;
}
return
true
;
}
...
...
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