} if (is_array($ovpnsrv[$id]['expertmode'])) { $pconfig['expertmode_options'] = ""; foreach ($ovpnsrv[$id]['expertmode']['option'] as $optent) { $pconfig['expertmode_options'] .= $optent . "\n"; } $pconfig['expertmode_options'] = rtrim($pconfig['expertmode_options']); } } else { /* creating - set defaults */ $pconfig = array(); $pconfig['type'] = "tun"; $pconfig['psh_options'] = array(); /* Initialise with some sensible defaults */ $pconfig['authentication_method'] = "rsasig"; $pconfig['port'] = getnxt_port(); $pconfig['proto'] = 'udp'; $pconfig['method'] = 'ovpn'; $pconfig['maxcli'] = ''; $pconfig['crypto'] = 'BF-CBC'; $pconfig['dupcn'] = false; $pconfig['verb'] = 1; $pconfig['enable'] = true; } if ($_POST) { unset($input_errors); unset($check_ipblock); /* input validation */ $reqdfields = explode(" ", "type bind_iface"); $reqdfieldsn = explode(",", "Tunnel type,Interface binding"); if ($_POST['authentication_method'] == "pre_shared_key") {
if ($ovpnent['type'] != $_POST['type']) { $input_errors[] = "Delete this interface first before changing the type of the tunnel to " . strtoupper($_POST['type']) . "."; } if (!isset($ovpnent['enable']) && !isset($_POST['disabled'])) { /* check if port number is free, else choose another one */ if (in_array($ovpnent['cport'], used_port_list())) { $ovpnent['cport'] = getnxt_port(); } } } else { /* Creating a new entry */ $ovpnent = array(); if (!($ovpnent['if'] = getnxt_if($_POST['type']))) { $input_errors[] = "Run out of devices for a tunnel of type {$_POST['type']}"; } $ovpnent['cport'] = getnxt_port(); /* double bridging? */ if ($_POST['bridge'] && $_POST['type'] == "tap" && $_POST['authentication_method'] == "rsasig") { $retval = check_bridging($_POST['bridge']); if (!empty($retval)) { $input_errors[] = $retval; } } } if (!$input_errors) { $ovpnent['enable'] = isset($_POST['disabled']) ? false : true; $ovpnent['type'] = $_POST['type']; $ovpnent['authentication_method'] = $_POST['authentication_method']; $ovpnent['proto'] = $_POST['proto']; $ovpnent['sport'] = $_POST['sport']; $ovpnent['ver'] = $_POST['ver'];