ocserv: added support for per-user split-dns directive

Resolves: #229

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
This commit is contained in:
Nikos Mavrogiannopoulos
2019-11-17 10:56:46 +01:00
parent 6739529e05
commit 4bcf29643d
9 changed files with 51 additions and 6 deletions

View File

@@ -62,6 +62,7 @@ message group_cfg_st
optional uint32 mobile_idle_timeout = 38;
repeated fw_port_st fw_ports = 39;
optional string hostname = 40;
repeated string split_dns = 41;
}
/* AUTH_COOKIE_REP */

View File

@@ -324,6 +324,11 @@ void apply_default_config(main_server_st *s, proc_st *proc, GroupCfgSt *gc)
gc->n_nbns = vhost->perm_config.config->network.nbns_size;
}
if (gc->split_dns == NULL) {
gc->split_dns = vhost->perm_config.config->split_dns;
gc->n_split_dns = vhost->perm_config.config->split_dns_size;
}
if (!gc->has_interim_update_secs) {
gc->interim_update_secs = vhost->perm_config.config->stats_report_time;
gc->has_interim_update_secs = 1;

View File

@@ -111,6 +111,8 @@ static int group_cfg_ini_handler(void *_ctx, const char *section, const char *na
READ_TF(msg->config->deny_roaming, msg->config->has_deny_roaming);
} else if (strcmp(name, "route") == 0) {
READ_RAW_MULTI_LINE(msg->config->routes, msg->config->n_routes);
} else if (strcmp(name, "split-dns") == 0) {
READ_RAW_MULTI_LINE(msg->config->split_dns, msg->config->n_split_dns);
} else if (strcmp(name, "no-route") == 0) {
READ_RAW_MULTI_LINE(msg->config->no_routes, msg->config->n_no_routes);
} else if (strcmp(name, "iroute") == 0) {

View File

@@ -2023,8 +2023,8 @@ static int connect_handler(worker_st * ws)
SEND_ERR(ret);
}
for (i = 0; i < WSCONFIG(ws)->split_dns_size; i++) {
if (strchr(WSCONFIG(ws)->split_dns[i], ':') != 0)
for (i = 0; i < ws->user_config->n_split_dns; i++) {
if (strchr(ws->user_config->split_dns[i], ':') != 0)
ip6 = 1;
else
ip6 = 0;
@@ -2035,10 +2035,10 @@ static int connect_handler(worker_st * ws)
continue;
oclog(ws, LOG_INFO, "adding split DNS %s",
WSCONFIG(ws)->split_dns[i]);
ws->user_config->split_dns[i]);
ret =
cstp_printf(ws, "X-CSTP-Split-DNS: %s\r\n",
WSCONFIG(ws)->split_dns[i]);
ws->user_config->split_dns[i]);
SEND_ERR(ret);
}