diff options
Diffstat (limited to 'src/protocol')
| -rw-r--r-- | src/protocol/bahamut.c | 66 | ||||
| -rw-r--r-- | src/protocol/inspircd11.c | 74 | ||||
| -rw-r--r-- | src/protocol/inspircd12.cpp | 85 | ||||
| -rw-r--r-- | src/protocol/ratbox.c | 46 | ||||
| -rw-r--r-- | src/protocol/unreal32.c | 118 |
5 files changed, 68 insertions, 321 deletions
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index c3ff0747c..d60641378 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -23,7 +23,6 @@ IRCDVar myIrcd[] = { "+o", /* Channel Umode used by Botserv bots */ 1, /* SVSNICK */ 0, /* Vhost */ - "-r+d", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -142,49 +141,6 @@ void bahamut_cmd_chghost(const char *nick, const char *vhost) class BahamutIRCdProto : public IRCDProto { - void ProcessUsermodes(User *user, int ac, const char **av) - { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - --ac; - if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes); - while (*modes) { - if (add) - user->SetMode(*modes); - else - user->RemoveMode(*modes); - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'd': - if (!ac) { - alog("user: umode +d with no parameter (?) for user %s", user->nick); - break; - } - --ac; - ++av; - break; - case 'o': - if (add) { - ++opcnt; - if (Config.WallOper) ircdproto->SendGlobops(Config.s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - } - else --opcnt; - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - user->RemoveMode(CMODE_REGISTERED); - } - } - } - } - void SendModeInternal(BotInfo *source, const char *dest, const char *buf) { if (!buf) return; @@ -192,6 +148,12 @@ class BahamutIRCdProto : public IRCDProto else send_cmd(source->nick, "MODE %s %s", dest, buf); } + void SendModeInternal(User *u, const char *buf) + { + if (!buf) return; + send_cmd(Config.ServerName, "SVSMODE %s %ld %s", u->nick, static_cast<long>(u->timestamp), buf); + } + /* SVSHOLD - set */ void SendSVSHold(const char *nick) { @@ -217,11 +179,6 @@ class BahamutIRCdProto : public IRCDProto else send_cmd(Config.ServerName, "SVSMODE %s %s", name, mode); } - void SendBotOp(const char *nick, const char *chan) - { - SendMode(findbot(nick), chan, "%s %s", ircd->botchanumode, nick); - } - /* SQLINE */ void SendSQLine(const char *mask, const char *reason) { @@ -329,7 +286,7 @@ class BahamutIRCdProto : public IRCDProto */ void SendSVSMode(User *u, int ac, const char **av) { - send_cmd(Config.ServerName, "SVSMODE %s %ld %s", u->nick, static_cast<long>(u->timestamp), merge_args(ac, av)); + this->SendModeInternal(u, merge_args(ac, av)); } void SendEOB() @@ -360,7 +317,8 @@ class BahamutIRCdProto : public IRCDProto /* nc_change was = 1, and there is no na->status */ void SendUnregisteredNick(User *u) { - common_svsmode(u, "+d", "1"); + u->RemoveMode(UMODE_REGISTERED); + ircdproto->SendMode(u, "+d 1"); } /* SERVER */ @@ -397,7 +355,8 @@ class BahamutIRCdProto : public IRCDProto u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); - common_svsmode(u, "+rd", svidbuf); + u->SetMode(UMODE_REGISTERED); + ircdproto->SendMode(u, "+d %s", svidbuf); } } ircd_proto; @@ -442,7 +401,7 @@ int anope_event_nick(const char *source, int ac, const char **av) */ user->CheckAuthenticationToken(av[7]); - ircdproto->ProcessUsermodes(user, 1, &av[3]); + UserSetInternalModes(user, 1, &av[3]); } } else { do_nick(source, av[0], NULL, NULL, NULL, NULL, @@ -723,6 +682,7 @@ void moduleAddModes() ModeManager::AddUserMode('r', new UserMode(UMODE_REGISTERED)); ModeManager::AddUserMode('s', new UserMode(UMODE_SNOMASK)); ModeManager::AddUserMode('w', new UserMode(UMODE_WALLOPS)); + ModeManager::AddUserMode('d', new UserMode(UMODE_DEAF)); /* b/e/I */ ModeManager::AddChannelMode('b', new ChannelModeBan()); diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 6c2b22c2b..b6c24bf18 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -40,7 +40,6 @@ IRCDVar myIrcd[] = { "+ao", /* Channel Umode used by Botserv bots */ 1, /* SVSNICK */ 1, /* Vhost */ - "-r", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -159,60 +158,6 @@ void inspircd_cmd_pass(const char *pass) class InspIRCdProto : public IRCDProto { - - void ProcessUsermodes(User *user, int ac, const char **av) - { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - --ac; - if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes); - while (*modes) { - if (add) - user->SetMode(*modes); - else - user->RemoveMode(*modes); - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'o': - if (add) { - ++opcnt; - if (Config.WallOper) ircdproto->SendGlobops(Config.s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - } - else --opcnt; - break; - case 'r': - if (add && !nick_identified(user)) - SendUnregisteredNick(user); - break; - case 'x': - if (add && user->vhost) - { - /* If +x is recieved then User::vhost IS the cloaked host, - * set the cloaked host correctly and destroy the vhost - Adam - */ - user->SetCloakedHost(user->vhost); - delete [] user->vhost; - user->vhost = NULL; - } - else - { - if (user->vhost) - delete [] user->vhost; - user->vhost = NULL; - } - user->UpdateHost(); - } - } - } - - /* *INDENT-ON* */ - void SendAkillDel(const char *user, const char *host) { send_cmd(Config.s_OperServ, "GLINE %s@%s", user, host); @@ -253,7 +198,7 @@ class InspIRCdProto : public IRCDProto void SendSVSMode(User *u, int ac, const char **av) { - send_cmd(Config.s_NickServ, "MODE %s %s", u->nick, merge_args(ac, av)); + this->SendModeInternal(u, merge_args(ac, av)); } void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf) @@ -273,6 +218,12 @@ class InspIRCdProto : public IRCDProto send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest, static_cast<unsigned>(c ? c->creation_time : time(NULL)), buf); } + void SendModeInternal(User *u, const char *buf) + { + if (!buf) return; + send_cmd(Config.s_NickServ, "MODE %s %s", u->nick, buf); + } + void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid) { send_cmd(Config.ServerName, "NICK %ld %s %s %s %s %s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick, host, host, user, modes, real); @@ -291,12 +242,6 @@ class InspIRCdProto : public IRCDProto send_cmd(Config.ServerName, "NOTICE @%s :%s", dest, buf); } - void SendBotOp(const char *nick, const char *chan) - { - SendMode(findbot(nick), chan, "%s %s %s", ircd->botchanumode, nick, nick); - } - - /* SERVER services-dev.chatspike.net password 0 :Description here */ void SendServer(Server *server) { @@ -388,8 +333,7 @@ class InspIRCdProto : public IRCDProto /* SVSMODE +- */ void SendUnregisteredNick(User *u) { - if (u->HasMode(UMODE_REGISTERED)) - common_svsmode(u, "-r", NULL); + u->RemoveMode(UMODE_REGISTERED); } void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) @@ -832,7 +776,7 @@ int anope_event_nick(const char *source, int ac, const char **av) */ user->CheckAuthenticationToken(av[0]); - ircdproto->ProcessUsermodes(user, 1, &av[5]); + UserSetInternalModes(user, 1, &av[5]); user->SetCloakedHost(av[3]); } } diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index da04bddb4..30d64f7fa 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -40,7 +40,6 @@ IRCDVar myIrcd[] = { "+ao", /* Channel Umode used by Botserv bots */ 1, /* SVSNICK */ 1, /* Vhost */ - "-r", /* Mode on UnReg */ 0, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -164,65 +163,6 @@ void inspircd_cmd_pass(const char *pass) class InspIRCdProto : public IRCDProto { - - void ProcessUsermodes(User *user, int ac, const char **av) - { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - --ac; - if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes); - while (*modes) { - if (add) - user->SetMode(*modes); - else - user->RemoveMode(*modes); - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'o': - if (add) { - ++opcnt; - if (Config.WallOper) ircdproto->SendGlobops(Config.s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - } - else --opcnt; - break; - case 'r': - /* The users server is syncing, do not - * set them -r yet - Adam - */ - if (user->server->sync == SSYNC_IN_PROGRESS) - break; - if (add && !nick_identified(user)) - SendUnregisteredNick(user); - break; - case 'x': - if (add && user->vhost) - { - /* If +x is recieved then User::vhost IS the cloaked host, - * set the cloaked host correctly and destroy the vhost - Adam - */ - user->SetCloakedHost(user->vhost); - delete [] user->vhost; - user->vhost = NULL; - } - else - { - if (user->vhost) - delete [] user->vhost; - user->vhost = NULL; - } - user->UpdateHost(); - } - } - } - - /* *INDENT-ON* */ - void SendAkillDel(const char *user, const char *host) { BotInfo *bi = findbot(Config.s_OperServ); @@ -266,8 +206,7 @@ class InspIRCdProto : public IRCDProto void SendSVSMode(User *u, int ac, const char **av) { - BotInfo *bi = findbot(Config.s_NickServ); - send_cmd(bi->uid, "MODE %s %s", u->GetUID().c_str(), merge_args(ac, av)); + this->SendModeInternal(u, merge_args(ac, av)); } void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf) @@ -286,6 +225,12 @@ class InspIRCdProto : public IRCDProto send_cmd(source ? source->uid : TS6SID, "FMODE %s %u %s", dest, static_cast<unsigned>(c ? c->creation_time : time(NULL)), buf); } + void SendModeInternal(User *u, const char *buf) + { + if (!buf) return; + send_cmd(findbot(Config.s_NickServ)->uid, "MODE %s %s", u->GetUID().c_str(), buf); + } + void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid) { send_cmd(TS6SID, "UID %s %ld %s %s %s %s 0.0.0.0 %ld %s :%s", uid, static_cast<long>(time(NULL)), nick, host, host, user, static_cast<long>(time(NULL)), modes, real); @@ -305,11 +250,6 @@ class InspIRCdProto : public IRCDProto send_cmd(TS6SID, "NOTICE @%s :%s", dest, buf); } - void SendBotOp(const char *nick, const char *chan) - { - SendMode(findbot(nick), chan, "%s %s %s", ircd->botchanumode, nick, nick); - } - /* SERVER services-dev.chatspike.net password 0 :Description here */ void SendServer(Server *server) { @@ -401,8 +341,7 @@ class InspIRCdProto : public IRCDProto /* SVSMODE -r */ void SendUnregisteredNick(User *u) { - if (u->HasMode(UMODE_REGISTERED)) - common_svsmode(u, "-r", NULL); + u->RemoveMode(UMODE_REGISTERED); } void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param) @@ -466,7 +405,7 @@ class InspIRCdProto : public IRCDProto if (!u->nc) return; - common_svsmode(u, "+r", NULL); + u->SetMode(UMODE_REGISTERED); } } ircd_proto; @@ -907,7 +846,7 @@ int anope_event_uid(const char *source, int ac, const char **av) { validate_user(user); if (user->HasMode(UMODE_REGISTERED)) - common_svsmode(user, "-r", NULL); + user->RemoveMode(UMODE_REGISTERED); } user = NULL; @@ -924,7 +863,7 @@ int anope_event_uid(const char *source, int ac, const char **av) { prev_u_intro = user; } - ircdproto->ProcessUsermodes(user, 1, &av[8]); + UserSetInternalModes(user, 1, &av[8]); user->SetCloakedHost(av[4]); } @@ -1193,7 +1132,7 @@ int anope_event_endburst(const char *source, int ac, const char **av) { validate_user(u); if (u->HasMode(UMODE_REGISTERED)) - common_svsmode(u, "-r", NULL); + u->RemoveMode(UMODE_REGISTERED); } alog("Processed ENDBURST for %s", s->name); diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index 73820de7e..249f8b685 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -21,7 +21,6 @@ IRCDVar myIrcd[] = { "+o", /* Channel Umode used by Botserv bots */ 0, /* SVSNICK */ 0, /* Vhost */ - NULL, /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 0, /* Supports SZlines */ @@ -166,35 +165,6 @@ void ratbox_cmd_pass(const char *pass) class RatboxProto : public IRCDTS6Proto { - void ProcessUsermodes(User *user, int ac, const char **av) - { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - --ac; - if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes); - while (*modes) { - if (add) - user->SetMode(*modes); - else - user->RemoveMode(*modes); - - switch (*modes++) { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'o': - if (add) { - ++opcnt; - if (Config.WallOper) ircdproto->SendGlobops(Config.s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - } - else --opcnt; - } - } - } - void SendGlobopsInternal(const char *source, const char *buf) { if (source) @@ -266,7 +236,7 @@ class RatboxProto : public IRCDTS6Proto void SendSVSMode(User *u, int ac, const char **av) { - send_cmd(TS6SID, "SVSMODE %s %s", u->nick, av[0]); + this->SendModeInternal(u, merge_args(ac, av)); } /* SERVER name hop descript */ @@ -315,6 +285,12 @@ class RatboxProto : public IRCDTS6Proto else send_cmd(TS6SID, "MODE %s %s", dest, buf); } + void SendModeInternal(User *u, const char *buf) + { + if (!buf) return; + send_cmd(TS6SID, "SVSMODE %s %s", u->nick, buf); + } + void SendKickInternal(BotInfo *bi, const char *chan, const char *user, const char *buf) { User *u = finduser(user); @@ -327,12 +303,6 @@ class RatboxProto : public IRCDTS6Proto send_cmd(NULL, "NOTICE @%s :%s", dest, buf); } - void SendBotOp(const char *nick, const char *chan) - { - BotInfo *bi = findbot(nick); - ratbox_cmd_tmode(nick, chan, "%s %s", ircd->botchanumode, bi ? bi->uid.c_str() : nick); - } - /* QUIT */ void SendQuitInternal(BotInfo *bi, const char *buf) { @@ -440,7 +410,7 @@ int anope_event_nick(const char *source, int ac, const char **av) */ user->CheckAuthenticationToken(av[2]); - ircdproto->ProcessUsermodes(user, 1, &av[3]); + UserSetInternalModes(user, 1, &av[3]); } } else { if (ac == 2) diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index bf619d27d..35eedfbb0 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -23,7 +23,6 @@ IRCDVar myIrcd[] = { "+ao", /* Channel Umode used by Botserv bots */ 1, /* SVSNICK */ 1, /* Vhost */ - "-r+d", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -169,85 +168,6 @@ void unreal_cmd_chgident(const char *nick, const char *vIdent) class UnrealIRCdProto : public IRCDProto { - void ProcessUsermodes(User *user, int ac, const char **av) - { - int add = 1; /* 1 if adding modes, 0 if deleting */ - const char *modes = av[0]; - --ac; - if (!user || !modes) return; /* Prevent NULLs from doing bad things */ - if (debug) alog("debug: Changing mode for %s to %s", user->nick, modes); - - while (*modes) { - if (add) - user->SetMode(*modes); - else - user->RemoveMode(*modes); - - switch (*modes++) - { - case '+': - add = 1; - break; - case '-': - add = 0; - break; - case 'd': - if (ac <= 0) - break; - if (isdigit(*av[1])) - { - /* +d was setting a service stamp, ignore the usermode +d */ - if (add) - user->RemoveMode('d'); - else - user->SetMode('d'); - } - break; - case 'o': - if (add) { - ++opcnt; - if (Config.WallOper) ircdproto->SendGlobops(Config.s_OperServ, "\2%s\2 is now an IRC operator.", user->nick); - } - else --opcnt; - break; - case 'r': - if (add && !nick_identified(user)) { - common_svsmode(user, "-r", NULL); - } - break; - case 't': - if (add && !user->vhost && !user->GetCloakedHost().empty()) - { - /* The user was introduced with a vhost as their host, so we don't - * know their cloaked host.. Set their vhost correctly and clear - * the chost so we can request it later (if needed) - */ - user->SetDisplayedHost(user->GetCloakedHost()); - user->chost.clear(); - } - break; - case 'x': - if (add) - { - /* We don't know their cloaked host.. get it */ - if (user->GetCloakedHost().empty()) - send_cmd(NULL, "USERHOST :%s", user->nick); - } - else - { - if (user->vhost) - delete [] user->vhost; - user->vhost = NULL; - } - user->UpdateHost(); - break; - default: - break; - } - } - } - - /* SVSNOOP */ void SendSVSNOOP(const char *server, int set) { @@ -266,8 +186,9 @@ class UnrealIRCdProto : public IRCDProto void SendVhostDel(User *u) { - common_svsmode(u, "-xt", NULL); - common_svsmode(u, "+x", NULL); + u->RemoveMode(UMODE_CLOAK); + u->RemoveMode(UMODE_VHOST); + u->SetMode(UMODE_CLOAK); } void SendAkill(const char *user, const char *host, const char *who, time_t when, time_t expires, const char *reason) @@ -301,7 +222,7 @@ class UnrealIRCdProto : public IRCDProto { if (ac >= 1) { if (!u || !av[0]) return; - send_cmd(Config.ServerName, "v %s %s", u->nick, merge_args(ac, av)); + this->SendModeInternal(u, merge_args(ac, av)); } } @@ -311,6 +232,12 @@ class UnrealIRCdProto : public IRCDProto send_cmd(source->nick, "G %s %s", dest, buf); } + void SendModeInternal(User *u, const char *buf) + { + if (!buf) return; + send_cmd(Config.ServerName, "v %s %s", u->nick, buf); + } + void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid) { EnforceQlinedNick(nick, Config.s_BotServ); @@ -331,11 +258,6 @@ class UnrealIRCdProto : public IRCDProto send_cmd(source->nick, "B @%s :%s", dest, buf); } - void SendBotOp(const char *nick, const char *chan) - { - SendMode(findbot(nick), chan, "%s %s %s", myIrcd->botchanumode, nick, nick); - } - /* SERVER name hop descript */ /* Unreal 3.2 actually sends some info about itself in the descript area */ void SendServer(Server *server) @@ -548,7 +470,14 @@ class UnrealIRCdProto : public IRCDProto u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); - common_svsmode(u, "+rd", svidbuf); + u->SetMode(UMODE_REGISTERED); + ircdproto->SendMode(u, "+d %s", svidbuf); + } + + void SendUnregisteredNick(User *u) + { + u->RemoveMode(UMODE_REGISTERED); + ircdproto->SendMode(u, "+d 1"); } } ircd_proto; @@ -665,6 +594,11 @@ int anope_event_mode(const char *source, int ac, const char **av) if (ac < 2) return MOD_CONT; + /* When a server sends a mode string it is appended with a timestamp + * we don't need it + */ + if (findserver(servlist, source)) + --ac; if (*av[0] == '#' || *av[0] == '&') { do_cmode(source, ac, av); } else { @@ -895,7 +829,7 @@ int anope_event_nick(const char *source, int ac, const char **av) */ user->CheckAuthenticationToken(av[6]); - ircdproto->ProcessUsermodes(user, 1, &av[7]); + UserSetInternalModes(user, 1, &av[7]); } } else { @@ -910,7 +844,7 @@ int anope_event_nick(const char *source, int ac, const char **av) */ user->CheckAuthenticationToken(av[6]); - ircdproto->ProcessUsermodes(user, 1, &av[7]); + UserSetInternalModes(user, 1, &av[7]); } } } else { @@ -1194,7 +1128,7 @@ void moduleAddModes() ModeManager::AddChannelMode('i', new ChannelMode(CMODE_INVITE)); ModeManager::AddChannelMode('j', new ChannelModeParam(CMODE_JOINFLOOD, true)); ModeManager::AddChannelMode('k', new ChannelModeKey()); - ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT)); + ModeManager::AddChannelMode('l', new ChannelModeParam(CMODE_LIMIT, true)); ModeManager::AddChannelMode('m', new ChannelMode(CMODE_MODERATED)); ModeManager::AddChannelMode('n', new ChannelMode(CMODE_NOEXTERNAL)); ModeManager::AddChannelMode('p', new ChannelMode(CMODE_PRIVATE)); |
