Project

General

Profile

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