mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Added support for multiple DNS and NBNS servers.
This patch also combines ipv4-dns and ipv6-dns options that are now handled as aliases to dns. A side-effect of this patch is that the local keyword is no longer supported.
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
for BSD-derivatives is untested).
|
for BSD-derivatives is untested).
|
||||||
- Default configuration file changed to /etc/ocserv/ocserv.conf and
|
- Default configuration file changed to /etc/ocserv/ocserv.conf and
|
||||||
default password file for ocpasswd to /etc/ocserv/ocpasswd.
|
default password file for ocpasswd to /etc/ocserv/ocpasswd.
|
||||||
|
- Added support for multiple DNS and NBNS servers in ocserv.conf.
|
||||||
|
The 'local' keyword is no longer supported.
|
||||||
- occtl: fixed gathering of interface statistics.
|
- occtl: fixed gathering of interface statistics.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -137,7 +137,7 @@ socket-file = /var/run/ocserv-socket
|
|||||||
# The user the worker processes will be run as. It should be
|
# The user the worker processes will be run as. It should be
|
||||||
# unique (no other services run as this user).
|
# unique (no other services run as this user).
|
||||||
run-as-user = nobody
|
run-as-user = nobody
|
||||||
run-as-group = nobody
|
run-as-group = daemon
|
||||||
|
|
||||||
# Set the protocol-defined priority (SO_PRIORITY) for packets to
|
# Set the protocol-defined priority (SO_PRIORITY) for packets to
|
||||||
# be sent. That is a number from 0 to 6 with 0 being the lowest
|
# be sent. That is a number from 0 to 6 with 0 being the lowest
|
||||||
@@ -159,9 +159,10 @@ default-domain = example.com
|
|||||||
|
|
||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
|
||||||
# ipv4-dns = 192.168.2.1
|
# dns = 192.168.2.1
|
||||||
ipv4-dns = local
|
dns = 192.168.1.1
|
||||||
|
dns = fe80::1
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
+36
-15
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Nikos Mavrogiannopoulos
|
* Copyright (C) 2013, 2014 Nikos Mavrogiannopoulos
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -101,13 +101,16 @@ static struct cfg_options available_options[] = {
|
|||||||
|
|
||||||
{ .name = "ipv4-network", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "ipv4-network", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "ipv4-netmask", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "ipv4-netmask", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "ipv4-dns", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "dns", .type = OPTION_MULTI_LINE, .mandatory = 0 },
|
||||||
{ .name = "ipv4-nbns", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "ipv4-dns", .type = OPTION_MULTI_LINE, .mandatory = 0 }, /* alias dns */
|
||||||
|
{ .name = "ipv6-dns", .type = OPTION_MULTI_LINE, .mandatory = 0 }, /* alias dns */
|
||||||
|
{ .name = "nbns", .type = OPTION_MULTI_LINE, .mandatory = 0 },
|
||||||
|
{ .name = "ipv4-nbns", .type = OPTION_MULTI_LINE, .mandatory = 0 }, /* alias nbns */
|
||||||
|
{ .name = "ipv6-nbns", .type = OPTION_MULTI_LINE, .mandatory = 0 }, /* alias nbns */
|
||||||
|
|
||||||
{ .name = "ipv6-network", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "ipv6-network", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "ipv6-netmask", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "ipv6-netmask", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "ipv6-prefix", .type = OPTION_NUMERIC, .mandatory = 0 },
|
{ .name = "ipv6-prefix", .type = OPTION_NUMERIC, .mandatory = 0 },
|
||||||
{ .name = "ipv6-dns", .type = OPTION_STRING, .mandatory = 0 },
|
|
||||||
{ .name = "ipv6-nbns", .type = OPTION_STRING, .mandatory = 0 },
|
|
||||||
{ .name = "route-add-cmd", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "route-add-cmd", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "route-del-cmd", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "route-del-cmd", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
{ .name = "config-per-user", .type = OPTION_STRING, .mandatory = 0 },
|
{ .name = "config-per-user", .type = OPTION_STRING, .mandatory = 0 },
|
||||||
@@ -135,6 +138,7 @@ unsigned j;
|
|||||||
if (s_name == NULL) { \
|
if (s_name == NULL) { \
|
||||||
num = 0; \
|
num = 0; \
|
||||||
s_name = malloc(sizeof(char*)*MAX_CONFIG_ENTRIES); \
|
s_name = malloc(sizeof(char*)*MAX_CONFIG_ENTRIES); \
|
||||||
|
} \
|
||||||
do { \
|
do { \
|
||||||
if (val && !strcmp(val->pzName, name)==0) \
|
if (val && !strcmp(val->pzName, name)==0) \
|
||||||
continue; \
|
continue; \
|
||||||
@@ -144,7 +148,6 @@ unsigned j;
|
|||||||
break; \
|
break; \
|
||||||
} while((val = optionNextValue(pov, val)) != NULL); \
|
} while((val = optionNextValue(pov, val)) != NULL); \
|
||||||
s_name[num] = NULL; \
|
s_name[num] = NULL; \
|
||||||
} \
|
|
||||||
} else if (mand != 0) { \
|
} else if (mand != 0) { \
|
||||||
fprintf(stderr, "Configuration option %s is mandatory.\n", name); \
|
fprintf(stderr, "Configuration option %s is mandatory.\n", name); \
|
||||||
exit(1); \
|
exit(1); \
|
||||||
@@ -401,7 +404,6 @@ unsigned force_cert_auth;
|
|||||||
|
|
||||||
READ_STRING("ipv4-network", config->network.ipv4);
|
READ_STRING("ipv4-network", config->network.ipv4);
|
||||||
READ_STRING("ipv4-netmask", config->network.ipv4_netmask);
|
READ_STRING("ipv4-netmask", config->network.ipv4_netmask);
|
||||||
READ_STRING("ipv4-dns", config->network.ipv4_dns);
|
|
||||||
|
|
||||||
READ_STRING("ipv6-network", config->network.ipv6);
|
READ_STRING("ipv6-network", config->network.ipv6);
|
||||||
READ_STRING("ipv6-netmask", config->network.ipv6_netmask);
|
READ_STRING("ipv6-netmask", config->network.ipv6_netmask);
|
||||||
@@ -410,12 +412,27 @@ unsigned force_cert_auth;
|
|||||||
if (prefix > 0)
|
if (prefix > 0)
|
||||||
config->network.ipv6_netmask = ipv6_prefix_to_mask(prefix);
|
config->network.ipv6_netmask = ipv6_prefix_to_mask(prefix);
|
||||||
|
|
||||||
READ_STRING("ipv6-dns", config->network.ipv6_dns);
|
|
||||||
|
|
||||||
READ_STRING("ipv4-nbns", config->network.ipv4_nbns);
|
|
||||||
READ_STRING("ipv6-nbns", config->network.ipv6_nbns);
|
|
||||||
|
|
||||||
READ_MULTI_LINE("route", config->network.routes, config->network.routes_size);
|
READ_MULTI_LINE("route", config->network.routes, config->network.routes_size);
|
||||||
|
READ_MULTI_LINE("dns", config->network.dns, config->network.dns_size);
|
||||||
|
if (config->network.dns_size == 0) {
|
||||||
|
/* try the aliases */
|
||||||
|
READ_MULTI_LINE("ipv6-dns", config->network.dns, config->network.dns_size);
|
||||||
|
READ_MULTI_LINE("ipv4-dns", config->network.dns, config->network.dns_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j=0;j<config->network.dns_size;j++) {
|
||||||
|
if (strcmp(config->network.dns[j], "local") == 0) {
|
||||||
|
fprintf(stderr, "The 'local' DNS keyword is no longer supported.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
READ_MULTI_LINE("nbns", config->network.nbns, config->network.nbns_size);
|
||||||
|
if (config->network.nbns_size == 0) {
|
||||||
|
/* try the aliases */
|
||||||
|
READ_MULTI_LINE("ipv6-nbns", config->network.nbns, config->network.nbns_size);
|
||||||
|
READ_MULTI_LINE("ipv4-nbns", config->network.nbns, config->network.nbns_size);
|
||||||
|
}
|
||||||
|
|
||||||
READ_STRING("route-add-cmd", config->route_add_cmd);
|
READ_STRING("route-add-cmd", config->route_add_cmd);
|
||||||
READ_STRING("route-del-cmd", config->route_del_cmd);
|
READ_STRING("route-del-cmd", config->route_del_cmd);
|
||||||
@@ -575,19 +592,23 @@ unsigned i;
|
|||||||
|
|
||||||
DEL(config->network.ipv4);
|
DEL(config->network.ipv4);
|
||||||
DEL(config->network.ipv4_netmask);
|
DEL(config->network.ipv4_netmask);
|
||||||
DEL(config->network.ipv4_dns);
|
|
||||||
DEL(config->network.ipv6);
|
DEL(config->network.ipv6);
|
||||||
DEL(config->network.ipv6_netmask);
|
DEL(config->network.ipv6_netmask);
|
||||||
DEL(config->network.ipv6_dns);
|
|
||||||
for (i=0;i<config->network.routes_size;i++)
|
for (i=0;i<config->network.routes_size;i++)
|
||||||
DEL(config->network.routes[i]);
|
DEL(config->network.routes[i]);
|
||||||
|
DEL(config->network.routes);
|
||||||
|
for (i=0;i<config->network.dns_size;i++)
|
||||||
|
DEL(config->network.dns[i]);
|
||||||
|
DEL(config->network.dns);
|
||||||
|
for (i=0;i<config->network.nbns_size;i++)
|
||||||
|
DEL(config->network.nbns[i]);
|
||||||
|
DEL(config->network.nbns);
|
||||||
for (i=0;i<config->key_size;i++)
|
for (i=0;i<config->key_size;i++)
|
||||||
DEL(config->key[i]);
|
DEL(config->key[i]);
|
||||||
DEL(config->key);
|
DEL(config->key);
|
||||||
for (i=0;i<config->cert_size;i++)
|
for (i=0;i<config->cert_size;i++)
|
||||||
DEL(config->cert[i]);
|
DEL(config->cert[i]);
|
||||||
DEL(config->cert);
|
DEL(config->cert);
|
||||||
DEL(config->network.routes);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-13
@@ -42,10 +42,12 @@ struct cfg_options {
|
|||||||
static struct cfg_options available_options[] = {
|
static struct cfg_options available_options[] = {
|
||||||
{ .name = "route", .type = OPTION_MULTI_LINE },
|
{ .name = "route", .type = OPTION_MULTI_LINE },
|
||||||
{ .name = "iroute", .type = OPTION_MULTI_LINE },
|
{ .name = "iroute", .type = OPTION_MULTI_LINE },
|
||||||
{ .name = "ipv4-dns", .type = OPTION_STRING },
|
{ .name = "dns", .type = OPTION_MULTI_LINE },
|
||||||
{ .name = "ipv6-dns", .type = OPTION_STRING },
|
{ .name = "ipv4-dns", .type = OPTION_MULTI_LINE }, /* alias of dns */
|
||||||
{ .name = "ipv4-nbns", .type = OPTION_STRING },
|
{ .name = "ipv6-dns", .type = OPTION_MULTI_LINE }, /* alias of dns */
|
||||||
{ .name = "ipv6-nbns", .type = OPTION_STRING },
|
{ .name = "nbns", .type = OPTION_MULTI_LINE },
|
||||||
|
{ .name = "ipv4-nbns", .type = OPTION_MULTI_LINE }, /* alias of nbns */
|
||||||
|
{ .name = "ipv6-nbns", .type = OPTION_MULTI_LINE }, /* alias of nbns */
|
||||||
{ .name = "ipv4-network", .type = OPTION_STRING },
|
{ .name = "ipv4-network", .type = OPTION_STRING },
|
||||||
{ .name = "ipv6-network", .type = OPTION_STRING },
|
{ .name = "ipv6-network", .type = OPTION_STRING },
|
||||||
{ .name = "ipv4-netmask", .type = OPTION_STRING },
|
{ .name = "ipv4-netmask", .type = OPTION_STRING },
|
||||||
@@ -63,6 +65,7 @@ static struct cfg_options available_options[] = {
|
|||||||
if (s_name == NULL) { \
|
if (s_name == NULL) { \
|
||||||
num = 0; \
|
num = 0; \
|
||||||
s_name = malloc(sizeof(char*)*MAX_CONFIG_ENTRIES); \
|
s_name = malloc(sizeof(char*)*MAX_CONFIG_ENTRIES); \
|
||||||
|
} \
|
||||||
do { \
|
do { \
|
||||||
if (val && !strcmp(val->pzName, name)==0) \
|
if (val && !strcmp(val->pzName, name)==0) \
|
||||||
continue; \
|
continue; \
|
||||||
@@ -72,7 +75,6 @@ static struct cfg_options available_options[] = {
|
|||||||
break; \
|
break; \
|
||||||
} while((val = optionNextValue(pov, val)) != NULL); \
|
} while((val = optionNextValue(pov, val)) != NULL); \
|
||||||
s_name[num] = NULL; \
|
s_name[num] = NULL; \
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define READ_RAW_STRING(name, s_name) \
|
#define READ_RAW_STRING(name, s_name) \
|
||||||
@@ -148,11 +150,21 @@ unsigned prefix = 0;
|
|||||||
READ_RAW_MULTI_LINE("route", config->routes, config->routes_size);
|
READ_RAW_MULTI_LINE("route", config->routes, config->routes_size);
|
||||||
READ_RAW_MULTI_LINE("iroute", config->iroutes, config->iroutes_size);
|
READ_RAW_MULTI_LINE("iroute", config->iroutes, config->iroutes_size);
|
||||||
|
|
||||||
|
READ_RAW_MULTI_LINE("dns", config->dns, config->dns_size);
|
||||||
|
if (config->dns_size == 0) {
|
||||||
|
/* try aliases */
|
||||||
|
READ_RAW_MULTI_LINE("ipv6-dns", config->dns, config->dns_size);
|
||||||
|
READ_RAW_MULTI_LINE("ipv4-dns", config->dns, config->dns_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
READ_RAW_MULTI_LINE("nbns", config->nbns, config->nbns_size);
|
||||||
|
if (config->nbns_size == 0) {
|
||||||
|
/* try aliases */
|
||||||
|
READ_RAW_MULTI_LINE("ipv6-nbns", config->nbns, config->nbns_size);
|
||||||
|
READ_RAW_MULTI_LINE("ipv4-nbns", config->nbns, config->nbns_size);
|
||||||
|
}
|
||||||
|
|
||||||
READ_RAW_STRING("cgroup", config->cgroup);
|
READ_RAW_STRING("cgroup", config->cgroup);
|
||||||
READ_RAW_STRING("ipv4-dns", config->ipv4_dns);
|
|
||||||
READ_RAW_STRING("ipv6-dns", config->ipv6_dns);
|
|
||||||
READ_RAW_STRING("ipv4-nbns", config->ipv4_nbns);
|
|
||||||
READ_RAW_STRING("ipv6-nbns", config->ipv6_nbns);
|
|
||||||
READ_RAW_STRING("ipv4-network", config->ipv4_network);
|
READ_RAW_STRING("ipv4-network", config->ipv4_network);
|
||||||
READ_RAW_STRING("ipv6-network", config->ipv6_network);
|
READ_RAW_STRING("ipv6-network", config->ipv6_network);
|
||||||
READ_RAW_STRING("ipv4-netmask", config->ipv4_netmask);
|
READ_RAW_STRING("ipv4-netmask", config->ipv4_netmask);
|
||||||
@@ -189,11 +201,17 @@ unsigned i;
|
|||||||
}
|
}
|
||||||
free(config->iroutes);
|
free(config->iroutes);
|
||||||
|
|
||||||
|
for(i=0;i<config->dns_size;i++) {
|
||||||
|
free(config->dns[i]);
|
||||||
|
}
|
||||||
|
free(config->dns);
|
||||||
|
|
||||||
|
for(i=0;i<config->nbns_size;i++) {
|
||||||
|
free(config->nbns[i]);
|
||||||
|
}
|
||||||
|
free(config->nbns);
|
||||||
|
|
||||||
free(config->cgroup);
|
free(config->cgroup);
|
||||||
free(config->ipv4_dns);
|
|
||||||
free(config->ipv6_dns);
|
|
||||||
free(config->ipv4_nbns);
|
|
||||||
free(config->ipv6_nbns);
|
|
||||||
free(config->ipv4_network);
|
free(config->ipv4_network);
|
||||||
free(config->ipv6_network);
|
free(config->ipv6_network);
|
||||||
free(config->ipv4_netmask);
|
free(config->ipv4_netmask);
|
||||||
|
|||||||
+2
-4
@@ -89,16 +89,14 @@ message auth_reply_msg
|
|||||||
optional string ipv6_local = 10;
|
optional string ipv6_local = 10;
|
||||||
|
|
||||||
/* additional config */
|
/* additional config */
|
||||||
optional string ipv4_dns = 11;
|
|
||||||
optional string ipv6_dns = 12;
|
|
||||||
optional string ipv4_nbns = 13;
|
|
||||||
optional string ipv6_nbns = 14;
|
|
||||||
optional string ipv4_netmask = 15;
|
optional string ipv4_netmask = 15;
|
||||||
optional string ipv6_netmask = 16;
|
optional string ipv6_netmask = 16;
|
||||||
optional uint32 rx_per_sec = 17;
|
optional uint32 rx_per_sec = 17;
|
||||||
optional uint32 tx_per_sec = 18;
|
optional uint32 tx_per_sec = 18;
|
||||||
optional uint32 net_priority = 19;
|
optional uint32 net_priority = 19;
|
||||||
repeated string routes = 20;
|
repeated string routes = 20;
|
||||||
|
repeated string dns = 21;
|
||||||
|
repeated string nbns = 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* RESUME_FETCH_REQ + RESUME_DELETE_REQ */
|
/* RESUME_FETCH_REQ + RESUME_DELETE_REQ */
|
||||||
|
|||||||
+12
-4
@@ -107,10 +107,6 @@ int send_auth_reply(main_server_st* s, struct proc_st* proc,
|
|||||||
ipv6_local, sizeof(ipv6_local), 0);
|
ipv6_local, sizeof(ipv6_local), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.ipv4_dns = proc->config.ipv4_dns;
|
|
||||||
msg.ipv6_dns = proc->config.ipv6_dns;
|
|
||||||
msg.ipv4_nbns = proc->config.ipv4_nbns;
|
|
||||||
msg.ipv6_nbns = proc->config.ipv6_nbns;
|
|
||||||
msg.ipv4_netmask = proc->config.ipv4_netmask;
|
msg.ipv4_netmask = proc->config.ipv4_netmask;
|
||||||
msg.ipv6_netmask = proc->config.ipv6_netmask;
|
msg.ipv6_netmask = proc->config.ipv6_netmask;
|
||||||
if (proc->config.rx_per_sec != 0) {
|
if (proc->config.rx_per_sec != 0) {
|
||||||
@@ -128,6 +124,18 @@ int send_auth_reply(main_server_st* s, struct proc_st* proc,
|
|||||||
msg.net_priority = proc->config.net_priority;
|
msg.net_priority = proc->config.net_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.n_dns = proc->config.dns_size;
|
||||||
|
for (i=0;i<proc->config.dns_size;i++) {
|
||||||
|
mslog(s, proc, LOG_DEBUG, "sending dns '%s'", proc->config.dns[i]);
|
||||||
|
msg.dns = proc->config.dns;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.n_nbns = proc->config.nbns_size;
|
||||||
|
for (i=0;i<proc->config.nbns_size;i++) {
|
||||||
|
mslog(s, proc, LOG_DEBUG, "sending nbns '%s'", proc->config.nbns[i]);
|
||||||
|
msg.nbns = proc->config.nbns;
|
||||||
|
}
|
||||||
|
|
||||||
msg.n_routes = proc->config.routes_size;
|
msg.n_routes = proc->config.routes_size;
|
||||||
for (i=0;i<proc->config.routes_size;i++) {
|
for (i=0;i<proc->config.routes_size;i++) {
|
||||||
mslog(s, proc, LOG_DEBUG, "sending route '%s'", proc->config.routes[i]);
|
mslog(s, proc, LOG_DEBUG, "sending route '%s'", proc->config.routes[i]);
|
||||||
|
|||||||
+12
-16
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Nikos Mavrogiannopoulos
|
* Copyright (C) 2013, 2014 Nikos Mavrogiannopoulos
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -180,24 +180,20 @@ static int read_additional_config_file(main_server_st * s, struct proc_st *proc,
|
|||||||
cfg.iroutes_size = 0;
|
cfg.iroutes_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc->config.ipv4_dns == NULL) {
|
if (proc->config.dns == NULL) {
|
||||||
proc->config.ipv4_dns = cfg.ipv4_dns;
|
proc->config.dns = cfg.dns;
|
||||||
cfg.ipv4_dns = NULL;
|
proc->config.dns_size = cfg.dns_size;
|
||||||
|
|
||||||
|
cfg.dns = NULL;
|
||||||
|
cfg.dns_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc->config.ipv6_dns == NULL) {
|
if (proc->config.nbns == NULL) {
|
||||||
proc->config.ipv6_dns = cfg.ipv6_dns;
|
proc->config.nbns = cfg.nbns;
|
||||||
cfg.ipv6_dns = NULL;
|
proc->config.nbns_size = cfg.nbns_size;
|
||||||
}
|
|
||||||
|
|
||||||
if (proc->config.ipv4_nbns == NULL) {
|
cfg.nbns = NULL;
|
||||||
proc->config.ipv4_nbns = cfg.ipv4_nbns;
|
cfg.nbns_size = 0;
|
||||||
cfg.ipv4_nbns = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proc->config.ipv6_nbns == NULL) {
|
|
||||||
proc->config.ipv6_nbns = cfg.ipv6_nbns;
|
|
||||||
cfg.ipv6_nbns = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proc->config.ipv4_network == NULL) {
|
if (proc->config.ipv4_network == NULL) {
|
||||||
|
|||||||
+3
-8
@@ -255,16 +255,11 @@ ipv4-network = 192.168.1.0
|
|||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
|
|
||||||
# The DNS advertized server
|
# The DNS advertized server
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# dns = fc00::4be0
|
||||||
# ipv4-dns = local
|
dns = 192.168.1.2
|
||||||
ipv4-dns = 192.168.1.2
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.1.3
|
#nbns = 192.168.1.3
|
||||||
|
|
||||||
# The same, but for IPv6.
|
|
||||||
#ipv6-dns =
|
|
||||||
#ipv6-nbns =
|
|
||||||
|
|
||||||
# The IPv6 subnet that leases will be given from.
|
# The IPv6 subnet that leases will be given from.
|
||||||
#ipv6-network = fc00::
|
#ipv6-network = fc00::
|
||||||
|
|||||||
@@ -117,10 +117,12 @@ struct group_cfg_st {
|
|||||||
char **iroutes;
|
char **iroutes;
|
||||||
unsigned int iroutes_size;
|
unsigned int iroutes_size;
|
||||||
|
|
||||||
char *ipv4_dns;
|
char **dns;
|
||||||
char *ipv6_dns;
|
unsigned int dns_size;
|
||||||
char *ipv4_nbns;
|
|
||||||
char *ipv6_nbns;
|
char **nbns;
|
||||||
|
unsigned int nbns_size;
|
||||||
|
|
||||||
char *ipv4_network;
|
char *ipv4_network;
|
||||||
char *ipv6_network;
|
char *ipv6_network;
|
||||||
char *ipv4_netmask;
|
char *ipv4_netmask;
|
||||||
@@ -142,13 +144,16 @@ struct vpn_st {
|
|||||||
char *ipv6_netmask;
|
char *ipv6_netmask;
|
||||||
char *ipv6;
|
char *ipv6;
|
||||||
char *ipv6_local; /* local IPv6 address */
|
char *ipv6_local; /* local IPv6 address */
|
||||||
char *ipv4_dns;
|
|
||||||
char *ipv6_dns;
|
|
||||||
char *ipv4_nbns;
|
|
||||||
char *ipv6_nbns;
|
|
||||||
unsigned int mtu;
|
unsigned int mtu;
|
||||||
|
|
||||||
char **routes;
|
char **routes;
|
||||||
unsigned int routes_size;
|
unsigned int routes_size;
|
||||||
|
|
||||||
|
char **dns;
|
||||||
|
unsigned int dns_size;
|
||||||
|
|
||||||
|
char **nbns;
|
||||||
|
unsigned int nbns_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cfg_st {
|
struct cfg_st {
|
||||||
|
|||||||
+12
-24
@@ -298,30 +298,6 @@ static int recv_auth_reply(worker_st * ws, char *txt, size_t max_txt_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read any additional data */
|
/* Read any additional data */
|
||||||
if (msg->ipv4_dns != NULL) {
|
|
||||||
free(ws->config->network.ipv4_dns);
|
|
||||||
ws->config->network.ipv4_dns =
|
|
||||||
strdup(msg->ipv4_dns);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->ipv6_dns != NULL) {
|
|
||||||
free(ws->config->network.ipv6_dns);
|
|
||||||
ws->config->network.ipv4_dns =
|
|
||||||
strdup(msg->ipv6_dns);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->ipv4_nbns != NULL) {
|
|
||||||
free(ws->config->network.ipv4_nbns);
|
|
||||||
ws->config->network.ipv4_nbns =
|
|
||||||
strdup(msg->ipv4_nbns);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->ipv6_nbns != NULL) {
|
|
||||||
free(ws->config->network.ipv6_nbns);
|
|
||||||
ws->config->network.ipv4_nbns =
|
|
||||||
strdup(msg->ipv6_nbns);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->ipv4_netmask != NULL) {
|
if (msg->ipv4_netmask != NULL) {
|
||||||
free(ws->config->network.ipv4_netmask);
|
free(ws->config->network.ipv4_netmask);
|
||||||
ws->config->network.ipv4_netmask =
|
ws->config->network.ipv4_netmask =
|
||||||
@@ -349,6 +325,18 @@ static int recv_auth_reply(worker_st * ws, char *txt, size_t max_txt_size)
|
|||||||
for (i = 0; i < ws->routes_size; i++) {
|
for (i = 0; i < ws->routes_size; i++) {
|
||||||
ws->routes[i] = strdup(msg->routes[i]);
|
ws->routes[i] = strdup(msg->routes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws->dns_size = msg->n_dns;
|
||||||
|
|
||||||
|
for (i = 0; i < ws->dns_size; i++) {
|
||||||
|
ws->dns[i] = strdup(msg->dns[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ws->nbns_size = msg->n_nbns;
|
||||||
|
|
||||||
|
for (i = 0; i < ws->nbns_size; i++) {
|
||||||
|
ws->nbns[i] = strdup(msg->nbns[i]);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
oclog(ws, LOG_ERR, "error in received message");
|
oclog(ws, LOG_ERR, "error in received message");
|
||||||
ret = ERR_AUTH_FAIL;
|
ret = ERR_AUTH_FAIL;
|
||||||
|
|||||||
+7
-23
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2013 Nikos Mavrogiannopoulos
|
* Copyright (C) 2013, 2014 Nikos Mavrogiannopoulos
|
||||||
*
|
*
|
||||||
* This file is part of ocserv.
|
* This file is part of ocserv.
|
||||||
*
|
*
|
||||||
@@ -149,30 +149,14 @@ int complete_vpn_info(worker_st * ws, struct vpn_st *vinfo)
|
|||||||
if (vinfo->ipv4 == NULL && vinfo->ipv6 == NULL) {
|
if (vinfo->ipv4 == NULL && vinfo->ipv6 == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#define LOCAL "local"
|
|
||||||
if (ws->config->network.ipv4_dns
|
|
||||||
&& strcmp(ws->config->network.ipv4_dns, LOCAL) == 0)
|
|
||||||
vinfo->ipv4_dns = vinfo->ipv4_local;
|
|
||||||
else
|
|
||||||
vinfo->ipv4_dns = ws->config->network.ipv4_dns;
|
|
||||||
|
|
||||||
if (ws->config->network.ipv6_dns
|
vinfo->dns_size = ws->config->network.dns_size;
|
||||||
&& strcmp(ws->config->network.ipv6_dns, LOCAL) == 0)
|
if (ws->config->network.dns_size > 0)
|
||||||
vinfo->ipv6_dns = vinfo->ipv6_local;
|
vinfo->dns = ws->config->network.dns;
|
||||||
else
|
|
||||||
vinfo->ipv6_dns = ws->config->network.ipv6_dns;
|
|
||||||
|
|
||||||
if (ws->config->network.ipv4_nbns
|
vinfo->nbns_size = ws->config->network.nbns_size;
|
||||||
&& strcmp(ws->config->network.ipv4_nbns, LOCAL) == 0)
|
if (ws->config->network.nbns_size > 0)
|
||||||
vinfo->ipv4_nbns = vinfo->ipv4_local;
|
vinfo->nbns = ws->config->network.nbns;
|
||||||
else
|
|
||||||
vinfo->ipv4_nbns = ws->config->network.ipv4_nbns;
|
|
||||||
|
|
||||||
if (ws->config->network.ipv6_nbns
|
|
||||||
&& strcmp(ws->config->network.ipv6_nbns, LOCAL) == 0)
|
|
||||||
vinfo->ipv6_nbns = vinfo->ipv6_local;
|
|
||||||
else
|
|
||||||
vinfo->ipv6_nbns = ws->config->network.ipv6_nbns;
|
|
||||||
|
|
||||||
vinfo->routes_size = ws->config->network.routes_size;
|
vinfo->routes_size = ws->config->network.routes_size;
|
||||||
if (ws->config->network.routes_size > 0)
|
if (ws->config->network.routes_size > 0)
|
||||||
|
|||||||
+15
-19
@@ -1136,20 +1136,6 @@ static int connect_handler(worker_st * ws)
|
|||||||
ws->vinfo.ipv4_netmask);
|
ws->vinfo.ipv4_netmask);
|
||||||
SEND_ERR(ret);
|
SEND_ERR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws->vinfo.ipv4_dns) {
|
|
||||||
ret =
|
|
||||||
tls_printf(ws->session, "X-CSTP-DNS: %s\r\n",
|
|
||||||
ws->vinfo.ipv4_dns);
|
|
||||||
SEND_ERR(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ws->vinfo.ipv4_nbns) {
|
|
||||||
ret =
|
|
||||||
tls_printf(ws->session, "X-CSTP-NBNS: %s\r\n",
|
|
||||||
ws->vinfo.ipv4_nbns);
|
|
||||||
SEND_ERR(ret);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws->vinfo.ipv6 && req->no_ipv6 == 0) {
|
if (ws->vinfo.ipv6 && req->no_ipv6 == 0) {
|
||||||
@@ -1165,21 +1151,31 @@ static int connect_handler(worker_st * ws)
|
|||||||
ws->vinfo.ipv6_netmask);
|
ws->vinfo.ipv6_netmask);
|
||||||
SEND_ERR(ret);
|
SEND_ERR(ret);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < ws->vinfo.dns_size; i++) {
|
||||||
|
if (req->no_ipv6 != 0 && strchr(ws->vinfo.dns[i], ':') != 0)
|
||||||
|
continue;
|
||||||
|
if (req->no_ipv4 != 0 && strchr(ws->vinfo.dns[i], '.') != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (ws->vinfo.ipv6_dns) {
|
|
||||||
ret =
|
ret =
|
||||||
tls_printf(ws->session, "X-CSTP-DNS: %s\r\n",
|
tls_printf(ws->session, "X-CSTP-DNS: %s\r\n",
|
||||||
ws->vinfo.ipv6_dns);
|
ws->vinfo.dns[i]);
|
||||||
SEND_ERR(ret);
|
SEND_ERR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ws->vinfo.ipv6_nbns) {
|
for (i = 0; i < ws->vinfo.nbns_size; i++) {
|
||||||
|
if (req->no_ipv6 != 0 && strchr(ws->vinfo.nbns[i], ':') != 0)
|
||||||
|
continue;
|
||||||
|
if (req->no_ipv4 != 0 && strchr(ws->vinfo.nbns[i], '.') != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
tls_printf(ws->session, "X-CSTP-NBNS: %s\r\n",
|
tls_printf(ws->session, "X-CSTP-NBNS: %s\r\n",
|
||||||
ws->vinfo.ipv6_nbns);
|
ws->vinfo.nbns[i]);
|
||||||
SEND_ERR(ret);
|
SEND_ERR(ret);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ws->vinfo.routes_size; i++) {
|
for (i = 0; i < ws->vinfo.routes_size; i++) {
|
||||||
if (req->no_ipv6 != 0 && strchr(ws->vinfo.routes[i], ':') != 0)
|
if (req->no_ipv6 != 0 && strchr(ws->vinfo.routes[i], ':') != 0)
|
||||||
|
|||||||
+6
-2
@@ -112,6 +112,8 @@ typedef struct worker_st {
|
|||||||
gnutls_session_t session;
|
gnutls_session_t session;
|
||||||
gnutls_session_t dtls_session;
|
gnutls_session_t dtls_session;
|
||||||
|
|
||||||
|
struct http_req_st req;
|
||||||
|
|
||||||
/* inique session identifier */
|
/* inique session identifier */
|
||||||
uint8_t sid[SID_SIZE];
|
uint8_t sid[SID_SIZE];
|
||||||
|
|
||||||
@@ -164,8 +166,10 @@ typedef struct worker_st {
|
|||||||
/* additional data - received per user or per group */
|
/* additional data - received per user or per group */
|
||||||
unsigned routes_size;
|
unsigned routes_size;
|
||||||
char* routes[MAX_ROUTES];
|
char* routes[MAX_ROUTES];
|
||||||
|
unsigned dns_size;
|
||||||
struct http_req_st req;
|
char* dns[MAX_ROUTES];
|
||||||
|
unsigned nbns_size;
|
||||||
|
char* nbns[MAX_ROUTES];
|
||||||
} worker_st;
|
} worker_st;
|
||||||
|
|
||||||
void vpn_server(struct worker_st* ws);
|
void vpn_server(struct worker_st* ws);
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
ipv4-dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
@@ -146,14 +146,13 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|
||||||
#ipv6-address =
|
ipv6-network = fe80::
|
||||||
#ipv6-mask =
|
ipv6-prefix = 16
|
||||||
#ipv6-dns =
|
#ipv6-dns =
|
||||||
|
|
||||||
# Prior to leasing any IP from the pool ping it to verify that
|
# Prior to leasing any IP from the pool ping it to verify that
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
ipv4-dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
ipv4-dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
+1
-2
@@ -146,8 +146,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
ipv4-dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
+1
-2
@@ -146,8 +146,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
ipv4-dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
+1
-2
@@ -146,8 +146,7 @@ default-domain = example.com
|
|||||||
ipv4-network = 192.168.1.0
|
ipv4-network = 192.168.1.0
|
||||||
ipv4-netmask = 255.255.255.0
|
ipv4-netmask = 255.255.255.0
|
||||||
# Use the keywork local to advertize the local P-t-P address as DNS server
|
# Use the keywork local to advertize the local P-t-P address as DNS server
|
||||||
# ipv4-dns = 192.168.2.1
|
dns = 192.168.1.1
|
||||||
ipv4-dns = local
|
|
||||||
|
|
||||||
# The NBNS server (if any)
|
# The NBNS server (if any)
|
||||||
#ipv4-nbns = 192.168.2.3
|
#ipv4-nbns = 192.168.2.3
|
||||||
|
|||||||
Reference in New Issue
Block a user