1
|
<?php
|
2
|
/*
|
3
|
vpn_openvpn_csc.php
|
4
|
|
5
|
Copyright (C) 2008 Shrew Soft Inc.
|
6
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
##|+PRIV
|
32
|
##|*IDENT=page-openvpn-csc
|
33
|
##|*NAME=OpenVPN: Client Specific Override page
|
34
|
##|*DESCR=Allow access to the 'OpenVPN: Client Specific Override' page.
|
35
|
##|*MATCH=vpn_openvpn_csc.php*
|
36
|
##|-PRIV
|
37
|
|
38
|
require("guiconfig.inc");
|
39
|
require_once("openvpn.inc");
|
40
|
require_once("pkg-utils.inc");
|
41
|
|
42
|
$pgtitle = array(gettext("OpenVPN"), gettext("Client Specific Override"));
|
43
|
$shortcut_section = "openvpn";
|
44
|
|
45
|
if (!is_array($config['openvpn']['openvpn-csc'])) {
|
46
|
$config['openvpn']['openvpn-csc'] = array();
|
47
|
}
|
48
|
|
49
|
$a_csc = &$config['openvpn']['openvpn-csc'];
|
50
|
|
51
|
if (is_numericint($_GET['id'])) {
|
52
|
$id = $_GET['id'];
|
53
|
}
|
54
|
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
|
55
|
$id = $_POST['id'];
|
56
|
}
|
57
|
|
58
|
$act = $_GET['act'];
|
59
|
if (isset($_POST['act'])) {
|
60
|
$act = $_POST['act'];
|
61
|
}
|
62
|
|
63
|
if ($_GET['act'] == "del") {
|
64
|
if (!$a_csc[$id]) {
|
65
|
pfSenseHeader("vpn_openvpn_csc.php");
|
66
|
exit;
|
67
|
}
|
68
|
|
69
|
openvpn_delete_csc($a_csc[$id]);
|
70
|
unset($a_csc[$id]);
|
71
|
write_config();
|
72
|
$savemsg = gettext("Client Specific Override successfully deleted")."<br />";
|
73
|
}
|
74
|
|
75
|
if ($_GET['act'] == "edit") {
|
76
|
|
77
|
if (isset($id) && $a_csc[$id]) {
|
78
|
$pconfig['custom_options'] = $a_csc[$id]['custom_options'];
|
79
|
$pconfig['disable'] = isset($a_csc[$id]['disable']);
|
80
|
$pconfig['common_name'] = $a_csc[$id]['common_name'];
|
81
|
$pconfig['block'] = $a_csc[$id]['block'];
|
82
|
$pconfig['description'] = $a_csc[$id]['description'];
|
83
|
|
84
|
$pconfig['tunnel_network'] = $a_csc[$id]['tunnel_network'];
|
85
|
$pconfig['local_network'] = $a_csc[$id]['local_network'];
|
86
|
$pconfig['local_networkv6'] = $a_csc[$id]['local_networkv6'];
|
87
|
$pconfig['remote_network'] = $a_csc[$id]['remote_network'];
|
88
|
$pconfig['remote_networkv6'] = $a_csc[$id]['remote_networkv6'];
|
89
|
$pconfig['gwredir'] = $a_csc[$id]['gwredir'];
|
90
|
|
91
|
$pconfig['push_reset'] = $a_csc[$id]['push_reset'];
|
92
|
|
93
|
$pconfig['dns_domain'] = $a_csc[$id]['dns_domain'];
|
94
|
if ($pconfig['dns_domain']) {
|
95
|
$pconfig['dns_domain_enable'] = true;
|
96
|
}
|
97
|
|
98
|
$pconfig['dns_server1'] = $a_csc[$id]['dns_server1'];
|
99
|
$pconfig['dns_server2'] = $a_csc[$id]['dns_server2'];
|
100
|
$pconfig['dns_server3'] = $a_csc[$id]['dns_server3'];
|
101
|
$pconfig['dns_server4'] = $a_csc[$id]['dns_server4'];
|
102
|
|
103
|
if ($pconfig['dns_server1'] ||
|
104
|
$pconfig['dns_server2'] ||
|
105
|
$pconfig['dns_server3'] ||
|
106
|
$pconfig['dns_server4']) {
|
107
|
$pconfig['dns_server_enable'] = true;
|
108
|
}
|
109
|
|
110
|
$pconfig['ntp_server1'] = $a_csc[$id]['ntp_server1'];
|
111
|
$pconfig['ntp_server2'] = $a_csc[$id]['ntp_server2'];
|
112
|
|
113
|
if ($pconfig['ntp_server1'] ||
|
114
|
$pconfig['ntp_server2']) {
|
115
|
$pconfig['ntp_server_enable'] = true;
|
116
|
}
|
117
|
|
118
|
$pconfig['netbios_enable'] = $a_csc[$id]['netbios_enable'];
|
119
|
$pconfig['netbios_ntype'] = $a_csc[$id]['netbios_ntype'];
|
120
|
$pconfig['netbios_scope'] = $a_csc[$id]['netbios_scope'];
|
121
|
|
122
|
$pconfig['wins_server1'] = $a_csc[$id]['wins_server1'];
|
123
|
$pconfig['wins_server2'] = $a_csc[$id]['wins_server2'];
|
124
|
|
125
|
if ($pconfig['wins_server1'] ||
|
126
|
$pconfig['wins_server2']) {
|
127
|
$pconfig['wins_server_enable'] = true;
|
128
|
}
|
129
|
|
130
|
$pconfig['nbdd_server1'] = $a_csc[$id]['nbdd_server1'];
|
131
|
if ($pconfig['nbdd_server1']) {
|
132
|
$pconfig['nbdd_server_enable'] = true;
|
133
|
}
|
134
|
}
|
135
|
}
|
136
|
|
137
|
if ($_POST) {
|
138
|
|
139
|
unset($input_errors);
|
140
|
$pconfig = $_POST;
|
141
|
|
142
|
/* input validation */
|
143
|
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'Tunnel network')) {
|
144
|
$input_errors[] = $result;
|
145
|
}
|
146
|
|
147
|
if ($result = openvpn_validate_cidr($pconfig['local_network'], 'IPv4 Local Network', true, "ipv4")) {
|
148
|
$input_errors[] = $result;
|
149
|
}
|
150
|
|
151
|
if ($result = openvpn_validate_cidr($pconfig['local_networkv6'], 'IPv6 Local Network', true, "ipv6")) {
|
152
|
$input_errors[] = $result;
|
153
|
}
|
154
|
|
155
|
if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
|
156
|
$input_errors[] = $result;
|
157
|
}
|
158
|
|
159
|
if ($result = openvpn_validate_cidr($pconfig['remote_networkv6'], 'IPv6 Remote Network', true, "ipv6")) {
|
160
|
$input_errors[] = $result;
|
161
|
}
|
162
|
|
163
|
if ($pconfig['dns_server_enable']) {
|
164
|
if (!empty($pconfig['dns_server1']) && !is_ipaddr(trim($pconfig['dns_server1']))) {
|
165
|
$input_errors[] = gettext("The field 'DNS Server #1' must contain a valid IP address");
|
166
|
}
|
167
|
if (!empty($pconfig['dns_server2']) && !is_ipaddr(trim($pconfig['dns_server2']))) {
|
168
|
$input_errors[] = gettext("The field 'DNS Server #2' must contain a valid IP address");
|
169
|
}
|
170
|
if (!empty($pconfig['dns_server3']) && !is_ipaddr(trim($pconfig['dns_server3']))) {
|
171
|
$input_errors[] = gettext("The field 'DNS Server #3' must contain a valid IP address");
|
172
|
}
|
173
|
if (!empty($pconfig['dns_server4']) && !is_ipaddr(trim($pconfig['dns_server4']))) {
|
174
|
$input_errors[] = gettext("The field 'DNS Server #4' must contain a valid IP address");
|
175
|
}
|
176
|
}
|
177
|
|
178
|
if ($pconfig['ntp_server_enable']) {
|
179
|
if (!empty($pconfig['ntp_server1']) && !is_ipaddr(trim($pconfig['ntp_server1']))) {
|
180
|
$input_errors[] = gettext("The field 'NTP Server #1' must contain a valid IP address");
|
181
|
}
|
182
|
if (!empty($pconfig['ntp_server2']) && !is_ipaddr(trim($pconfig['ntp_server2']))) {
|
183
|
$input_errors[] = gettext("The field 'NTP Server #2' must contain a valid IP address");
|
184
|
}
|
185
|
if (!empty($pconfig['ntp_server3']) && !is_ipaddr(trim($pconfig['ntp_server3']))) {
|
186
|
$input_errors[] = gettext("The field 'NTP Server #3' must contain a valid IP address");
|
187
|
}
|
188
|
if (!empty($pconfig['ntp_server4']) && !is_ipaddr(trim($pconfig['ntp_server4']))) {
|
189
|
$input_errors[] = gettext("The field 'NTP Server #4' must contain a valid IP address");
|
190
|
}
|
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[] = gettext("The field 'WINS Server #1' must contain a valid IP address");
|
197
|
}
|
198
|
if (!empty($pconfig['wins_server2']) && !is_ipaddr(trim($pconfig['wins_server2']))) {
|
199
|
$input_errors[] = gettext("The field 'WINS Server #2' must contain a valid IP address");
|
200
|
}
|
201
|
}
|
202
|
if ($pconfig['nbdd_server_enable']) {
|
203
|
if (!empty($pconfig['nbdd_server1']) && !is_ipaddr(trim($pconfig['nbdd_server1']))) {
|
204
|
$input_errors[] = gettext("The field 'NetBIOS Data Distribution Server #1' must contain a valid IP address");
|
205
|
}
|
206
|
}
|
207
|
}
|
208
|
|
209
|
$reqdfields[] = 'common_name';
|
210
|
$reqdfieldsn[] = 'Common name';
|
211
|
|
212
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
213
|
|
214
|
if (!$input_errors) {
|
215
|
$csc = array();
|
216
|
|
217
|
$csc['custom_options'] = $pconfig['custom_options'];
|
218
|
if ($_POST['disable'] == "yes") {
|
219
|
$csc['disable'] = true;
|
220
|
}
|
221
|
$csc['common_name'] = $pconfig['common_name'];
|
222
|
$csc['block'] = $pconfig['block'];
|
223
|
$csc['description'] = $pconfig['description'];
|
224
|
$csc['tunnel_network'] = $pconfig['tunnel_network'];
|
225
|
$csc['local_network'] = $pconfig['local_network'];
|
226
|
$csc['local_networkv6'] = $pconfig['local_networkv6'];
|
227
|
$csc['remote_network'] = $pconfig['remote_network'];
|
228
|
$csc['remote_networkv6'] = $pconfig['remote_networkv6'];
|
229
|
$csc['gwredir'] = $pconfig['gwredir'];
|
230
|
$csc['push_reset'] = $pconfig['push_reset'];
|
231
|
|
232
|
if ($pconfig['dns_domain_enable']) {
|
233
|
$csc['dns_domain'] = $pconfig['dns_domain'];
|
234
|
}
|
235
|
|
236
|
if ($pconfig['dns_server_enable']) {
|
237
|
$csc['dns_server1'] = $pconfig['dns_server1'];
|
238
|
$csc['dns_server2'] = $pconfig['dns_server2'];
|
239
|
$csc['dns_server3'] = $pconfig['dns_server3'];
|
240
|
$csc['dns_server4'] = $pconfig['dns_server4'];
|
241
|
}
|
242
|
|
243
|
if ($pconfig['ntp_server_enable']) {
|
244
|
$csc['ntp_server1'] = $pconfig['ntp_server1'];
|
245
|
$csc['ntp_server2'] = $pconfig['ntp_server2'];
|
246
|
}
|
247
|
|
248
|
$csc['netbios_enable'] = $pconfig['netbios_enable'];
|
249
|
$csc['netbios_ntype'] = $pconfig['netbios_ntype'];
|
250
|
$csc['netbios_scope'] = $pconfig['netbios_scope'];
|
251
|
|
252
|
if ($pconfig['netbios_enable']) {
|
253
|
if ($pconfig['wins_server_enable']) {
|
254
|
$csc['wins_server1'] = $pconfig['wins_server1'];
|
255
|
$csc['wins_server2'] = $pconfig['wins_server2'];
|
256
|
}
|
257
|
|
258
|
if ($pconfig['dns_server_enable']) {
|
259
|
$csc['nbdd_server1'] = $pconfig['nbdd_server1'];
|
260
|
}
|
261
|
}
|
262
|
|
263
|
if (isset($id) && $a_csc[$id]) {
|
264
|
$old_csc_cn = $a_csc[$id]['common_name'];
|
265
|
$a_csc[$id] = $csc;
|
266
|
} else {
|
267
|
$a_csc[] = $csc;
|
268
|
}
|
269
|
|
270
|
if (!empty($old_csc_cn)) {
|
271
|
openvpn_cleanup_csc($old_csc_cn);
|
272
|
}
|
273
|
openvpn_resync_csc($csc);
|
274
|
write_config();
|
275
|
|
276
|
header("Location: vpn_openvpn_csc.php");
|
277
|
exit;
|
278
|
}
|
279
|
}
|
280
|
|
281
|
include("head.inc");
|
282
|
|
283
|
if ($input_errors)
|
284
|
print_input_errors($input_errors);
|
285
|
|
286
|
if ($savemsg)
|
287
|
print_info_box($savemsg, 'success');
|
288
|
|
289
|
$tab_array = array();
|
290
|
$tab_array[] = array(gettext("Server"), false, "vpn_openvpn_server.php");
|
291
|
$tab_array[] = array(gettext("Client"), false, "vpn_openvpn_client.php");
|
292
|
$tab_array[] = array(gettext("Client Specific Overrides"), true, "vpn_openvpn_csc.php");
|
293
|
$tab_array[] = array(gettext("Wizards"), false, "wizard.php?xml=openvpn_wizard.xml");
|
294
|
add_package_tabs("OpenVPN", $tab_array);
|
295
|
display_top_tabs($tab_array);
|
296
|
|
297
|
if($act=="new" || $act=="edit"):
|
298
|
require('classes/Form.class.php');
|
299
|
|
300
|
$form = new Form();
|
301
|
|
302
|
$section = new Form_Section('General Information');
|
303
|
|
304
|
$section->addInput(new Form_Checkbox(
|
305
|
'disable',
|
306
|
'Disable',
|
307
|
'Disable this override',
|
308
|
$pconfig['disable']
|
309
|
))->setHelp('Set this option to disable this client-specific override without removing it from the list.');
|
310
|
|
311
|
$section->addInput(new Form_Input(
|
312
|
'common_name',
|
313
|
'Common name',
|
314
|
'text',
|
315
|
$pconfig['common_name']
|
316
|
))->setHelp('Enter the client\'s X.509 common name.');
|
317
|
|
318
|
$section->addInput(new Form_Input(
|
319
|
'description',
|
320
|
'Description',
|
321
|
'text',
|
322
|
$pconfig['description']
|
323
|
))->setHelp('You may enter a description here for your reference (not parsed). ');
|
324
|
|
325
|
$section->addInput(new Form_Checkbox(
|
326
|
'block',
|
327
|
'Connection blocking',
|
328
|
'Block this client connection based on its common name. ',
|
329
|
$pconfig['block']
|
330
|
))->setHelp('Don\'t use this option to permanently disable a client due to a compromised key or password. Use a CRL (certificate revocation list) instead. ');
|
331
|
|
332
|
$form->add($section);
|
333
|
|
334
|
$section = new Form_Section('Tunnel settings');
|
335
|
|
336
|
$section->addInput(new Form_Input(
|
337
|
'tunnel_network',
|
338
|
'Tunnel Network',
|
339
|
'text',
|
340
|
$pconfig['tunnel_network']
|
341
|
))->setHelp('This is the virtual network used for private communications between this client and the server expressed using CIDR (eg. 10.0.8.0/24). ' .
|
342
|
'The first network address is assumed to be the server address and the second network address will be assigned to the client virtual interface. ');
|
343
|
|
344
|
$section->addInput(new Form_Input(
|
345
|
'local_network',
|
346
|
'IPv4 Local Network/s',
|
347
|
'text',
|
348
|
$pconfig['local_network']
|
349
|
))->setHelp('These are the IPv4 networks that will be accessible from this particular client. Expressed as a comma-separated list of one or more CIDR ranges. ' . '<br />' .
|
350
|
'NOTE: You do not need to specify networks here if they have already been defined on the main server configuration.');
|
351
|
|
352
|
$section->addInput(new Form_Input(
|
353
|
'local_networkv6',
|
354
|
'IPv6 Local Network/s',
|
355
|
'text',
|
356
|
$pconfig['local_networkv6']
|
357
|
))->setHelp('These are the IPv4 networks that will be accessible from this particular client. Expressed as a comma-separated list of one or more IP/PREFIX networks.' . '<br />' .
|
358
|
'NOTE: You do not need to specify networks here if they have already been defined on the main server configuration.');
|
359
|
|
360
|
$section->addInput(new Form_Input(
|
361
|
'remote_network',
|
362
|
'IPv4 Remote Network/s',
|
363
|
'text',
|
364
|
$pconfig['remote_network']
|
365
|
))->setHelp('These are the IPv4 networks that will be routed to this client specifically using iroute, so that a site-to-site VPN can be established. ' .
|
366
|
'Expressed as a comma-separated list of one or more CIDR ranges. You may leave this blank if there are no client-side networks to be routed.' . '<br />' .
|
367
|
'NOTE: Remember to add these subnets to the IPv4 Remote Networks list on the corresponding OpenVPN server settings.');
|
368
|
|
369
|
$section->addInput(new Form_Input(
|
370
|
'remote_networkv6',
|
371
|
'IPv6 Remote Network/s',
|
372
|
'text',
|
373
|
$pconfig['remote_networkv6']
|
374
|
))->setHelp('These are the IPv4 networks that will be routed to this client specifically using iroute, so that a site-to-site VPN can be established. ' .
|
375
|
'Expressed as a comma-separated list of one or more IP/PREFIX networks. You may leave this blank if there are no client-side networks to be routed.' . '<br />' .
|
376
|
'NOTE: Remember to add these subnets to the IPv6 Remote Networks list on the corresponding OpenVPN server settings.');
|
377
|
|
378
|
$section->addInput(new Form_Checkbox(
|
379
|
'gwredir',
|
380
|
'Redirect Gateway',
|
381
|
'Force all client generated traffic through the tunnel.',
|
382
|
$pconfig['gwredir']
|
383
|
));
|
384
|
|
385
|
$form->add($section);
|
386
|
|
387
|
$section = new Form_Section('Client settings');
|
388
|
|
389
|
// Default domain name
|
390
|
$section->addInput(new Form_Checkbox(
|
391
|
'push_reset',
|
392
|
'Server Definitions',
|
393
|
'Prevent this client from receiving any server-defined client settings. ',
|
394
|
$pconfig['push_reset']
|
395
|
));
|
396
|
|
397
|
$section->addInput(new Form_Checkbox(
|
398
|
'dns_domain_enable',
|
399
|
'DNS Default Domain',
|
400
|
'Provide a default domain name to clients',
|
401
|
$pconfig['dns_domain_enable']
|
402
|
))->toggles('.dnsdomain');
|
403
|
|
404
|
$group = new Form_Group('DNS Domain');
|
405
|
$group->addClass('dnsdomain');
|
406
|
|
407
|
$group->add(new Form_Input(
|
408
|
'dns_domain',
|
409
|
'DNS Domain',
|
410
|
'text',
|
411
|
$pconfig['dns_domain']
|
412
|
));
|
413
|
|
414
|
$section->add($group);
|
415
|
|
416
|
// DNS servers
|
417
|
$section->addInput(new Form_Checkbox(
|
418
|
'dns_server_enable',
|
419
|
'DNS Servers',
|
420
|
'Provide a DNS server list to clients',
|
421
|
$pconfig['dns_server_enable']
|
422
|
))->toggles('.dnsservers');
|
423
|
|
424
|
$group = new Form_Group(null);
|
425
|
$group->addClass('dnsservers');
|
426
|
|
427
|
$group->add(new Form_Input(
|
428
|
'dns_server1',
|
429
|
null,
|
430
|
'text',
|
431
|
$pconfig['dns_server1']
|
432
|
))->setHelp('Server 1');
|
433
|
|
434
|
$group->add(new Form_Input(
|
435
|
'dns_server2',
|
436
|
null,
|
437
|
'text',
|
438
|
$pconfig['dns_server2']
|
439
|
))->setHelp('Server 2');
|
440
|
|
441
|
$group->add(new Form_Input(
|
442
|
'dns_server3',
|
443
|
null,
|
444
|
'text',
|
445
|
$pconfig['dns_server3']
|
446
|
))->setHelp('Server 3');
|
447
|
|
448
|
$group->add(new Form_Input(
|
449
|
'dns_server4',
|
450
|
null,
|
451
|
'text',
|
452
|
$pconfig['dns_server4']
|
453
|
))->setHelp('Server 4');
|
454
|
|
455
|
$section->add($group);
|
456
|
|
457
|
// NTP servers
|
458
|
$section->addInput(new Form_Checkbox(
|
459
|
'ntp_server_enable',
|
460
|
'NTP Servers',
|
461
|
'Provide an NTP server list to clients',
|
462
|
$pconfig['ntp_server_enable']
|
463
|
))->toggles('.ntpservers');
|
464
|
|
465
|
$group = new Form_Group(null);
|
466
|
$group->addClass('ntpservers');
|
467
|
|
468
|
$group->add(new Form_Input(
|
469
|
'ntp_server1',
|
470
|
null,
|
471
|
'text',
|
472
|
$pconfig['ntp_server1']
|
473
|
))->setHelp('Server 1');
|
474
|
|
475
|
$group->add(new Form_Input(
|
476
|
'ntp_server2',
|
477
|
null,
|
478
|
'text',
|
479
|
$pconfig['ntp_server2']
|
480
|
))->setHelp('Server 2');
|
481
|
|
482
|
$section->add($group);
|
483
|
|
484
|
// NTP servers - For this section we need to use Javascript hiding since there
|
485
|
// are nested toggles
|
486
|
$section->addInput(new Form_Checkbox(
|
487
|
'netbios_enable',
|
488
|
'Netbios Option',
|
489
|
'Enable Netbios over TCP/IP',
|
490
|
$pconfig['netbios_enable']
|
491
|
))->setHelp('If this option is not set, all NetBIOS-over-TCP/IP options (including WINS) will be disabled. ');
|
492
|
|
493
|
$section->addInput(new Form_Select(
|
494
|
'netbios_ntype',
|
495
|
'Node Type',
|
496
|
$pconfig['netbios_ntype'],
|
497
|
$netbios_nodetypes
|
498
|
))->setHelp('Possible options: b-node (broadcasts), p-node (point-to-point name queries to a WINS server), m-node (broadcast then query name server), ' .
|
499
|
'and h-node (query name server, then broadcast). ');
|
500
|
|
501
|
$section->addInput(new Form_Input(
|
502
|
'netbios_scope',
|
503
|
null,
|
504
|
'text',
|
505
|
$pconfig['netbios_scope']
|
506
|
))->setHelp('A NetBIOS Scope ID provides an extended naming service for NetBIOS over TCP/IP. ' .
|
507
|
'The NetBIOS scope ID isolates NetBIOS traffic on a single network to only those nodes with the same NetBIOS scope ID. ');
|
508
|
|
509
|
$section->addInput(new Form_Checkbox(
|
510
|
'wins_server_enable',
|
511
|
'WINS servers',
|
512
|
'Provide a WINS server list to clients',
|
513
|
$pconfig['wins_server_enable']
|
514
|
));
|
515
|
|
516
|
$group = new Form_Group(null);
|
517
|
|
518
|
$group->add(new Form_Input(
|
519
|
'wins_server1',
|
520
|
null,
|
521
|
'text',
|
522
|
$pconfig['wins_server1']
|
523
|
))->setHelp('Server 1');
|
524
|
|
525
|
$group->add(new Form_Input(
|
526
|
'wins_server2',
|
527
|
null,
|
528
|
'text',
|
529
|
$pconfig['wins_server2']
|
530
|
))->setHelp('Server 2');
|
531
|
|
532
|
$group->addClass('winsservers');
|
533
|
|
534
|
$section->add($group);
|
535
|
|
536
|
$section->addInput(new Form_TextArea(
|
537
|
'custom_options',
|
538
|
'Advanced',
|
539
|
$pconfig['custom_options']
|
540
|
))->setHelp('Enter any additional options you would like to add for this client specific override, separated by a semicolon. ' . '<br />' .
|
541
|
'EXAMPLE: push "route 10.0.0.0 255.255.255.0"; ');
|
542
|
|
543
|
// The hidden fields
|
544
|
$section->addInput(new Form_Input(
|
545
|
'act',
|
546
|
null,
|
547
|
'hidden',
|
548
|
$act
|
549
|
));
|
550
|
|
551
|
if (isset($id) && $a_csc[$id]) {
|
552
|
$section->addInput(new Form_Input(
|
553
|
'id',
|
554
|
null,
|
555
|
'hidden',
|
556
|
$id
|
557
|
));
|
558
|
}
|
559
|
|
560
|
$form->add($section);
|
561
|
print($form);
|
562
|
|
563
|
?>
|
564
|
|
565
|
<script>
|
566
|
//<![CDATA[
|
567
|
events.push(function(){
|
568
|
var visible = false;
|
569
|
|
570
|
// Hides the <div> in which the specified input element lives so that the input, its label and help text are hidden
|
571
|
function hideInput(id, hide) {
|
572
|
if(hide)
|
573
|
$('#' + id).parent().parent('div').addClass('hidden');
|
574
|
else
|
575
|
$('#' + id).parent().parent('div').removeClass('hidden');
|
576
|
}
|
577
|
|
578
|
// Hides the <div> in which the specified checkbox lives so that the checkbox, its label and help text are hidden
|
579
|
function hideCheckbox(id, hide) {
|
580
|
if(hide)
|
581
|
$('#' + id).parent().parent().parent('div').addClass('hidden');
|
582
|
else
|
583
|
$('#' + id).parent().parent().parent('div').removeClass('hidden');
|
584
|
}
|
585
|
|
586
|
// Hides all elements of the specified class. This will usually be a section or group
|
587
|
function hideClass(s_class, hide) {
|
588
|
if(hide)
|
589
|
$('.' + s_class).hide();
|
590
|
else
|
591
|
$('.' + s_class).show();
|
592
|
}
|
593
|
|
594
|
// Hide/show that section, but have to also respect the wins_server_enable checkbox
|
595
|
function setNetbios() {
|
596
|
if($('#netbios_enable').prop('checked')) {
|
597
|
hideInput('netbios_ntype', false);
|
598
|
hideInput('netbios_scope', false);
|
599
|
hideCheckbox('wins_server_enable', false);
|
600
|
setWins();
|
601
|
} else {
|
602
|
hideInput('netbios_ntype', true);
|
603
|
hideInput('netbios_scope', true);
|
604
|
hideCheckbox('wins_server_enable', true);
|
605
|
hideClass('winsservers', true);
|
606
|
}
|
607
|
}
|
608
|
|
609
|
function setWins() {
|
610
|
hideClass('winsservers', ! $('#wins_server_enable').prop('checked'));
|
611
|
}
|
612
|
|
613
|
// On clicking the netbios_enable checkbox
|
614
|
$('#netbios_enable').click(function () {
|
615
|
setNetbios();
|
616
|
});
|
617
|
|
618
|
// On clicking the wins_server_enable checkbox
|
619
|
$('#wins_server_enable').click(function () {
|
620
|
setWins();
|
621
|
});
|
622
|
|
623
|
// On initial page load
|
624
|
setNetbios();
|
625
|
});
|
626
|
//]]>
|
627
|
</script>
|
628
|
|
629
|
<?php
|
630
|
else : // Not an 'add' or an 'edit'. Just the table of Override CSCs
|
631
|
?>
|
632
|
|
633
|
<div class="panel panel-default">
|
634
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('CSC Overrides')?></h2></div>
|
635
|
<div class="panel-body table-responsive">
|
636
|
<table class="table table-striped table-hover table-condensed">
|
637
|
<thead>
|
638
|
<tr>
|
639
|
<th><?=gettext("Disabled")?></th>
|
640
|
<th><?=gettext("Common Name")?></th>
|
641
|
<th><?=gettext("Description")?></th>
|
642
|
<th> <!-- Buttons --></th>
|
643
|
</tr>
|
644
|
</thead>
|
645
|
<tbody>
|
646
|
<?php
|
647
|
$i = 0;
|
648
|
foreach($a_csc as $csc):
|
649
|
$disabled = isset($csc['disable']) ? "Yes":"No";
|
650
|
?>
|
651
|
<tr>
|
652
|
<td class="listlr">
|
653
|
<?=$disabled?>
|
654
|
</td>
|
655
|
<td class="listr">
|
656
|
<?=htmlspecialchars($csc['common_name'])?>
|
657
|
</td>
|
658
|
<td class="listbg">
|
659
|
<?=htmlspecialchars($csc['description'])?>
|
660
|
</td>
|
661
|
<td>
|
662
|
<a href="vpn_openvpn_csc.php?act=edit&id=<?=$i?>" class="btn btn-info btn-xs"><?=gettext('Edit')?></a>
|
663
|
<a href="vpn_openvpn_csc.php?act=del&id=<?=$i?>" class="btn btn-danger btn-xs"><?=gettext('Delete')?></a>
|
664
|
</td>
|
665
|
</tr>
|
666
|
<?php
|
667
|
$i++;
|
668
|
endforeach;
|
669
|
?>
|
670
|
</tbody>
|
671
|
</table>
|
672
|
|
673
|
<nav class="action-buttons">
|
674
|
<a href="vpn_openvpn_csc.php?act=new" class="btn btn-success btn-sm"><?=gettext('Add CSC')?></a>
|
675
|
</nav>
|
676
|
|
677
|
</div>
|
678
|
</div>
|
679
|
|
680
|
<?php
|
681
|
endif;
|
682
|
include("foot.inc");
|