Differenciate dhcpd6 and dhcpd4 in the service

This commit is contained in:
Julien VAUBOURG
2015-05-02 17:41:54 +02:00
parent ae4988d05b
commit 1ffb47a76e
3 changed files with 94 additions and 42 deletions

View File

@@ -82,10 +82,24 @@ function noneValue($str) {
function is_connected_through_hotspot($ip6_net, $ip4_nat_prefix) {
$ip = $_SERVER['REMOTE_ADDR'];
$ip6_regex = '/^'.preg_quote(preg_replace('/::$/', '', $ip6_net)).':/';
$ip4_regex = '/^'.preg_quote($ip4_nat_prefix).'\./';
return (preg_match($ip6_regex, $ip) || preg_match($ip4_regex, $ip));
foreach($ip6_net as $net) {
$ip6_regex = '/^'.preg_quote(preg_replace('/::$/', '', $net)).':/';
if(preg_match($ip6_regex, $ip)) {
return true;
}
}
foreach($ip4_nat_prefix as $prefix) {
$ip4_regex = '/^'.preg_quote($prefix).'\./';
if(preg_match($ip4_regex, $ip)) {
return true;
}
}
return false;
}
dispatch('/', function() {