mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Allow setting content-type urlfw, and allow tcp
This commit is contained in:
+2
-1
@@ -404,7 +404,8 @@ no-route = 192.168.5.0/255.255.255.0
|
||||
# This option allows you to specify a URL location where a client can
|
||||
# post, and the message will be forwarded to the provided server. Any
|
||||
# reply will be provided as body into POST reply.
|
||||
#url-fw = /kerberos udp@127.0.0.1:8888
|
||||
#url-fw = /kerberos udp@127.0.0.1:88 application/kerberos
|
||||
#url-fw = /kerberos1 tcp@127.0.0.1:88 application/kerberos
|
||||
|
||||
#
|
||||
# The following options are for (experimental) AnyConnect client
|
||||
|
||||
+15
-5
@@ -526,7 +526,7 @@ static void figure_auth_funcs(struct cfg_st *config, char **auth, unsigned auth_
|
||||
static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size)
|
||||
{
|
||||
unsigned i;
|
||||
char *p, *p2, *p3;
|
||||
char *p, *p2, *p3, *cont_type;
|
||||
struct addrinfo hints, *res;
|
||||
int ret;
|
||||
|
||||
@@ -546,12 +546,24 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
*p2 = 0;
|
||||
p2++;
|
||||
|
||||
if (strncmp(p2, "udp@", 4) != 0) {
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
if (strncmp(p2, "udp@", 4) == 0) {
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
} else if (strncmp(p2, "tcp@", 4) == 0) {
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
} else {
|
||||
fprintf(stderr, "cannot handle protocol %s\n", p2);
|
||||
exit(1);
|
||||
}
|
||||
p2 += 4;
|
||||
|
||||
cont_type = strchr(p2, ' ');
|
||||
if (cont_type != NULL) {
|
||||
*cont_type = 0;
|
||||
cont_type++;
|
||||
config->urlfw[i].content_type = talloc_strdup(config->urlfw, cont_type);
|
||||
}
|
||||
|
||||
p3 = strchr(p2, ':');
|
||||
if (p3 == NULL) {
|
||||
fprintf(stderr, "No server port specified in: %s\n", p2);
|
||||
@@ -560,8 +572,6 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
*p3 = 0;
|
||||
p3++;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
ret = getaddrinfo(p2, p3, &hints, &res);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "getaddrinfo(%s) failed: %s\n", p2,
|
||||
@@ -575,7 +585,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
config->urlfw[i].ai_socktype = res->ai_socktype;
|
||||
config->urlfw[i].ai_protocol = res->ai_protocol;
|
||||
|
||||
config->urlfw[i].url = talloc_strdup(config, p);
|
||||
config->urlfw[i].url = talloc_strdup(config->urlfw, p);
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
|
||||
@@ -219,6 +219,7 @@ typedef struct auth_struct_st {
|
||||
|
||||
typedef struct urlfw_st {
|
||||
char *url;
|
||||
char *content_type; /* Content-Type */
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t addr_len;
|
||||
int ai_family;
|
||||
|
||||
@@ -98,6 +98,14 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (handler->content_type) {
|
||||
ret =
|
||||
cstp_printf(ws, "Content-Type: %s\r\n", handler->content_type);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
ret =
|
||||
cstp_printf(ws, "Content-Length: %u\r\n",
|
||||
(unsigned int)length);
|
||||
|
||||
Reference in New Issue
Block a user