1
|
<?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
|
|
38
|
require("guiconfig.inc");
|
39
|
|
40
|
$pgtitle = array("OpenVPN", "Server");
|
41
|
|
42
|
if (!is_array($config['openvpn']['openvpn-server']))
|
43
|
$config['openvpn']['openvpn-server'] = array();
|
44
|
|
45
|
$a_server = &$config['openvpn']['openvpn-server'];
|
46
|
|
47
|
$id = $_GET['id'];
|
48
|
if (isset($_POST['id']))
|
49
|
$id = $_POST['id'];
|
50
|
|
51
|
$act = $_GET['act'];
|
52
|
if (isset($_POST['act']))
|
53
|
$act = $_POST['act'];
|
54
|
|
55
|
if ($_GET['act'] == "del") {
|
56
|
|
57
|
if (!$a_server[$id]) {
|
58
|
pfSenseHeader("vpn_openvpn_server.php");
|
59
|
exit;
|
60
|
}
|
61
|
|
62
|
openvpn_delete('server', $a_server[$id]);
|
63
|
unset($a_server[$id]);
|
64
|
write_config();
|
65
|
$savemsg = gettext("Server successfully deleted")."<br/>";
|
66
|
}
|
67
|
|
68
|
if($_GET['act']=="new"){
|
69
|
$pconfig['interface'] = "wan";
|
70
|
$pconfig['local_port'] = openvpn_port_next('UDP');
|
71
|
$pconfig['pool_enable'] = "yes";
|
72
|
}
|
73
|
|
74
|
if($_GET['act']=="edit"){
|
75
|
|
76
|
if (isset($id) && $a_server[$id]) {
|
77
|
|
78
|
$pconfig['disable'] = $a_server[$id]['disable'];
|
79
|
$pconfig['protocol'] = $a_server[$id]['protocol'];
|
80
|
$pconfig['interface'] = $a_server[$id]['interface'];
|
81
|
$pconfig['local_port'] = $a_server[$id]['local_port'];
|
82
|
$pconfig['description'] = $a_server[$id]['description'];
|
83
|
|
84
|
$pconfig['auth_method'] = $a_server[$id]['auth_method'];
|
85
|
if ($pconfig['auth_method'] == "shared_key")
|
86
|
$pconfig['shared_key'] = base64_decode($a_server[$id]['shared_key']);
|
87
|
else {
|
88
|
$pconfig['caref'] = $a_server[$id]['caref'];
|
89
|
$pconfig['certref'] = $a_server[$id]['certref'];
|
90
|
}
|
91
|
$pconfig['crypto'] = $a_server[$id]['crypto'];
|
92
|
|
93
|
$pconfig['tunnel_network'] = $a_server[$id]['tunnel_network'];
|
94
|
$pconfig['remote_network'] = $a_server[$id]['remote_network'];
|
95
|
$pconfig['gwredir'] = $a_server[$id]['gwredir'];
|
96
|
$pconfig['local_network'] = $a_server[$id]['local_network'];
|
97
|
$pconfig['maxclients'] = $a_server[$id]['maxclients'];
|
98
|
$pconfig['compression'] = $a_server[$id]['compression'];
|
99
|
$pconfig['settos'] = $a_server[$id]['settos'];
|
100
|
$pconfig['client2client'] = $a_server[$id]['client2client'];
|
101
|
|
102
|
$pconfig['pool_enable'] = $a_server[$id]['pool_enable'];
|
103
|
|
104
|
$pconfig['dns_domain'] = $a_server[$id]['dns_domain'];
|
105
|
if ($pconfig['dns_domain'])
|
106
|
$pconfig['dns_domain_enable'] = true;
|
107
|
|
108
|
$pconfig['dns_server1'] = $a_server[$id]['dns_server1'];
|
109
|
$pconfig['dns_server2'] = $a_server[$id]['dns_server2'];
|
110
|
$pconfig['dns_server3'] = $a_server[$id]['dns_server3'];
|
111
|
$pconfig['dns_server4'] = $a_server[$id]['dns_server4'];
|
112
|
if ($pconfig['dns_server1'] ||
|
113
|
$pconfig['dns_server2'] ||
|
114
|
$pconfig['dns_server3'] ||
|
115
|
$pconfig['dns_server4'])
|
116
|
$pconfig['dns_server_enable'] = true;
|
117
|
|
118
|
$pconfig['ntp_server1'] = $a_server[$id]['ntp_server1'];
|
119
|
$pconfig['ntp_server2'] = $a_server[$id]['ntp_server2'];
|
120
|
if ($pconfig['ntp_server1'] ||
|
121
|
$pconfig['ntp_server2'])
|
122
|
$pconfig['ntp_server_enable'] = true;
|
123
|
|
124
|
$pconfig['netbios_enable'] = $a_server[$id]['netbios_enable'];
|
125
|
$pconfig['netbios_ntype'] = $a_server[$id]['netbios_ntype'];
|
126
|
$pconfig['netbios_scope'] = $a_server[$id]['netbios_scope'];
|
127
|
|
128
|
$pconfig['wins_server1'] = $a_server[$id]['wins_server1'];
|
129
|
$pconfig['wins_server2'] = $a_server[$id]['wins_server2'];
|
130
|
if ($pconfig['wins_server1'] ||
|
131
|
$pconfig['wins_server2'])
|
132
|
$pconfig['wins_server_enable'] = true;
|
133
|
|
134
|
$pconfig['nbdd_server1'] = $a_server[$id]['nbdd_server1'];
|
135
|
if ($pconfig['nbdd_server1'])
|
136
|
$pconfig['nbdd_server_enable'] = true;
|
137
|
}
|
138
|
}
|
139
|
|
140
|
if ($_POST) {
|
141
|
|
142
|
unset($input_errors);
|
143
|
$pconfig = $_POST;
|
144
|
|
145
|
if (isset($id) && $a_server[$id])
|
146
|
$vpnid = $a_server[$id]['vpnid'];
|
147
|
else
|
148
|
$vpnid = 0;
|
149
|
|
150
|
/* input validation */
|
151
|
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port'))
|
152
|
$input_errors[] = $result;
|
153
|
|
154
|
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network'))
|
155
|
$input_errors[] = $result;
|
156
|
|
157
|
if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'Remote network'))
|
158
|
$input_errors[] = $result;
|
159
|
|
160
|
if ($result = openvpn_validate_cidr($pconfig['local_network'], 'Local network'))
|
161
|
$input_errors[] = $result;
|
162
|
|
163
|
if (openvpn_port_used($pconfig['protocol'], $pconfig['local_port']) != $vpnid)
|
164
|
$input_errors[] = "The specified 'Local port' is in use. Please select another value";
|
165
|
|
166
|
if ($pconfig['auth_method'] == 'shared_key')
|
167
|
if (!strstr($pconfig['shared_key'], "-----BEGIN OpenVPN Static key V1-----") ||
|
168
|
!strstr($pconfig['shared_key'], "-----END OpenVPN Static key V1-----"))
|
169
|
$input_errors[] = "The field 'Shared Key' does not appear to be valid";
|
170
|
|
171
|
if ($pconfig['dns_server_enable']) {
|
172
|
if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1'])))
|
173
|
$input_errors[] = "The field 'DNS Server #1' must contain a valid IP address";
|
174
|
if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2'])))
|
175
|
$input_errors[] = "The field 'DNS Server #2' must contain a valid IP address";
|
176
|
if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3'])))
|
177
|
$input_errors[] = "The field 'DNS Server #3' must contain a valid IP address";
|
178
|
if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4'])))
|
179
|
$input_errors[] = "The field 'DNS Server #4' must contain a valid IP address";
|
180
|
}
|
181
|
|
182
|
if ($pconfig['ntp_server_enable']) {
|
183
|
if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1'])))
|
184
|
$input_errors[] = "The field 'NTP Server #1' must contain a valid IP address";
|
185
|
if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2'])))
|
186
|
$input_errors[] = "The field 'NTP Server #2' must contain a valid IP address";
|
187
|
if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3'])))
|
188
|
$input_errors[] = "The field 'NTP Server #3' must contain a valid IP address";
|
189
|
if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4'])))
|
190
|
$input_errors[] = "The field 'NTP Server #4' must contain a valid IP address";
|
191
|
}
|
192
|
|
193
|
if ($pconfig['netbios_enable']) {
|
194
|
if ($pconfig['wins_server_enable']) {
|
195
|
if (!empty($pconfig['wins_server1']) && !is_ipaddr(trim($pconfig['wins_server1'])))
|
196
|
$input_errors[] = "The field 'WINS Server #1' must contain a valid IP address";
|
197
|
if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2'])))
|
198
|
$input_errors[] = "The field 'WINS Server #2' must contain a valid IP address";
|
199
|
}
|
200
|
if ($pconfig['nbdd_server_enable'])
|
201
|
if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1'])))
|
202
|
$input_errors[] = "The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address";
|
203
|
}
|
204
|
|
205
|
if ($pconfig['maxclients'] && !is_numeric($pconfig['maxclients']))
|
206
|
$input_errors[] = "The field 'Concurrent connections' must be numeric.";
|
207
|
|
208
|
if ($pconfig['auth_method'] == 'shared_key') {
|
209
|
$reqfields[] = 'shared_key';
|
210
|
$reqfieldsn[] = 'Shared key';
|
211
|
} else {
|
212
|
$reqfields[] = explode(" ", "caref certref");
|
213
|
$reqfieldsn[] = explode(",", "Certificate Authority,Certificate");;
|
214
|
}
|
215
|
|
216
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
217
|
|
218
|
if (!$input_errors) {
|
219
|
|
220
|
$server = array();
|
221
|
|
222
|
if ($vpnid)
|
223
|
$server['vpnid'] = $vpnid;
|
224
|
else
|
225
|
$server['vpnid'] = openvpn_vpnid_next();
|
226
|
|
227
|
$server['disable'] = $pconfig['disable'];
|
228
|
$server['protocol'] = $pconfig['protocol'];
|
229
|
$server['interface'] = $pconfig['interface'];
|
230
|
$server['local_port'] = $pconfig['local_port'];
|
231
|
$server['description'] = $pconfig['description'];
|
232
|
|
233
|
$server['auth_method'] = $pconfig['auth_method'];
|
234
|
if ($server['auth_method'] == "shared_key")
|
235
|
$server['shared_key'] = base64_encode($pconfig['shared_key']);
|
236
|
else {
|
237
|
$server['caref'] = $pconfig['caref'];
|
238
|
$server['certref'] = $pconfig['certref'];
|
239
|
}
|
240
|
$server['crypto'] = $pconfig['crypto'];
|
241
|
|
242
|
$server['tunnel_network'] = $pconfig['tunnel_network'];
|
243
|
$server['remote_network'] = $pconfig['remote_network'];
|
244
|
$server['gwredir'] = $pconfig['gwredir'];
|
245
|
$server['local_network'] = $pconfig['local_network'];
|
246
|
$server['maxclients'] = $pconfig['maxclients'];
|
247
|
$server['compression'] = $pconfig['compression'];
|
248
|
$server['client2client'] = $pconfig['client2client'];
|
249
|
|
250
|
$server['pool_enable'] = $pconfig['pool_enable'];
|
251
|
|
252
|
if ($pconfig['dns_domain_enable'])
|
253
|
$server['dns_domain'] = $pconfig['dns_domain'];
|
254
|
|
255
|
if ($pconfig['dns_server_enable']) {
|
256
|
$server['dns_server1'] = $pconfig['dns_server1'];
|
257
|
$server['dns_server2'] = $pconfig['dns_server2'];
|
258
|
$server['dns_server3'] = $pconfig['dns_server3'];
|
259
|
$server['dns_server4'] = $pconfig['dns_server4'];
|
260
|
}
|
261
|
|
262
|
if ($pconfig['ntp_server_enable']) {
|
263
|
$server['ntp_server1'] = $pconfig['ntp_server1'];
|
264
|
$server['ntp_server2'] = $pconfig['ntp_server2'];
|
265
|
}
|
266
|
|
267
|
$server['netbios_enable'] = $pconfig['netbios_enable'];
|
268
|
$server['netbios_ntype'] = $pconfig['netbios_ntype'];
|
269
|
$server['netbios_scope'] = $pconfig['netbios_scope'];
|
270
|
|
271
|
if ($pconfig['netbios_enable']) {
|
272
|
|
273
|
if ($pconfig['wins_server_enable']) {
|
274
|
$server['wins_server1'] = $pconfig['wins_server1'];
|
275
|
$server['wins_server2'] = $pconfig['wins_server2'];
|
276
|
}
|
277
|
|
278
|
if ($pconfig['dns_server_enable'])
|
279
|
$server['nbdd_server1'] = $pconfig['nbdd_server1'];
|
280
|
}
|
281
|
|
282
|
if (isset($id) && $a_server[$id])
|
283
|
$a_server[$id] = $server;
|
284
|
else
|
285
|
$a_server[] = $server;
|
286
|
|
287
|
openvpn_resync('server', $server);
|
288
|
write_config();
|
289
|
|
290
|
header("Location: vpn_openvpn_server.php");
|
291
|
exit;
|
292
|
}
|
293
|
}
|
294
|
|
295
|
include("head.inc");
|
296
|
|
297
|
?>
|
298
|
|
299
|
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
|
300
|
<?php include("fbegin.inc"); ?>
|
301
|
<script language="JavaScript">
|
302
|
<!--
|
303
|
|
304
|
function method_change() {
|
305
|
index = document.iform.auth_method.selectedIndex;
|
306
|
value = document.iform.auth_method.options[index].value;
|
307
|
switch(value) {
|
308
|
case "pki":
|
309
|
document.getElementById("pki_ca").style.display="";
|
310
|
document.getElementById("pki_cert").style.display="";
|
311
|
document.getElementById("psk").style.display="none";
|
312
|
break;
|
313
|
case "shared_key":
|
314
|
document.getElementById("pki_ca").style.display="none";
|
315
|
document.getElementById("pki_cert").style.display="none";
|
316
|
document.getElementById("psk").style.display="";
|
317
|
break;
|
318
|
}
|
319
|
}
|
320
|
|
321
|
function gwredir_change() {
|
322
|
|
323
|
if (document.iform.gwredir.checked)
|
324
|
document.getElementById("local_opts").style.display="none";
|
325
|
else
|
326
|
document.getElementById("local_opts").style.display="";
|
327
|
}
|
328
|
|
329
|
function dns_domain_change() {
|
330
|
|
331
|
if (document.iform.dns_domain_enable.checked)
|
332
|
document.getElementById("dns_domain_data").style.display="";
|
333
|
else
|
334
|
document.getElementById("dns_domain_data").style.display="none";
|
335
|
}
|
336
|
|
337
|
function dns_server_change() {
|
338
|
|
339
|
if (document.iform.dns_server_enable.checked)
|
340
|
document.getElementById("dns_server_data").style.display="";
|
341
|
else
|
342
|
document.getElementById("dns_server_data").style.display="none";
|
343
|
}
|
344
|
|
345
|
function wins_server_change() {
|
346
|
|
347
|
if (document.iform.wins_server_enable.checked)
|
348
|
document.getElementById("wins_server_data").style.display="";
|
349
|
else
|
350
|
document.getElementById("wins_server_data").style.display="none";
|
351
|
}
|
352
|
|
353
|
function ntp_server_change() {
|
354
|
|
355
|
if (document.iform.ntp_server_enable.checked)
|
356
|
document.getElementById("ntp_server_data").style.display="";
|
357
|
else
|
358
|
document.getElementById("ntp_server_data").style.display="none";
|
359
|
}
|
360
|
|
361
|
function netbios_change() {
|
362
|
|
363
|
if (document.iform.netbios_enable.checked) {
|
364
|
document.getElementById("netbios_data").style.display="";
|
365
|
document.getElementById("wins_opts").style.display="";
|
366
|
} else {
|
367
|
document.getElementById("netbios_data").style.display="none";
|
368
|
document.getElementById("wins_opts").style.display="none";
|
369
|
}
|
370
|
}
|
371
|
|
372
|
//-->
|
373
|
</script>
|
374
|
<?php
|
375
|
if ($input_errors)
|
376
|
print_input_errors($input_errors);
|
377
|
if ($savemsg)
|
378
|
print_info_box($savemsg);
|
379
|
?>
|
380
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
381
|
<tr>
|
382
|
<td class="tabnavtbl">
|
383
|
<ul id="tabnav">
|
384
|
<?php
|
385
|
$tab_array = array();
|
386
|
$tab_array[] = array(gettext("Server"), true, "vpn_openvpn_server.php");
|
387
|
$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
|
388
|
$tab_array[] = array(gettext("Client Specific Overrides"), false, "vpn_openvpn_csc.php");
|
389
|
display_top_tabs($tab_array);
|
390
|
?>
|
391
|
</ul>
|
392
|
</td>
|
393
|
</tr>
|
394
|
<tr>
|
395
|
<td class="tabcont">
|
396
|
|
397
|
<?php if($act=="new" || $act=="edit"): ?>
|
398
|
|
399
|
<form action="vpn_openvpn_server.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
|
400
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
401
|
<tr>
|
402
|
<td width="22%" valign="top" class="vncellreq">Disabled</td>
|
403
|
<td width="78%" class="vtable">
|
404
|
<table border="0" cellpadding="0" cellspacing="0">
|
405
|
<tr>
|
406
|
<td>
|
407
|
<?php set_checked($pconfig['disable'],$chk); ?>
|
408
|
<input name="disable" type="checkbox" value="yes" <?=$chk;?>/>
|
409
|
</td>
|
410
|
<td>
|
411
|
|
412
|
<span class="vexpl">
|
413
|
<strong>Disable this server</strong><br>
|
414
|
</span>
|
415
|
</td>
|
416
|
</tr>
|
417
|
</table>
|
418
|
Set this option to disable this server without removing it from the list.
|
419
|
</td>
|
420
|
</tr>
|
421
|
<tr>
|
422
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol");?></td>
|
423
|
<td width="78%" class="vtable">
|
424
|
<select name='protocol' class="formselect">
|
425
|
<?php
|
426
|
foreach ($openvpn_prots as $prot):
|
427
|
$selected = "";
|
428
|
if ($pconfig['protocol'] == $prot)
|
429
|
$selected = "selected";
|
430
|
?>
|
431
|
<option value="<?=$prot;?>" <?=$selected;?>><?=$prot;?></option>
|
432
|
<?php endforeach; ?>
|
433
|
</select>
|
434
|
</td>
|
435
|
</tr>
|
436
|
<tr>
|
437
|
<td width="22%" valign="top" class="vncellreq">Interface</td>
|
438
|
<td width="78%" class="vtable">
|
439
|
<select name="interface" class="formselect">
|
440
|
<?php
|
441
|
$interfaces = get_configured_interface_with_descr();
|
442
|
$carpips = find_number_of_needed_carp_interfaces();
|
443
|
for ($i=0; $i<$carpips; $i++) {
|
444
|
$carpip = find_interface_ip("carp" . $i);
|
445
|
$interfaces['carp' . $i] = "CARP{$i} ({$carpip})";
|
446
|
}
|
447
|
foreach ($interfaces as $iface => $ifacename):
|
448
|
?>
|
449
|
<option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
|
450
|
<?=htmlspecialchars($ifacename);?>
|
451
|
</option>
|
452
|
<?php endforeach; ?>
|
453
|
</select> <br>
|
454
|
</td>
|
455
|
</tr>
|
456
|
<tr>
|
457
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Local port");?></td>
|
458
|
<td width="78%" class="vtable">
|
459
|
<input name="local_port" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['local_port']);?>"/>
|
460
|
</td>
|
461
|
</tr>
|
462
|
<tr>
|
463
|
<td width="22%" valign="top" class="vncell">Description</td>
|
464
|
<td width="78%" class="vtable">
|
465
|
<input name="description" type="text" class="formfld unknown" size="30" value="<?=htmlspecialchars($pconfig['description']);?>">
|
466
|
<br>
|
467
|
You may enter a description here for your reference (not parsed).
|
468
|
</td>
|
469
|
</tr>
|
470
|
<tr>
|
471
|
<td colspan="2" class="list" height="12"></td>
|
472
|
</tr>
|
473
|
<tr>
|
474
|
<td colspan="2" valign="top" class="listtopic">Cryptographic Settings</td>
|
475
|
</tr>
|
476
|
<tr>
|
477
|
<td width="22%" valign="top" class="vncellreq">Authentication Method</td>
|
478
|
<td width="78%" class="vtable">
|
479
|
<select name='auth_method' id='auth_method' class="formselect" onchange='method_change()'>
|
480
|
<?php
|
481
|
foreach ($openvpn_auth_methods as $method => $name):
|
482
|
$selected = "";
|
483
|
if ($pconfig['auth_method'] == $method)
|
484
|
$selected = "selected";
|
485
|
?>
|
486
|
<option value="<?=$method;?>" <?=$selected;?>><?=$name;?></option>
|
487
|
<?php endforeach; ?>
|
488
|
</select>
|
489
|
</td>
|
490
|
</tr>
|
491
|
<tr id="pki_ca">
|
492
|
<td width="22%" valign="top" class="vncellreq">Certificate Authority</td>
|
493
|
<td width="78%" class="vtable">
|
494
|
<select name='caref' class="formselect">
|
495
|
<?php
|
496
|
foreach ($config['system']['ca'] as $ca):
|
497
|
$selected = "";
|
498
|
if ($pconfig['caref'] == $ca['refid'])
|
499
|
$selected = "selected";
|
500
|
?>
|
501
|
<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['name'];?></option>
|
502
|
<?php endforeach; ?>
|
503
|
</select>
|
504
|
</td>
|
505
|
</tr>
|
506
|
<tr id="pki_cert">
|
507
|
<td width="22%" valign="top" class="vncellreq">Certificate</td>
|
508
|
<td width="78%" class="vtable">
|
509
|
<select name='certref' class="formselect">
|
510
|
<?php
|
511
|
foreach ($config['system']['cert'] as $cert):
|
512
|
$selected = "";
|
513
|
if ($pconfig['certref'] == $cert['refid'])
|
514
|
$selected = "selected";
|
515
|
?>
|
516
|
<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['name'];?></option>
|
517
|
<?php endforeach; ?>
|
518
|
</select>
|
519
|
</td>
|
520
|
</tr>
|
521
|
<tr id="psk">
|
522
|
<td width="22%" valign="top" class="vncellreq">Shared Key</td>
|
523
|
<td width="78%" class="vtable">
|
524
|
<textarea name="shared_key" cols="65" rows="7" class="formpre"><?=htmlspecialchars($pconfig['shared_key']);?></textarea>
|
525
|
<br/>
|
526
|
Paste your shared key here.
|
527
|
</td>
|
528
|
</tr>
|
529
|
<tr>
|
530
|
<td width="22%" valign="top" class="vncellreq">Encryption algorithm</td>
|
531
|
<td width="78%" class="vtable">
|
532
|
<select name="crypto" class="formselect">
|
533
|
<?php
|
534
|
$cipherlist = openvpn_get_cipherlist();
|
535
|
foreach ($cipherlist as $name => $desc):
|
536
|
$selected = '';
|
537
|
if ($name == $pconfig['crypto'])
|
538
|
$selected = ' selected';
|
539
|
?>
|
540
|
<option value="<?=$name;?>"<?=$selected?>>
|
541
|
<?=htmlspecialchars($desc);?>
|
542
|
</option>
|
543
|
<?php endforeach; ?>
|
544
|
</select>
|
545
|
</td>
|
546
|
</tr>
|
547
|
<tr>
|
548
|
<td colspan="2" class="list" height="12"></td>
|
549
|
</tr>
|
550
|
<tr>
|
551
|
<td colspan="2" valign="top" class="listtopic">Tunnel Settings</td>
|
552
|
</tr>
|
553
|
<tr>
|
554
|
<td width="22%" valign="top" class="vncellreq">Tunnel Network</td>
|
555
|
<td width="78%" class="vtable">
|
556
|
<input name="tunnel_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['tunnel_network']);?>">
|
557
|
<br>
|
558
|
This is the virtual network used for private
|
559
|
communications between this server and client
|
560
|
hosts expressed using CIDR (eg. 10.0.8.0/24).
|
561
|
The first network address will be assigned to
|
562
|
the server virtual interface. The remaining
|
563
|
network addresses can optionally be assigned
|
564
|
to connecting clients. (see Address Pool)
|
565
|
</td>
|
566
|
</tr>
|
567
|
<tr>
|
568
|
<td width="22%" valign="top" class="vncell">Remote Network</td>
|
569
|
<td width="78%" class="vtable">
|
570
|
<input name="remote_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['remote_network']);?>">
|
571
|
<br>
|
572
|
This is a network that will be routed through
|
573
|
the tunnel, so that a site-to-site VPN can be
|
574
|
established without manually changing the
|
575
|
routing tables. Expressed as a CIDR range. If
|
576
|
this is a site-to-site VPN, enter here the
|
577
|
remote LAN here. You may leave this blank if
|
578
|
you don't want a site-to-site VPN.
|
579
|
</td>
|
580
|
</tr>
|
581
|
<tr>
|
582
|
<td width="22%" valign="top" class="vncell">Redirect Gateway</td>
|
583
|
<td width="78%" class="vtable">
|
584
|
<table border="0" cellpadding="2" cellspacing="0">
|
585
|
<tr>
|
586
|
<td>
|
587
|
<?php set_checked($pconfig['gwredir'],$chk); ?>
|
588
|
<input name="gwredir" type="checkbox" value="yes" <?=$chk;?> onClick="gwredir_change()"/>
|
589
|
</td>
|
590
|
<td>
|
591
|
<span class="vexpl">
|
592
|
Force all client generated traffic through the tunnel.
|
593
|
</span>
|
594
|
</td>
|
595
|
</tr>
|
596
|
</table>
|
597
|
</td>
|
598
|
</tr>
|
599
|
<tr id="local_opts">
|
600
|
<td width="22%" valign="top" class="vncell">Local Network</td>
|
601
|
<td width="78%" class="vtable">
|
602
|
<input name="local_network" type="text" class="formfld unknown" size="20" value="<?=htmlspecialchars($pconfig['local_network']);?>">
|
603
|
<br>
|
604
|
This is the network that will be accessable
|
605
|
from the remote endpoint. Expressed as a CIDR
|
606
|
range. You may leave this blank if you don't
|
607
|
want to add a route to the local network
|
608
|
through this tunnel on the remote machine.
|
609
|
This is generally set to your LAN network.
|
610
|
</td>
|
611
|
</tr>
|
612
|
<tr>
|
613
|
<td width="22%" valign="top" class="vncell"><?=gettext("Concurrent connections");?></td>
|
614
|
<td width="78%" class="vtable">
|
615
|
<input name="maxclients" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['maxclients']);?>"/>
|
616
|
<br/>
|
617
|
Specify the maximum number of clients allowed to concurrently connect to this server.
|
618
|
</td>
|
619
|
</tr>
|
620
|
<tr>
|
621
|
<td width="22%" valign="top" class="vncell">Compression</td>
|
622
|
<td width="78%" class="vtable">
|
623
|
<table border="0" cellpadding="2" cellspacing="0">
|
624
|
<tr>
|
625
|
<td>
|
626
|
<?php set_checked($pconfig['compression'],$chk); ?>
|
627
|
<input name="compression" type="checkbox" value="yes" <?=$chk;?>>
|
628
|
</td>
|
629
|
<td>
|
630
|
<span class="vexpl">
|
631
|
Compress tunnel packets using the LZO algorithm.
|
632
|
</span>
|
633
|
</td>
|
634
|
</tr>
|
635
|
</table>
|
636
|
</td>
|
637
|
</tr>
|
638
|
<tr>
|
639
|
<td width="22%" valign="top" class="vncell">Type-of-Service</td>
|
640
|
<td width="78%" class="vtable">
|
641
|
<table border="0" cellpadding="2" cellspacing="0">
|
642
|
<tr>
|
643
|
<td>
|
644
|
<?php set_checked($pconfig['settos'],$chk); ?>
|
645
|
<input name="settos" type="checkbox" value="yes" <?=$chk;?>>
|
646
|
</td>
|
647
|
<td>
|
648
|
<span class="vexpl">
|
649
|
Set the TOS IP header value of tunnel packets to match the encapsulated packet value.
|
650
|
</span>
|
651
|
</td>
|
652
|
</tr>
|
653
|
</table>
|
654
|
</td>
|
655
|
</tr>
|
656
|
<tr>
|
657
|
<td width="22%" valign="top" class="vncell">Inter-client communication</td>
|
658
|
<td width="78%" class="vtable">
|
659
|
<table border="0" cellpadding="2" cellspacing="0">
|
660
|
<tr>
|
661
|
<td>
|
662
|
<?php set_checked($pconfig['client2client'],$chk); ?>
|
663
|
<input name="client2client" type="checkbox" value="yes" <?=$chk;?>/>
|
664
|
</td>
|
665
|
<td>
|
666
|
<span class="vexpl">
|
667
|
Allow communication between clients connected to this server
|
668
|
</span>
|
669
|
</td>
|
670
|
</tr>
|
671
|
</table>
|
672
|
</td>
|
673
|
</tr>
|
674
|
<tr>
|
675
|
<td colspan="2" class="list" height="12"></td>
|
676
|
</tr>
|
677
|
<tr>
|
678
|
<td colspan="2" valign="top" class="listtopic">Client Settings</td>
|
679
|
</tr>
|
680
|
<tr>
|
681
|
<td width="22%" valign="top" class="vncell">Address Pool</td>
|
682
|
<td width="78%" class="vtable">
|
683
|
<table border="0" cellpadding="2" cellspacing="0">
|
684
|
<tr>
|
685
|
<td>
|
686
|
<?php set_checked($pconfig['pool_enable'],$chk); ?>
|
687
|
<input name="pool_enable" type="checkbox" id="pool_enable" value="yes" <?=$chk;?>">
|
688
|
</td>
|
689
|
<td>
|
690
|
<span class="vexpl">
|
691
|
Provide a virtual adapter IP address to clients (see Tunnel Network)<br>
|
692
|
</span>
|
693
|
</td>
|
694
|
</tr>
|
695
|
</table>
|
696
|
</td>
|
697
|
</tr>
|
698
|
<tr>
|
699
|
<td width="22%" valign="top" class="vncell">DNS Default Domain</td>
|
700
|
<td width="78%" class="vtable">
|
701
|
<table border="0" cellpadding="2" cellspacing="0">
|
702
|
<tr>
|
703
|
<td>
|
704
|
<?php set_checked($pconfig['dns_domain_enable'],$chk); ?>
|
705
|
<input name="dns_domain_enable" type="checkbox" id="dns_domain_enable" value="yes" <?=$chk;?> onClick="dns_domain_change()">
|
706
|
</td>
|
707
|
<td>
|
708
|
<span class="vexpl">
|
709
|
Provide a default domain name to clients<br>
|
710
|
</span>
|
711
|
</td>
|
712
|
</tr>
|
713
|
</table>
|
714
|
<table border="0" cellpadding="2" cellspacing="0" id="dns_domain_data">
|
715
|
<tr>
|
716
|
<td>
|
717
|
<input name="dns_domain" type="text" class="formfld unknown" id="dns_domain" size="30" value="<?=htmlspecialchars($pconfig['dns_domain']);?>">
|
718
|
</td>
|
719
|
</tr>
|
720
|
</table>
|
721
|
</td>
|
722
|
</tr>
|
723
|
<tr>
|
724
|
<td width="22%" valign="top" class="vncell">DNS Servers</td>
|
725
|
<td width="78%" class="vtable">
|
726
|
<table border="0" cellpadding="2" cellspacing="0">
|
727
|
<tr>
|
728
|
<td>
|
729
|
<?php set_checked($pconfig['dns_server_enable'],$chk); ?>
|
730
|
<input name="dns_server_enable" type="checkbox" id="dns_server_enable" value="yes" <?=$chk;?> onClick="dns_server_change()">
|
731
|
</td>
|
732
|
<td>
|
733
|
<span class="vexpl">
|
734
|
Provide a DNS server list to clients<br>
|
735
|
</span>
|
736
|
</td>
|
737
|
</tr>
|
738
|
</table>
|
739
|
<table border="0" cellpadding="2" cellspacing="0" id="dns_server_data">
|
740
|
<tr>
|
741
|
<td>
|
742
|
<span class="vexpl">
|
743
|
Server #1:
|
744
|
</span>
|
745
|
<input name="dns_server1" type="text" class="formfld unknown" id="dns_server1" size="20" value="<?=$pconfig['dns_server1'];?>">
|
746
|
</td>
|
747
|
</tr>
|
748
|
<tr>
|
749
|
<td>
|
750
|
<span class="vexpl">
|
751
|
Server #2:
|
752
|
</span>
|
753
|
<input name="dns_server2" type="text" class="formfld unknown" id="dns_server2" size="20" value="<?=$pconfig['dns_server2'];?>">
|
754
|
</td>
|
755
|
</tr>
|
756
|
<tr>
|
757
|
<td>
|
758
|
<span class="vexpl">
|
759
|
Server #3:
|
760
|
</span>
|
761
|
<input name="dns_server3" type="text" class="formfld unknown" id="dns_server3" size="20" value="<?=$pconfig['dns_server3'];?>">
|
762
|
</td>
|
763
|
</tr>
|
764
|
<tr>
|
765
|
<td>
|
766
|
<span class="vexpl">
|
767
|
Server #4:
|
768
|
</span>
|
769
|
<input name="dns_server4" type="text" class="formfld unknown" id="dns_server4" size="20" value="<?=$pconfig['dns_server4'];?>">
|
770
|
</td>
|
771
|
</tr>
|
772
|
</table>
|
773
|
</td>
|
774
|
</tr>
|
775
|
<tr>
|
776
|
<td width="22%" valign="top" class="vncell">NTP Servers</td>
|
777
|
<td width="78%" class="vtable">
|
778
|
<table border="0" cellpadding="2" cellspacing="0">
|
779
|
<tr>
|
780
|
<td>
|
781
|
<?php set_checked($pconfig['ntp_server_enable'],$chk); ?>
|
782
|
<input name="ntp_server_enable" type="checkbox" id="ntp_server_enable" value="yes" <?=$chk;?> onClick="ntp_server_change()">
|
783
|
</td>
|
784
|
<td>
|
785
|
<span class="vexpl">
|
786
|
Provide a NTP server list to clients<br>
|
787
|
</span>
|
788
|
</td>
|
789
|
</tr>
|
790
|
</table>
|
791
|
<table border="0" cellpadding="2" cellspacing="0" id="ntp_server_data">
|
792
|
<tr>
|
793
|
<td>
|
794
|
<span class="vexpl">
|
795
|
Server #1:
|
796
|
</span>
|
797
|
<input name="ntp_server1" type="text" class="formfld unknown" id="ntp_server1" size="20" value="<?=$pconfig['ntp_server1'];?>">
|
798
|
</td>
|
799
|
</tr>
|
800
|
<tr>
|
801
|
<td>
|
802
|
<span class="vexpl">
|
803
|
Server #2:
|
804
|
</span>
|
805
|
<input name="ntp_server2" type="text" class="formfld unknown" id="ntp_server2" size="20" value="<?=$pconfig['ntp_server2'];?>">
|
806
|
</td>
|
807
|
</tr>
|
808
|
</table>
|
809
|
</td>
|
810
|
</tr>
|
811
|
<tr>
|
812
|
<td width="22%" valign="top" class="vncell">NetBIOS Options</td>
|
813
|
<td width="78%" class="vtable">
|
814
|
<table border="0" cellpadding="2" cellspacing="0">
|
815
|
<tr>
|
816
|
<td>
|
817
|
<?php set_checked($pconfig['netbios_enable'],$chk); ?>
|
818
|
<input name="netbios_enable" type="checkbox" id="netbios_enable" value="yes" <?=$chk;?> onClick="netbios_change()">
|
819
|
</td>
|
820
|
<td>
|
821
|
<span class="vexpl">
|
822
|
Enable NetBIOS over TCP/IP<br>
|
823
|
</span>
|
824
|
</td>
|
825
|
</tr>
|
826
|
</table>
|
827
|
If this option is not set, all Netbios-over-TCP/IP options (includeing WINS) will be disabled.
|
828
|
<br/>
|
829
|
<table border="0" cellpadding="2" cellspacing="0" id="netbios_data">
|
830
|
<tr>
|
831
|
<td>
|
832
|
<br/>
|
833
|
<span class="vexpl">
|
834
|
Node Type:
|
835
|
</span>
|
836
|
<select name='netbios_ntype' class="formselect">
|
837
|
<?php
|
838
|
foreach ($netbios_nodetypes as $type => $name):
|
839
|
$selected = "";
|
840
|
if ($pconfig['netbios_ntype'] == $type)
|
841
|
$selected = "selected";
|
842
|
?>
|
843
|
<option value="<?=$type;?>" <?=$selected;?>><?=$name;?></option>
|
844
|
<?php endforeach; ?>
|
845
|
</select>
|
846
|
<br/>
|
847
|
Possible options: b-node (broadcasts), p-node
|
848
|
(point-to-point name queries to a WINS server),
|
849
|
m-node (broadcast then query name server), and
|
850
|
h-node (query name server, then broadcast).
|
851
|
</td>
|
852
|
</tr>
|
853
|
<tr>
|
854
|
<td>
|
855
|
<br/>
|
856
|
<span class="vexpl">
|
857
|
Scope ID:
|
858
|
</span>
|
859
|
<input name="netbios_scope" type="text" class="formfld unknown" id="netbios_scope" size="30" value="<?=htmlspecialchars($pconfig['netbios_scope']);?>">
|
860
|
<br/>
|
861
|
A NetBIOS Scope ID provides an extended naming
|
862
|
service for NetBIOS over TCP/IP. The NetBIOS
|
863
|
scope ID isolates NetBIOS traffic on a single
|
864
|
network to only those nodes with the same
|
865
|
NetBIOS scope ID.
|
866
|
</td>
|
867
|
</tr>
|
868
|
</table>
|
869
|
</td>
|
870
|
</tr>
|
871
|
<tr id="wins_opts">
|
872
|
<td width="22%" valign="top" class="vncell">WINS Servers</td>
|
873
|
<td width="78%" class="vtable">
|
874
|
<table border="0" cellpadding="2" cellspacing="0">
|
875
|
<tr>
|
876
|
<td>
|
877
|
<?php set_checked($pconfig['wins_server_enable'],$chk); ?>
|
878
|
<input name="wins_server_enable" type="checkbox" id="wins_server_enable" value="yes" <?=$chk;?> onClick="wins_server_change()">
|
879
|
</td>
|
880
|
<td>
|
881
|
<span class="vexpl">
|
882
|
Provide a WINS server list to clients<br>
|
883
|
</span>
|
884
|
</td>
|
885
|
</tr>
|
886
|
</table>
|
887
|
<table border="0" cellpadding="2" cellspacing="0" id="wins_server_data">
|
888
|
<tr>
|
889
|
<td>
|
890
|
<span class="vexpl">
|
891
|
Server #1:
|
892
|
</span>
|
893
|
<input name="wins_server1" type="text" class="formfld unknown" id="wins_server1" size="20" value="<?=$pconfig['wins_server1'];?>">
|
894
|
</td>
|
895
|
</tr>
|
896
|
<tr>
|
897
|
<td>
|
898
|
<span class="vexpl">
|
899
|
Server #2:
|
900
|
</span>
|
901
|
<input name="wins_server2" type="text" class="formfld unknown" id="wins_server2" size="20" value="<?=$pconfig['wins_server2'];?>">
|
902
|
</td>
|
903
|
</tr>
|
904
|
</table>
|
905
|
</td>
|
906
|
</tr>
|
907
|
<tr>
|
908
|
<td width="22%" valign="top"> </td>
|
909
|
<td width="78%">
|
910
|
<input name="save" type="submit" class="formbtn" value="Save">
|
911
|
<input name="act" type="hidden" value="<?=$act;?>">
|
912
|
<?php if (isset($id) && $a_server[$id]): ?>
|
913
|
<input name="id" type="hidden" value="<?=$id;?>">
|
914
|
<?php endif; ?>
|
915
|
</td>
|
916
|
</tr>
|
917
|
</table>
|
918
|
</form>
|
919
|
|
920
|
<?php else: ?>
|
921
|
|
922
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
923
|
<tr>
|
924
|
<td width="10%" class="listhdrr">Disabled</td>
|
925
|
<td width="10%" class="listhdrr">Protocol</td>
|
926
|
<td width="30%" class="listhdrr">Tunnel Network</td>
|
927
|
<td width="40%" class="listhdrr">Description</td>
|
928
|
<td width="10%" class="list"></td>
|
929
|
</tr>
|
930
|
<?php
|
931
|
$i = 0;
|
932
|
foreach($a_server as $server):
|
933
|
$disabled = "NO";
|
934
|
if ($server['disable'])
|
935
|
$disabled = "YES";
|
936
|
?>
|
937
|
<tr>
|
938
|
<td class="listlr">
|
939
|
<?=$disabled;?>
|
940
|
</td>
|
941
|
<td class="listr">
|
942
|
<?=htmlspecialchars($server['protocol']);?>
|
943
|
</td>
|
944
|
<td class="listr">
|
945
|
<?=htmlspecialchars($server['tunnel_network']);?>
|
946
|
</td>
|
947
|
<td class="listr">
|
948
|
<?=htmlspecialchars($server['description']);?>
|
949
|
</td>
|
950
|
<td valign="middle" nowrap class="list">
|
951
|
<a href="vpn_openvpn_server.php?act=edit&id=<?=$i;?>">
|
952
|
<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="edit server" width="17" height="17" border="0">
|
953
|
</a>
|
954
|
|
955
|
<a href="vpn_openvpn_server.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this server?')">
|
956
|
<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="delete server" width="17" height="17" border="0">
|
957
|
</a>
|
958
|
</td>
|
959
|
</tr>
|
960
|
<?php
|
961
|
$i++;
|
962
|
endforeach;
|
963
|
?>
|
964
|
<tr>
|
965
|
<td class="list" colspan="4"></td>
|
966
|
<td class="list">
|
967
|
<a href="vpn_openvpn_server.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="add server" width="17" height="17" border="0">
|
968
|
</a>
|
969
|
</td>
|
970
|
</tr>
|
971
|
<tr>
|
972
|
<td colspan="4">
|
973
|
<p>
|
974
|
<?=gettext("Additional OpenVPN servers can be added here.");?>
|
975
|
</p>
|
976
|
</td>
|
977
|
</tr>
|
978
|
</table>
|
979
|
|
980
|
<? endif; ?>
|
981
|
|
982
|
</td>
|
983
|
</tr>
|
984
|
</table>
|
985
|
<script language="JavaScript">
|
986
|
<!--
|
987
|
method_change();
|
988
|
gwredir_change();
|
989
|
dns_domain_change();
|
990
|
dns_server_change();
|
991
|
wins_server_change();
|
992
|
ntp_server_change();
|
993
|
netbios_change();
|
994
|
//-->
|
995
|
</script>
|
996
|
</body>
|
997
|
<?php include("fend.inc"); ?>
|
998
|
|
999
|
<?php
|
1000
|
|
1001
|
/* local utility functions */
|
1002
|
|
1003
|
function set_checked($var,& $chk) {
|
1004
|
if($var)
|
1005
|
$chk = 'checked';
|
1006
|
else
|
1007
|
$chk = '';
|
1008
|
}
|
1009
|
|
1010
|
?>
|
1011
|
|