#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. */
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));
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;
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));