Project

General

Profile

« Previous | Next » 

Revision e3924384

Added by Jim Pingle over 14 years ago

Reorder some code and combine the nobind test with the lport code to ensure only the needed options are used in any given combination.

View differences:

etc/inc/openvpn.inc
445 445
				break;
446 446
		}
447 447

  
448
		// The port we'll listen at
449
		// If local_port is used, bind the management port
450
		$lport = ($settings['local_port']) ? $settings['local_port'] : "0";
451
		$conf .= "lport {$lport}\n";
448
		// If there is no bind option at all (ip and/or port), add "nobind" directive
449
		//  Otherwise, use the local port if defined, failing that, use lport 0 to 
450
		//  ensure a random source port.
451
		if ((empty($iface_ip)) && (!$settings['local_port']))
452
			$conf .= "nobind\n";
453
		elseif ($settings['local_port'])
454
			$conf .= "lport {$settings['local_port']}\n";
455
		else
456
			$conf .= "lport 0\n";
452 457

  
453 458
		// Use unix socket to overcome the problem on any type of server
454 459
		$conf .= "management {$g['varetc_path']}/openvpn/{$mode_id}.sock unix\n";
455 460

  
456
		// If there is no bind option at all (ip and/or port), add "nobind" directive
457
		if ((empty($iface_ip)) && (!$settings['local_port'])) {
458
			$conf .= "nobind\n";
459
		}
460

  
461 461
		// The remote server
462 462
		$conf .= "remote {$settings['server_addr']} {$settings['server_port']}\n";
463 463

  

Also available in: Unified diff