mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
Added configuration option to send custom headers to client.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user