Project

General

Profile

Download (76 KB) Statistics
| Branch: | Tag: | Revision:
1 d799787e Matthew Grooms
<?php 
2
/*
3
	vpn_openvpn_server.php
4
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	All rights reserved. 
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
##|+PRIV
31
##|*IDENT=page-openvpn-server
32
##|*NAME=OpenVPN: Server page
33
##|*DESCR=Allow access to the 'OpenVPN: Server' page.
34
##|*MATCH=vpn_openvpn_server.php*
35
##|-PRIV
36
37
require("guiconfig.inc");
38 d84bd468 Ermal Lu?i
require_once("openvpn.inc");
39 d799787e Matthew Grooms
40
if (!is_array($config['openvpn']['openvpn-server']))
41
	$config['openvpn']['openvpn-server'] = array();
42
43
$a_server = &$config['openvpn']['openvpn-server'];
44
45 428e66b6 jim-p
if (!is_array($config['ca']))
46
	$config['ca'] = array();
47
48
$a_ca =& $config['ca'];
49
50
if (!is_array($config['cert']))
51
	$config['cert'] = array();
52
53
$a_cert =& $config['cert'];
54
55
if (!is_array($config['crl']))
56
	$config['crl'] = array();
57
58
$a_crl =& $config['crl'];
59
60 c1f95f5c jim-p
foreach ($a_crl as $cid => $acrl)
61
	if (!isset($acrl['refid']))
62
		unset ($a_crl[$cid]);
63
64 e41ec584 Renato Botelho
if (is_numericint($_GET['id']))
65
	$id = $_GET['id'];
66
if (isset($_POST['id']) && is_numericint($_POST['id']))
67 d799787e Matthew Grooms
	$id = $_POST['id'];
68
69
$act = $_GET['act'];
70
if (isset($_POST['act']))
71
	$act = $_POST['act'];
72
73 6d9b1074 jim-p
if (isset($id) && $a_server[$id])
74
	$vpnid = $a_server[$id]['vpnid'];
75
else
76
	$vpnid = 0;
77
78 d799787e Matthew Grooms
if ($_GET['act'] == "del") {
79
80 767cf960 jim-p
	if (!isset($a_server[$id])) {
81 d799787e Matthew Grooms
		pfSenseHeader("vpn_openvpn_server.php");
82
		exit;
83
	}
84 767cf960 jim-p
	if (!empty($a_server[$id]))
85
		openvpn_delete('server', $a_server[$id]);
86 d799787e Matthew Grooms
	unset($a_server[$id]);
87
	write_config();
88 8cd558b6 ayvis
	$savemsg = gettext("Server successfully deleted")."<br />";
89 d799787e Matthew Grooms
}
90
91 f432e364 Matthew Grooms
if($_GET['act']=="new"){
92 3c11bd3c Matthew Grooms
	$pconfig['autokey_enable'] = "yes";
93
	$pconfig['tlsauth_enable'] = "yes";
94
	$pconfig['autotls_enable'] = "yes";
95 fe787fc7 Matthew Grooms
	$pconfig['dh_length'] = 1024;
96 4936ff53 jim-p
	$pconfig['dev_mode'] = "tun";
97 f432e364 Matthew Grooms
	$pconfig['interface'] = "wan";
98 8cd0a3fa jim-p
	$pconfig['local_port'] = openvpn_port_next('UDP');
99 f432e364 Matthew Grooms
	$pconfig['pool_enable'] = "yes";
100 41936acc jim-p
	$pconfig['cert_depth'] = 1;
101 b9e9903d Dmitriy K.
	$pconfig['verbosity_level'] = 1; // Default verbosity is 1
102 97d5b59b jim-p
	// OpenVPN Defaults to SHA1
103
	$pconfig['digest'] = "SHA1";
104 f432e364 Matthew Grooms
}
105
106 d799787e Matthew Grooms
if($_GET['act']=="edit"){
107
108
	if (isset($id) && $a_server[$id]) {
109 870318b9 Ermal Lu?i
		$pconfig['disable'] = isset($a_server[$id]['disable']);
110 3c11bd3c Matthew Grooms
		$pconfig['mode'] = $a_server[$id]['mode'];
111 d799787e Matthew Grooms
		$pconfig['protocol'] = $a_server[$id]['protocol'];
112 e8a58de4 Ermal Lu?i
		$pconfig['authmode'] = $a_server[$id]['authmode'];
113 4936ff53 jim-p
		$pconfig['dev_mode'] = $a_server[$id]['dev_mode'];
114 d799787e Matthew Grooms
		$pconfig['interface'] = $a_server[$id]['interface'];
115 67b0902f pierrepomes
		if (!empty($a_server[$id]['ipaddr'])) {
116
			$pconfig['interface'] = $pconfig['interface'] . '|' . $a_server[$id]['ipaddr'];
117
		}
118 d799787e Matthew Grooms
		$pconfig['local_port'] = $a_server[$id]['local_port'];
119
		$pconfig['description'] = $a_server[$id]['description'];
120 a9a613dd Scott Ullrich
		$pconfig['custom_options'] = $a_server[$id]['custom_options'];
121 d799787e Matthew Grooms
122 3c11bd3c Matthew Grooms
		if ($pconfig['mode'] != "p2p_shared_key") {
123
			if ($a_server[$id]['tls']) {
124
				$pconfig['tlsauth_enable'] = "yes";
125
				$pconfig['tls'] = base64_decode($a_server[$id]['tls']);
126
			}
127 fe787fc7 Matthew Grooms
			$pconfig['caref'] = $a_server[$id]['caref'];
128 6db02381 jim-p
			$pconfig['crlref'] = $a_server[$id]['crlref'];
129 fe787fc7 Matthew Grooms
			$pconfig['certref'] = $a_server[$id]['certref'];
130
			$pconfig['dh_length'] = $a_server[$id]['dh_length'];
131 41936acc jim-p
			if (isset($a_server[$id]['cert_depth']))
132
				$pconfig['cert_depth'] = $a_server[$id]['cert_depth'];
133
			else
134
				$pconfig['cert_depth'] = 1;
135 94823361 jim-p
			if ($pconfig['mode'] == "server_tls_user")
136
				$pconfig['strictusercn'] = $a_server[$id]['strictusercn'];
137 3c11bd3c Matthew Grooms
		} else
138
			$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
139 d799787e Matthew Grooms
		$pconfig['crypto'] = $a_server[$id]['crypto'];
140 97d5b59b jim-p
		// OpenVPN Defaults to SHA1 if unset
141
		$pconfig['digest'] = !empty($a_server[$id]['digest']) ? $a_server[$id]['digest'] : "SHA1";
142 582c58ae jim-p
		$pconfig['engine'] = $a_server[$id]['engine'];
143 d799787e Matthew Grooms
144
		$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
145 b1ba04cf Seth Mos
		$pconfig['tunnel_networkv6'] = $a_server[$id]['tunnel_networkv6'];
146 1ab6bdb5 jim-p
147 d799787e Matthew Grooms
		$pconfig['remote_network'] = $a_server[$id]['remote_network'];
148 4856df9b jim-p
		$pconfig['remote_networkv6'] = $a_server[$id]['remote_networkv6'];
149 d799787e Matthew Grooms
		$pconfig['gwredir'] = $a_server[$id]['gwredir'];
150
		$pconfig['local_network'] = $a_server[$id]['local_network'];
151 b1ba04cf Seth Mos
		$pconfig['local_networkv6'] = $a_server[$id]['local_networkv6'];
152 d799787e Matthew Grooms
		$pconfig['maxclients'] = $a_server[$id]['maxclients'];
153
		$pconfig['compression'] = $a_server[$id]['compression'];
154 1cb0b40a Matthew Grooms
		$pconfig['passtos'] = $a_server[$id]['passtos'];
155 d799787e Matthew Grooms
		$pconfig['client2client'] = $a_server[$id]['client2client'];
156
157 65ff8497 jim-p
		$pconfig['dynamic_ip'] = $a_server[$id]['dynamic_ip'];
158 d799787e Matthew Grooms
		$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
159 ee55ce7d jim-p
		$pconfig['topology_subnet'] = $a_server[$id]['topology_subnet'];
160 d799787e Matthew Grooms
161 1ab6bdb5 jim-p
		$pconfig['serverbridge_dhcp'] = $a_server[$id]['serverbridge_dhcp'];
162
		$pconfig['serverbridge_interface'] = $a_server[$id]['serverbridge_interface'];
163
		$pconfig['serverbridge_dhcp_start'] = $a_server[$id]['serverbridge_dhcp_start'];
164
		$pconfig['serverbridge_dhcp_end'] = $a_server[$id]['serverbridge_dhcp_end'];
165
166 d799787e Matthew Grooms
		$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
167
		if ($pconfig['dns_domain'])
168
			$pconfig['dns_domain_enable'] = true;
169
170
		$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
171
		$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
172
		$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
173
		$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
174
		if ($pconfig['dns_server1'] ||
175
			$pconfig['dns_server2'] ||
176
			$pconfig['dns_server3'] ||
177
			$pconfig['dns_server4'])
178
			$pconfig['dns_server_enable'] = true;
179
180
		$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
181
		$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
182
		if ($pconfig['ntp_server1'] ||
183
			$pconfig['ntp_server2'])
184
			$pconfig['ntp_server_enable'] = true;
185
186
		$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
187
		$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
188
		$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
189
190
		$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
191
		$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
192
		if ($pconfig['wins_server1'] ||
193
			$pconfig['wins_server2'])
194
			$pconfig['wins_server_enable'] = true;
195
196 faf61f12 Phil Davis
		$pconfig['client_mgmt_port'] = $a_server[$id]['client_mgmt_port'];
197
		if ($pconfig['client_mgmt_port'])
198
			$pconfig['client_mgmt_port_enable'] = true;
199
200 d799787e Matthew Grooms
		$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
201
		if ($pconfig['nbdd_server1'])
202
			$pconfig['nbdd_server_enable'] = true;
203 3c11bd3c Matthew Grooms
204
		// just in case the modes switch
205
		$pconfig['autokey_enable'] = "yes";
206
		$pconfig['autotls_enable'] = "yes";
207 bca35cff jim-p
208
		$pconfig['duplicate_cn'] = isset($a_server[$id]['duplicate_cn']);
209 b9e9903d Dmitriy K.
		
210
		$pconfig['no_tun_ipv6'] = $a_server[$id]['no_tun_ipv6'];
211 c7264382 Dmitriy K.
		if (isset($a_server[$id]['verbosity_level']))
212
			$pconfig['verbosity_level'] = $a_server[$id]['verbosity_level'];
213
		else
214
			$pconfig['verbosity_level'] = 1; // Default verbosity is 1
215 d799787e Matthew Grooms
	}
216
}
217
if ($_POST) {
218
219
	unset($input_errors);
220
	$pconfig = $_POST;
221
222 f432e364 Matthew Grooms
	if (isset($id) && $a_server[$id])
223
		$vpnid = $a_server[$id]['vpnid'];
224
	else
225
		$vpnid = 0;
226
227 198bb449 jim-p
	list($iv_iface, $iv_ip) = explode ("|",$pconfig['interface']);
228
	if (is_ipaddrv4($iv_ip) && (stristr($pconfig['protocol'], "6") !== false)) {
229
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
230
	} elseif (is_ipaddrv6($iv_ip) && (stristr($pconfig['protocol'], "6") === false)) {
231
		$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
232 489f484c jim-p
	} elseif ((stristr($pconfig['protocol'], "6") === false) && !get_interface_ip($iv_iface) && ($pconfig['interface'] != "any")) {
233 198bb449 jim-p
		$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
234 489f484c jim-p
	} elseif ((stristr($pconfig['protocol'], "6") !== false) && !get_interface_ipv6($iv_iface) && ($pconfig['interface'] != "any")) {
235 198bb449 jim-p
		$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
236
	}
237
238 98c0c87a jim-p
	if ($pconfig['mode'] != "p2p_shared_key")
239 3c11bd3c Matthew Grooms
		$tls_mode = true;
240
	else
241
		$tls_mode = false;
242
243 b0b6d575 jim-p
	if (empty($pconfig['authmode']) && (($pconfig['mode'] == "server_user") || ($pconfig['mode'] == "server_tls_user")))
244
		$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
245
246 d799787e Matthew Grooms
	/* input validation */
