This is what we need to support VPN providers.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
"LOCAL_SUBNETS" => &decode_subnets($peers{$key}[10]),
"PSK" => $peers{$key}[11],
"KEEPALIVE" => $peers{$key}[12],
+ "LOCAL_ADDRESS" => $peers{$key}[13],
"INTERFACE" => ($type eq "host") ? "wg0" : "wg${key}",
);
# Address
if ($key eq "Address") {
if (&Network::check_ip_address($val)) {
- $peer{'CLIENT_ADDRESS'} = $val;
+ $peer{'LOCAL_ADDRESS'} = $val;
} else {
push(@errormessages, $Lang::tr{'invalid ip address'});
}
"LOCAL_SUBNETS" => join(", ", @$local_subnets),
"PSK" => $Wireguard::peers{$key}[11],
"KEEPALIVE" => $Wireguard::peers{$key}[12],
+ "LOCAL_ADDRESS" => $Wireguard::peers{$key}[13],
);
# Jump to the editor
$peer->{"PSK"},
# 12 = Keepalive
$peer->{"KEEPALIVE"} || $Wireguard::DEFAULT_KEEPALIVE,
+ # 13 = Local Address
+ $peer->{"LOCAL_ADDRESS"},
];
# Store the configuration
$psk,
# 12 = Keepalive
$Wireguard::DEFAULT_KEEPALIVE,
+ # 13 = Local Address
+ "",
];
# Store the configuration
$cgiparams{"PSK"} || "",
# 12 = Keepalive
$cgiparams{"KEEPALIVE"} || 0,
+ # 13 = Local Address
+ "",
];
# Store the configuration
$cgiparams{"PSK"},
# 12 = Keepalive
0,
+ # 13 = Local Address
+ "",
];
# Store the configuration
local local_subnets
local psk
local keepalive
+ local local_address
local _rest
# Handles the special case of the RW interface
fi
while read -r id enabled type name pubkey privkey port endpoint_addr endpoint_port \
- remote_subnets remarks local_subnets psk keepalive _rest; do
+ remote_subnets remarks local_subnets psk keepalive local_address _rest; do
# Skip peers that are not hosts or not enabled
[ "${type}" = "host" ] || continue
[ "${enabled}" = "on" ] || continue
local remote_subnet
while read -r id enabled type name pubkey privkey port endpoint_addr endpoint_port \
- remote_subnets remarks local_subnets psk keepalive _rest; do
+ remote_subnets remarks local_subnets psk keepalive local_address _rest; do
# Check for the matching connection
[ "${type}" = "net" ] || continue
[ "${intf}" = "wg${id}" ] || continue
# Update the interface alias
ip link set "${intf}" alias "${name}"
+ # Flush any addresses
+ ip addr flush dev "${intf}"
+
+ # Assign the local address
+ if [ -n "${local_address}" ]; then
+ ip addr add "${local_address}" dev "${intf}"
+ fi
+
echo "[Interface]"
if [ -n "${privkey}" ]; then