コード例 #1
0
     $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'));
 }
 if (filter_var("{$ssid['ip4_nat_prefix']}.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) !== false) {
     throw new Exception(_('The IPv4 NAT Prefix must be from a private range'));
 }
 array_push($ssids, $ssid);
コード例 #2
0
ファイル: controller.php プロジェクト: xfj106/vpnclient_ynh
         }
         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);
 if ($service_enabled == 1) {
     ynh_setting_set('server_name', $_POST['server_name']);
     ynh_setting_set('server_port', $_POST['server_port']);
     ynh_setting_set('server_proto', $_POST['server_proto']);
     ynh_setting_set('login_user', $_POST['login_user']);
     ynh_setting_set('login_passphrase', $_POST['login_passphrase']);
     ynh_setting_set('ip6_net', $ip6_net);