From f432e364b2acdf561eaaef02d110c821ab4cb451 Mon Sep 17 00:00:00 2001 From: Matthew Grooms Date: Tue, 26 Aug 2008 23:49:04 +0000 Subject: Set some important default values for the new OpenVPN interface screens. Add functions and interface code to handle local port conflict detection and resolution. --- usr/local/www/vpn_openvpn_client.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'usr/local/www/vpn_openvpn_client.php') diff --git a/usr/local/www/vpn_openvpn_client.php b/usr/local/www/vpn_openvpn_client.php index 4f42e40..107edf3 100644 --- a/usr/local/www/vpn_openvpn_client.php +++ b/usr/local/www/vpn_openvpn_client.php @@ -65,6 +65,11 @@ if ($_GET['act'] == "del") { $savemsg = gettext("Client successfully deleted")."
"; } +if($_GET['act']=="new"){ + $pconfig['interface'] = "wan"; + $pconfig['server_port'] = 1194; +} + if($_GET['act']=="edit"){ if (isset($id) && $a_client[$id]) { @@ -101,7 +106,21 @@ if ($_POST) { unset($input_errors); $pconfig = $_POST; + if (isset($id) && $a_server[$id]) + $vpnid = $a_server[$id]['vpnid']; + else + $vpnid = 0; + /* input validation */ + if ($pconfig['local_port']) { + + if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) + $input_errors[] = $result; + + if (openvpn_port_used($pconfig['protocol'], $pconfig['local_port']) != $vpnid) + $input_errors[] = "The specified 'Local port' is in use. Please select another value"; + } + if ($result = openvpn_validate_host($pconfig['server_addr'], 'Server host or address')) $input_errors[] = $result; @@ -142,8 +161,8 @@ if ($_POST) { $client = array(); - if (isset($id) && $a_client[$id]) - $client['vpnid'] = $a_client[$id]['vpnid']; + if ($vpnid) + $client['vpnid'] = $vpnid; else $client['vpnid'] = openvpn_vpnid_next(); -- cgit v1.1