Project

General

Profile

Feature #248 » openvpn.tuntap.patch

- /etc/inc/openvpn.inc - Antonio No, 12/25/2009 12:05 PM

View differences:

openvpn.inc 2009-12-25 17:41:58.000000000 +0100
52 52

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

  
55
$openvpn_dev_mode = array("tun", "tap");
56

  
55 57
/* 
56 58
 * The User Auth mode below is disabled because
57 59
 * OpenVPN erroneously requires that we provide
......
246 248
	}
247 249
}
248 250

  
249
function openvpn_add_keyfile(& $data, & $conf, $mode_id, $directive) {
251
function openvpn_add_keyfile(& $data, & $conf, $mode_id, $directive, $opt = "") {
250 252
	global $g;
251 253

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

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

  
260 262
function openvpn_reconfigure($mode,& $settings) {
......
274 276
	$vpnid = $settings['vpnid'];
275 277
	$mode_id = $mode.$vpnid;
276 278

  
277
	$tunname = "tun{$vpnid}";
279
	if (isset($settings['dev_mode']))
280
		$tunname = "{$settings['dev_mode']}{$vpnid}";
281
	else {	/* defaults to tun */
282
		$tunname = "tun{$vpnid}";
283
		$settings['dev_mode'] = "tun";
284
	}
285

  
278 286
	if ($mode == "server")
279 287
		$devname = "ovpns{$vpnid}";
280 288
	else
......
313 321
	}
314 322

  
315 323
	$conf  = "dev {$devname}\n";
316
	$conf .= "dev-type tun\n";
324
	$conf .= "dev-type {$settings['dev_mode']}\n";
317 325
	$conf .= "dev-node /dev/{$tunname}\n";
318 326
	$conf .= "writepid {$pfile}\n";
319 327
	$conf .= "#user nobody\n";
......
464 472
			if ($settings['crl'])
465 473
				openvpn_add_keyfile($settings['crl'], $conf, $mode_id, "crl-verify");
466 474
			if ($settings['tls'])
467
				openvpn_add_keyfile($settings['tls'], $conf, $mode_id, "tls-auth");
475
				openvpn_add_keyfile($settings['tls'], $conf, $mode_id, "tls-auth", $settings['mode'] == "server_tls" ? "0" : "1");
468 476
			break;
469 477
	}
470 478

  
(1-1/2)