X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=dccp_send.c;h=d0f9448e8e048445ce0e0c6a6adf8d0d903449cc;hp=7b7c80517f7dee6d5fa7c2a34cf4993cd0dbe28b;hb=8157cf8316ef9b3769933d5b17e169b400d36da8;hpb=2b4a72bab701de1add388f89a92f1b7a358dab79 diff --git a/dccp_send.c b/dccp_send.c index 7b7c8051..d0f9448e 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -28,9 +28,12 @@ #include "close_on_fork.h" #include "chunk_queue.h" #include "server.cmdline.h" +#include "acl.h" /** the list of connected clients **/ static struct list_head clients; +/** The whitelist/blacklist. */ +static struct list_head dccp_acl; static int listen_fd = -1; /** Maximal number of bytes in a chunk queue. */ @@ -69,6 +72,9 @@ static void dccp_post_select(fd_set *rfds, __a_unused fd_set *wfds) goto err; } ret = mark_fd_nonblocking(fd); + if (ret < 0) + goto err; + ret = acl_check_access(fd, &dccp_acl, conf.dccp_default_deny_given); if (ret < 0) goto err; sc = para_calloc(sizeof(*sc)); @@ -102,6 +108,20 @@ static void dccp_shutdown_clients(void) shutdown_client(sc); } +static int dccp_com_deny(struct sender_command_data *scd) +{ + acl_deny(scd->addr, scd->netmask, &dccp_acl, + conf.dccp_default_deny_given); + return 1; +} + +static int dccp_com_allow(struct sender_command_data *scd) +{ + acl_allow(scd->addr, scd->netmask, &dccp_acl, + conf.dccp_default_deny_given); + return 1; +} + static char *dccp_info(void) { int num_clients = 0; @@ -138,10 +158,11 @@ void dccp_send_init(struct sender *s) s->help = dccp_help; s->client_cmds[SENDER_ON] = NULL; s->client_cmds[SENDER_OFF] = NULL; - s->client_cmds[SENDER_DENY] = NULL; - s->client_cmds[SENDER_ALLOW] = NULL; + s->client_cmds[SENDER_DENY] = dccp_com_deny; + s->client_cmds[SENDER_ALLOW] = dccp_com_allow; s->client_cmds[SENDER_ADD] = NULL; s->client_cmds[SENDER_DELETE] = NULL; + acl_init(&dccp_acl, conf.dccp_access_arg, conf.dccp_access_given); ret = open_sender(IPPROTO_DCCP, conf.dccp_port_arg); if (ret < 0) PARA_ERROR_LOG("%s\n", para_strerror(-ret));