Skip to content

Commit

Permalink
Add $CISCO_SPLIT_DNS environment variable for vpnc-script
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jun 8, 2012
1 parent 412e4b0 commit 978c369
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cstp.c
Expand Up @@ -183,7 +183,12 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
free(inc);
inc = next;
}
vpninfo->split_includes = vpninfo->split_excludes = NULL;
for (inc = vpninfo->split_dns; inc; ) {
struct split_include *next = inc->next;
free(inc);
inc = next;
}
vpninfo->split_dns = vpninfo->split_includes = vpninfo->split_excludes = NULL;

/* Create (new) random master key for DTLS connection, if needed */
if (vpninfo->dtls_times.last_rekey + vpninfo->dtls_times.rekey <
Expand Down Expand Up @@ -377,6 +382,13 @@ static int start_cstp_connection(struct openconnect_info *vpninfo)
vpninfo->vpn_proxy_pac = new_option->value;
} else if (!strcmp(buf + 7, "Banner")) {
vpninfo->banner = new_option->value;
} else if (!strcmp(buf + 7, "Split-DNS")) {
struct split_include *dns = malloc(sizeof(*dns));
if (!dns)
continue;
dns->route = new_option->value;
dns->next = vpninfo->split_dns;
vpninfo->split_dns = dns;
} else if (!strcmp(buf + 7, "Split-Include")) {
struct split_include *inc = malloc(sizeof(*inc));
if (!inc)
Expand Down
1 change: 1 addition & 0 deletions openconnect-internal.h
Expand Up @@ -209,6 +209,7 @@ struct openconnect_info {
const char *vpn_nbns[3];
const char *vpn_domain;
const char *vpn_proxy_pac;
struct split_include *split_dns;
struct split_include *split_includes;
struct split_include *split_excludes;

Expand Down
26 changes: 26 additions & 0 deletions tun.c
Expand Up @@ -310,6 +310,32 @@ static void set_script_env(struct openconnect_info *vpninfo)
if (vpninfo->vpn_proxy_pac)
setenv("CISCO_PROXY_PAC", vpninfo->vpn_proxy_pac, 1);

if (vpninfo->split_dns) {
char *list;
int len = 0;
struct split_include *dns = vpninfo->split_dns;

while (dns) {
len += strlen(dns->route) + 1;
dns = dns->next;
}
list = malloc(len);
if (list) {
char *p = list;

dns = vpninfo->split_dns;
while (1) {
strcpy(p, dns->route);
p += strlen(p);
dns = dns->next;
if (!dns)
break;
*(p++) = ' ';
}
setenv("CISCO_SPLIT_DNS", list, 1);
free(list);
}
}
if (vpninfo->split_includes) {
struct split_include *this = vpninfo->split_includes;
int nr_split_includes = 0;
Expand Down

0 comments on commit 978c369

Please sign in to comment.