} else { /* Creating a new entry */ $ovpnent = array(); /* port number syntactically valid, so lets check, if it is free */ if ($_POST['port']) { /* new port number */ $bind_list = used_bind_list($_POST['port']); if (in_array($_POST['port'], used_port_list())) { /* port in use, check binding */ if ($_POST['bind_iface'] == "all" || in_array("all", $bind_list) || in_array($_POST['bind_iface'], $bind_list)) { /* binding in use */ $input_errors[] = "Port {$_POST['port']} is already used for another interface."; } } } if (!($ovpnent['tun_iface'] = getnxt_if($_POST['type']))) { $input_errors[] = "Run out of devices for a tunnel of type {$_POST['type']}"; } /* double bridging? */ if ($ovpnent['bridge'] != $_POST['bridge']) { /* 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;
} } /* Test Server type hasn't changed */ 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'];