Skip to content
6 changes: 6 additions & 0 deletions openwisp_controller/config/base/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,12 @@ def auto_client(self, auto_cert=True, template_backend_class=None):
vxlan=self.config.get("vxlan", [{}])[0],
**context_keys,
)
if self.subnet and self.subnet.subnet.version == 6:
for interface in auto.get("interfaces", []):
if interface.get("type") == "wireguard":
for addr in interface.get("addresses", []):
addr["family"] = "ipv6"
addr["mask"] = 128
# If the backend is 'zerotier' then
# call auto_client and update the config
elif self._is_backend_type("zerotier") and template_backend_class:
Expand Down
14 changes: 14 additions & 0 deletions openwisp_controller/config/tests/test_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,20 @@ def test_auto_client(self):
)
self.assertEqual(auto, expected)

def test_auto_client_ipv6(self):
device, vpn, template = self._create_wireguard_vpn_template(
vpn_options={
"subnet": self._create_subnet(
name="wireguard ipv6", subnet="fdca:1234::/64"
)
}
)
auto = vpn.auto_client(template_backend_class=template.backend_class)
addresses = auto["interfaces"][0]["addresses"]
self.assertEqual(len(addresses), 1)
self.assertEqual(addresses[0]["family"], "ipv6")
self.assertEqual(addresses[0]["mask"], 128)
Comment thread
devangpratap marked this conversation as resolved.
Outdated

def test_change_vpn_backend(self):
vpn = self._create_vpn(name="new", backend=self._BACKENDS["openvpn"])
subnet = self._create_subnet(
Expand Down
Loading