Hi,
 I got a report in ocserv that openconnect would not see an IPv6 DNS
address. Checking it further it seems that openconnect client would
only set INTERNAL_IP4_DNS with the contents of whatever the servers
provided (ipv4 or ipv6 address). As ocserv may send an IPv6 address,
that would be wrong.

The attached patch can make openconnect set INTERNAL_IP6_DNS instead,
however vpnc-script doesn't seem to anything with that variable.

Is there already some handling of IPv6 DNS addresses that I'm missing,
or it is not supported at this point?

regards,
Nikos
From f4753d8923b801416e42dfa7ac911c19aae2024e Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <[email protected]>
Date: Wed, 17 Jan 2018 09:36:27 +0100
Subject: [PATCH] When an IPv6 address is found set INTERNAL_IP6_DNS

Signed-off-by: Nikos Mavrogiannopoulos <[email protected]>
---
 script.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/script.c b/script.c
index 4a78e67..0bed21a 100644
--- a/script.c
+++ b/script.c
@@ -223,6 +223,8 @@ static void set_banner(struct openconnect_info *vpninfo)
 
 void prepare_script_env(struct openconnect_info *vpninfo)
 {
+	unsigned i;
+
 	if (vpninfo->ip_info.gateway_addr)
 		script_setenv(vpninfo, "VPNGATEWAY", vpninfo->ip_info.gateway_addr, 0);
 
@@ -264,14 +266,17 @@ void prepare_script_env(struct openconnect_info *vpninfo)
                }
 	}
 
-	if (vpninfo->ip_info.dns[0])
-		script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[0], 0);
-	else
-		script_setenv(vpninfo, "INTERNAL_IP4_DNS", NULL, 0);
-	if (vpninfo->ip_info.dns[1])
-		script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[1], 1);
-	if (vpninfo->ip_info.dns[2])
-		script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[2], 1);
+	for (i=0;i<3;i++) {
+		if (vpninfo->ip_info.dns[i]) {
+			if (strstr(vpninfo->ip_info.dns[i], ':') != 0)
+				script_setenv(vpninfo, "INTERNAL_IP6_DNS", vpninfo->ip_info.dns[i], 0);
+			else /* ipv4 */
+				script_setenv(vpninfo, "INTERNAL_IP4_DNS", vpninfo->ip_info.dns[i], 0);
+		} else if (i==0) {
+			script_setenv(vpninfo, "INTERNAL_IP4_DNS", NULL, 0);
+			script_setenv(vpninfo, "INTERNAL_IP6_DNS", NULL, 0);
+		}
+	}
 
 	if (vpninfo->ip_info.nbns[0])
 		script_setenv(vpninfo, "INTERNAL_IP4_NBNS", vpninfo->ip_info.nbns[0], 0);
-- 
2.14.3

_______________________________________________
openconnect-devel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/openconnect-devel

Reply via email to