247
	if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
248
		$input_errors[] = $result;
249
250 a28d40cb jim-p
	if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4"))
251 d799787e Matthew Grooms
		$input_errors[] = $result;
252
253 a28d40cb jim-p
	if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6"))
254 d799787e Matthew Grooms
		$input_errors[] = $result;
255
256 a28d40cb jim-p
	if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4"))
257
		$input_errors[] = $result;
258
259
	if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6"))
260
		$input_errors[] = $result;
261
262
	if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4"))
263
		$input_errors[] = $result;
264
265
	if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6"))
266 d799787e Matthew Grooms
		$input_errors[] = $result;
267
268 49b76122 Renato Botelho
	$portused = openvpn_port_used($pconfig['protocol'], $pconfig['interface'], $pconfig['local_port'], $vpnid);
269 5accf130 jim-p
	if (($portused != $vpnid) && ($portused != 0))
270 4d8b3382 Carlos Eduardo Ramos
		$input_errors[] = gettext("The specified 'Local port' is in use. Please select another value");
271 f432e364 Matthew Grooms
272 89e6e210 jim-p
	if ($pconfig['autokey_enable'])
273
		$pconfig['shared_key'] = openvpn_create_key();
274
275 3c11bd3c Matthew Grooms
	if (!$tls_mode && !$pconfig['autokey_enable'])
276 d799787e Matthew Grooms
		if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
277
			!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
278 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'Shared Key' does not appear to be valid");
279 3c11bd3c Matthew Grooms
280
	if ($tls_mode && $pconfig['tlsauth_enable'] && !$pconfig['autotls_enable'])
281
		if (!strstr($pconfig['tls'], "-----BEGIN OpenVPN Static key V1-----") ||
282
			!strstr($pconfig['tls'], "-----END OpenVPN Static key V1-----"))
283 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'TLS Authentication Key' does not appear to be valid");
284 d799787e Matthew Grooms
285
	if ($pconfig['dns_server_enable']) {
286
		if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
287 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
288 d799787e Matthew Grooms
		if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
289 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
290 d799787e Matthew Grooms
		if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
291 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
292 d799787e Matthew Grooms
		if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
293 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
294 d799787e Matthew Grooms
	}
295
296
	if ($pconfig['ntp_server_enable']) {
297
		if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
298 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
299 d799787e Matthew Grooms
		if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
300 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
301 d799787e Matthew Grooms
		if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
302 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
303 d799787e Matthew Grooms
		if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
304 4d8b3382 Carlos Eduardo Ramos
			$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
305 d799787e Matthew Grooms
	}
