From: Pekka Riikonen Date: Mon, 2 May 2005 08:50:28 +0000 (+0000) Subject: Added channel_join_limit, default is 50. X-Git-Tag: autodist.1.3~5 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=0ef42261bd743310fba768150a1540c2d6bc5539 Added channel_join_limit, default is 50. --- diff --git a/CHANGES b/CHANGES index cb4b36e9..0279f209 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Mon May 2 10:42:49 EEST 2005 Pekka Riikonen + + * Added default limit how many channels client can join, + default is 50. Added 'channel_join_limit' configuration + option to server too. Affected files are apps/silcd/command.c + and serverconfig.[ch]. + Sun May 1 17:42:55 EEST 2005 Pekka Riikonen * --without-silc -> --with-silc, --without-irssi -> --with-irssi. diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 927e14cc..aab26224 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -2417,6 +2417,17 @@ SILC_SERVER_CMD_FUNC(join) goto out; } +#ifndef SILC_DIST_INPLACE + /* Limit how many channels client can join */ + if (entry->channels && silc_hash_table_count(entry->channels) >= + server->config->param.chlimit) { + silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN, + SILC_STATUS_ERR_RESOURCE_LIMIT, + 0); + goto out; + } +#endif /* SILC_DIST_INPLACE */ + silc_free(client_id); client_id = silc_id_dup(entry->id, SILC_ID_CLIENT); diff --git a/apps/silcd/server.h b/apps/silcd/server.h index 55e5f1fc..07f5d63d 100644 --- a/apps/silcd/server.h +++ b/apps/silcd/server.h @@ -86,6 +86,7 @@ typedef struct { #define SILC_SERVER_QOS_BYTES_LIMIT 2048 /* Default QoS bytes limit */ #define SILC_SERVER_QOS_LIMIT_SEC 0 /* Default QoS limit sec */ #define SILC_SERVER_QOS_LIMIT_USEC 500000 /* Default QoS limit usec */ +#define SILC_SERVER_CH_JOIN_LIMIT 50 /* Default join limit */ /* Macros */ diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 545a39ff..133b576a 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -4,12 +4,11 @@ Author: Giovanni Giacobbi - Copyright (C) 1997 - 2004 Pekka Riikonen + Copyright (C) 1997 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -97,6 +96,7 @@ my_set_param_defaults(SilcServerConfigConnParams *params, SET_PARAM_DEFAULT(qos_bytes_limit, SILC_SERVER_QOS_BYTES_LIMIT); SET_PARAM_DEFAULT(qos_limit_sec, SILC_SERVER_QOS_LIMIT_SEC); SET_PARAM_DEFAULT(qos_limit_usec, SILC_SERVER_QOS_LIMIT_USEC); + SET_PARAM_DEFAULT(chlimit, SILC_SERVER_CH_JOIN_LIMIT); #undef SET_PARAM_DEFAULT } @@ -305,6 +305,9 @@ SILC_CONFIG_CALLBACK(fetch_generic) else if (!strcmp(name, "qos_limit_usec")) { config->param.qos_limit_usec = *(SilcUInt32 *)val; } + else if (!strcmp(name, "channel_join_limit")) { + config->param.chlimit = *(SilcUInt32 *)val; + } else if (!strcmp(name, "debug_string")) { CONFIG_IS_DOUBLE(config->debug_string); config->debug_string = (*(char *)val ? strdup((char *) val) : NULL); @@ -1168,6 +1171,7 @@ static const SilcConfigTable table_general[] = { { "qos_bytes_limit", SILC_CONFIG_ARG_INT, fetch_generic, NULL }, { "qos_limit_sec", SILC_CONFIG_ARG_INT, fetch_generic, NULL }, { "qos_limit_usec", SILC_CONFIG_ARG_INT, fetch_generic, NULL }, + { "channel_join_limit", SILC_CONFIG_ARG_INT, fetch_generic, NULL }, { "debug_string", SILC_CONFIG_ARG_STR, fetch_generic, NULL }, { 0, 0, 0, 0 } }; diff --git a/apps/silcd/serverconfig.h b/apps/silcd/serverconfig.h index 2104976e..cc1ecb21 100644 --- a/apps/silcd/serverconfig.h +++ b/apps/silcd/serverconfig.h @@ -4,12 +4,11 @@ Author: Giovanni Giacobbi - Copyright (C) 1997 - 2002 Pekka Riikonen + Copyright (C) 1997 - 2005 Pekka Riikonen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -94,6 +93,7 @@ typedef struct SilcServerConfigConnParams { SilcUInt32 qos_bytes_limit; SilcUInt32 qos_limit_sec; SilcUInt32 qos_limit_usec; + SilcUInt32 chlimit; unsigned int key_exchange_pfs : 1; unsigned int reconnect_keep_trying : 1; unsigned int anonymous : 1;