mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
renamed urlfw to kkdcp
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ ocserv_SOURCES = main.c main-auth.c worker-vpn.c worker-auth.c tlslib.c \
|
||||
main-user.c worker-misc.c route-add.c route-add.h worker-privs.c \
|
||||
sec-mod.c sec-mod-db.c sec-mod-auth.c sec-mod-auth.h sec-mod.h sec-mod-ban.c \
|
||||
script-list.h $(COMMON_SOURCES) $(AUTH_SOURCES) \
|
||||
icmp-ping.c icmp-ping.h worker-urlfw.c \
|
||||
icmp-ping.c icmp-ping.h worker-kkdcp.c \
|
||||
sec-mod-sup-config.c sec-mod-sup-config.h \
|
||||
sup-config/file.c sup-config/file.h \
|
||||
sup-config/radius.c sup-config/radius.h \
|
||||
|
||||
+18
-18
@@ -95,7 +95,7 @@ static struct cfg_options available_options[] = {
|
||||
{ .name = "connect-script", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "disconnect-script", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "pid-file", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "url-fw", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "kkdcp", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "socket-file", .type = OPTION_STRING, .mandatory = 1 },
|
||||
{ .name = "listen-clear-file", .type = OPTION_STRING, .mandatory = 0 },
|
||||
{ .name = "occtl-socket-file", .type = OPTION_STRING, .mandatory = 0 },
|
||||
@@ -525,15 +525,15 @@ static void figure_auth_funcs(struct cfg_st *config, char **auth, unsigned auth_
|
||||
talloc_free(auth);
|
||||
}
|
||||
|
||||
static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size)
|
||||
static void parse_kkdcp(struct cfg_st *config, char **urlfw, unsigned urlfw_size)
|
||||
{
|
||||
unsigned i;
|
||||
char *p, *p2, *p3, *cont_type;
|
||||
struct addrinfo hints, *res;
|
||||
int ret;
|
||||
|
||||
config->urlfw = talloc_size(config, urlfw_size*sizeof(urlfw_st));
|
||||
if (config->urlfw == NULL) {
|
||||
config->kkdcp = talloc_size(config, urlfw_size*sizeof(kkdcp_st));
|
||||
if (config->kkdcp == NULL) {
|
||||
fprintf(stderr, "memory error\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -542,7 +542,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
p = urlfw[i];
|
||||
p2 = strchr(p, ' ');
|
||||
if (p2 == NULL) {
|
||||
fprintf(stderr, "Cannot parse url-fw string: %s\n", p);
|
||||
fprintf(stderr, "Cannot parse kkdcp string: %s\n", p);
|
||||
exit(1);
|
||||
}
|
||||
*p2 = 0;
|
||||
@@ -563,7 +563,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
if (cont_type != NULL) {
|
||||
*cont_type = 0;
|
||||
cont_type++;
|
||||
config->urlfw[i].content_type = talloc_strdup(config->urlfw, cont_type);
|
||||
config->kkdcp[i].content_type = talloc_strdup(config->kkdcp, cont_type);
|
||||
}
|
||||
|
||||
p3 = strchr(p2, ':');
|
||||
@@ -581,17 +581,17 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memcpy(&config->urlfw[i].addr, res->ai_addr, res->ai_addrlen);
|
||||
config->urlfw[i].addr_len = res->ai_addrlen;
|
||||
config->urlfw[i].ai_family = res->ai_family;
|
||||
config->urlfw[i].ai_socktype = res->ai_socktype;
|
||||
config->urlfw[i].ai_protocol = res->ai_protocol;
|
||||
memcpy(&config->kkdcp[i].addr, res->ai_addr, res->ai_addrlen);
|
||||
config->kkdcp[i].addr_len = res->ai_addrlen;
|
||||
config->kkdcp[i].ai_family = res->ai_family;
|
||||
config->kkdcp[i].ai_socktype = res->ai_socktype;
|
||||
config->kkdcp[i].ai_protocol = res->ai_protocol;
|
||||
|
||||
config->urlfw[i].url = talloc_strdup(config->urlfw, p);
|
||||
config->kkdcp[i].url = talloc_strdup(config->kkdcp, p);
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
config->urlfw_size = urlfw_size;
|
||||
config->kkdcp_size = urlfw_size;
|
||||
}
|
||||
|
||||
static void parse_cfg_file(const char* file, struct cfg_st *config, unsigned reload)
|
||||
@@ -656,9 +656,9 @@ unsigned urlfw_size = 0;
|
||||
READ_TF("listen-host-is-dyndns", config->is_dyndns, 0);
|
||||
READ_STRING("listen-clear-file", config->unix_conn_file);
|
||||
|
||||
READ_MULTI_LINE("url-fw", urlfw, urlfw_size);
|
||||
READ_MULTI_LINE("kkdcp", urlfw, urlfw_size);
|
||||
if (urlfw_size > 0) {
|
||||
parse_urlfw(config, urlfw, urlfw_size);
|
||||
parse_kkdcp(config, urlfw, urlfw_size);
|
||||
talloc_free(urlfw);
|
||||
}
|
||||
|
||||
@@ -1074,9 +1074,9 @@ unsigned i;
|
||||
DEL(config->disconnect_script);
|
||||
DEL(config->proxy_url);
|
||||
|
||||
for (i=0;i<config->urlfw_size;i++)
|
||||
DEL(config->urlfw[i].url);
|
||||
DEL(config->urlfw);
|
||||
for (i=0;i<config->kkdcp_size;i++)
|
||||
DEL(config->kkdcp[i].url);
|
||||
DEL(config->kkdcp);
|
||||
|
||||
DEL(config->network.ipv4);
|
||||
DEL(config->network.ipv4_netmask);
|
||||
|
||||
@@ -217,7 +217,7 @@ typedef struct auth_struct_st {
|
||||
bool enabled;
|
||||
} auth_struct_st;
|
||||
|
||||
typedef struct urlfw_st {
|
||||
typedef struct kkdcp_st {
|
||||
char *url;
|
||||
char *content_type; /* Content-Type */
|
||||
struct sockaddr_storage addr;
|
||||
@@ -225,7 +225,7 @@ typedef struct urlfw_st {
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
} urlfw_st;
|
||||
} kkdcp_st;
|
||||
|
||||
struct cfg_st {
|
||||
char *name; /* server name */
|
||||
@@ -236,8 +236,8 @@ struct cfg_st {
|
||||
unsigned int sup_config_type; /* one of SUP_CONFIG_ */
|
||||
unsigned int stats_report_time;
|
||||
|
||||
urlfw_st *urlfw;
|
||||
unsigned int urlfw_size;
|
||||
kkdcp_st *kkdcp;
|
||||
unsigned int kkdcp_size;
|
||||
|
||||
char *pin_file;
|
||||
char *srk_pin_file;
|
||||
|
||||
+3
-3
@@ -420,9 +420,9 @@ url_handler_fn http_post_url_handler(struct worker_st *ws, const char *url)
|
||||
p++;
|
||||
} while (p->url != NULL);
|
||||
|
||||
for (i=0;i<ws->config->urlfw_size;i++) {
|
||||
if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, url) == 0)
|
||||
return post_urlfw_handler;
|
||||
for (i=0;i<ws->config->kkdcp_size;i++) {
|
||||
if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, url) == 0)
|
||||
return post_kkdcp_handler;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -27,38 +27,38 @@
|
||||
#include <vpn.h>
|
||||
#include <worker.h>
|
||||
|
||||
int post_urlfw_handler(worker_st *ws, unsigned http_ver)
|
||||
int post_kkdcp_handler(worker_st *ws, unsigned http_ver)
|
||||
{
|
||||
int ret, e, fd;
|
||||
struct http_req_st *req = &ws->req;
|
||||
unsigned i, length;
|
||||
urlfw_st *handler = NULL;
|
||||
kkdcp_st *handler = NULL;
|
||||
char buf[16*1024];
|
||||
const char *reason = "Unknown";
|
||||
|
||||
for (i=0;i<ws->config->urlfw_size;i++) {
|
||||
if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, req->url) == 0) {
|
||||
handler = &ws->config->urlfw[i];
|
||||
for (i=0;i<ws->config->kkdcp_size;i++) {
|
||||
if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, req->url) == 0) {
|
||||
handler = &ws->config->kkdcp[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (handler == NULL) {
|
||||
oclog(ws, LOG_HTTP_DEBUG, "could not figure urlfw handler for %s", req->url);
|
||||
oclog(ws, LOG_HTTP_DEBUG, "could not figure kkdcp handler for %s", req->url);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (req->body_length == 0) {
|
||||
oclog(ws, LOG_HTTP_DEBUG, "empty body length for urlfw handler %s", req->url);
|
||||
oclog(ws, LOG_HTTP_DEBUG, "empty body length for kkdcp handler %s", req->url);
|
||||
return -1;
|
||||
}
|
||||
|
||||
oclog(ws, LOG_HTTP_DEBUG, "POST urlfw data: %u bytes", (unsigned)req->body_length);
|
||||
oclog(ws, LOG_HTTP_DEBUG, "POST kkdcp data: %u bytes", (unsigned)req->body_length);
|
||||
|
||||
fd = socket(handler->ai_family, handler->ai_socktype, handler->ai_protocol);
|
||||
if (fd == -1) {
|
||||
e = errno;
|
||||
oclog(ws, LOG_INFO, "urlfw: socket error: %s", strerror(e));
|
||||
oclog(ws, LOG_INFO, "kkdcp: socket error: %s", strerror(e));
|
||||
reason = "Socket error";
|
||||
goto fail;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
|
||||
ret = connect(fd, (struct sockaddr*)&handler->addr, handler->addr_len);
|
||||
if (ret == -1) {
|
||||
e = errno;
|
||||
oclog(ws, LOG_INFO, "urlfw: connect error: %s", strerror(e));
|
||||
oclog(ws, LOG_INFO, "kkdcp: connect error: %s", strerror(e));
|
||||
reason = "Connect error";
|
||||
goto fail;
|
||||
}
|
||||
@@ -75,9 +75,9 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
|
||||
if (ret != req->body_length) {
|
||||
if (ret == -1) {
|
||||
e = errno;
|
||||
oclog(ws, LOG_INFO, "urlfw: send error: %s", strerror(e));
|
||||
oclog(ws, LOG_INFO, "kkdcp: send error: %s", strerror(e));
|
||||
} else {
|
||||
oclog(ws, LOG_INFO, "urlfw: send error: only %d were sent", ret);
|
||||
oclog(ws, LOG_INFO, "kkdcp: send error: only %d were sent", ret);
|
||||
}
|
||||
reason = "Send error";
|
||||
goto fail;
|
||||
@@ -86,7 +86,7 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
|
||||
ret = recv(fd, buf, sizeof(buf), 0);
|
||||
if (ret == -1) {
|
||||
e = errno;
|
||||
oclog(ws, LOG_INFO, "urlfw: recv error: %s", strerror(e));
|
||||
oclog(ws, LOG_INFO, "kkdcp: recv error: %s", strerror(e));
|
||||
reason = "Recv error";
|
||||
goto fail;
|
||||
}
|
||||
+1
-1
@@ -269,7 +269,7 @@ int auth_user_deinit(worker_st *ws);
|
||||
|
||||
int get_auth_handler(worker_st *server, unsigned http_ver);
|
||||
int post_auth_handler(worker_st *server, unsigned http_ver);
|
||||
int post_urlfw_handler(worker_st *server, unsigned http_ver);
|
||||
int post_kkdcp_handler(worker_st *server, unsigned http_ver);
|
||||
|
||||
int get_empty_handler(worker_st *server, unsigned http_ver);
|
||||
int get_config_handler(worker_st *ws, unsigned http_ver);
|
||||
|
||||
Reference in New Issue
Block a user