306
307
	if ($pconfig['netbios_enable']) {
308
		if ($pconfig['wins_server_enable']) {
309
			if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
310 4d8b3382 Carlos Eduardo Ramos
				$input_errors[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
311 d799787e Matthew Grooms
			if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
312 4d8b3382 Carlos Eduardo Ramos
				$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
313 d799787e Matthew Grooms
		}
314
		if ($pconfig['nbdd_server_enable'])
315
			if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
316 4d8b3382 Carlos Eduardo Ramos
				$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
317 d799787e Matthew Grooms
	}
318
319 faf61f12 Phil Davis
	if ($pconfig['client_mgmt_port_enable']) {
320
		if ($result = openvpn_validate_port($pconfig['client_mgmt_port'], 'Client management port'))
321
			$input_errors[] = $result;
322
	}
323
324 d799787e Matthew Grooms
	if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
325 4d8b3382 Carlos Eduardo Ramos
		$input_errors[] = gettext("The field 'Concurrent connections' must be numeric.");
326 d799787e Matthew Grooms
327 21c776dd jim-p
	/* If we are not in shared key mode, then we need the CA/Cert. */
328
	if ($pconfig['mode'] != "p2p_shared_key") {
329 872d9195 Matthew Grooms
		$reqdfields = explode(" ", "caref certref");
330 fe6d7a55 jim-p
		$reqdfieldsn = array(gettext("Certificate Authority"),gettext("Certificate"));
331 21c776dd jim-p
	} elseif (!$pconfig['autokey_enable']) {
332
		/* We only need the shared key filled in if we are in shared key mode and autokey is not selected. */
333
		$reqdfields = array('shared_key');
334 4d8b3382 Carlos Eduardo Ramos
		$reqdfieldsn = array(gettext('Shared key'));
335 d799787e Matthew Grooms
	}
336
337 1ab6bdb5 jim-p
	if ($pconfig['dev_mode'] != "tap") {
338
		$reqdfields[] = 'tunnel_network';
339
		$reqdfieldsn[] = gettext('Tunnel network');
340
	} else {
341 74a556a3 jim-p
		if ($pconfig['serverbridge_dhcp'] && $pconfig['tunnel_network'])
342
			$input_errors[] = gettext("Using a tunnel network and server bridge settings together is not allowed.");
343 1ab6bdb5 jim-p
		if (($pconfig['serverbridge_dhcp_start'] && !$pconfig['serverbridge_dhcp_end']) 
344
		|| (!$pconfig['serverbridge_dhcp_start'] && $pconfig['serverbridge_dhcp_end']))
345
			$input_errors[] = gettext("Server Bridge DHCP Start and End must both be empty, or defined.");
346
		if (($pconfig['serverbridge_dhcp_start'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_start'])))
347
			$input_errors[] = gettext("Server Bridge DHCP Start must be an IPv4 address.");
348
		if (($pconfig['serverbridge_dhcp_end'] && !is_ipaddrv4($pconfig['serverbridge_dhcp_end'])))
349
			$input_errors[] = gettext("Server Bridge DHCP End must be an IPv4 address.");
350
		if (ip2ulong($pconfig['serverbridge_dhcp_start']) > ip2ulong($pconfig['serverbridge_dhcp_end']))
351
			$input_errors[] = gettext("The Server Bridge DHCP range is invalid (start higher than end).");
352
	}
353 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
354 d799787e Matthew Grooms
	
355
	if (!$input_errors) {
356
357
		$server = array();
358
359 da601f8e PiBa-NL
		if ($id && $pconfig['dev_mode'] <> $a_server[$id]['dev_mode'])
360
			openvpn_delete('server', $a_server[$id]);// delete(rename) old interface so a new TUN or TAP interface can be created.
361
362 f432e364 Matthew Grooms
		if ($vpnid)
363
			$server['vpnid'] = $vpnid;
364 e28120e5 Matthew Grooms
		else
365 d799787e Matthew Grooms
			$server['vpnid'] = openvpn_vpnid_next();
366
367 870318b9 Ermal Lu?i
		if ($_POST['disable'] == "yes")
368
			$server['disable'] = true;
369 3c11bd3c Matthew Grooms
		$server['mode'] = $pconfig['mode'];
370 8a47c190 Ermal Lu?i
		if (!empty($pconfig['authmode']))
371
			$server['authmode'] = implode(",", $pconfig['authmode']);
372 d799787e Matthew Grooms
		$server['protocol'] = $pconfig['protocol'];
373 4936ff53 jim-p
		$server['dev_mode'] = $pconfig['dev_mode'];
374 67b0902f pierrepomes
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
375 d799787e Matthew Grooms
		$server['local_port'] = $pconfig['local_port'];
376
		$server['description'] = $pconfig['description'];
377 e3bbd29a Ermal
		$server['custom_options'] = str_replace("\r\n", "\n", $pconfig['custom_options']);
378 d799787e Matthew Grooms
379 3c11bd3c Matthew Grooms
		if ($tls_mode) {
380
			if ($pconfig['tlsauth_enable']) {
381
				if ($pconfig['autotls_enable'])
382
					$pconfig['tls'] = openvpn_create_key();
383
				$server['tls'] = base64_encode($pconfig['tls']);
384
			}
385 fe787fc7 Matthew Grooms
			$server['caref'] = $pconfig['caref'];
386 6db02381 jim-p
			$server['crlref'] = $pconfig['crlref'];
387 fe787fc7 Matthew Grooms
			$server['certref'] = $pconfig['certref'];
388
			$server['dh_length'] = $pconfig['dh_length'];
389 98963f27 jim-p
			$server['cert_depth'] = $pconfig['cert_depth'];
390 94823361 jim-p
			if ($pconfig['mode'] == "server_tls_user")
391
				$server['strictusercn'] = $pconfig['strictusercn'];
392 3c11bd3c Matthew Grooms
		} else {
393
			$server['shared_key'] = base64_encode($pconfig['shared_key']);
394 d799787e Matthew Grooms
		}
395
		$server['crypto'] = $pconfig['crypto'];
396 97d5b59b jim-p
		$server['digest'] = $pconfig['digest'];
397 582c58ae jim-p
		$server['engine'] = $pconfig['engine'];
398 d799787e Matthew Grooms
399
		$server['tunnel_network'] = $pconfig['tunnel_network'];
400 b1ba04cf Seth Mos
		$server['tunnel_networkv6'] = $pconfig['tunnel_networkv6'];
401 d799787e Matthew Grooms
		$server['remote_network'] = $pconfig['remote_network'];
402 4856df9b jim-p
		$server['remote_networkv6'] = $pconfig['remote_networkv6'];
403 d799787e Matthew Grooms
		$server['gwredir'] = $pconfig['gwredir'];
404
		$server['local_network'] = $pconfig['local_network'];
405 b1ba04cf Seth Mos
		$server['local_networkv6'] = $pconfig['local_networkv6'];
406 d799787e Matthew Grooms
		$server['maxclients'] = $pconfig['maxclients'];
407
		$server['compression'] = $pconfig['compression'];
408 1cb0b40a Matthew Grooms
		$server['passtos'] = $pconfig['passtos'];
409 d799787e Matthew Grooms
		$server['client2client'] = $pconfig['client2client'];
410
411 65ff8497 jim-p
		$server['dynamic_ip'] = $pconfig['dynamic_ip'];
412 d799787e Matthew Grooms
		$server['pool_enable'] = $pconfig['pool_enable'];
413 ee55ce7d jim-p
		$server['topology_subnet'] = $pconfig['topology_subnet'];
414 d799787e Matthew Grooms
415 1ab6bdb5 jim-p
		$server['serverbridge_dhcp'] = $pconfig['serverbridge_dhcp'];
416
		$server['serverbridge_interface'] = $pconfig['serverbridge_interface'];
417
		$server['serverbridge_dhcp_start'] = $pconfig['serverbridge_dhcp_start'];
418
		$server['serverbridge_dhcp_end'] = $pconfig['serverbridge_dhcp_end'];
419
420 d799787e Matthew Grooms
		if ($pconfig['dns_domain_enable'])
421
			$server['dns_domain'] = $pconfig['dns_domain'];
422
423
		if ($pconfig['dns_server_enable']) {
424
			$server['dns_server1'] = $pconfig['dns_server1'];
425
			$server['dns_server2'] = $pconfig['dns_server2'];
426
			$server['dns_server3'] = $pconfig['dns_server3'];
427
			$server['dns_server4'] = $pconfig['dns_server4'];
428
		}
429
430
		if ($pconfig['ntp_server_enable']) {
431
			$server['ntp_server1'] = $pconfig['ntp_server1'];
432
			$server['ntp_server2'] = $pconfig['ntp_server2'];
433
		}
434
435
		$server['netbios_enable'] = $pconfig['netbios_enable'];
436
		$server['netbios_ntype'] = $pconfig['netbios_ntype'];
437
		$server['netbios_scope'] = $pconfig['netbios_scope'];
438 b9e9903d Dmitriy K.
		 
439
		$server['no_tun_ipv6'] = $pconfig['no_tun_ipv6'];
440
		$server['verbosity_level'] = $pconfig['verbosity_level'];
441 d799787e Matthew Grooms
442
		if ($pconfig['netbios_enable']) {
443
444
			if ($pconfig['wins_server_enable']) {
445
				$server['wins_server1'] = $pconfig['wins_server1'];
446
				$server['wins_server2'] = $pconfig['wins_server2'];
447
			}
448
449
			if ($pconfig['dns_server_enable'])
450
				$server['nbdd_server1'] = $pconfig['nbdd_server1'];
451
		}
452 bca35cff jim-p
453 faf61f12 Phil Davis
		if ($pconfig['client_mgmt_port_enable'])
454
			$server['client_mgmt_port'] = $pconfig['client_mgmt_port'];
455
456 bca35cff jim-p
		if ($_POST['duplicate_cn'] == "yes")
457
			$server['duplicate_cn'] = true;
458
459 d799787e Matthew Grooms
		if (isset($id) && $a_server[$id])
460
			$a_server[$id] = $server;
461
		else
462
			$a_server[] = $server;
463
464 dc408939 Matthew Grooms
		openvpn_resync('server', $server);
465 d799787e Matthew Grooms
		write_config();
466
		
467
		header("Location: vpn_openvpn_server.php");
468
		exit;
469
	}
470 8a47c190 Ermal Lu?i
	if (!empty($pconfig['authmode']))
471
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
472 d799787e Matthew Grooms
}
473 6d9b1074 jim-p
$pgtitle = array(gettext("OpenVPN"), gettext("Server"));
474
$shortcut_section = "openvpn";
475 d799787e Matthew Grooms
476
include("head.inc");
477
478
?>
479
480
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
481
<?php include("fbegin.inc"); ?>
482 91f026b0 ayvis
<script type="text/javascript">
483 2b5c9e58 Colin Fleming
//<![CDATA[
484 d799787e Matthew Grooms
485 3c11bd3c Matthew Grooms
function mode_change() {
486
	index = document.iform.mode.selectedIndex;
487
	value = document.iform.mode.options[index].value;
488 d799787e Matthew Grooms
	switch(value) {
489 3c11bd3c Matthew Grooms
		case "p2p_tls":
490
		case "server_tls":
491
		case "server_user":
492 94823361 jim-p
			document.getElementById("tls").style.display="";
493
			document.getElementById("tls_ca").style.display="";
494
			document.getElementById("tls_crl").style.display="";
495
			document.getElementById("tls_cert").style.display="";
496
			document.getElementById("tls_dh").style.display="";
497 98963f27 jim-p
			document.getElementById("cert_depth").style.display="";
498 94823361 jim-p
			document.getElementById("strictusercn").style.display="none";
499
			document.getElementById("psk").style.display="none";
500
			break;
501 3c11bd3c Matthew Grooms
		case "server_tls_user":
502
			document.getElementById("tls").style.display="";
503
			document.getElementById("tls_ca").style.display="";
504 6db02381 jim-p
			document.getElementById("tls_crl").style.display="";
505 3c11bd3c Matthew Grooms
			document.getElementById("tls_cert").style.display="";
506 fe787fc7 Matthew Grooms
			document.getElementById("tls_dh").style.display="";
507 98963f27 jim-p
			document.getElementById("cert_depth").style.display="";
508 94823361 jim-p
			document.getElementById("strictusercn").style.display="";
509 d799787e Matthew Grooms
			document.getElementById("psk").style.display="none";
510
			break;
511 3c11bd3c Matthew Grooms
		case "p2p_shared_key":
512
			document.getElementById("tls").style.display="none";
513
			document.getElementById("tls_ca").style.display="none";
514 6db02381 jim-p
			document.getElementById("tls_crl").style.display="none";
515 3c11bd3c Matthew Grooms
			document.getElementById("tls_cert").style.display="none";
516 fe787fc7 Matthew Grooms
			document.getElementById("tls_dh").style.display="none";
517 98963f27 jim-p
			document.getElementById("cert_depth").style.display="none";
518 94823361 jim-p
			document.getElementById("strictusercn").style.display="none";
519 d799787e Matthew Grooms
			document.getElementById("psk").style.display="";
520
			break;
521
	}
522 3c11bd3c Matthew Grooms
	switch(value) {
523
		case "p2p_shared_key":
524
			document.getElementById("client_opts").style.display="none";
525 415bddea jim-p
			document.getElementById("remote_optsv4").style.display="";
526
			document.getElementById("remote_optsv6").style.display="";
527 a2ff08f8 jim-p
			document.getElementById("gwredir_opts").style.display="none";
528 4856df9b jim-p
			document.getElementById("local_optsv4").style.display="none";
529
			document.getElementById("local_optsv6").style.display="none";
530 b008c1eb jim-p
			document.getElementById("authmodetr").style.display="none";
531 107794cc jim-p
			document.getElementById("inter_client_communication").style.display="none";
532 b008c1eb jim-p
			break;
533
		case "p2p_tls":
534
			document.getElementById("client_opts").style.display="none";
535 415bddea jim-p
			document.getElementById("remote_optsv4").style.display="";
536
			document.getElementById("remote_optsv6").style.display="";
537 a2ff08f8 jim-p
			document.getElementById("gwredir_opts").style.display="";
538 4856df9b jim-p
			document.getElementById("local_optsv4").style.display="";
539
			document.getElementById("local_optsv6").style.display="";
540 e8a58de4 Ermal Lu?i
			document.getElementById("authmodetr").style.display="none";
541 107794cc jim-p
			document.getElementById("inter_client_communication").style.display="none";
542 3c11bd3c Matthew Grooms
			break;
543 e8a58de4 Ermal Lu?i
		case "server_user":
544
                case "server_tls_user":
545
			document.getElementById("authmodetr").style.display="";
546 54b9de56 Ermal Lu?i
			document.getElementById("client_opts").style.display="";
547 415bddea jim-p
			document.getElementById("remote_optsv4").style.display="none";
548
			document.getElementById("remote_optsv6").style.display="none";
549 a2ff08f8 jim-p
			document.getElementById("gwredir_opts").style.display="";
550 4856df9b jim-p
			document.getElementById("local_optsv4").style.display="";
551
			document.getElementById("local_optsv6").style.display="";
552 107794cc jim-p
			document.getElementById("inter_client_communication").style.display="";
553 54b9de56 Ermal Lu?i
			break;
554
		case "server_tls":
555
			document.getElementById("authmodetr").style.display="none";
556 3c11bd3c Matthew Grooms
		default:
557
			document.getElementById("client_opts").style.display="";
558 415bddea jim-p
			document.getElementById("remote_optsv4").style.display="none";
559
			document.getElementById("remote_optsv6").style.display="none";
560 a2ff08f8 jim-p
			document.getElementById("gwredir_opts").style.display="";
561 4856df9b jim-p
			document.getElementById("local_optsv4").style.display="";
562
			document.getElementById("local_optsv6").style.display="";
563 107794cc jim-p
			document.getElementById("inter_client_communication").style.display="";
564 3c11bd3c Matthew Grooms
			break;
565
	}
566 a2ff08f8 jim-p
	gwredir_change();
567 3c11bd3c Matthew Grooms
}
568
569
function autokey_change() {
570
571 f54712b6 jim-p
	if ((document.iform.autokey_enable != null) && (document.iform.autokey_enable.checked))
572 3c11bd3c Matthew Grooms
		document.getElementById("autokey_opts").style.display="none";
573
	else
574
		document.getElementById("autokey_opts").style.display="";
575
}
576
577
function tlsauth_change() {
578
579
<?php if (!$pconfig['tls']): ?>
580
	if (document.iform.tlsauth_enable.checked)
581
		document.getElementById("tlsauth_opts").style.display="";
582
	else
583
		document.getElementById("tlsauth_opts").style.display="none";
584
<?php endif; ?>
585
586
	autotls_change();
587
}
588
589
function autotls_change() {
590
591
<?php if (!$pconfig['tls']): ?>
592
	autocheck = document.iform.autotls_enable.checked;
593
<?php else: ?>
594
	autocheck = false;
595
<?php endif; ?>
596
597
	if (document.iform.tlsauth_enable.checked && !autocheck)
598
		document.getElementById("autotls_opts").style.display="";
599
	else
600
		document.getElementById("autotls_opts").style.display="none";
601 d799787e Matthew Grooms
}
602
603
function gwredir_change() {
604
605 fd96a3fc bcyrill
	if (document.iform.gwredir.checked) {
606
		document.getElementById("local_optsv4").style.display="none";
607
		document.getElementById("local_optsv6").style.display="none";
608
	} else {
609
		document.getElementById("local_optsv4").style.display="";
610
		document.getElementById("local_optsv6").style.display="";
611
	}
612 d799787e Matthew Grooms
}
613
614
function dns_domain_change() {
615
616
	if (document.iform.dns_domain_enable.checked)
617
		document.getElementById("dns_domain_data").style.display="";
618
	else
619
		document.getElementById("dns_domain_data").style.display="none";
620
}
621
622
function dns_server_change() {
623
624
	if (document.iform.dns_server_enable.checked)
625
		document.getElementById("dns_server_data").style.display="";
626
	else
627
		document.getElementById("dns_server_data").style.display="none";
628
}
629
630
function wins_server_change() {
631
632
	if (document.iform.wins_server_enable.checked)
633
		document.getElementById("wins_server_data").style.display="";
634
	else
635
		document.getElementById("wins_server_data").style.display="none";
636
}
637
638 faf61f12 Phil Davis
function client_mgmt_port_change() {
639
640
	if (document.iform.client_mgmt_port_enable.checked)
641
		document.getElementById("client_mgmt_port_data").style.display="";
642
	else
643
		document.getElementById("client_mgmt_port_data").style.display="none";
644
}
645
646 d799787e Matthew Grooms
function ntp_server_change() {
647
648
	if (document.iform.ntp_server_enable.checked)
649
		document.getElementById("ntp_server_data").style.display="";
650
	else
651
		document.getElementById("ntp_server_data").style.display="none";
652
}
653
654
function netbios_change() {
655
656
	if (document.iform.netbios_enable.checked) {
657
		document.getElementById("netbios_data").style.display="";
658
		document.getElementById("wins_opts").style.display="";
659
	} else {
660
		document.getElementById("netbios_data").style.display="none";
661
		document.getElementById("wins_opts").style.display="none";
662
	}
663
}
664
665 1ab6bdb5 jim-p
function tuntap_change() {
666
667
	mindex = document.iform.mode.selectedIndex;
668
	mvalue = document.iform.mode.options[mindex].value;
669
670
	switch(mvalue) {
671
		case "p2p_tls":
672
		case "p2p_shared_key":
673
			p2p = true;
674
			break;
675
		default:
676
			p2p = false;
677
			break;
678
	}
679
680
	index = document.iform.dev_mode.selectedIndex;
681
	value = document.iform.dev_mode.options[index].value;
682
	switch(value) {
683
		case "tun":
684 caf58ced Dmitriy K.
			document.getElementById("chkboxNoTunIPv6").style.display="";
685 74a556a3 jim-p
			document.getElementById("ipv4_tunnel_network").className="vncellreq";
686 1ab6bdb5 jim-p
			document.getElementById("serverbridge_dhcp").style.display="none";
687
			document.getElementById("serverbridge_interface").style.display="none";
688
			document.getElementById("serverbridge_dhcp_start").style.display="none";
689
			document.getElementById("serverbridge_dhcp_end").style.display="none";
690 ee55ce7d jim-p
			document.getElementById("topology_subnet_opt").style.display="";
691 1ab6bdb5 jim-p
			break;
692
		case "tap":
693 caf58ced Dmitriy K.
			document.getElementById("chkboxNoTunIPv6").style.display="none";
694 74a556a3 jim-p
			document.getElementById("ipv4_tunnel_network").className="vncell";
695 1ab6bdb5 jim-p
			if (!p2p) {
696
				document.getElementById("serverbridge_dhcp").style.display="";
697
				document.getElementById("serverbridge_interface").style.display="";
698
				document.getElementById("serverbridge_dhcp_start").style.display="";
699
				document.getElementById("serverbridge_dhcp_end").style.display="";
700 ee55ce7d jim-p
				document.getElementById("topology_subnet_opt").style.display="none";
701 f54712b6 jim-p
				document.iform.serverbridge_dhcp.disabled = false;
702 1ab6bdb5 jim-p
				if (document.iform.serverbridge_dhcp.checked) {
703
					document.iform.serverbridge_interface.disabled = false;
704
					document.iform.serverbridge_dhcp_start.disabled = false;
705
					document.iform.serverbridge_dhcp_end.disabled = false;
706
				} else {
707
					document.iform.serverbridge_interface.disabled = true;
708
					document.iform.serverbridge_dhcp_start.disabled = true;
709
					document.iform.serverbridge_dhcp_end.disabled = true;
710
				}
711
			} else {
712 ee55ce7d jim-p
				document.getElementById("topology_subnet_opt").style.display="none";
713 1ab6bdb5 jim-p
				document.iform.serverbridge_dhcp.disabled = true;
714
				document.iform.serverbridge_interface.disabled = true;
715
				document.iform.serverbridge_dhcp_start.disabled = true;
716
				document.iform.serverbridge_dhcp_end.disabled = true;
717
			}
718
			break;
719
	}
720
}
721 2b5c9e58 Colin Fleming
//]]>
722 d799787e Matthew Grooms
</script>
723
<?php
724 428e66b6 jim-p
if (!$savemsg)
725
	$savemsg = "";
726
727
if ($input_errors)
728
	print_input_errors($input_errors);
729
if ($savemsg)
730
	print_info_box_np($savemsg);
731 d799787e Matthew Grooms
?>
732 2b5c9e58 Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn openvpn server">
733 5a3b0d3b mgrooms
	<tr>
734 d799787e Matthew Grooms
		<td class="tabnavtbl">
735
			<?php 
736
				$tab_array = array();
737
				$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
738
				$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
739
				$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
740 5540aee6 Ermal Lu?i
				$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
741 b63f2e8b Matthew Grooms
				add_package_tabs("OpenVPN", $tab_array);
742 d799787e Matthew Grooms
				display_top_tabs($tab_array);
743
			?>
744
		</td>
745
	</tr>    
746
	<tr>
747
		<td class="tabcont">
748
749
			<?php if($act=="new" || $act=="edit"): ?>
750
751
			<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
752 2b5c9e58 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="general information">
753 47c00c09 Scott Ullrich
					<tr>
754 4d8b3382 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("General information"); ?></td>
755 b63f2e8b Matthew Grooms
					</tr>
756 d799787e Matthew Grooms
					<tr>
757 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Disabled"); ?></td>
758 d799787e Matthew Grooms
						<td width="78%" class="vtable">
759 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="0" cellspacing="0" summary="enable disable server">
760 d799787e Matthew Grooms
								<tr>
761
									<td>
762
										<?php set_checked($pconfig['disable'],$chk); ?>
763 2b5c9e58 Colin Fleming
										<input name="disable" type="checkbox" value="yes" <?=$chk;?> />
764 d799787e Matthew Grooms
									</td>
765
									<td>
766
										&nbsp;
767
										<span class="vexpl">
768 8cd558b6 ayvis
											<strong><?=gettext("Disable this server"); ?></strong><br />
769 d799787e Matthew Grooms
										</span>
770
									</td>
771
								</tr>
772
							</table>
773 4d8b3382 Carlos Eduardo Ramos
							<?=gettext("Set this option to disable this server without removing it from the list"); ?>.
774 d799787e Matthew Grooms
						</td>
775
					</tr>
776 3c11bd3c Matthew Grooms
					<tr>
777
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Mode");?></td>
778
							<td width="78%" class="vtable">
779 1ab6bdb5 jim-p
							<select name='mode' id='mode' class="formselect" onchange='mode_change(); tuntap_change()'>
780 3c11bd3c Matthew Grooms
							<?php
781
								foreach ($openvpn_server_modes as $name => $desc):
782
									$selected = "";
783
									if ($pconfig['mode'] == $name)
784 2b5c9e58 Colin Fleming
										$selected = "selected=\"selected\"";
785 3c11bd3c Matthew Grooms
							?>
786
								<option value="<?=$name;?>" <?=$selected;?>><?=$desc;?></option>
787
							<?php endforeach; ?>
788
							</select>
789
						</td>
790
					</tr>
791 e8a58de4 Ermal Lu?i
					<tr id="authmodetr" style="display:none">
792
                                                <td width="22%" valign="top" class="vncellreq"><?=gettext("Backend for authentication");?></td>
793
                                                        <td width="78%" class="vtable">
794 2b5c9e58 Colin Fleming
                                                        <select name='authmode[]' id='authmode' class="formselect" multiple="multiple" size="<?php echo count($auth_servers); ?>">
795 c61e4626 Ermal Lu?i
							<?php $authmodes = explode(",", $pconfig['authmode']); ?>
796 e8a58de4 Ermal Lu?i
                                                        <?php
797 6306b5dd Ermal Lu?i
								$auth_servers = auth_get_authserver_list();
798 e8a58de4 Ermal Lu?i
                                                                foreach ($auth_servers as $auth_server):
799
                                                                        $selected = "";
800 c61e4626 Ermal Lu?i
                                                                        if (in_array($auth_server['name'], $authmodes))
801 2b5c9e58 Colin Fleming
                                                                                $selected = "selected=\"selected\"";
802 e8a58de4 Ermal Lu?i
                                                        ?>
803
                                                                <option value="<?=$auth_server['name'];?>" <?=$selected;?>><?=$auth_server['name'];?></option>
804
                                                        <?php 	endforeach; ?>
805
                                                        </select>
806
                                                </td>
807
                                        </tr>
808 d799787e Matthew Grooms
					<tr>
809
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
810
							<td width="78%" class="vtable">
811
							<select name='protocol' class="formselect">
812
							<?php
813
								foreach ($openvpn_prots as $prot):
814
									$selected = "";
815
									if ($pconfig['protocol'] == $prot)
816 2b5c9e58 Colin Fleming
										$selected = "selected=\"selected\"";
817 d799787e Matthew Grooms
							?>
818
								<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
819
							<?php endforeach; ?>
820
							</select>
821
							</td>
822
					</tr>
823 bf87b4d7 lgcosta
					<tr>
824
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Device Mode"); ?></td>
825
						<td width="78%" class="vtable">
826 1ab6bdb5 jim-p
							<select name="dev_mode" class="formselect" onchange='tuntap_change()'>
827 bf87b4d7 lgcosta
                                                        <?php
828
                                                                foreach ($openvpn_dev_mode as $device):
829 71edee5e lgcosta
                                                                       $selected = "";
830 4936ff53 jim-p
                                                                       if (! empty($pconfig['dev_mode'])) {
831
                                                                               if ($pconfig['dev_mode'] == $device)
832 2b5c9e58 Colin Fleming
                                                                                       $selected = "selected=\"selected\"";
833 71edee5e lgcosta
                                                                       } else {
834
                                                                               if ($device == "tun")
835 2b5c9e58 Colin Fleming
                                                                                       $selected = "selected=\"selected\"";
836 71edee5e lgcosta
                                                                       }
837 bf87b4d7 lgcosta
                                                        ?>
838
                                                                <option value="<?=$device;?>" <?=$selected;?>><?=$device;?></option>
839
                                                        <?php endforeach; ?>
840
                                                        </select>
841
                                                        </td>
842
                                        </tr>
843 d799787e Matthew Grooms
					<tr>
844 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Interface"); ?></td>
845 d799787e Matthew Grooms
						<td width="78%" class="vtable">
846
							<select name="interface" class="formselect">
847
								<?php
848
									$interfaces = get_configured_interface_with_descr();
849 3d06e8f0 pierrepomes
									$carplist = get_configured_carp_interface_list();
850
									foreach ($carplist as $cif => $carpip)
851 dd62256f Pierre POMES
										$interfaces[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
852 67b0902f pierrepomes
									$aliaslist = get_configured_ip_aliases_list();
853
									foreach ($aliaslist as $aliasip => $aliasif)
854 dd62256f Pierre POMES
										$interfaces[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
855 47c48e28 smos
									$grouplist = return_gateway_groups_array();
856
									foreach ($grouplist as $name => $group) {
857
										if($group['ipprotocol'] != inet)
858
											continue;
859
										if($group[0]['vip'] <> "")
860
											$vipif = $group[0]['vip'];
861
										else
862
											$vipif = $group[0]['int'];
863
										$interfaces[$name] = "GW Group {$name}";
864
									}
865 5c94aa12 jim-p
									$interfaces['lo0'] = "Localhost";
866 67b0902f pierrepomes
									$interfaces['any'] = "any";
867 d799787e Matthew Grooms
									foreach ($interfaces as $iface => $ifacename):
868 1d3bcd2a Matthew Grooms
										$selected = "";
869
										if ($iface == $pconfig['interface'])
870 2b5c9e58 Colin Fleming
											$selected = "selected=\"selected\"";
871 d799787e Matthew Grooms
								?>
872 1d3bcd2a Matthew Grooms
									<option value="<?=$iface;?>" <?=$selected;?>>
873
										<?=htmlspecialchars($ifacename);?>
874
									</option>
875 d799787e Matthew Grooms
								<?php endforeach; ?>
876 8cd558b6 ayvis
							</select> <br />
877 d799787e Matthew Grooms
						</td>
878
					</tr>
879
					<tr>
880
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
881
						<td width="78%" class="vtable">
882 2b5c9e58 Colin Fleming
							<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>" />
883 d799787e Matthew Grooms
						</td>
884
					</tr>
885
					<tr> 
886 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Description"); ?></td>
887 d799787e Matthew Grooms
						<td width="78%" class="vtable"> 
888 2b5c9e58 Colin Fleming
							<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>" />
889 8cd558b6 ayvis
							<br />
890 4d8b3382 Carlos Eduardo Ramos
							<?=gettext("You may enter a description here for your reference (not parsed)"); ?>.
891 d799787e Matthew Grooms
						</td>
892
					</tr>
893
					<tr>
894
						<td colspan="2" class="list" height="12"></td>
895
					</tr>
896
					<tr>
897 4d8b3382 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Cryptographic Settings"); ?></td>
898 d799787e Matthew Grooms
					</tr>
899 3c11bd3c Matthew Grooms
					<tr id="tls">
900 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("TLS Authentication"); ?></td>
901 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
902 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="tls authentication">
903 3c11bd3c Matthew Grooms
								<tr>
904
									<td>
905
										<?php set_checked($pconfig['tlsauth_enable'],$chk); ?>
906 2b5c9e58 Colin Fleming
										<input name="tlsauth_enable" id="tlsauth_enable" type="checkbox" value="yes" <?=$chk;?> onclick="tlsauth_change()" />
907 3c11bd3c Matthew Grooms
									</td>
908
									<td>
909
										<span class="vexpl">
910 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Enable authentication of TLS packets"); ?>.
911 3c11bd3c Matthew Grooms
										</span>
912
									</td>
913
								</tr>
914
							</table>
915
							<?php if (!$pconfig['tls']): ?>
916 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="tlsauth_opts" summary="tls authentication options">
917 3c11bd3c Matthew Grooms
								<tr>
918
									<td>
919
										<?php set_checked($pconfig['autotls_enable'],$chk); ?>
920 2b5c9e58 Colin Fleming
										<input name="autotls_enable" id="autotls_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autotls_change()" />
921 3c11bd3c Matthew Grooms
									</td>
922
									<td>
923
										<span class="vexpl">
924 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Automatically generate a shared TLS authentication key"); ?>.
925 3c11bd3c Matthew Grooms
										</span>
926
									</td>
927
								</tr>
928
							</table>
929
							<?php endif; ?>
930 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="autotls_opts" summary="tls authentication key">
931 3c11bd3c Matthew Grooms
								<tr>
932
									<td>
933
										<textarea name="tls" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['tls']);?></textarea>
934 8cd558b6 ayvis
										<br />
935 4d8b3382 Carlos Eduardo Ramos
										<?=gettext("Paste your shared key here"); ?>.
936 3c11bd3c Matthew Grooms
									</td>
937
								</tr>
938
							</table>
939
						</td>
940 d799787e Matthew Grooms
					</tr>
941 3c11bd3c Matthew Grooms
					<tr id="tls_ca">
942 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Authority"); ?></td>
943 d799787e Matthew Grooms
							<td width="78%" class="vtable">
944 19cdeb3e jim-p
							<?php if (count($a_ca)): ?>
945 d799787e Matthew Grooms
							<select name='caref' class="formselect">
946
							<?php
947 428e66b6 jim-p
								foreach ($a_ca as $ca):
948 d799787e Matthew Grooms
									$selected = "";
949
									if ($pconfig['caref'] == $ca['refid'])
950 2b5c9e58 Colin Fleming
										$selected = "selected=\"selected\"";
951 d799787e Matthew Grooms
							?>
952 f2a86ca9 jim-p
								<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
953 d799787e Matthew Grooms
							<?php endforeach; ?>
954
							</select>
955 19cdeb3e jim-p
							<?php else: ?>
956 8cd558b6 ayvis
								<b>No Certificate Authorities defined.</b> <br />Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
957 19cdeb3e jim-p
							<?php endif; ?>
958 d799787e Matthew Grooms
							</td>
959
					</tr>
960 6db02381 jim-p
					<tr id="tls_crl">
961
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Peer Certificate Revocation List"); ?></td>
962
							<td width="78%" class="vtable">
963 19cdeb3e jim-p
							<?php if (count($a_crl)): ?>
964 6db02381 jim-p
							<select name='crlref' class="formselect">
965
								<option value="">None</option>
966
							<?php
967 428e66b6 jim-p
								foreach ($a_crl as $crl):
968 6db02381 jim-p
									$selected = "";
969 f02c3e1d jim-p
									$caname = "";
970
									$ca = lookup_ca($crl['caref']);
971
									if ($ca) {
972
										$caname = " (CA: {$ca['descr']})";
973
										if ($pconfig['crlref'] == $crl['refid'])
974 2b5c9e58 Colin Fleming
											$selected = "selected=\"selected\"";
975 f02c3e1d jim-p
									}
976 6db02381 jim-p
							?>
977 f02c3e1d jim-p
								<option value="<?=$crl['refid'];?>" <?=$selected;?>><?=$crl['descr'] . $caname;?></option>
978 6db02381 jim-p
							<?php endforeach; ?>
979
							</select>
980 19cdeb3e jim-p
							<?php else: ?>
981 8cd558b6 ayvis
								<b>No Certificate Revocation Lists (CRLs) defined.</b> <br />Create one under <a href="system_crlmanager.php">System &gt; Cert Manager</a>.
982 19cdeb3e jim-p
							<?php endif; ?>
983 6db02381 jim-p
							</td>
984
					</tr>
985 3c11bd3c Matthew Grooms
					<tr id="tls_cert">
986 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Server Certificate"); ?></td>
987 d799787e Matthew Grooms
							<td width="78%" class="vtable">
988 19cdeb3e jim-p
							<?php if (count($a_cert)): ?>
989 d799787e Matthew Grooms
							<select name='certref' class="formselect">
990
							<?php
991 428e66b6 jim-p
							foreach ($a_cert as $cert):
992 9e303f2f jim-p
								$selected = "";
993
								$caname = "";
994
								$inuse = "";
995
								$revoked = "";
996
								$ca = lookup_ca($cert['caref']);
997
								if ($ca)
998
									$caname = " (CA: {$ca['descr']})";
999
								if ($pconfig['certref'] == $cert['refid'])
1000 2b5c9e58 Colin Fleming
									$selected = "selected=\"selected\"";
1001 9e303f2f jim-p
								if (cert_in_use($cert['refid']))
1002
									$inuse = " *In Use";
1003
								if (is_cert_revoked($cert))
1004
								$revoked = " *Revoked";
1005 d799787e Matthew Grooms
							?>
1006 6a0b3ea4 jim-p
								<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
1007 d799787e Matthew Grooms
							<?php endforeach; ?>
1008
							</select>
1009 19cdeb3e jim-p
							<?php else: ?>
1010 8cd558b6 ayvis
								<b>No Certificates defined.</b> <br />Create one under <a href="system_certmanager.php">System &gt; Cert Manager</a>.
1011 19cdeb3e jim-p
							<?php endif; ?>
1012 d799787e Matthew Grooms
						</td>
1013
					</tr>
1014 fe787fc7 Matthew Grooms
					<tr id="tls_dh">
1015 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("DH Parameters Length"); ?></td>
1016 fe787fc7 Matthew Grooms
						<td width="78%" class="vtable">
1017
							<select name="dh_length" class="formselect">
1018
								<?php
1019
									foreach ($openvpn_dh_lengths as $length):
1020 2b5c9e58 Colin Fleming
									$selected = "";
1021 fe787fc7 Matthew Grooms
									if ($length == $pconfig['dh_length'])
1022 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1023 fe787fc7 Matthew Grooms
								?>
1024
								<option<?=$selected?>><?=$length;?></option>
1025
								<?php endforeach; ?>
1026
							</select>
1027
							<span class="vexpl">
1028 1c83021a Carlos Eduardo Ramos
								<?=gettext("bits"); ?>
1029 fe787fc7 Matthew Grooms
							</span>
1030
						</td>
1031
					</tr>
1032 d799787e Matthew Grooms
					<tr id="psk">
1033 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Key"); ?></td>
1034 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
1035
							<?php if (!$pconfig['shared_key']): ?>
1036 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="shared key">
1037 3c11bd3c Matthew Grooms
								<tr>
1038
									<td>
1039
										<?php set_checked($pconfig['autokey_enable'],$chk); ?>
1040 2b5c9e58 Colin Fleming
										<input name="autokey_enable" type="checkbox" value="yes" <?=$chk;?> onclick="autokey_change()" />
1041 3c11bd3c Matthew Grooms
									</td>
1042
									<td>
1043
										<span class="vexpl">
1044 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Automatically generate a shared key"); ?>.
1045 3c11bd3c Matthew Grooms
										</span>
1046
									</td>
1047
								</tr>
1048
							</table>
1049
							<?php endif; ?>
1050 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="autokey_opts" summary="shared key">
1051 3c11bd3c Matthew Grooms
								<tr>
1052
									<td>
1053
										<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
1054 8cd558b6 ayvis
										<br />
1055 4d8b3382 Carlos Eduardo Ramos
										<?=gettext("Paste your shared key here"); ?>.
1056 3c11bd3c Matthew Grooms
									</td>
1057
								</tr>
1058
							</table>
1059 d799787e Matthew Grooms
						</td>
1060
					</tr>
1061
					<tr>
1062 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Encryption algorithm"); ?></td>
1063 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1064
							<select name="crypto" class="formselect">
1065
								<?php
1066
									$cipherlist = openvpn_get_cipherlist();
1067
									foreach ($cipherlist as $name => $desc):
1068 2b5c9e58 Colin Fleming
									$selected = "";
1069 d799787e Matthew Grooms
									if ($name == $pconfig['crypto'])
1070 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1071 d799787e Matthew Grooms
								?>
1072
								<option value="<?=$name;?>"<?=$selected?>>
1073
									<?=htmlspecialchars($desc);?>
1074
								</option>
1075
								<?php endforeach; ?>
1076 582c58ae jim-p
							</select>
1077
						</td>
1078
					</tr>
1079 97d5b59b jim-p
					<tr>
1080
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Auth Digest Algorithm"); ?></td>
1081
						<td width="78%" class="vtable">
1082
							<select name="digest" class="formselect">
1083
								<?php
1084
									$digestlist = openvpn_get_digestlist();
1085
									foreach ($digestlist as $name => $desc):
1086 2b5c9e58 Colin Fleming
									$selected = "";
1087 97d5b59b jim-p
									if ($name == $pconfig['digest'])
1088 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1089 97d5b59b jim-p
								?>
1090
								<option value="<?=$name;?>"<?=$selected?>>
1091
									<?=htmlspecialchars($desc);?>
1092
								</option>
1093
								<?php endforeach; ?>
1094
							</select>
1095
						</td>
1096
					</tr>
1097 582c58ae jim-p
					<tr id="engine">
1098
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Hardware Crypto"); ?></td>
1099
						<td width="78%" class="vtable">
1100
							<select name="engine" class="formselect">
1101
								<?php
1102
									$engines = openvpn_get_engines();
1103
									foreach ($engines as $name => $desc):
1104 2b5c9e58 Colin Fleming
									$selected = "";
1105 582c58ae jim-p
									if ($name == $pconfig['engine'])
1106 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1107 582c58ae jim-p
								?>
1108
								<option value="<?=$name;?>"<?=$selected?>>
1109
									<?=htmlspecialchars($desc);?>
1110
								</option>
1111
								<?php endforeach; ?>
1112 d799787e Matthew Grooms
							</select>
1113
						</td>
1114
					</tr>
1115 98963f27 jim-p
					<tr id="cert_depth">
1116
						<td width="22%" valign="top" class="vncell"><?=gettext("Certificate Depth"); ?></td>
1117
						<td width="78%" class="vtable">
1118 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="certificate depth">
1119 98963f27 jim-p
							<tr><td>
1120
							<select name="cert_depth" class="formselect">
1121
								<option value="">Do Not Check</option>
1122
								<?php
1123
									foreach ($openvpn_cert_depths as $depth => $depthdesc):
1124 2b5c9e58 Colin Fleming
									$selected = "";
1125 98963f27 jim-p
									if ($depth == $pconfig['cert_depth'])
1126 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1127 98963f27 jim-p
								?>
1128
								<option value="<?= $depth ?>" <?= $selected ?>><?= $depthdesc ?></option>
1129
								<?php endforeach; ?>
1130
							</select>
1131
							</td></tr>
1132
							<tr><td>
1133
							<span class="vexpl">
1134
								<?=gettext("When a certificate-based client logs in, do not accept certificates below this depth. Useful for denying certificates made with intermediate CAs generated from the same CA as the server."); ?>
1135
							</span>
1136
							</td></tr>
1137
							</table>
1138
						</td>
1139
					</tr>
1140 94823361 jim-p
					<tr id="strictusercn">
1141
						<td width="22%" valign="top" class="vncell"><?=gettext("Strict User/CN Matching"); ?></td>
1142
						<td width="78%" class="vtable">
1143 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="strict user/cn matching">
1144 94823361 jim-p
								<tr>
1145
									<td>
1146
										<?php set_checked($pconfig['strictusercn'],$chk); ?>
1147 2b5c9e58 Colin Fleming
										<input name="strictusercn" type="checkbox" value="yes" <?=$chk;?> />
1148 94823361 jim-p
									</td>
1149
									<td>
1150
										<span class="vexpl">
1151
											<?=gettext("When authenticating users, enforce a match between the common name of the client certificate and the username given at login."); ?>
1152
										</span>
1153
									</td>
1154
								</tr>
1155
							</table>
1156
						</td>
1157
					</tr>
1158 d799787e Matthew Grooms
					<tr>
1159
						<td colspan="2" class="list" height="12"></td>
1160
					</tr>
1161
					<tr>
1162 4d8b3382 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Tunnel Settings"); ?></td>
1163 d799787e Matthew Grooms
					</tr>
1164 74a556a3 jim-p
					<tr>
1165
						<td width="22%" valign="top" class="vncellreq" id="ipv4_tunnel_network"><?=gettext("IPv4 Tunnel Network"); ?></td>
1166 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1167 2b5c9e58 Colin Fleming
							<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>" />
1168 8cd558b6 ayvis
							<br />
1169 b1ba04cf Seth Mos
							<?=gettext("This is the IPv4 virtual network used for private " .
1170 4d8b3382 Carlos Eduardo Ramos
							"communications between this server and client " .
1171
							"hosts expressed using CIDR (eg. 10.0.8.0/24). " .
1172
							"The first network address will be assigned to " .
1173
							"the	server virtual interface. The remaining " .
1174
							"network addresses can optionally be assigned " .
1175
							"to connecting clients. (see Address Pool)"); ?>
1176 d799787e Matthew Grooms
						</td>
1177
					</tr>
1178 74a556a3 jim-p
					<tr>
1179
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Tunnel Network"); ?></td>
1180 b1ba04cf Seth Mos
						<td width="78%" class="vtable">
1181 2b5c9e58 Colin Fleming
							<input name="tunnel_networkv6" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_networkv6']);?>" />
1182 8cd558b6 ayvis
							<br />
1183 b1ba04cf Seth Mos
							<?=gettext("This is the IPv6 virtual network used for private " .
1184
							"communications between this server and client " .
1185
							"hosts expressed using CIDR (eg. fe80::/64). " .
1186
							"The first network address will be assigned to " .
1187 4856df9b jim-p
							"the server virtual interface. The remaining " .
1188 b1ba04cf Seth Mos
							"network addresses can optionally be assigned " .
1189
							"to connecting clients. (see Address Pool)"); ?>
1190
						</td>
1191
					</tr>
1192 1ab6bdb5 jim-p
					<tr id="serverbridge_dhcp">
1193
						<td width="22%" valign="top" class="vncell"><?=gettext("Bridge DHCP"); ?></td>
1194
						<td width="78%" class="vtable">
1195 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="bridge dhcp">
1196 1ab6bdb5 jim-p
								<tr>
1197
									<td>
1198
										<?php set_checked($pconfig['serverbridge_dhcp'],$chk); ?>
1199 2b5c9e58 Colin Fleming
										<input name="serverbridge_dhcp" type="checkbox" value="yes" <?=$chk;?> onchange="tuntap_change()" />
1200 1ab6bdb5 jim-p
									</td>
1201
									<td>
1202
										<span class="vexpl">
1203 8cd558b6 ayvis
											<?=gettext("Allow clients on the bridge to obtain DHCP."); ?><br />
1204 1ab6bdb5 jim-p
										</span>
1205
									</td>
1206
								</tr>
1207
							</table>
1208
						</td>
1209
					</tr>
1210
					<tr id="serverbridge_interface">
1211
						<td width="22%" valign="top" class="vncell"><?=gettext("Bridge Interface"); ?></td>
1212
						<td width="78%" class="vtable">
1213
							<select name="serverbridge_interface" class="formselect">
1214
								<?php
1215
									$serverbridge_interface['none'] = "none";
1216
									$serverbridge_interface = array_merge($serverbridge_interface, get_configured_interface_with_descr());
1217
									$carplist = get_configured_carp_interface_list();
1218
									foreach ($carplist as $cif => $carpip)
1219
										$serverbridge_interface[$cif.'|'.$carpip] = $carpip." (".get_vip_descr($carpip).")";
1220
									$aliaslist = get_configured_ip_aliases_list();
1221
									foreach ($aliaslist as $aliasip => $aliasif)
1222
										$serverbridge_interface[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
1223
									foreach ($serverbridge_interface as $iface => $ifacename):
1224
										$selected = "";
1225
										if ($iface == $pconfig['serverbridge_interface'])
1226 2b5c9e58 Colin Fleming
											$selected = "selected=\"selected\"";
1227 1ab6bdb5 jim-p
								?>
1228
									<option value="<?=$iface;?>" <?=$selected;?>>
1229
										<?=htmlspecialchars($ifacename);?>
1230
									</option>
1231
								<?php endforeach; ?>
1232 8cd558b6 ayvis
							</select> <br />
1233 8e932fb5 Phil Davis
							<?=gettext("The interface to which this tap instance will be " .
1234 1ab6bdb5 jim-p
							"bridged. This is not done automatically. You must assign this " .
1235
							"interface and create the bridge separately. " .
1236
							"This setting controls which existing IP address and subnet " .
1237
							"mask are used by OpenVPN for the bridge. Setting this to " .
1238
							"'none' will cause the Server Bridge DHCP settings below to be ignored."); ?>
1239
						</td>
1240
					</tr>
1241
					<tr id="serverbridge_dhcp_start">
1242
						<td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP Start"); ?></td>
1243
						<td width="78%" class="vtable">
1244 2b5c9e58 Colin Fleming
							<input name="serverbridge_dhcp_start" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_start']);?>" />
1245 8cd558b6 ayvis
							<br />
1246 8e932fb5 Phil Davis
							<?=gettext("When using tap mode as a multi-point server, " .
1247 1ab6bdb5 jim-p
							"you may optionally supply a DHCP range to use on the " .
1248
							"interface to which this tap instance is bridged. " .
1249
							"If these settings are left blank, DHCP will be passed " .
1250
							"through to the LAN, and the interface setting above " .
1251
							"will be ignored."); ?>
1252
						</td>
1253
					</tr>
1254
					<tr id="serverbridge_dhcp_end">
1255 850ae59e Irving Popovetsky
						<td width="22%" valign="top" class="vncell"><?=gettext("Server Bridge DHCP End"); ?></td>
1256 1ab6bdb5 jim-p
						<td width="78%" class="vtable">
1257 2b5c9e58 Colin Fleming
							<input name="serverbridge_dhcp_end" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['serverbridge_dhcp_end']);?>" />
1258 8cd558b6 ayvis
							<br />
1259 1ab6bdb5 jim-p
						</td>
1260
					</tr>
1261 a2ff08f8 jim-p
					<tr id="gwredir_opts">
1262 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Redirect Gateway"); ?></td>
1263 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1264 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="redirect gateway">
1265 d799787e Matthew Grooms
								<tr>
1266
									<td>
1267
										<?php set_checked($pconfig['gwredir'],$chk); ?>
1268 2b5c9e58 Colin Fleming
										<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onclick="gwredir_change()" />
1269 d799787e Matthew Grooms
									</td>
1270
									<td>
1271
										<span class="vexpl">
1272 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Force all client generated traffic through the tunnel"); ?>.
1273 d799787e Matthew Grooms
										</span>
1274
									</td>
1275
								</tr>
1276
							</table>
1277
						</td>
1278
					</tr>
1279 4856df9b jim-p
					<tr id="local_optsv4">
1280 332f5781 Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Local Network/s"); ?></td>
1281 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1282 2b5c9e58 Colin Fleming
							<input name="local_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['local_network']);?>" />
1283 8cd558b6 ayvis
							<br />
1284 332f5781 Phil Davis
							<?=gettext("These are the IPv4 networks that will be accessible " .
1285
							"from the remote endpoint. Expressed as a comma-separated list of one or more CIDR ranges. " .
1286
							"You may leave this blank if you don't " .
1287 4d8b3382 Carlos Eduardo Ramos
							"want to add a route to the local network " .
1288
							"through this tunnel on the remote machine. " .
1289
							"This is generally set to your LAN network"); ?>.
1290 d799787e Matthew Grooms
						</td>
1291
					</tr>
1292 4856df9b jim-p
					<tr id="local_optsv6">
1293 332f5781 Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Local Network/s"); ?></td>
1294 b1ba04cf Seth Mos
						<td width="78%" class="vtable">
1295 2b5c9e58 Colin Fleming
							<input name="local_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['local_networkv6']);?>" />
1296 8cd558b6 ayvis
							<br />
1297 332f5781 Phil Davis
							<?=gettext("These are the IPv6 networks that will be accessible " .
1298
							"from the remote endpoint. Expressed as a comma-separated list of one or more IP/PREFIX. " .
1299
							"You may leave this blank if you don't " .
1300 b1ba04cf Seth Mos
							"want to add a route to the local network " .
1301
							"through this tunnel on the remote machine. " .
1302
							"This is generally set to your LAN network"); ?>.
1303
						</td>
1304
					</tr>
1305 415bddea jim-p
					<tr id="remote_optsv4">
1306 332f5781 Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv4 Remote Network/s"); ?></td>
1307 3c11bd3c Matthew Grooms
						<td width="78%" class="vtable">
1308 2b5c9e58 Colin Fleming
							<input name="remote_network" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_network']);?>" />
1309 8cd558b6 ayvis
							<br />
1310 332f5781 Phil Davis
							<?=gettext("These are the IPv4 networks that will be routed through " .
1311 4d8b3382 Carlos Eduardo Ramos
							"the tunnel, so that a site-to-site VPN can be " .
1312 332f5781 Phil Davis
							"established without manually changing the routing tables. " .
1313
							"Expressed as a comma-separated list of one or more CIDR ranges. " .
1314
							"If this is a site-to-site VPN, enter the " .
1315
							"remote LAN/s here. You may leave this blank if " .
1316 4d8b3382 Carlos Eduardo Ramos
							"you don't want a site-to-site VPN"); ?>.
1317 3c11bd3c Matthew Grooms
						</td>
1318
					</tr>
1319 415bddea jim-p
					<tr id="remote_optsv6">
1320 332f5781 Phil Davis
						<td width="22%" valign="top" class="vncell"><?=gettext("IPv6 Remote Network/s"); ?></td>
1321 4856df9b jim-p
						<td width="78%" class="vtable">
1322 2b5c9e58 Colin Fleming
							<input name="remote_networkv6" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['remote_networkv6']);?>" />
1323 8cd558b6 ayvis
							<br />
1324 332f5781 Phil Davis
							<?=gettext("These are the IPv6 networks that will be routed through " .
1325 4856df9b jim-p
							"the tunnel, so that a site-to-site VPN can be " .
1326 332f5781 Phil Davis
							"established without manually changing the routing tables. " .
1327
							"Expressed as a comma-separated list of one or more IP/PREFIX. " .
1328
							"If this is a site-to-site VPN, enter the " .
1329
							"remote LAN/s here. You may leave this blank if " .
1330 4856df9b jim-p
							"you don't want a site-to-site VPN"); ?>.
1331
						</td>
1332
					</tr>
1333 d799787e Matthew Grooms
					<tr>
1334
						<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
1335
						<td width="78%" class="vtable">
1336 2b5c9e58 Colin Fleming
							<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>" />
1337 8cd558b6 ayvis
							<br />
1338 4d8b3382 Carlos Eduardo Ramos
							<?=gettext("Specify the maximum number of clients allowed to concurrently connect to this server"); ?>.
1339 d799787e Matthew Grooms
						</td>
1340
					</tr>
1341
					<tr>
1342 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Compression"); ?></td>
1343 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1344 edba1982 jim-p
							<select name="compression" class="formselect">
1345
								<?php
1346
									foreach ($openvpn_compression_modes as $cmode => $cmodedesc):
1347 2b5c9e58 Colin Fleming
									$selected = "";
1348 edba1982 jim-p
									if ($cmode == $pconfig['compression'])
1349 2b5c9e58 Colin Fleming
										$selected = " selected=\"selected\"";
1350 edba1982 jim-p
								?>
1351
								<option value="<?= $cmode ?>" <?= $selected ?>><?= $cmodedesc ?></option>
1352
								<?php endforeach; ?>
1353
							</select>
1354 8cd558b6 ayvis
							<br />
1355 caf58ced Dmitriy K.
							<?=gettext("Compress tunnel packets using the LZO algorithm. Adaptive compression will dynamically disable compression for a period of time if OpenVPN detects that the data in the packets is not being compressed efficiently"); ?>.
1356 d799787e Matthew Grooms
						</td>
1357
					</tr>
1358
					<tr>
1359 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Type-of-Service"); ?></td>
1360 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1361 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="type-of-service">
1362 d799787e Matthew Grooms
								<tr>
1363
									<td>
1364 1cb0b40a Matthew Grooms
										<?php set_checked($pconfig['passtos'],$chk); ?>
1365 2b5c9e58 Colin Fleming
										<input name="passtos" type="checkbox" value="yes" <?=$chk;?> />
1366 d799787e Matthew Grooms
									</td>
1367
									<td>
1368
										<span class="vexpl">
1369 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Set the TOS IP header value of tunnel packets to match the encapsulated packet value"); ?>.
1370 d799787e Matthew Grooms
										</span>
1371
									</td>
1372
								</tr>
1373
							</table>
1374
						</td>
1375
					</tr>
1376 107794cc jim-p
					<tr id="inter_client_communication">
1377 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Inter-client communication"); ?></td>
1378 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1379 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="inter-client communication">
1380 d799787e Matthew Grooms
								<tr>
1381
									<td>
1382
										<?php set_checked($pconfig['client2client'],$chk); ?>
1383 2b5c9e58 Colin Fleming
										<input name="client2client" type="checkbox" value="yes" <?=$chk;?> />
1384 d799787e Matthew Grooms
									</td>
1385
									<td>
1386
										<span class="vexpl">
1387 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Allow communication between clients connected to this server"); ?>
1388 d799787e Matthew Grooms
										</span>
1389
									</td>
1390
								</tr>
1391
							</table>
1392
						</td>
1393
					</tr>
1394 bca35cff jim-p
					<tr id="duplicate_cn">
1395
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate Connections"); ?></td>
1396
						<td width="78%" class="vtable">
1397 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="duplicate connection">
1398 bca35cff jim-p
								<tr>
1399
									<td>
1400
										<?php set_checked($pconfig['duplicate_cn'],$chk); ?>
1401 2b5c9e58 Colin Fleming
										<input name="duplicate_cn" type="checkbox" value="yes" <?=$chk;?> />
1402 bca35cff jim-p
									</td>
1403
									<td>
1404
										<span class="vexpl">
1405 8cd558b6 ayvis
											<?=gettext("Allow multiple concurrent connections from clients using the same Common Name.<br />NOTE: This is not generally recommended, but may be needed for some scenarios."); ?>
1406 bca35cff jim-p
										</span>
1407
									</td>
1408
								</tr>
1409
							</table>
1410
						</td>
1411
					</tr>
1412 b9e9903d Dmitriy K.
1413 caf58ced Dmitriy K.
					<tr id="chkboxNoTunIPv6">
1414 b9e9903d Dmitriy K.
						<td width="22%" valign="top" class="vncell"><?=gettext("Disable IPv6"); ?></td>
1415
						<td width="78%" class="vtable">
1416
							<table border="0" cellpadding="2" cellspacing="0" summary="disable-ipv6-srv">
1417
								<tr>
1418
									<td>
1419
										<?php set_checked($pconfig['no_tun_ipv6'],$chk); ?>
1420
										<input name="no_tun_ipv6" type="checkbox" value="yes" <?=$chk;?> />
1421
									</td>
1422
									<td>
1423
										<span class="vexpl">
1424 b176474b Dmitriy K.
											<?=gettext("Don't forward IPv6 traffic"); ?>.
1425 b9e9903d Dmitriy K.
										</span>
1426
									</td>
1427
								</tr>
1428
							</table>
1429
						</td>
1430
					</tr>
1431
1432 3c11bd3c Matthew Grooms
				</table>
1433
1434 2b5c9e58 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="client settings">
1435 d799787e Matthew Grooms
					<tr>
1436
						<td colspan="2" class="list" height="12"></td>
1437
					</tr>
1438
					<tr>
1439 4d8b3382 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Client Settings"); ?></td>
1440 d799787e Matthew Grooms
					</tr>
1441 65ff8497 jim-p
					<tr>
1442 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Dynamic IP"); ?></td>
1443 65ff8497 jim-p
						<td width="78%" class="vtable">
1444 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="dynamic ip">
1445 65ff8497 jim-p
								<tr>
1446
									<td>
1447
										<?php set_checked($pconfig['dynamic_ip'],$chk); ?>
1448 2b5c9e58 Colin Fleming
										<input name="dynamic_ip" type="checkbox" id="dynamic_ip" value="yes" <?=$chk;?> />
1449 65ff8497 jim-p
									</td>
1450
									<td>
1451
										<span class="vexpl">
1452 8cd558b6 ayvis
											<?=gettext("Allow connected clients to retain their connections if their IP address changes"); ?>.<br />
1453 65ff8497 jim-p
										</span>
1454
									</td>
1455
								</tr>
1456
							</table>
1457
						</td>
1458
					</tr>
1459 d799787e Matthew Grooms
					<tr>
1460 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Address Pool"); ?></td>
1461 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1462 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="address pool">
1463 d799787e Matthew Grooms
								<tr>
1464
									<td>
1465
										<?php set_checked($pconfig['pool_enable'],$chk); ?>
1466 2b5c9e58 Colin Fleming
										<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?> />
1467 d799787e Matthew Grooms
									</td>
1468
									<td>
1469
										<span class="vexpl">
1470 8cd558b6 ayvis
											<?=gettext("Provide a virtual adapter IP address to clients (see Tunnel Network)"); ?><br />
1471 d799787e Matthew Grooms
										</span>
1472
									</td>
1473
								</tr>
1474
							</table>
1475
						</td>
1476
					</tr>
1477 ee55ce7d jim-p
					<tr id="topology_subnet_opt">
1478
						<td width="22%" valign="top" class="vncell"><?=gettext("Topology"); ?></td>
1479
						<td width="78%" class="vtable">
1480 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="topology">
1481 ee55ce7d jim-p
								<tr>
1482
									<td>
1483
										<?php set_checked($pconfig['topology_subnet'],$chk); ?>
1484 2b5c9e58 Colin Fleming
										<input name="topology_subnet" type="checkbox" id="topology_subnet" value="yes" <?=$chk;?> />
1485 ee55ce7d jim-p
									</td>
1486
									<td>
1487
										<span class="vexpl">
1488 8cd558b6 ayvis
											<?=gettext("Allocate only one IP per client (topology subnet), rather than an isolated subnet per client (topology net30)."); ?><br />
1489 ee55ce7d jim-p
										</span>
1490
									</td>
1491
								</tr>
1492
								<tr>
1493
									<td>&nbsp;</td>
1494
									<td>
1495 8cd558b6 ayvis
										<?=gettext("Relevant when supplying a virtual adapter IP address to clients when using tun mode on IPv4."); ?><br />
1496
										<?=gettext("Some clients may require this even for IPv6, such as OpenVPN Connect (iOS/Android). Others may break if it is present, such as older versions of OpenVPN or clients such as Yealink phones."); ?><br />
1497 ee55ce7d jim-p
									</td>
1498
								</tr>
1499
							</table>
1500
						</td>
1501
					</tr>
1502 d799787e Matthew Grooms
					<tr>
1503 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Default Domain"); ?></td>
1504 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1505 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="dns default domain">
1506 d799787e Matthew Grooms
								<tr>
1507
									<td>
1508
										<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
1509 2b5c9e58 Colin Fleming
										<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onclick="dns_domain_change()" />
1510 d799787e Matthew Grooms
									</td>
1511
									<td>
1512
										<span class="vexpl">
1513 8cd558b6 ayvis
	                                        <?=gettext("Provide a default domain name to clients"); ?><br />
1514 d799787e Matthew Grooms
										</span>
1515
									</td>
1516
								</tr>
1517
							</table>
1518 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data" summary="dns domain data">
1519 d799787e Matthew Grooms
								<tr>
1520
									<td>
1521 2b5c9e58 Colin Fleming
										<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>" />
1522 d799787e Matthew Grooms
									</td>
1523
								</tr>
1524
							</table>
1525
						</td>
1526
					</tr>
1527
					<tr>
1528 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("DNS Servers"); ?></td>
1529 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1530 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="dns servers">
1531 d799787e Matthew Grooms
								<tr>
1532
									<td>
1533
										<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
1534 2b5c9e58 Colin Fleming
										<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onclick="dns_server_change()" />
1535 d799787e Matthew Grooms
									</td>
1536
									<td>
1537
										<span class="vexpl">
1538 8cd558b6 ayvis
											<?=gettext("Provide a DNS server list to clients"); ?><br />
1539 d799787e Matthew Grooms
										</span>
1540
									</td>
1541
								</tr>
1542
							</table>
1543 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data" summary="dns servers">
1544 d799787e Matthew Grooms
								<tr>
1545
									<td>
1546
										<span class="vexpl">
1547 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #1:&nbsp;
1548 d799787e Matthew Grooms
										</span>
1549 2b5c9e58 Colin Fleming
										<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=htmlspecialchars($pconfig['dns_server1']);?>" />
1550 d799787e Matthew Grooms
									</td>
1551
								</tr>
1552
								<tr>
1553
									<td>
1554
										<span class="vexpl">
1555 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #2:&nbsp;
1556 d799787e Matthew Grooms
										</span>
1557 2b5c9e58 Colin Fleming
										<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=htmlspecialchars($pconfig['dns_server2']);?>" />
1558 d799787e Matthew Grooms
									</td>
1559
								</tr>
1560
								<tr>
1561
									<td>
1562
										<span class="vexpl">
1563 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #3:&nbsp;
1564 d799787e Matthew Grooms
										</span>
1565 2b5c9e58 Colin Fleming
										<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=htmlspecialchars($pconfig['dns_server3']);?>" />
1566 d799787e Matthew Grooms
									</td>
1567
								</tr>
1568
								<tr>
1569
									<td>
1570
										<span class="vexpl">
1571 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #4:&nbsp;
1572 d799787e Matthew Grooms
										</span>
1573 2b5c9e58 Colin Fleming
										<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=htmlspecialchars($pconfig['dns_server4']);?>" />
1574 d799787e Matthew Grooms
									</td>
1575
								</tr>
1576
							</table>
1577
						</td>
1578
					</tr>
1579
					<tr>
1580 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("NTP Servers"); ?></td>
1581 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1582 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="ntp servers">
1583 d799787e Matthew Grooms
								<tr>
1584
									<td>
1585
										<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
1586 2b5c9e58 Colin Fleming
										<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onclick="ntp_server_change()" />
1587 d799787e Matthew Grooms
									</td>
1588
									<td>
1589
										<span class="vexpl">
1590 8cd558b6 ayvis
											<?=gettext("Provide a NTP server list to clients"); ?><br />
1591 d799787e Matthew Grooms
										</span>
1592
									</td>
1593
								</tr>
1594
							</table>
1595 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data" summary="ntp servers">
1596 d799787e Matthew Grooms
								<tr>
1597
									<td>
1598
										<span class="vexpl">
1599 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #1:&nbsp;
1600 d799787e Matthew Grooms
										</span>
1601 2b5c9e58 Colin Fleming
										<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=htmlspecialchars($pconfig['ntp_server1']);?>" />
1602 d799787e Matthew Grooms
									</td>
1603
								</tr>
1604
								<tr>
1605
									<td>
1606
										<span class="vexpl">
1607 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #2:&nbsp;
1608 d799787e Matthew Grooms
										</span>
1609 2b5c9e58 Colin Fleming
										<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=htmlspecialchars($pconfig['ntp_server2']);?>" />
1610 d799787e Matthew Grooms
									</td>
1611
								</tr>
1612
							</table>
1613
						</td>
1614
					</tr>
1615
					<tr>
1616 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("NetBIOS Options"); ?></td>
1617 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1618 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="netboios options">
1619 d799787e Matthew Grooms
								<tr>
1620
									<td>
1621
										<?php set_checked($pconfig['netbios_enable'],$chk); ?>
1622 2b5c9e58 Colin Fleming
										<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onclick="netbios_change()" />
1623 d799787e Matthew Grooms
									</td>
1624
									<td>
1625
										<span class="vexpl">
1626 8cd558b6 ayvis
											<?=gettext("Enable NetBIOS over TCP/IP"); ?><br />
1627 d799787e Matthew Grooms
										</span>
1628
									</td>
1629
								</tr>
1630
							</table>
1631 4d8b3382 Carlos Eduardo Ramos
							<?=gettext("If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled"); ?>.
1632 8cd558b6 ayvis
							<br />
1633 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="netbios_data" summary="netboios options">
1634 d799787e Matthew Grooms
								<tr>
1635
									<td>
1636 8cd558b6 ayvis
										<br />
1637 d799787e Matthew Grooms
										<span class="vexpl">
1638 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Node Type"); ?>:&nbsp;
1639 d799787e Matthew Grooms
										</span>
1640
										<select name='netbios_ntype' class="formselect">
1641
										<?php
1642
											foreach ($netbios_nodetypes as $type => $name):
1643
												$selected = "";
1644
												if ($pconfig['netbios_ntype'] == $type)
1645 2b5c9e58 Colin Fleming
													$selected = "selected=\"selected\"";
1646 d799787e Matthew Grooms
										?>
1647
											<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
1648
										<?php endforeach; ?>
1649
										</select>
1650 8cd558b6 ayvis
										<br />
1651 4d8b3382 Carlos Eduardo Ramos
										<?=gettext("Possible options: b-node (broadcasts), p-node " .
1652
										"(point-to-point name queries to a WINS server), " .
1653
										"m-node (broadcast then query name server), and " .
1654
										"h-node (query name server, then broadcast)"); ?>.
1655 d799787e Matthew Grooms
									</td>
1656
								</tr>
1657
								<tr>
1658
									<td>
1659 8cd558b6 ayvis
										<br />
1660 d799787e Matthew Grooms
										<span class="vexpl">
1661 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Scope ID"); ?>:&nbsp;
1662 d799787e Matthew Grooms
										</span>
1663 2b5c9e58 Colin Fleming
										<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>" />
1664 8cd558b6 ayvis
										<br />
1665 4d8b3382 Carlos Eduardo Ramos
										<?=gettext("A NetBIOS Scope	ID provides an extended naming " .
1666
										"service for	NetBIOS over TCP/IP. The NetBIOS " .
1667
										"scope ID isolates NetBIOS traffic on a single " .
1668
										"network to only those nodes with the same " .
1669
										"NetBIOS scope ID"); ?>.
1670 d799787e Matthew Grooms
									</td>
1671
								</tr>
1672
							</table>
1673
						</td>
1674
					</tr>
1675
					<tr id="wins_opts">
1676 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("WINS Servers"); ?></td>
1677 d799787e Matthew Grooms
						<td width="78%" class="vtable">
1678 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="wins servers">
1679 d799787e Matthew Grooms
								<tr>
1680
									<td>
1681
										<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
1682 2b5c9e58 Colin Fleming
										<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onclick="wins_server_change()" />
1683 d799787e Matthew Grooms
									</td>
1684
									<td>
1685
										<span class="vexpl">
1686 8cd558b6 ayvis
											<?=gettext("Provide a WINS server list to clients"); ?><br />
1687 d799787e Matthew Grooms
										</span>
1688
									</td>
1689
								</tr>
1690
							</table>
1691 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data" summary="wins servers">
1692 d799787e Matthew Grooms
								<tr>
1693
									<td>
1694
										<span class="vexpl">
1695 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #1:&nbsp;
1696 d799787e Matthew Grooms
										</span>
1697 2b5c9e58 Colin Fleming
										<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=htmlspecialchars($pconfig['wins_server1']);?>" />
1698 d799787e Matthew Grooms
									</td>
1699
								</tr>
1700
								<tr>
1701
									<td>
1702
										<span class="vexpl">
1703 4d8b3382 Carlos Eduardo Ramos
											<?=gettext("Server"); ?> #2:&nbsp;
1704 d799787e Matthew Grooms
										</span>
1705 2b5c9e58 Colin Fleming
										<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=htmlspecialchars($pconfig['wins_server2']);?>" />
1706 d799787e Matthew Grooms
									</td>
1707
								</tr>
1708
							</table>
1709
						</td>
1710
					</tr>
1711 faf61f12 Phil Davis
					<tr>
1712
						<td width="22%" valign="top" class="vncell"><?=gettext("Client Management Port"); ?></td>
1713
						<td width="78%" class="vtable">
1714 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="client management port">
1715 faf61f12 Phil Davis
								<tr>
1716
									<td>
1717
										<?php set_checked($pconfig['client_mgmt_port_enable'],$chk); ?>
1718 2b5c9e58 Colin Fleming
										<input name="client_mgmt_port_enable" type="checkbox" id="client_mgmt_port_enable" value="yes" <?=$chk;?> onclick="client_mgmt_port_change()" />
1719 faf61f12 Phil Davis
									</td>
1720
									<td>
1721
										<span class="vexpl">
1722 8cd558b6 ayvis
	                                        <?=gettext("Use a different management port on clients. The default port is 166. Specify a different port if the client machines need to select from multiple OpenVPN links."); ?><br />
1723 faf61f12 Phil Davis
										</span>
1724
									</td>
1725
								</tr>
1726
							</table>
1727 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" id="client_mgmt_port_data" summary="client management port">
1728 faf61f12 Phil Davis
								<tr>
1729
									<td>
1730 2b5c9e58 Colin Fleming
										<input name="client_mgmt_port" type="text" class="formfld unknown" id="client_mgmt_port" size="30" value="<?=htmlspecialchars($pconfig['client_mgmt_port']);?>" />
1731 faf61f12 Phil Davis
									</td>
1732
								</tr>
1733
							</table>
1734
						</td>
1735
					</tr>
1736 3c11bd3c Matthew Grooms
				</table>
1737
1738 2b5c9e58 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="client_opts" summary="advance configuration">
1739 2f4f30ee Scott Ullrich
					<tr>
1740
						<td colspan="2" class="list" height="12"></td>
1741
					</tr>
1742
					<tr>
1743 4d8b3382 Carlos Eduardo Ramos
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Advanced configuration"); ?></td>
1744 2f4f30ee Scott Ullrich
					</tr>
1745
					<tr>
1746 4d8b3382 Carlos Eduardo Ramos
						<td width="22%" valign="top" class="vncell"><?=gettext("Advanced"); ?></td>
1747 2f4f30ee Scott Ullrich
						<td width="78%" class="vtable">
1748 2b5c9e58 Colin Fleming
							<table border="0" cellpadding="2" cellspacing="0" summary="advance configuration">
1749 2f4f30ee Scott Ullrich
								<tr>
1750
									<td>
1751 8cd558b6 ayvis
										<textarea rows="6" cols="78" name="custom_options" id="custom_options"><?=htmlspecialchars($pconfig['custom_options']);?></textarea><br />
1752
										<?=gettext("Enter any additional options you would like to add to the OpenVPN server configuration here, separated by a semicolon"); ?><br />
1753 4d8b3382 Carlos Eduardo Ramos
										<?=gettext("EXAMPLE: push \"route 10.0.0.0 255.255.255.0\""); ?>;
1754 2f4f30ee Scott Ullrich
									</td>
1755
								</tr>
1756
							</table>
1757
						</td>
1758
					</tr>
1759 b9e9903d Dmitriy K.
1760
					<tr id="comboboxVerbosityLevel">
1761
							<td width="22%" valign="top" class="vncell"><?=gettext("Verbosity level");?></td>
1762
							<td width="78%" class="vtable">
1763
							<select name="verbosity_level" class="formselect">
1764
							<?php
1765
								foreach ($openvpn_verbosity_level as $verb_value => $verb_desc):
1766
									$selected = "";
1767
									if ($pconfig['verbosity_level'] == $verb_value)
1768
										$selected = "selected=\"selected\"";
1769
							?>
1770
								<option value="<?=$verb_value;?>" <?=$selected;?>><?=$verb_desc;?></option>
1771
							<?php endforeach; ?>
1772
							</select>
1773
							<br />
1774
							<?=gettext("Each level shows all info from the previous levels. Level 3 is recommended if you want a good summary of what's happening without being swamped by output"); ?>.<br /> <br />
1775
							<strong>none</strong> -- <?=gettext("No output except fatal errors"); ?>. <br />
1776
							<strong>default</strong>-<strong>4</strong> -- <?=gettext("Normal usage range"); ?>. <br />
1777
							<strong>5</strong> -- <?=gettext("Output R and W characters to the console for each packet read and write, uppercase is used for TCP/UDP packets and lowercase is used for TUN/TAP packets"); ?>. <br />
1778
							<strong>6</strong>-<strong>11</strong> -- <?=gettext("Debug info range"); ?>.
1779
							</td>
1780
					</tr>
1781
1782 2f4f30ee Scott Ullrich
				</table>
1783
1784 8cd558b6 ayvis
				<br />
1785 2b5c9e58 Colin Fleming
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="icons">
1786 d799787e Matthew Grooms
					<tr>
1787
						<td width="22%" valign="top">&nbsp;</td>
1788
						<td width="78%"> 
1789 2b5c9e58 Colin Fleming
							<input name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> 
1790
							<input name="act" type="hidden" value="<?=$act;?>" />
1791 d799787e Matthew Grooms
							<?php if (isset($id) && $a_server[$id]): ?>
1792 2b5c9e58 Colin Fleming
							<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1793 d799787e Matthew Grooms
							<?php endif; ?>
1794
						</td>
1795
					</tr>
1796
				</table>
1797
			</form>
1798
1799
			<?php else: ?>
1800
1801 2b5c9e58 Colin Fleming
			<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="list">
1802 80fa045a jim-p
				<thead>
1803 d799787e Matthew Grooms
				<tr>
1804 4d8b3382 Carlos Eduardo Ramos
					<td width="10%" class="listhdrr"><?=gettext("Disabled"); ?></td>
1805
					<td width="10%" class="listhdrr"><?=gettext("Protocol / Port"); ?></td>
1806
					<td width="30%" class="listhdrr"><?=gettext("Tunnel Network"); ?></td>
1807
					<td width="40%" class="listhdrr"><?=gettext("Description"); ?></td>
1808 d799787e Matthew Grooms
					<td width="10%" class="list"></td>
1809
				</tr>
1810 80fa045a jim-p
				</thead>
1811 2b5c9e58 Colin Fleming
				<tfoot>
1812
				<tr>
1813
					<td class="list" colspan="4"></td>
1814
					<td class="list">
1815
						<a href="vpn_openvpn_server.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server"); ?>" width="17" height="17" border="0" alt="add" />
1816
						</a>
1817
					</td>
1818
				</tr>
1819
				</tfoot>
1820 80fa045a jim-p
				<tbody>
1821 d799787e Matthew Grooms
				<?php
1822
					$i = 0;
1823
					foreach($a_server as $server):
1824
						$disabled = "NO";
1825 870318b9 Ermal Lu?i
						if (isset($server['disable']))
1826 d799787e Matthew Grooms
							$disabled = "YES";
1827
				?>
1828
				<tr>
1829 2b5c9e58 Colin Fleming
					<td class="listlr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1830 d799787e Matthew Grooms
						<?=$disabled;?>
1831
					</td>
1832 2b5c9e58 Colin Fleming
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1833 43cea754 Chris Buechler
						<?=htmlspecialchars($server['protocol']);?> / <?=htmlspecialchars($server['local_port']);?>
1834 d799787e Matthew Grooms
					</td>
1835 2b5c9e58 Colin Fleming
					<td class="listr" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1836 8cd558b6 ayvis
						<?=htmlspecialchars($server['tunnel_network']);?><br />
1837
						<?=htmlspecialchars($server['tunnel_networkv6']);?><br />
1838 d799787e Matthew Grooms
					</td>
1839 2b5c9e58 Colin Fleming
					<td class="listbg" ondblclick="document.location='vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>'">
1840 d799787e Matthew Grooms
						<?=htmlspecialchars($server['description']);?>
1841
					</td>
1842 2b5c9e58 Colin Fleming
					<td valign="middle" class="list nowrap">
1843
						<a href="vpn_openvpn_server.php?act=edit&amp;id=<?=$i;?>">
1844
							<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server"); ?>" width="17" height="17" border="0" alt="edit" />
1845 d799787e Matthew Grooms
						</a>
1846
						&nbsp;
1847 2b5c9e58 Colin Fleming
						<a href="vpn_openvpn_server.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this server?"); ?>')">
1848
							<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server"); ?>" width="17" height="17" border="0" alt="delete" />
1849 d799787e Matthew Grooms
						</a>
1850
					</td>
1851
				</tr>
1852
				<?php
1853
					$i++;
1854
					endforeach;
1855
				?>
1856 2b5c9e58 Colin Fleming
				<tr style="dispaly:none;"><td></td></tr>
1857 80fa045a jim-p
				</tbody>
1858 d799787e Matthew Grooms
			</table>
1859
1860 7128ed17 Scott Ullrich
			<?=gettext("Additional OpenVPN servers can be added here.");?>
1861
1862 ee9933b6 Renato Botelho
			<?php endif; ?>
1863 d799787e Matthew Grooms
1864
		</td>
1865
	</tr>
1866
</table>
1867 91f026b0 ayvis
<script type="text/javascript">
1868 2b5c9e58 Colin Fleming
//<![CDATA[
1869 3c11bd3c Matthew Grooms
mode_change();
1870
autokey_change();
1871
tlsauth_change();
1872 d799787e Matthew Grooms
gwredir_change();
1873
dns_domain_change();
1874
dns_server_change();
1875
wins_server_change();
1876 faf61f12 Phil Davis
client_mgmt_port_change();
1877 d799787e Matthew Grooms
ntp_server_change();
1878
netbios_change();
1879 1ab6bdb5 jim-p
tuntap_change();
1880 2b5c9e58 Colin Fleming
//]]>
1881 d799787e Matthew Grooms
</script>
1882
<?php include("fend.inc"); ?>
1883 2b5c9e58 Colin Fleming
</body>
1884
</html>
1885 d799787e Matthew Grooms
<?php
1886
1887
/* local utility functions */
1888
1889
function set_checked($var,& $chk) {
1890
    if($var)
1891 2b5c9e58 Colin Fleming
        $chk = "checked=\"checked\"";
1892 d799787e Matthew Grooms
    else
1893 2b5c9e58 Colin Fleming
        $chk = "";
1894 d799787e Matthew Grooms
}
1895
1896 52971880 Vinicius Coque
?>