if (empty($ssid['ip6_net'])) { throw new Exception(_('The IPv6 Delegated Prefix format looks bad')); } $ip6_blocs = explode(':', $ssid['ip6_net']); $ssid['ip6_addr'] = "{$ip6_blocs[0]}:{$ip6_blocs[1]}:{$ip6_blocs[2]}:{$ip6_blocs[3]}:{$ip6_blocs[4]}:{$ip6_blocs[5]}:{$ip6_blocs[6]}:42"; $ssid['ip6_net'] = ipv6_compressed($ssid['ip6_net']); $ssid['ip6_addr'] = ipv6_compressed($ssid['ip6_addr']); } if (!empty($ssid['ip6_dns0'])) { $ssid['ip6_dns0'] = ipv6_expanded($ssid['ip6_dns0']); if (empty($ssid['ip6_dns0'])) { throw new Exception(_('The format of the first IPv6 DNS Resolver looks bad')); } $ssid['ip6_dns0'] = ipv6_compressed($ssid['ip6_dns0']); if (!empty($ssid['ip6_dns1'])) { $ssid['ip6_dns1'] = ipv6_expanded($ssid['ip6_dns1']); if (empty($ssid['ip6_dns1'])) { throw new Exception(_('The format of the second IPv6 DNS Resolver looks bad')); } $ssid['ip6_dns1'] = ipv6_compressed($ssid['ip6_dns1']); } } if (inet_pton($ssid['ip4_dns0']) === false) { throw new Exception(_('The format of the first IPv4 DNS Resolver looks bad')); } if (inet_pton($ssid['ip4_dns1']) === false) { throw new Exception(_('The format of the second IPv4 DNS Resolver looks bad')); } if (inet_pton("{$ssid['ip4_nat_prefix']}.0") === false) { throw new Exception(_('The format of the IPv4 NAT Prefix (/24) looks bad: x.x.x expected')); }
throw new Exception(_('The Protocol must be "udp" or "tcp"')); } if ($_FILES['crt_client']['error'] == UPLOAD_ERR_OK && $_FILES['crt_client_key']['error'] != UPLOAD_ERR_OK && (!$crt_client_key_exists || $_POST['crt_client_key_delete'] == 1) || $_FILES['crt_client_key']['error'] == UPLOAD_ERR_OK && $_FILES['crt_client']['error'] != UPLOAD_ERR_OK && (!$crt_client_exists || $_POST['crt_client_delete'] == 1)) { throw new Exception(_('A Client Certificate is needed when you suggest a Key, or vice versa')); } if (empty($_POST['login_user']) xor empty($_POST['login_passphrase'])) { throw new Exception(_('A Password is needed when you suggest a Username, or vice versa')); } if ($_FILES['crt_server_ca']['error'] != UPLOAD_ERR_OK && !$crt_server_ca_exists) { throw new Exception(_('You need a Server CA.')); } if ($_FILES['crt_client_key']['error'] != UPLOAD_ERR_OK && (!$crt_client_key_exists || $_POST['crt_client_key_delete'] == 1) && empty($_POST['login_user'])) { throw new Exception(_('You need either a Client Certificate, either a Username, or both')); } if ($ip6_net != 'none') { $ip6_net = ipv6_expanded($ip6_net); if (empty($ip6_net)) { throw new Exception(_('The IPv6 Delegated Prefix format looks bad')); } $ip6_blocs = explode(':', $ip6_net); $ip6_addr = "{$ip6_blocs[0]}:{$ip6_blocs[1]}:{$ip6_blocs[2]}:{$ip6_blocs[3]}:{$ip6_blocs[4]}:{$ip6_blocs[5]}:{$ip6_blocs[6]}:42"; $ip6_net = ipv6_compressed($ip6_net); $ip6_addr = ipv6_compressed($ip6_addr); } } catch (Exception $e) { flash('error', $e->getMessage() . ' (' . _('configuration not updated') . ').'); goto redirect; } } stop_service(); ynh_setting_set('service_enabled', $service_enabled);