renamed urlfw to kkdcp

This commit is contained in:
Nikos Mavrogiannopoulos
2015-02-19 11:47:20 +01:00
parent b5a0fe354f
commit 6334bada15
6 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -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 \ 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 \ 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) \ 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 \ sec-mod-sup-config.c sec-mod-sup-config.h \
sup-config/file.c sup-config/file.h \ sup-config/file.c sup-config/file.h \
sup-config/radius.c sup-config/radius.h \ sup-config/radius.c sup-config/radius.h \
+18 -18
View File
@@ -95,7 +95,7 @@ static struct cfg_options available_options[] = {
{ .name = "connect-script", .type = OPTION_STRING, .mandatory = 0 }, { .name = "connect-script", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "disconnect-script", .type = OPTION_STRING, .mandatory = 0 }, { .name = "disconnect-script", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "pid-file", .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 = "socket-file", .type = OPTION_STRING, .mandatory = 1 },
{ .name = "listen-clear-file", .type = OPTION_STRING, .mandatory = 0 }, { .name = "listen-clear-file", .type = OPTION_STRING, .mandatory = 0 },
{ .name = "occtl-socket-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); 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; unsigned i;
char *p, *p2, *p3, *cont_type; char *p, *p2, *p3, *cont_type;
struct addrinfo hints, *res; struct addrinfo hints, *res;
int ret; int ret;
config->urlfw = talloc_size(config, urlfw_size*sizeof(urlfw_st)); config->kkdcp = talloc_size(config, urlfw_size*sizeof(kkdcp_st));
if (config->urlfw == NULL) { if (config->kkdcp == NULL) {
fprintf(stderr, "memory error\n"); fprintf(stderr, "memory error\n");
exit(1); exit(1);
} }
@@ -542,7 +542,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
p = urlfw[i]; p = urlfw[i];
p2 = strchr(p, ' '); p2 = strchr(p, ' ');
if (p2 == NULL) { if (p2 == NULL) {
fprintf(stderr, "Cannot parse url-fw string: %s\n", p); fprintf(stderr, "Cannot parse kkdcp string: %s\n", p);
exit(1); exit(1);
} }
*p2 = 0; *p2 = 0;
@@ -563,7 +563,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
if (cont_type != NULL) { if (cont_type != NULL) {
*cont_type = 0; *cont_type = 0;
cont_type++; 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, ':'); p3 = strchr(p2, ':');
@@ -581,17 +581,17 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size
exit(1); exit(1);
} }
memcpy(&config->urlfw[i].addr, res->ai_addr, res->ai_addrlen); memcpy(&config->kkdcp[i].addr, res->ai_addr, res->ai_addrlen);
config->urlfw[i].addr_len = res->ai_addrlen; config->kkdcp[i].addr_len = res->ai_addrlen;
config->urlfw[i].ai_family = res->ai_family; config->kkdcp[i].ai_family = res->ai_family;
config->urlfw[i].ai_socktype = res->ai_socktype; config->kkdcp[i].ai_socktype = res->ai_socktype;
config->urlfw[i].ai_protocol = res->ai_protocol; 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); 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) 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_TF("listen-host-is-dyndns", config->is_dyndns, 0);
READ_STRING("listen-clear-file", config->unix_conn_file); 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) { if (urlfw_size > 0) {
parse_urlfw(config, urlfw, urlfw_size); parse_kkdcp(config, urlfw, urlfw_size);
talloc_free(urlfw); talloc_free(urlfw);
} }
@@ -1074,9 +1074,9 @@ unsigned i;
DEL(config->disconnect_script); DEL(config->disconnect_script);
DEL(config->proxy_url); DEL(config->proxy_url);
for (i=0;i<config->urlfw_size;i++) for (i=0;i<config->kkdcp_size;i++)
DEL(config->urlfw[i].url); DEL(config->kkdcp[i].url);
DEL(config->urlfw); DEL(config->kkdcp);
DEL(config->network.ipv4); DEL(config->network.ipv4);
DEL(config->network.ipv4_netmask); DEL(config->network.ipv4_netmask);
+4 -4
View File
@@ -217,7 +217,7 @@ typedef struct auth_struct_st {
bool enabled; bool enabled;
} auth_struct_st; } auth_struct_st;
typedef struct urlfw_st { typedef struct kkdcp_st {
char *url; char *url;
char *content_type; /* Content-Type */ char *content_type; /* Content-Type */
struct sockaddr_storage addr; struct sockaddr_storage addr;
@@ -225,7 +225,7 @@ typedef struct urlfw_st {
int ai_family; int ai_family;
int ai_socktype; int ai_socktype;
int ai_protocol; int ai_protocol;
} urlfw_st; } kkdcp_st;
struct cfg_st { struct cfg_st {
char *name; /* server name */ char *name; /* server name */
@@ -236,8 +236,8 @@ struct cfg_st {
unsigned int sup_config_type; /* one of SUP_CONFIG_ */ unsigned int sup_config_type; /* one of SUP_CONFIG_ */
unsigned int stats_report_time; unsigned int stats_report_time;
urlfw_st *urlfw; kkdcp_st *kkdcp;
unsigned int urlfw_size; unsigned int kkdcp_size;
char *pin_file; char *pin_file;
char *srk_pin_file; char *srk_pin_file;
+3 -3
View File
@@ -420,9 +420,9 @@ url_handler_fn http_post_url_handler(struct worker_st *ws, const char *url)
p++; p++;
} while (p->url != NULL); } while (p->url != NULL);
for (i=0;i<ws->config->urlfw_size;i++) { for (i=0;i<ws->config->kkdcp_size;i++) {
if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, url) == 0) if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, url) == 0)
return post_urlfw_handler; return post_kkdcp_handler;
} }
return NULL; return NULL;
+13 -13
View File
@@ -27,38 +27,38 @@
#include <vpn.h> #include <vpn.h>
#include <worker.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; int ret, e, fd;
struct http_req_st *req = &ws->req; struct http_req_st *req = &ws->req;
unsigned i, length; unsigned i, length;
urlfw_st *handler = NULL; kkdcp_st *handler = NULL;
char buf[16*1024]; char buf[16*1024];
const char *reason = "Unknown"; const char *reason = "Unknown";
for (i=0;i<ws->config->urlfw_size;i++) { for (i=0;i<ws->config->kkdcp_size;i++) {
if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, req->url) == 0) { if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, req->url) == 0) {
handler = &ws->config->urlfw[i]; handler = &ws->config->kkdcp[i];
break; break;
} }
} }
if (handler == NULL) { 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; return -1;
} }
if (req->body_length == 0) { 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; 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); fd = socket(handler->ai_family, handler->ai_socktype, handler->ai_protocol);
if (fd == -1) { if (fd == -1) {
e = errno; 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"; reason = "Socket error";
goto fail; 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); ret = connect(fd, (struct sockaddr*)&handler->addr, handler->addr_len);
if (ret == -1) { if (ret == -1) {
e = errno; 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"; reason = "Connect error";
goto fail; goto fail;
} }
@@ -75,9 +75,9 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
if (ret != req->body_length) { if (ret != req->body_length) {
if (ret == -1) { if (ret == -1) {
e = errno; e = errno;
oclog(ws, LOG_INFO, "urlfw: send error: %s", strerror(e)); oclog(ws, LOG_INFO, "kkdcp: send error: %s", strerror(e));
} else { } 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"; reason = "Send error";
goto fail; goto fail;
@@ -86,7 +86,7 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver)
ret = recv(fd, buf, sizeof(buf), 0); ret = recv(fd, buf, sizeof(buf), 0);
if (ret == -1) { if (ret == -1) {
e = errno; 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"; reason = "Recv error";
goto fail; goto fail;
} }
+1 -1
View File
@@ -269,7 +269,7 @@ int auth_user_deinit(worker_st *ws);
int get_auth_handler(worker_st *server, unsigned http_ver); int get_auth_handler(worker_st *server, unsigned http_ver);
int post_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_empty_handler(worker_st *server, unsigned http_ver);
int get_config_handler(worker_st *ws, unsigned http_ver); int get_config_handler(worker_st *ws, unsigned http_ver);