X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=dccp_send.c;h=d0f9448e8e048445ce0e0c6a6adf8d0d903449cc;hp=c94e1624493e511b59c41c61c17205426b869754;hb=5b8e525dfb2f18a4e0d67b9da264259159ad2184;hpb=17081d1ed686e0717a545582dd04e3377f16a6e6;ds=sidebyside diff --git a/dccp_send.c b/dccp_send.c index c94e1624..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,16 +108,28 @@ 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) { - char *buf; int num_clients = 0; struct sender_client *sc, *tmp; list_for_each_entry_safe(sc, tmp, &clients, node) num_clients++; - buf = make_message("dccp connected clients: %d\n", num_clients); - return buf; + return make_message("dccp connected clients: %d\n", num_clients); } static char *dccp_help(void) @@ -140,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));