Browse Source

[fix] IPV6 unique case

ljf 7 years ago
parent
commit
b81c2ba239
1 changed files with 7 additions and 3 deletions
  1. 7 3
      vpn/models.py

+ 7 - 3
vpn/models.py

@@ -95,9 +95,13 @@ class VPNConfiguration(CoinLdapSyncMixin, Configuration):
             subnets_v6 = [s for s in subnets if s.inet.version == 6]
             subnets_v6 = [s for s in subnets if s.inet.version == 6]
             if len(subnets_v6) > 0:
             if len(subnets_v6) > 0:
                 # With v6, we choose the second host of the subnet (cafe::1)
                 # With v6, we choose the second host of the subnet (cafe::1)
-                gen = subnets_v6[0].inet.iter_hosts()
-                gen.next()
-                self.ipv6_endpoint = gen.next()
+                net = subnets_v6[0].inet
+                if inet.prefixlen != 128:
+                    gen = inet.iter_hosts()
+                    gen.next()
+                    self.ipv6_endpoint = gen.next()
+                else:
+                    self.ipv6_endpoint = inet.ip
                 updated = True
                 updated = True
         return updated
         return updated