Project

General

Profile

« Previous | Next » 

Revision f319adf4

Added by Luiz Souza over 4 years ago

Add the tunnel address to WG interface.

Wireguard support is now functional.

View differences:

src/etc/inc/web/wg.inc
68 68

  
69 69
	echo $tunnel['name'] . " ";
70 70
	wg_destroy_if($tunnel['name']);
71
	$if = pfSense_interface_create($tunnel['name']);
72
//echo "<pre>"; print_r($if); echo "</pre>";
71
	//$if = pfSense_interface_create($tunnel['name']);
73 72
	$conf_path = $g["wg_conf_path"] . "/" . $tunnel['name'] . ".conf";
74 73
	/* XXX - workaround while pfSense-module 0.69 isn't available */
75 74
	mwexec("/sbin/ifconfig " . escapeshellarg($tunnel['name']) . " create");
76 75
	mwexec("/usr/local/bin/wg setconf " . escapeshellarg($tunnel['name']) . " " . escapeshellarg($conf_path));
76
	$ip4_first = true;
77
	$ip6_first = true;
78
	foreach (explode(",", $tunnel['interface']['address']) as $addr) {
79
		if (strstr($addr, "/") == false) {
80
			continue;
81
		}
82
		list($ip, $mask) = explode("/", trim($addr));
83
		if (is_ipaddrv4($ip)) {
84
			mwexec("/sbin/ifconfig " . escapeshellarg($tunnel['name']) . " inet " . escapeshellarg($ip) .
85
			    " netmask " . escapeshellarg(gen_subnet_mask($mask)) . ($ip4_first ? "" : " alias"));
86
			$ip4_first = false;
87
		} elseif (is_ipaddrv6($ip)) {
88
			mwexec("/sbin/ifconfig " . escapeshellarg($tunnel['name']) . " inet6 " . escapeshellarg($ip) .
89
			    " netmask " . escapeshellarg(gen_subnet_mask($mask)) . ($ip6_first ? "" : " alias"));
90
			$ip6_first = false;
91
		}
92
	}
77 93
}
78 94

  
79 95
// Setup Wireguard tunnel

Also available in: Unified diff