From 5bd4f4499d0fa3e2163fdba2ac20b487af87b158 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 6 May 2004 09:46:38 +0000 Subject: [PATCH] basic off-channel support; restructuring how part functions are handled * added srvx.conf setting to allow chanserv to work being outside of a channel; if you'd like to have srvx set a mode as it joins, edit REGISTERED_MODE in hash.h. this will not work properly on P10 networks - though it may be nice for bahamut-based networks. either way, please do not ask us for assistance. * changed the way part functions are called - a modeNode is now passed, and they are run *before* the user's membership link in that channel is nuked. git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-58 --- ChangeLog | 19 ++++++++++++++++ src/chanserv.c | 56 ++++++++++++++++++++++++++-------------------- src/hash.c | 6 ++--- src/hash.h | 5 ++++- src/mod-helpserv.c | 22 +++++++++--------- src/mod-snoop.c | 6 ++--- src/proto-common.c | 1 + src/proto-p10.c | 10 +++++---- srvx.conf.example | 6 +++++ 9 files changed, 85 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index b5c8193..c9e5b0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,25 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3 # +2004-05-06 09:46:38 GMT adam patch-58 + + Summary: + basic off-channel support; restructuring how part functions are handled + Revision: + srvx--devo--1.3--patch-58 + + * added srvx.conf setting to allow chanserv to work being outside of a channel; if you'd like to have srvx set a mode as it joins, edit REGISTERED_MODE in hash.h. this will not work properly on P10 networks - though it may be nice for bahamut-based networks. either way, please do not ask us for assistance. + + * changed the way part functions are called - a modeNode is now passed, and they are run *before* the user's membership link in that channel is nuked. + + + + modified files: + ChangeLog src/chanserv.c src/hash.c src/hash.h + src/mod-helpserv.c src/mod-snoop.c src/proto-common.c + src/proto-p10.c srvx.conf.example + + 2004-05-01 11:17:11 GMT adam patch-57 Summary: diff --git a/src/chanserv.c b/src/chanserv.c index 75f7ee2..927522e 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -5982,45 +5982,45 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle)) } static void -handle_part(struct userNode *user, struct chanNode *channel, UNUSED_ARG(const char *reason)) +handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) { struct chanData *cData; struct userData *uData; - cData = channel->channel_info; - if(!cData || IsSuspended(cData) || IsLocal(user)) + cData = mn->channel->channel_info; + if(!cData || IsSuspended(cData) || IsLocal(mn->user)) return; - if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !channel->join_flooded) + if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !mn->channel->join_flooded) { /* Allow for a bit of padding so that the limit doesn't track the user count exactly, which could get annoying. */ - if((channel->limit - channel->members.used) > chanserv_conf.adjust_threshold + 5) + if((mn->channel->limit - mn->channel->members.used) > chanserv_conf.adjust_threshold + 5) { timeq_del(0, chanserv_adjust_limit, cData, TIMEQ_IGNORE_WHEN); timeq_add(now + chanserv_conf.adjust_delay, chanserv_adjust_limit, cData); } } - if((uData = GetTrueChannelAccess(cData, user->handle_info))) + if((uData = GetTrueChannelAccess(cData, mn->user->handle_info))) { - scan_user_presence(uData, user); + scan_user_presence(uData, mn->user); uData->seen = now; } - if(IsHelping(user) && IsSupportHelper(user)) + if(IsHelping(mn->user) && IsSupportHelper(mn->user)) { unsigned int ii, jj; for(ii = 0; ii < chanserv_conf.support_channels.used; ++ii) { - for(jj = 0; jj < user->channels.used; ++jj) - if(user->channels.list[jj]->channel == chanserv_conf.support_channels.list[ii]) + for(jj = 0; jj < mn->user->channels.used; ++jj) + if(mn->user->channels.list[jj]->channel == chanserv_conf.support_channels.list[ii]) break; - if(jj < user->channels.used) + if(jj < mn->user->channels.used) break; } if(ii == chanserv_conf.support_channels.used) - HANDLE_CLEAR_FLAG(user->handle_info, HELPING); + HANDLE_CLEAR_FLAG(mn->user->handle_info, HELPING); } } @@ -6243,6 +6243,7 @@ chanserv_conf_read(void) struct string_list *strlist; struct chanNode *chan; unsigned int ii; + extern int off_channel; if(!(conf_node = conf_get_data(CHANSERV_CONF_NAME, RECDB_OBJECT))) { @@ -6374,6 +6375,10 @@ chanserv_conf_read(void) else strlist = alloc_string_list(2); chanserv_conf.old_ban_names = strlist; + /* the variable itself is actually declared in proto-common.c; this is equally + * parse issue. */ + str = database_get_data(conf_node, "off_channel", RECDB_QSTRING); + off_channel = (str && enabled_string(str)) ? 1 : 0; } static void @@ -6535,6 +6540,7 @@ chanserv_channel_read(const char *key, struct record_data *hir) char *str, *argv[10]; dict_iterator_t it; unsigned int argc; + extern int off_channel; channel = hir->d.object; @@ -6649,18 +6655,18 @@ chanserv_channel_read(const char *key, struct record_data *hir) cData->flags &= ~CHANNEL_SUSPENDED; } - if(!(cData->flags & CHANNEL_SUSPENDED)) - { - struct mod_chanmode change; - mod_chanmode_init(&change); - change.argc = 1; - change.args[0].mode = MODE_CHANOP; - change.args[0].member = AddChannelUser(chanserv, cNode); - mod_chanmode_announce(chanserv, cNode, &change); - } - else if(suspended->expires > now) - { - timeq_add(suspended->expires, chanserv_expire_suspension, suspended); + if (!off_channel) { + if (!(cData->flags & CHANNEL_SUSPENDED)) { + struct mod_chanmode change; + mod_chanmode_init(&change); + change.argc = 1; + change.args[0].mode = MODE_CHANOP; + change.args[0].member = AddChannelUser(chanserv, cNode); + mod_chanmode_announce(chanserv, cNode, &change); + + } else if (suspended->expires > now) { + timeq_add(suspended->expires, chanserv_expire_suspension, suspended); + } } str = database_get_data(channel, KEY_REGISTERED, RECDB_QSTRING); @@ -6682,6 +6688,8 @@ chanserv_channel_read(const char *key, struct record_data *hir) && (argc = split_line(str, 0, ArrayLength(argv), argv)) && (modes = mod_chanmode_parse(cNode, argv, argc, MCP_KEY_FREE))) { cData->modes = *modes; + if(off_channel && !(REGISTERED_MODE == 0)) + cData->modes.modes_set |= REGISTERED_MODE; if(cData->modes.argc > 1) cData->modes.argc = 1; if(!IsSuspended(cData)) diff --git a/src/hash.c b/src/hash.c index 98705ba..cbe43ce 100644 --- a/src/hash.c +++ b/src/hash.c @@ -544,14 +544,14 @@ DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reas if (!mNode) return; + for (n=0; nmembers, mNode); modeList_remove(&user->channels, mNode); free(mNode); - for (n=0; nmembers.used && !channel->locks) DelChannel(channel); } diff --git a/src/hash.h b/src/hash.h index ce02a2b..82eddae 100644 --- a/src/hash.h +++ b/src/hash.h @@ -74,6 +74,9 @@ #define IsReggedNick(x) ((x)->modes & FLAGS_REGNICK) #define IsLocal(x) ((x)->uplink == self) +/* Please set this and define the mode you wish to be set/maintained on registered channels. */ +#define REGISTERED_MODE 0 + #define NICKLEN 30 #define USERLEN 10 #define HOSTLEN 63 @@ -217,7 +220,7 @@ void UnlockChannel(struct chanNode *channel); struct modeNode* AddChannelUser(struct userNode* user, struct chanNode* channel); -typedef void (*part_func_t) (struct userNode *user, struct chanNode *chan, const char *reason); +typedef void (*part_func_t) (struct modeNode *mn, const char *reason); void reg_part_func(part_func_t handler); void unreg_part_func(part_func_t handler); void DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reason, int deleting); diff --git a/src/mod-helpserv.c b/src/mod-helpserv.c index bb210b9..1a8efc5 100644 --- a/src/mod-helpserv.c +++ b/src/mod-helpserv.c @@ -3689,13 +3689,13 @@ helpserv_define_func(const char *name, helpserv_func_t *func, enum helpserv_leve } /* Drop requests that persist until part when a user leaves the chan */ -static void handle_part(struct userNode *user, struct chanNode *chan, UNUSED_ARG(const char *reason)) { +static void handle_part(struct modeNode *mn, UNUSED_ARG(const char *reason)) { struct helpserv_botlist *botlist; struct helpserv_userlist *userlist; const int from_opserv = 0; /* for helpserv_notice */ unsigned int i; - if ((botlist = dict_find(helpserv_bots_bychan_dict, chan->name, NULL))) { + if ((botlist = dict_find(helpserv_bots_bychan_dict, mn->channel->name, NULL))) { for (i=0; i < botlist->used; i++) { struct helpserv_bot *hs; dict_iterator_t it; @@ -3709,13 +3709,13 @@ static void handle_part(struct userNode *user, struct chanNode *chan, UNUSED_ARG for (it=dict_first(hs->requests); it; it=iter_next(it)) { struct helpserv_request *req = iter_data(it); - if (user != req->user) + if (mn->user != req->user) continue; if (req->text->used) { - helpserv_message(hs, user, MSGTYPE_REQ_DROPPED); - helpserv_msguser(user, "HSMSG_REQ_DROPPED_PART", chan->name, req->id); + helpserv_message(hs, mn->user, MSGTYPE_REQ_DROPPED); + helpserv_msguser(mn->user, "HSMSG_REQ_DROPPED_PART", mn->channel->name, req->id); if (req->helper && (hs->notify >= NOTIFY_DROP)) - helpserv_notify(req->helper, "HSMSG_NOTIFY_REQ_DROP_PART", req->id, user->nick); + helpserv_notify(req->helper, "HSMSG_NOTIFY_REQ_DROP_PART", req->id, mn->user->nick); } helpserv_log_request(req, "Dropped"); dict_remove(hs->requests, iter_key(it)); @@ -3724,13 +3724,13 @@ static void handle_part(struct userNode *user, struct chanNode *chan, UNUSED_ARG } } - if (user->handle_info && (userlist = dict_find(helpserv_users_byhand_dict, user->handle_info->handle, NULL))) { + if (mn->user->handle_info && (userlist = dict_find(helpserv_users_byhand_dict, mn->user->handle_info->handle, NULL))) { for (i=0; i < userlist->used; i++) { struct helpserv_user *hs_user = userlist->list[i]; struct helpserv_bot *hs = hs_user->hs; dict_iterator_t it; - if ((hs->helpserv == NULL) || (hs->helpchan != chan) || find_handle_in_channel(hs->helpchan, user->handle_info, user)) + if ((hs->helpserv == NULL) || (hs->helpchan != mn->channel) || find_handle_in_channel(hs->helpchan, mn->user->handle_info, mn->user)) continue; /* In case of the clock being set back for whatever reason, @@ -3749,7 +3749,7 @@ static void handle_part(struct userNode *user, struct chanNode *chan, UNUSED_ARG if ((hs->persist_types[PERSIST_T_HELPER] == PERSIST_PART) && (req->helper == hs_user)) { char reason[CHANNELLEN + 8]; - sprintf(reason, "parted %s", chan->name); + sprintf(reason, "parted %s", mn->channel->name); helpserv_page_helper_gone(hs, req, reason); } } @@ -3765,9 +3765,9 @@ static void handle_part(struct userNode *user, struct chanNode *chan, UNUSED_ARG unh = unh->next_unhandled; if (num_trials) { - helpserv_page(PGSRC_ALERT, "HSMSG_PAGE_FIRSTONLYTRIALALERT", hs->helpchan->name, user->nick, num_trials, num_unh); + helpserv_page(PGSRC_ALERT, "HSMSG_PAGE_FIRSTONLYTRIALALERT", hs->helpchan->name, mn->user->nick, num_trials, num_unh); } else { - helpserv_page(PGSRC_ALERT, "HSMSG_PAGE_FIRSTEMPTYALERT", hs->helpchan->name, user->nick, num_unh); + helpserv_page(PGSRC_ALERT, "HSMSG_PAGE_FIRSTEMPTYALERT", hs->helpchan->name, mn->user->nick, num_unh); } if (num_unh || !hs->req_on_join) { timeq_del(0, run_empty_interval, hs, TIMEQ_IGNORE_WHEN); diff --git a/src/mod-snoop.c b/src/mod-snoop.c index 1cb5e58..3d463a3 100644 --- a/src/mod-snoop.c +++ b/src/mod-snoop.c @@ -81,11 +81,11 @@ snoop_join(struct modeNode *mNode) { } static void -snoop_part(struct userNode *user, struct chanNode *chan, const char *reason) { +snoop_part(struct modeNode *mn, const char *reason) { if (!snoop_cfg.enabled) return; - if (user->dead) return; + if (mn->user->dead) return; UPDATE_TIMESTAMP(); - SNOOP("$bPART$b %s by %s (%s)", chan->name, user->nick, reason ? reason : ""); + SNOOP("$bPART$b %s by %s (%s)", mn->channel->name, mn->user->nick, reason ? reason : ""); } static void diff --git a/src/proto-common.c b/src/proto-common.c index f556045..44f92fa 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -39,6 +39,7 @@ FILE *replay_file; struct io_fd *socket_io_fd; int force_n2k; const char *hidden_host_suffix; +int off_channel; static char replay_line[MAXLEN+80]; static int ping_freq; diff --git a/src/proto-p10.c b/src/proto-p10.c index 4340ff5..aacaa59 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -563,8 +563,6 @@ irc_burst(struct chanNode *chan) long last_mode=-1; unsigned int n; - if (!chan->members.used) - return; base_len = sprintf(burst_line, "%s " P10_BURST " %s " FMT_TIME_T " ", self->numeric, chan->name, chan->timestamp); len = irc_make_chanmode(chan, burst_line+base_len); @@ -683,7 +681,7 @@ irc_kick(struct userNode *who, struct userNode *target, struct chanNode *channel { const char *numeric; struct modeNode *mn = GetUserMode(channel, who); - numeric = (mn && (mn->modes & MODE_CHANOP)) ? who->numeric : self->numeric; + numeric = ((!mn && off_channel) || (mn->modes & MODE_CHANOP)) ? who->numeric : self->numeric; putsock("%s " P10_KICK " %s %s :%s", numeric, channel->name, target->numeric, msg); } @@ -1410,10 +1408,12 @@ init_parse(void) inttobase64(numer, (numnick << 12) + (usermask & 0x00fff), 3); else inttobase64(numer, (numnick << 18) + (usermask & 0x3ffff), 5); + str = conf_get_data("server/his_servername", RECDB_QSTRING); his_servername = str ? strdup(str) : NULL; str = conf_get_data("server/his_servercomment", RECDB_QSTRING); his_servercomment = str ? strdup(str) : NULL; + str = conf_get_data("server/hostname", RECDB_QSTRING); desc = conf_get_data("server/description", RECDB_QSTRING); if (!str || !desc) { @@ -2135,7 +2135,9 @@ mod_chanmode_announce(struct userNode *who, struct chanNode *channel, struct mod chbuf.channel = channel; chbuf.actor = who; chbuf.chname_len = strlen(channel->name); - if ((mn = GetUserMode(channel, who)) && (mn->modes & MODE_CHANOP)) + + mn = GetUserMode(channel, who); + if ((!mn && off_channel) || (mn->modes & MODE_CHANOP)) chbuf.is_chanop = 1; /* First remove modes */ diff --git a/srvx.conf.example b/srvx.conf.example index e0304fa..0d73051 100644 --- a/srvx.conf.example +++ b/srvx.conf.example @@ -178,6 +178,12 @@ // (This is changed relative srvx-1.0.x, which would use default // unless you specified ".disabled".) "nick" "ChanServ"; + // Should ChanServ join the channel? Please do not ask the srvx dev + // team for help configuring your ircd or a patch if you attempt to + // use this option on ircds that do not support having services off + // of the channel. Most people will leave this off; we cannot assist + // you in designing your network to make this option usefull to you. + "off_channel" "no"; // how long should a person be unseen before resending infoline? "info_delay" "120"; // maximum greeting length -- 2.20.1