Project

General

Profile

« Previous | Next » 

Revision 236f8ecc

Added by Jim Pingle over 4 years ago

Automatic WireGuard interface gateways. Part of NG 5437

View differences:

src/etc/inc/gwlb.inc
832 832
							continue 2;
833 833
						}
834 834
					}
835
				} elseif (substr($ifcfg['if'], 0, 2) == "wg") {
836
					if (!find_interface_ip($ifcfg['if'])) {
837
						continue 2;
838
					}
839
					$ctype = "WGv4";
835 840
				} elseif ($tunnelif == "gif" || $tunnelif == "gre") {
836 841
					$ctype = "TUNNELv4";
837 842
				}
......
975 980
							continue 2;
976 981
						}
977 982
					}
983
				} elseif (substr($ifcfg['if'], 0, 2) == "wg") {
984
					if (!find_interface_ipv6($ifcfg['if'])) {
985
						continue 2;
986
					}
987
					$ctype = "WGv6";
978 988
				} else if ($tunnelif == "gif" || $tunnelif == "gre") {
979 989
					$ctype = "TUNNELv6";
980 990
				}
src/etc/inc/interfaces.inc
6886 6886
				} elseif (substr($ifname['if'], 0, 5) == "ipsec" ||
6887 6887
				    !empty($ifname['gateway'])) {
6888 6888
					$ints[$ifdescr] = $ifdescr;
6889
				} elseif (substr($ifname['if'], 0, 2) == "wg" ||
6890
				    !empty($ifname['gateway'])) {
6891
					$ints[$ifdescr] = $ifdescr;
6889 6892
				}
6890 6893

  
6891 6894
				break;
......
6910 6913
			break;
6911 6914
			default:
6912 6915
				if ((substr($ifname['if'], 0, 4) == "ovpn") ||
6913
				    (substr($ifname['if'], 0, 5) == "ipsec")) {
6916
				    (substr($ifname['if'], 0, 5) == "ipsec") ||
6917
				    (substr($ifname['if'], 0, 2) == "wg")) {
6914 6918
					return true;
6915 6919
				}
6916 6920
				$tunnelif = substr($ifname['if'], 0, 3);
......
6944 6948
				break;
6945 6949
			default:
6946 6950
				if ((substr($ifname['if'], 0, 4) == "ovpn") ||
6947
				    (substr($ifname['if'], 0, 5) == "ipsec")) {
6951
				    (substr($ifname['if'], 0, 5) == "ipsec") ||
6952
				    (substr($ifname['if'], 0, 2) == "wg")) {
6948 6953
					return true;
6949 6954
				}
6950 6955
				$tunnelif = substr($ifname['if'], 0, 3);
src/etc/inc/web/wg.inc
227 227
			    escapeshellarg($ip) . " netmask " .
228 228
			    escapeshellarg(gen_subnet_mask($mask)) .
229 229
			    ($ip4_first ? "" : " alias"));
230
			if ($ip4_first) {
231
				file_put_contents("/tmp/{$tunnel['name']}_router", $ip);
232
			}
230 233
			$ip4_first = false;
231 234
		} elseif (is_ipaddrv6($ip)) {
232 235
			mwexec("/sbin/ifconfig " .
......
234 237
			    escapeshellarg($ip) . " netmask " .
235 238
			    escapeshellarg(gen_subnet_mask($mask)) .
236 239
			    ($ip6_first ? "" : " alias"));
240
			if ($ip6_first) {
241
				file_put_contents("/tmp/{$tunnel['name']}_routerv6", $ip);
242
			}
237 243
			$ip6_first = false;
238 244
		}
239 245
	}

Also available in: Unified diff