From 72715c46eb88309d4696ba7ced1f6362c88ba865 Mon Sep 17 00:00:00 2001 From: Julien VAUBOURG Date: Mon, 23 Mar 2015 20:20:27 +0100 Subject: [PATCH] Fix ip6_dns* error --- sources/controller.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/sources/controller.php b/sources/controller.php index f8a1700..d40717f 100644 --- a/sources/controller.php +++ b/sources/controller.php @@ -113,6 +113,8 @@ dispatch_put('/settings', function() { $ip6_net = empty($_POST['ip6_net']) ? 'none' : $_POST['ip6_net']; $ip6_addr = 'none'; + $ip6_dns0 = $_POST['ip6_dns0']; + $ip6_dns1 = $_POST['ip6_dns1']; $service_enabled = isset($_POST['service_enabled']) ? 1 : 0; $wifi_secure = isset($_POST['wifi_secure']) ? 1 : 0; @@ -148,21 +150,26 @@ dispatch_put('/settings', function() { $ip6_addr = ipv6_compressed($ip6_addr); } - $ip6_dns0 = ipv6_expanded($ip6_dns0); + if(!empty($ip6_dns0)) { + $ip6_dns0 = ipv6_expanded($ip6_dns0); - if(empty($_POST['ip6_dns0'])) { - throw new Exception(T_('The format of the first IPv6 DNS Resolver looks bad')); + if(empty($ip6_dns0)) { + throw new Exception(T_('The format of the first IPv6 DNS Resolver looks bad')); + } + + $ip6_dns0 = ipv6_compressed($ip6_dns0); + + if(!empty($ip6_dns1)) { + $ip6_dns1 = ipv6_expanded($ip6_dns1); + + if(empty($ip6_dns1)) { + throw new Exception(T_('The format of the second IPv6 DNS Resolver looks bad')); + } + + $ip6_dns1 = ipv6_compressed($ip6_dns1); + } } - $ip6_dns0 = ipv6_compressed($ip6_dns0); - $ip6_dns1 = ipv6_expanded($ip6_dns1); - - if(empty($_POST['ip6_dns1'])) { - throw new Exception(T_('The format of the second IPv6 DNS Resolver looks bad')); - } - - $ip6_dns1 = ipv6_compressed($ip6_dns1); - if(inet_pton($_POST['ip4_dns0']) === false) { throw new Exception(T_('The format of the first IPv4 DNS Resolver looks bad')); }