Project

General

Profile

Download (17.6 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
/* $Id$ */
4
/*
5
	$RCSfile$
6
	
7
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
8
	All rights reserved.
9
	
10
	Copyright (C) 2006  Fernando Lemos
11
	All rights reserved.
12

    
13
	This file was rewritten from scratch by Fernando Lemos but
14
	*MIGHT* contain code previously written by:
15

    
16
	Copyright (C) 2005 Peter Allgeyer <allgeyer_AT_web.de>
17
	All rights reserved.
18

    
19
	Copyright (C) 2004 Peter Curran (peter@closeconsultants.com).
20
	All rights reserved.
21

    
22
	Redistribution and use in source and binary forms, with or without
23
	modification, are permitted provided that the following conditions are met:
24

    
25
	1. Redistributions of source code must retain the above copyright notices,
26
	   this list of conditions and the following disclaimer.
27

    
28
	2. Redistributions in binary form must reproduce the above copyright
29
	   notices, this list of conditions and the following disclaimer in the
30
	   documentation and/or other materials provided with the distribution.
31

    
32
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
34
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
36
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41
	POSSIBILITY OF SUCH DAMAGE.
42
	
43
	DISABLE_PHP_LINT_CHECKING
44
	
45
	pfSense_BUILDER_BINARIES:	/usr/local/sbin/openvpn	/usr/bin/openssl	/sbin/ifconfig
46
	pfSense_MODULE:	openvpn
47

    
48
*/
49
require_once('config.inc');
50
require_once("certs.inc");
51
require_once('pfsense-utils.inc');
52

    
53
$openvpn_prots = array("UDP", "TCP");
54

    
55
/* 
56
 * The User Auth mode below is disabled because
57
 * OpenVPN erroneously requires that we provide
58
 * a CA configuration parameter. In this mode,
59
 * clients don't send a certificate so there is
60
 * no need for a CA. If we require that admins
61
 * provide one in the pfSense UI due to a bogus
62
 * requirement imposed by OpenVPN, it could be
63
 * considered very confusing ( I know I was ).
64
 *
65
 * -mgrooms
66
 */
67

    
68
$openvpn_dh_lengths = array(
69
	1024, 2048, 4096 );
70

    
71
$openvpn_server_modes = array(
72
	'p2p_tls' => "Peer to Peer ( SSL/TLS )",
73
	'p2p_shared_key' => "Peer to Peer ( Shared Key )",
74
	'server_tls' => "Remote Access ( SSL/TLS )",
75
//	'server_user' => "Remote Access ( User Auth )",
76
	'server_tls_user' => "Remote Access ( SSL/TLS + User Auth )");
77

    
78
$openvpn_client_modes = array(
79
	'p2p_tls' => "Peer to Peer ( SSL/TLS )",
80
	'p2p_shared_key' => "Peer to Peer ( Shared Key )" );
81

    
82
function openvpn_create_key() {
83

    
84
	$fp = popen("/usr/local/sbin/openvpn --genkey --secret /dev/stdout 2>/dev/null", "r");
85
	if (!$fp)
86
		return false;
87

    
88
	$rslt = stream_get_contents($fp);
89
	pclose($fp);
90

    
91
	return $rslt;
92
}
93

    
94
function openvpn_create_dhparams($bits) {
95

    
96
	$fp = popen("/usr/bin/openssl dhparam {$bits} 2>/dev/null", "r");
97
	if (!$fp)
98
		return false;
99

    
100
	$rslt = stream_get_contents($fp);
101
	pclose($fp);
102

    
103
	return $rslt;
104
}
105

    
106
function openvpn_vpnid_used($vpnid) {
107
	global $config;
108

    
109
	if (is_array($config['openvpn']['openvpn-server']))
110
		foreach ($config['openvpn']['openvpn-server'] as & $settings)
111
			if ($vpnid == $settings['vpnid'])
112
				return true;
113

    
114
	if (is_array($config['openvpn']['openvpn-client']))
115
		foreach ($config['openvpn']['openvpn-client'] as & $settings)
116
			if ($vpnid == $settings['vpnid'])
117
				return true;
118

    
119
	return false;
120
}
121

    
122
function openvpn_vpnid_next() {
123

    
124
	$vpnid = 1;
125
	while(openvpn_vpnid_used($vpnid))
126
		$vpnid++;
127

    
128
	return $vpnid;
129
}
130

    
131
function openvpn_port_used($prot, $port) {
132
	global $config;
133

    
134
	if (is_array($config['openvpn']['openvpn-server']))
135
		foreach ($config['openvpn']['openvpn-server'] as & $settings)
136
			if ($port == $settings['local_port'] &&
137
				$prot == $settings['protocol'])
138
				return $settings['vpnid'];
139

    
140
	if (is_array($config['openvpn']['openvpn-client']))
141
		foreach ($config['openvpn']['openvpn-client'] as & $settings)
142
			if ($port == $settings['local_port'] &&
143
				$prot == $settings['protocol'])
144
				return $settings['vpnid'];
145

    
146
	return 0;
147
}
148

    
149
function openvpn_port_next($prot) {
150

    
151
	$port = 1194;
152
	while(openvpn_port_used($prot, $port))
153
		$port++;
154

    
155
	return $port;
156
}
157

    
158
function openvpn_get_cipherlist() {
159

    
160
	$ciphers = array();
161
	$cipher_out = shell_exec('openvpn --show-ciphers | grep "default key" | awk \'{print $1, "(" $2 "-" $3 ")";}\'');
162
	$cipher_lines = explode("\n", trim($cipher_out));
163
	sort($cipher_lines);
164
	foreach ($cipher_lines as $line) {
165
		$words = explode(' ', $line);
166
		$ciphers[$words[0]] = "{$words[0]} {$words[1]}";
167
	}
168

    
169
	return $ciphers;
170
}
171

    
172
function openvpn_validate_host($value, $name) {
173
	$value = trim($value);
174
	if (empty($value) || (!is_domain($value) && !is_ipaddr($value)))
175
		return "The field '$name' must contain a valid IP address or domain name.";
176
	return false;
177
}
178

    
179
function openvpn_validate_port($value, $name) {
180
	$value = trim($value);
181
	if (empty($value) || !is_numeric($value) || $value < 0 || ($value > 65535))
182
		return "The field '$name' must contain a valid port, ranging from 0 to 65535.";
183
	return false;
184
}
185

    
186
function openvpn_validate_cidr($value, $name) {
187
	$value = trim($value);
188
	if (!empty($value)) {
189
		list($ip, $mask) = explode('/', $value);
190
		if (!is_ipaddr($ip) or !is_numeric($mask) or ($mask > 32) or ($mask < 0))
191
			return "The field '$name' must contain a valid CIDR range.";
192
	}
193
	return false;
194
}
195

    
196
function openvpn_add_dhcpopts(& $settings, & $conf) {
197

    
198
	if (!empty($settings['dns_domain'])) 
199
		$conf .= "push \"dhcp-option DOMAIN {$settings['dns_domain']}\"\n";
200

    
201
	if (!empty($settings['dns_server1']))
202
		$conf .= "push \"dhcp-option DNS {$settings['dns_server1']}\"\n";
203
	if (!empty($settings['dns_server2']))
204
		$conf .= "push \"dhcp-option DNS {$settings['dns_server2']}\"\n";
205
	if (!empty($settings['dns_server3']))
206
		$conf .= "push \"dhcp-option DNS {$settings['dns_server3']}\"\n";
207
	if (!empty($settings['dns_server4']))
208
		$conf .= "push \"dhcp-option DNS {$settings['dns_server4']}\"\n";
209

    
210
	if (!empty($settings['ntp_server1']))
211
		$conf .= "push \"dhcp-option NTP {$settings['dhcp_ntp']}\"\n";
212
	if (!empty($settings['ntp_server2']))
213
		$conf .= "push \"dhcp-option NTP {$settings['dhcp_ntp']}\"\n";
214

    
215
	if ($settings['netbios_enable']) {
216

    
217
		if (!empty($settings['dhcp_nbttype']) && ($settings['dhcp_nbttype'] != 0))
218
			$conf .= "push \"dhcp-option NBT {$settings['dhcp_nbttype']}\"\n";
219
		if (!empty($settings['dhcp_nbtscope'])) 
220
			$conf .= "push \"dhcp-option NBS {$settings['dhcp_nbtscope']}\"\n";
221

    
222
		if (!empty($settings['wins_server1']))
223
			$conf .= "push \"dhcp-option WINS {$settings['wins_server1']}\"\n";
224
		if (!empty($settings['wins_server2']))
225
			$conf .= "push \"dhcp-option WINS {$settings['wins_server2']}\"\n";
226

    
227
		if (!empty($settings['nbdd_server1']))
228
			$conf .= "push \"dhcp-option NBDD {$settings['nbdd_server1']}\"\n";
229
	}
230

    
231
	if ($settings['gwredir']) 
232
		$conf .= "push \"redirect-gateway def1\"\n";
233
}
234

    
235
function openvpn_add_custom(& $settings, & $conf) {
236

    
237
	if ($settings['custom_options']) {
238

    
239
		$options = explode(';', $settings['custom_options']);
240

    
241
		if (is_array($options)) {
242
			foreach ($options as $option)
243
				$conf .= "$option\n";
244
		} else
245
			$conf .= "{$settings['custom_options']}\n";
246
	}
247
}
248

    
249
function openvpn_add_keyfile(& $data, & $conf, $mode_id, $directive) {
250
	global $g;
251

    
252
	$fpath = $g['varetc_path']."/openvpn/{$mode_id}.{$directive}";
253
	file_put_contents($fpath, base64_decode($data));
254
	chown($fpath, 'nobody');
255
	chgrp($fpath, 'nobody');
256

    
257
	$conf .= "{$directive} {$fpath}\n";
258
}
259

    
260
function openvpn_reconfigure($mode,& $settings) {
261
	global $g, $config;
262

    
263
	if (empty($settings))
264
		return;
265
	if ($settings['disable']) 
266
		return;
267

    
268
	/*
269
	 * NOTE: Deleting tap devices causes spontaneous reboots. Instead,
270
	 * we use a vpnid number which is allocated for a particular client
271
	 * or server configuration. ( see openvpn_vpnid_next() )
272
	 */
273

    
274
	$vpnid = $settings['vpnid'];
275
	$mode_id = $mode.$vpnid;
276

    
277
	$tunname = "tun{$vpnid}";
278
	if ($mode == "server")
279
		$devname = "ovpns{$vpnid}";
280
	else
281
		$devname = "ovpnc{$vpnid}";
282

    
283
	/* is our device already configured */
284
	if (mwexec("/sbin/ifconfig {$devname}")) {
285

    
286
		/* create the tap device if required */
287
		if (!file_exists("/dev/{$tunname}"))
288
			exec("/sbin/ifconfig {$tunname} create");
289

    
290
		/* rename the device */
291
		mwexec("/sbin/ifconfig {$tunname} name {$devname}");
292

    
293
		/* add the device to the openvpn group */
294
		mwexec("/sbin/ifconfig {$devname} group openvpn");
295
	}
296

    
297
	$pfile = $g['varrun_path'] . "/openvpn_{$mode_id}.pid";
298
	$proto = ($settings['protocol'] == 'UDP' ? 'udp' : "tcp-{$mode}");
299
	$cipher = $settings['crypto'];
300

    
301
	$interface = $settings['interface'];
302
	$ipaddr = $settings['ipaddr'];
303

    
304
	// If a specific ip address (VIP) is requested, use it.
305
	// Otherwise, if a specific interface is requested, use it
306
	// If "any" interface was selected, local directive will be ommited.
307
	if (!empty($ipaddr)) {
308
		$iface_ip=$ipaddr;
309
	} else {
310
		if ((!empty($interface)) && (strcmp($interface, "any"))) {
311
			$iface_ip=get_interface_ip($interface);
312
		}
313
	}
314

    
315
	$conf  = "dev {$devname}\n";
316
	$conf .= "dev-type tun\n";
317
	$conf .= "dev-node /dev/{$tunname}\n";
318
	$conf .= "writepid {$pfile}\n";
319
	$conf .= "#user nobody\n";
320
	$conf .= "#group nobody\n";
321
	$conf .= "daemon\n";
322
	$conf .= "keepalive 10 60\n";
323
	$conf .= "ping-timer-rem\n";
324
	$conf .= "persist-tun\n";
325
	$conf .= "persist-key\n";
326
	$conf .= "proto {$proto}\n";
327
	$conf .= "cipher {$cipher}\n";
328
	$conf .= "up /etc/rc.filter_configure\n";
329
	$conf .= "down /etc/rc.filter_configure\n";
330

    
331
	if (!empty($iface_ip)) {
332
		$conf .= "local {$iface_ip}\n";	
333
	}
334

    
335
	// server specific settings
336
	if ($mode == 'server') {
337

    
338
		list($ip, $mask) = explode('/', $settings['tunnel_network']);
339
		$mask = gen_subnet_mask($mask);
340

    
341
		// configure tls modes
342
		switch($settings['mode']) {
343
			case 'p2p_tls':
344
			case 'server_tls':
345
			case 'server_tls_user':
346
				$conf .= "tls-server\n";
347
				break;
348
		}
349

    
350
		// configure p2p/server modes
351
		switch($settings['mode']) {
352
			case 'p2p_tls':
353
			case 'p2p_shared_key':
354
				$baselong = ip2long($ip) & ip2long($mask);
355
				$ip1 = long2ip($baselong + 1);
356
				$ip2 = long2ip($baselong + 2);
357
				$conf .= "ifconfig $ip1 $ip2\n";
358
				break;
359
			case 'server_tls':
360
			case 'server_user':
361
			case 'server_tls_user':
362
				$conf .= "server {$ip} {$mask}\n";
363
				$conf .= "client-config-dir {$g['varetc_path']}/openvpn-csc\n";
364
				break;
365
		}
366

    
367
		// configure user auth modes
368
		switch($settings['mode']) {
369
			case 'server_user':
370
				$conf .= "client-cert-not-required\n";
371
			case 'server_tls_user':
372
				$conf .= "username-as-common-name\n";
373
				$conf .= "auth-user-pass-verify /etc/inc/openvpn.auth-user.php via-env\n";
374
				break;
375
		}
376

    
377
		// The local port to listen on
378
		$conf .= "lport {$settings['local_port']}\n";
379

    
380
		// The management port to listen on
381
		$conf .= "management 127.0.0.1 {$settings['local_port']}\n";
382

    
383
		if ($settings['maxclients'])
384
			$conf .= "max-clients {$settings['maxclients']}\n";
385

    
386
		// Can we push routes
387
		if ($settings['local_network']) {
388
			list($ip, $mask) = explode('/', $settings['local_network']);
389
			$mask = gen_subnet_mask($mask);
390
			$conf .= "push \"route $ip $mask\"\n";
391
		}
392

    
393
		// Configure client dhcp options
394
		switch($settings['mode']) {
395
			case 'server_tls':
396
			case 'server_user':
397
			case 'server_tls_user':
398
				openvpn_add_dhcpopts($settings, $conf);
399
				break;
400
		}
401
	}
402

    
403
	// client specific settings
404

    
405
	if ($mode == 'client') {
406

    
407
		// configure p2p mode
408
		switch($settings['mode']) {
409
			case 'p2p_tls':
410
				$conf .= "tls-client\n";
411
			case 'shared_key':
412
				$conf .= "client\n";
413
				break;
414
		}
415

    
416
		// The port we'll listen at
417
		if ($settings['local_port'])
418
			$conf .= "lport {$settings['local_port']}\n";
419
		else
420
			$conf .= "nobind\n";
421

    
422
		// The remote server
423
		$conf .= "remote {$settings['server_addr']} {$settings['server_port']}\n";
424

    
425
		if (!empty($settings['use_shaper']))
426
			$conf .= "shaper {$settings['use_shaper']}\n";
427

    
428
		if (!empty($settings['tunnel_network'])) {
429
			list($ip, $mask) = explode('/', $settings['tunnel_network']);
430
			$mask = gen_subnet_mask($mask);
431
			$baselong = ip2long($ip) & ip2long($mask);
432
			$ip1 = long2ip($baselong + 1);
433
			$ip2 = long2ip($baselong + 2);
434
			$conf .= "ifconfig $ip2 $ip1\n";
435
		}
436

    
437
		if ($settings['proxy_addr'])
438
			$conf .= "http-proxy {$settings['proxy_addr']} {$settings['proxy_port']}\n";
439
	}
440

    
441
	// Add a remote network route if set
442
	if ($settings['remote_network']) {
443
		list($ip, $mask) = explode('/', $settings['remote_network']);
444
		$mask = gen_subnet_mask($mask);
445
		$conf .= "route $ip $mask\n";
446
	}
447

    
448
	// Write the settings for the keys
449
	switch($settings['mode']) {
450
		case 'p2p_shared_key':
451
			openvpn_add_keyfile($settings['shared_key'], $conf, $mode_id, "secret");
452
			break;
453
		case 'p2p_tls':
454
		case 'server_tls':
455
		case 'server_tls_user':
456
			$ca = lookup_ca($settings['caref']);
457
			openvpn_add_keyfile($ca['crt'], $conf, $mode_id, "ca");
458
		case 'server_user':
459
			$cert = lookup_cert($settings['certref']);
460
			openvpn_add_keyfile($cert['crt'], $conf, $mode_id, "cert");
461
			openvpn_add_keyfile($cert['prv'], $conf, $mode_id, "key");
462
			if ($mode == 'server')
463
				$conf .= "dh {$g['etc_path']}/dh-parameters.{$settings['dh_length']}\n";
464
			if ($settings['crl'])
465
				openvpn_add_keyfile($settings['crl'], $conf, $mode_id, "crl-verify");
466
			if ($settings['tls'])
467
				openvpn_add_keyfile($settings['tls'], $conf, $mode_id, "tls-auth");
468
			break;
469
	}
470

    
471
	if ($settings['compression'])
472
		$conf .= "comp-lzo\n";
473

    
474
	if ($settings['passtos'])
475
		$conf .= "passtos\n";
476

    
477
	if ($settings['resolve_retry'])
478
		$conf .= "resolv-retry infinite\n";
479

    
480
	if ($settings['dynamic_ip']) {
481
		$conf .= "persist-remote-ip\n";
482
		$conf .= "float\n";
483
	}
484

    
485
	openvpn_add_custom($settings, $conf);
486

    
487
	$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
488
	file_put_contents($fpath, $conf);
489
	chown($fpath, 'nobody');
490
	chgrp($fpath, 'nobody');
491
}
492

    
493
function openvpn_restart($mode, & $settings) {
494
	global $g, $config;
495

    
496
	$vpnid = $settings['vpnid'];
497
	$mode_id = $mode.$vpnid;
498

    
499
	/* kill the process if running */
500
	$pfile = $g['varrun_path']."/openvpn_{$mode_id}.pid";
501
	if (file_exists($pfile)) {
502

    
503
		/* read the pid file */
504
		$pid = rtrim(file_get_contents($pfile));
505
		unlink($pfile);
506

    
507
		/* send a term signal to the process */
508
		posix_kill($pid, SIGTERM);
509

    
510
		/* wait until the process exits */
511
		while(posix_kill($pid, 0))
512
			usleep(250000);
513
	}
514

    
515
	if ($settings['disable'])
516
		return;
517

    
518
	/* start the new process */
519
	$fpath = $g['varetc_path']."/openvpn/{$mode_id}.conf";
520
	mwexec_bg("nohup openvpn --config {$fpath}");
521
	touch("{$g['tmp_path']}/filter_dirty");
522
}
523

    
524
function openvpn_delete($mode, & $settings) {
525
	global $g, $config;
526

    
527
	$vpnid = $settings['vpnid'];
528
	$mode_id = $mode.$vpnid;
529

    
530
	$tunname = "tun{$vpnid}";
531
	if ($mode == "server")
532
		$devname = "ovpns{$vpnid}";
533
	else
534
		$devname = "ovpnc{$vpnid}";
535

    
536
	/* kill the process if running */
537
	$pfile = "{$g['varrun_path']}/openvpn_{$mode_id}.pid";
538
	if (file_exists($pfile)) {
539

    
540
		/* read the pid file */
541
		$pid = trim(file_get_contents($pfile));
542
		unlink($pfile);
543

    
544
		/* send a term signal to the process */
545
		posix_kill($pid, SIGTERM);
546
	}
547

    
548
	/* remove the device from the openvpn group */
549
	mwexec("/sbin/ifconfig {$devname} -group openvpn");
550

    
551
	/* restore the original adapter name */
552
	mwexec("/sbin/ifconfig {$devname} name {$tunname}");
553

    
554
	/* remove the configuration files */
555
	mwexec("/bin/rm {$g['varetc_path']}/openvpn/{$mode_id}.*");
556
}
557

    
558
function openvpn_resync_csc(& $settings) {
559
	global $g, $config;
560

    
561
	$fpath = $g['varetc_path']."/openvpn-csc/".$settings['common_name'];
562

    
563
	if ($settings['disable']) {
564
		unlink_if_exists($fpath);
565
		return;
566
	}
567

    
568
	$conf = '';
569
	if ($settings['block'])
570
		$conf .= "disable\n";
571

    
572
	if ($settings['push_reset'])
573
		$conf .= "push-reset\n";
574

    
575
	if (!empty($settings['tunnel_network'])) {
576
		list($ip, $mask) = explode('/', $settings['tunnel_network']);
577
		$baselong = ip2long($ip) & gen_subnet_mask_long($mask);
578
		$ip1 = long2ip($baselong + 1);
579
		$ip2 = long2ip($baselong + 2);
580
		$conf .= "ifconfig-push {$ip1} {$ip2}\n";
581
	}
582

    
583
	openvpn_add_dhcpopts($settings, $conf);
584

    
585
	if ($settings['gwredir'])
586
		$conf .= "push \"redirect-gateway def1\"\n";
587

    
588
	openvpn_add_custom($settings, $conf);
589

    
590
	file_put_contents($fpath, $conf);
591
	chown($fpath, 'nobody');
592
	chgrp($fpath, 'nobody');
593
}
594

    
595
function openvpn_delete_csc(& $settings) {
596
	global $g, $config;
597

    
598
	$fpath = $g['varetc_path']."/openvpn-csc/".$settings['common_name'];
599
	unlink_if_exists($fpath);
600
}
601

    
602
// Resync the configuration and restart the VPN
603
function openvpn_resync($mode, & $settings) {
604
	openvpn_reconfigure($mode, $settings);
605
	openvpn_restart($mode, $settings);
606
}
607

    
608
// Resync and restart all VPNs
609
function openvpn_resync_all() {
610
	global $g, $config;
611

    
612
	// delay our setup until the system
613
	// has a chance to init our paths
614
	if (!file_exists($g['varetc_path']."/openvpn") ||
615
		!file_exists($g['varetc_path']."/openvpn-csc"))
616
		return;
617

    
618
	if (!is_array($config['openvpn']))
619
		$config['openvpn'] = array();
620

    
621
/*
622
	if (!$config['openvpn']['dh-parameters']) {
623
		echo "Configuring OpenVPN Parameters ...\n";
624
		$dh_parameters = openvpn_create_dhparams(1024);
625
		$dh_parameters = base64_encode($dh_parameters);
626
		$config['openvpn']['dh-parameters'] = $dh_parameters;
627
		write_config("OpenVPN DH parameters");
628
	}
629

    
630
	$path_ovdh = $g['varetc_path']."/openvpn/dh-parameters";
631
	if (!file_exists($path_ovdh)) {
632
		$dh_parameters = $config['openvpn']['dh-parameters'];
633
		$dh_parameters = base64_decode($dh_parameters);
634
		file_put_contents($path_ovdh, $dh_parameters);
635
	}
636
*/
637

    
638
	if (is_array($config['openvpn']['openvpn-server']))
639
		foreach ($config['openvpn']['openvpn-server'] as & $settings)
640
			openvpn_resync('server', $settings);
641

    
642
	if (is_array($config['openvpn']['openvpn-client']))
643
		foreach ($config['openvpn']['openvpn-client'] as & $settings)
644
			openvpn_resync('client', $settings);
645

    
646
	if (is_array($config['openvpn']['openvpn-csc']))
647
		foreach ($config['openvpn']['openvpn-csc'] as & $settings)
648
			openvpn_resync_csc($settings);
649

    
650
}
651

    
652
?>
(28-28/51)