Added configuration option to send custom headers to client.

This commit is contained in:
Nikos Mavrogiannopoulos
2014-02-01 18:55:27 +01:00
parent 0ec67882c0
commit 311d5ddd20
4 changed files with 22 additions and 1 deletions

View File

@@ -50,6 +50,7 @@ struct cfg_options {
static struct cfg_options available_options[] = {
{ .name = "auth", .type = OPTION_MULTI_LINE, .mandatory = 1 },
{ .name = "route", .type = OPTION_MULTI_LINE, .mandatory = 0 },
{ .name = "custom-header", .type = OPTION_MULTI_LINE, .mandatory = 0 },
{ .name = "listen-host", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "tcp-port", .type = OPTION_NUMERIC, .mandatory = 0 },
{ .name = "udp-port", .type = OPTION_NUMERIC, .mandatory = 0 },
@@ -412,6 +413,8 @@ unsigned force_cert_auth;
if (prefix > 0)
config->network.ipv6_netmask = ipv6_prefix_to_mask(prefix);
READ_MULTI_LINE("custom-header", config->custom_header, config->custom_header_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) {
@@ -609,6 +612,9 @@ unsigned i;
for (i=0;i<config->cert_size;i++)
DEL(config->cert[i]);
DEL(config->cert);
for (i=0;i<config->custom_header_size;i++)
DEL(config->custom_header[i]);
DEL(config->custom_header);
return;
}

View File

@@ -334,6 +334,11 @@ route = 192.168.5.0/255.255.255.0
# set for them.
#cisco-client-compat = false
#Advanced options
# Option to allow sending arbitrary custom headers to the client after
# authentication and prior to VPN tunnel establishment.
#custom-header = "X-My-Header: hi there"
@end example

View File

@@ -180,7 +180,10 @@ struct cfg_st {
char *banner;
char *ocsp_response; /* file with the OCSP response */
char *default_domain; /* domain to be advertised */
char **custom_header;
unsigned custom_header_size;;
char* socket_file_prefix;
time_t cookie_validity; /* in seconds */
time_t min_reauth_time; /* after a failed auth, how soon one can reauthenticate -> in seconds */

View File

@@ -1225,6 +1225,13 @@ static int connect_handler(worker_st * ws)
"X-CSTP-License: accept\r\n");
SEND_ERR(ret);
for (i = 0; i < ws->config->custom_header_size; i++) {
oclog(ws, LOG_DEBUG, "adding custom header '%s'", ws->config->custom_header[i]);
ret = tls_printf(ws->session,
"%s\r\n", ws->config->custom_header[i]);
SEND_ERR(ret);
}
if (ws->config->default_mtu > 0) {
ws->vinfo.mtu = ws->config->default_mtu;
}