diff options
-rw-r--r-- | include/extern.h | 7 | ||||
-rw-r--r-- | include/services.h | 40 | ||||
-rw-r--r-- | src/channels.c | 27 | ||||
-rw-r--r-- | src/core/os_stats.c | 31 | ||||
-rw-r--r-- | src/ircd.c | 6 | ||||
-rw-r--r-- | src/main.c | 3 | ||||
-rw-r--r-- | src/protocol/bahamut.c | 47 | ||||
-rw-r--r-- | src/protocol/inspircd11.c | 42 | ||||
-rw-r--r-- | src/protocol/inspircd12.cpp | 44 | ||||
-rw-r--r-- | src/protocol/ratbox.c | 41 | ||||
-rw-r--r-- | src/protocol/unreal32.c | 45 | ||||
-rw-r--r-- | src/servers.c | 85 |
12 files changed, 113 insertions, 305 deletions
diff --git a/include/extern.h b/include/extern.h index a3d7a1734..e9609dcfb 100644 --- a/include/extern.h +++ b/include/extern.h @@ -29,7 +29,6 @@ E char *uplink; /* IRC Variables */ E IRCDVar *ircd; -E IRCDCAPAB *ircdcap; E int UseTSMODE; /* hack to get around bahamut clones that don't send TSMODE */ E IRCDProto *ircdproto; @@ -187,7 +186,6 @@ E Uplink *uplink_server; /**** ircd.c ****/ E void pmodule_ircd_proto(IRCDProto *); E void pmodule_ircd_var(IRCDVar * ircdvar); -E void pmodule_ircd_cap(IRCDCAPAB * cap); E void pmodule_ircd_version(const char *version); E void pmodule_ircd_useTSMode(int use); @@ -473,12 +471,13 @@ E void notice_help(const char *source, User *dest, int message, ...); // MARK_DE E Server *servlist; E Server *me_server; E Server *serv_uplink; -E uint32 uplink_capab; -E CapabInfo capab_info[]; +E Flags<CapabType> Capab; +E CapabInfo Capab_Info[]; E Server *first_server(ServerFlag flag); E Server *next_server(ServerFlag flag); +E void CapabParse(int ac, const char **av); E int is_ulined(const char *server); E int is_sync(Server *server); diff --git a/include/services.h b/include/services.h index 964542ab7..7bfb0134c 100644 --- a/include/services.h +++ b/include/services.h @@ -376,7 +376,6 @@ typedef struct session_ Session; /* Protocol tweaks */ typedef struct ircdvars_ IRCDVar; -typedef struct ircdcapab_ IRCDCAPAB; struct ircdvars_ { const char *name; /* Name of the IRCd command */ @@ -407,14 +406,12 @@ struct ircdvars_ { int chgreal; /* Change RealName */ int check_nick_id; /* On nick change check if they could be identified */ int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */ - char *chanmodes; /* If the ircd sends CHANMODE in CAPAB this is where we store it */ int token; /* Does Anope support the tokens for the ircd */ int sjb64; int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */ int sglineenforce; int ts6; /* ircd is TS6 */ int p10; /* ircd is P10 */ - char *nickchars; /* character set */ int cidrchanbei; /* channel bans/excepts/invites support CIDR (syntax: +b *!*@192.168.0.0/15) * 0 for no support, 1 for strict cidr support, anything else * for ircd specific support (nefarious only cares about first /mask) */ @@ -423,39 +420,6 @@ struct ircdvars_ { int maxmodes; /* Max modes to send per line */ }; -struct ircdcapab_ { - uint32 noquit; - uint32 tsmode; - uint32 unconnect; - uint32 nickip; - uint32 nsjoin; - uint32 zip; - uint32 burst; - uint32 ts5; - uint32 ts3; - uint32 dkey; - uint32 pt4; - uint32 scs; - uint32 qs; - uint32 uid; - uint32 knock; - uint32 client; - uint32 ipv6; - uint32 ssj5; - uint32 sn2; - uint32 token; - uint32 vhost; - uint32 ssj3; - uint32 nick2; - uint32 vl; - uint32 tlkext; - uint32 dodkey; - uint32 dozip; - uint32 chanmodes; - uint32 sjb64; - uint32 nickchars; -}; - /*************************************************************************/ /* File version for each database. Was one version for all before but was @@ -1018,8 +982,8 @@ enum CapabType /* CAPAB stuffs */ struct CapabInfo { - const char *token; - CapabType flag; + std::string Token; + CapabType Flag; }; /*************************************************************************/ diff --git a/src/channels.c b/src/channels.c index 69843d1da..594388c2f 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1323,24 +1323,21 @@ void do_cmode(const char *source, int ac, const char **av) unsigned int i; const char *t; - if (ircdcap->tsmode) + if (Capab.HasFlag(CAPAB_TSMODE) || UseTSMODE) { - if (uplink_capab & ircdcap->tsmode || UseTSMODE) + for (i = 0; i < strlen(av[1]); i++) + if (!isdigit(av[1][i])) + break; + if (av[1][i] == '\0') { - for (i = 0; i < strlen(av[1]); i++) - if (!isdigit(av[1][i])) - break; - if (av[1][i] == '\0') - { - t = av[0]; - av[0] = av[1]; - av[1] = t; - ac--; - av++; - } - else - Alog() << "TSMODE enabled but MODE has no valid TS"; + t = av[0]; + av[0] = av[1]; + av[1] = t; + ac--; + av++; } + else + Alog() << "TSMODE enabled but MODE has no valid TS"; } /* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */ diff --git a/src/core/os_stats.c b/src/core/os_stats.c index ade762e0c..4ff9617ae 100644 --- a/src/core/os_stats.c +++ b/src/core/os_stats.c @@ -202,32 +202,21 @@ class CommandOSStats : public Command CommandReturn DoStatsUplink(User *u) { - char buf[512] = ""; - int i; - for (i = 0; capab_info[i].token; ++i) + std::string buf; + + for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j) { - if (uplink_capab & capab_info[i].flag) + if (Capab.HasFlag(Capab_Info[j].Flag)) { - strlcat(buf, " ", sizeof(buf)); - strlcat(buf, capab_info[i].token, sizeof(buf)); - /* Special cases */ - if (capab_info[i].flag == CAPAB_CHANMODE) - { - strlcat(buf, "=", sizeof(buf)); - strlcat(buf, ircd->chanmodes, sizeof(buf)); - } - if (capab_info[i].flag == CAPAB_NICKCHARS) - { - strlcat(buf, "=", sizeof(buf)); - if (ircd->nickchars) - { - strlcat(buf, ircd->nickchars, sizeof(buf)); - } /* leave blank if it was null */ - } + buf += " " + Capab_Info[j].Token; } } + + if (!buf.empty()) + buf.erase(buf.begin()); + notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER, serv_uplink->name); - notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf); + notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_CAPAB, buf.c_str()); notice_lang(Config.s_OperServ, u, OPER_STATS_UPLINK_SERVER_COUNT, stats_count_servers(serv_uplink)); return MOD_CONT; } diff --git a/src/ircd.c b/src/ircd.c index 983e5ccb9..e1c15fc8f 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -21,7 +21,6 @@ IRCDProto *ircdproto; * Globals we want from the protocol file **/ IRCDVar *ircd; -IRCDCAPAB *ircdcap; char *version_protocol; int UseTSMODE; @@ -50,11 +49,6 @@ void pmodule_ircd_var(IRCDVar * ircdvar) ircd = ircdvar; } -void pmodule_ircd_cap(IRCDCAPAB * cap) -{ - ircdcap = cap; -} - void pmodule_ircd_version(const char *version) { version_protocol = sstrdup(version); diff --git a/src/main.c b/src/main.c index cb649a939..5ef579e5a 100644 --- a/src/main.c +++ b/src/main.c @@ -190,9 +190,6 @@ static void services_shutdown() ircdproto->SendSquit(Config.ServerName, quitmsg); if (uplink) delete [] uplink; - if (ircd->chanmodes) { - delete [] ircd->chanmodes; - } u = firstuser(); while (u) { next = nextuser(); diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index 1115e05e7..14407eb6b 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -45,14 +45,12 @@ IRCDVar myIrcd[] = { 0, /* Change RealName */ 1, 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ 0, /* We support TOKENS */ 0, /* TIME STAMPS are BASE64 */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ 0, /* ts6 */ 0, /* p10 */ - NULL, /* character set */ 0, /* CIDR channelbans */ "$", /* TLD Prefix for Global */ false, /* Auth for users is sent after the initial NICK/UID command */ @@ -62,39 +60,6 @@ IRCDVar myIrcd[] = { {NULL} }; -IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - CAPAB_TSMODE, /* TSMODE */ - CAPAB_UNCONNECT, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - CAPAB_BURST, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - CAPAB_DKEY, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - CAPAB_DOZIP, /* DOZIP */ - 0, 0, 0} -}; - - void bahamut_cmd_burst() { send_cmd(NULL, "BURST"); @@ -140,8 +105,10 @@ class BahamutIRCdProto : public IRCDProto void SendModeInternal(BotInfo *source, Channel *dest, const char *buf) { if (!buf) return; - if (ircdcap->tsmode && (uplink_capab & ircdcap->tsmode)) send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf); - else send_cmd(source->nick, "MODE %s %s", dest->name.c_str(), buf); + if (Capab.HasFlag(CAPAB_TSMODE)) + send_cmd(source->nick, "MODE %s 0 %s", dest->name.c_str(), buf); + else + send_cmd(source->nick, "MODE %s %s", dest->name.c_str(), buf); } void SendModeInternal(BotInfo *bi, User *u, const char *buf) @@ -550,6 +517,7 @@ int anope_event_nick(const char *source, int ac, const char **av) /* EVENT : CAPAB */ int anope_event_capab(const char *source, int ac, const char **av) { + CapabParse(ac, av); return MOD_CONT; } @@ -851,10 +819,13 @@ class ProtoBahamut : public Module this->SetType(PROTOCOL); pmodule_ircd_version("BahamutIRCd 1.4.*/1.8.*"); - pmodule_ircd_cap(myIrcdcap); pmodule_ircd_var(myIrcd); pmodule_ircd_useTSMode(0); + CapabType c[] = { CAPAB_NOQUIT, CAPAB_TSMODE, CAPAB_UNCONNECT, CAPAB_BURST, CAPAB_DKEY, CAPAB_DOZIP }; + for (unsigned i = 0; i < 6; ++i) + Capab.SetFlag(c[i]); + moduleAddIRCDMsgs(); moduleAddModes(); diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 35f3b6edb..95f93e652 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -62,14 +62,12 @@ IRCDVar myIrcd[] = { 0, /* Change RealName */ 0, 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ 0, /* We support inspircd TOKENS */ 0, /* TIME STAMPS are BASE64 */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ 0, /* ts6 */ 0, /* p10 */ - NULL, /* character set */ 1, /* CIDR channelbans */ "$", /* TLD Prefix for Global */ false, /* Auth for users is sent after the initial NICK/UID command */ @@ -80,39 +78,6 @@ IRCDVar myIrcd[] = { }; -IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 1, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, - 0, 0} -}; - static int has_servicesmod = 0; static int has_globopsmod = 0; static int has_svsholdmod = 0; @@ -1116,6 +1081,8 @@ int anope_event_capab(const char *source, int ac, const char **av) } ircd->svshold = has_svsholdmod; } + + CapabParse(ac, av); return MOD_CONT; } @@ -1193,10 +1160,13 @@ class ProtoInspIRCd : public Module this->SetType(PROTOCOL); pmodule_ircd_version("inspircdIRCd 1.1"); - pmodule_ircd_cap(myIrcdcap); pmodule_ircd_var(myIrcd); pmodule_ircd_useTSMode(0); + CapabType c[] = { CAPAB_NOQUIT, CAPAB_SSJ3, CAPAB_NICK2, CAPAB_VL, CAPAB_TLKEXT }; + for (unsigned i = 0; i < 5; ++i) + Capab.SetFlag(c[i]); + AddModes(); pmodule_ircd_proto(&ircd_proto); diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 27acf77a2..698cc86ea 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -62,14 +62,12 @@ IRCDVar myIrcd[] = { 0, /* Change RealName */ 0, 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ 0, /* We support inspircd TOKENS */ 0, /* TIME STAMPS are BASE64 */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ 1, /* ts6 */ 0, /* p10 */ - NULL, /* character set */ 1, /* CIDR channelbans */ "$", /* TLD Prefix for Global */ true, /* Auth for users is sent after the initial NICK/UID command */ @@ -79,40 +77,6 @@ IRCDVar myIrcd[] = { {NULL} }; - -IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 1, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - 0, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, - 0, 0} -}; - static int has_servicesmod = 0; static int has_globopsmod = 0; static int has_svsholdmod = 0; @@ -1303,6 +1267,9 @@ int anope_event_capab(const char *source, int ac, const char **av) } ircd->svshold = has_svsholdmod; } + + CapabParse(ac, av); + return MOD_CONT; } @@ -1392,10 +1359,13 @@ class ProtoInspIRCd : public Module TS6SID = sstrdup(Config.Numeric); pmodule_ircd_version("InspIRCd 1.2"); - pmodule_ircd_cap(myIrcdcap); pmodule_ircd_var(myIrcd); pmodule_ircd_useTSMode(0); + CapabType c[] = { CAPAB_NOQUIT, CAPAB_SSJ3, CAPAB_NICK2, CAPAB_VL, CAPAB_TLKEXT }; + for (unsigned i = 0; i < 5; ++i) + Capab.SetFlag(c[i]); + pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); } diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index b3fa7eaf0..3fd7315fe 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -43,14 +43,12 @@ IRCDVar myIrcd[] = { 0, /* Change RealName */ 0, /* On nick change check if they could be identified */ 0, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ 0, /* We support TOKENS */ 0, /* TIME STAMPS are BASE64 */ 0, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ 1, /* ts6 */ 0, /* p10 */ - NULL, /* character set */ 0, /* CIDR channelbans */ "$$", /* TLD Prefix for Global */ false, /* Auth for users is sent after the initial NICK/UID command */ @@ -60,39 +58,6 @@ IRCDVar myIrcd[] = { {NULL} }; -IRCDCAPAB myIrcdcap[] = { - { - 0, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - 0, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - CAPAB_TS5, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - CAPAB_QS, /* QS */ - CAPAB_UID, /* UID */ - CAPAB_KNOCK, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - 0, /* TOKEN */ - 0, /* VHOST */ - 0, /* SSJ3 */ - 0, /* NICK2 */ - 0, /* VL */ - 0, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - 0, 0, 0} -}; - - /* * SVINFO * parv[0] = sender prefix @@ -795,6 +760,7 @@ int anope_event_tmode(const char *source, int ac, const char **av) /* Event: PROTOCTL */ int anope_event_capab(const char *source, int ac, const char **av) { + CapabParse(ac, av); return MOD_CONT; } @@ -923,10 +889,13 @@ class ProtoRatbox : public Module UseTSMODE = 1; /* TMODE */ pmodule_ircd_version("Ratbox IRCD 2.0+"); - pmodule_ircd_cap(myIrcdcap); pmodule_ircd_var(myIrcd); pmodule_ircd_useTSMode(1); + CapabType c[] = { CAPAB_ZIP, CAPAB_TS5, CAPAB_QS, CAPAB_UID, CAPAB_KNOCK }; + for (unsigned i = 0; i < 5; ++i) + Capab.SetFlag(c[i]); + moduleAddModes(); pmodule_ircd_proto(&ircd_proto); diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 8ef6ca187..4016a5f18 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -45,14 +45,12 @@ IRCDVar myIrcd[] = { 1, /* Change RealName */ 0, /* On nick change check if they could be identified */ 1, /* No Knock requires +i */ - NULL, /* CAPAB Chan Modes */ 1, /* We support Unreal TOKENS */ 1, /* TIME STAMPS are BASE64 */ 1, /* Can remove User Channel Modes with SVSMODE */ 0, /* Sglines are not enforced until user reconnects */ 0, /* ts6 */ 0, /* p10 */ - NULL, /* character set */ 0, /* CIDR channelbans */ "$", /* TLD Prefix for Global */ false, /* Auth for users is sent after the initial NICK/UID command */ @@ -62,41 +60,6 @@ IRCDVar myIrcd[] = { {NULL} }; -IRCDCAPAB myIrcdcap[] = { - { - CAPAB_NOQUIT, /* NOQUIT */ - 0, /* TSMODE */ - 0, /* UNCONNECT */ - CAPAB_NICKIP, /* NICKIP */ - 0, /* SJOIN */ - CAPAB_ZIP, /* ZIP */ - 0, /* BURST */ - 0, /* TS5 */ - 0, /* TS3 */ - 0, /* DKEY */ - 0, /* PT4 */ - 0, /* SCS */ - 0, /* QS */ - 0, /* UID */ - 0, /* KNOCK */ - 0, /* CLIENT */ - 0, /* IPV6 */ - 0, /* SSJ5 */ - 0, /* SN2 */ - CAPAB_TOKEN, /* TOKEN */ - 0, /* VHOST */ - CAPAB_SSJ3, /* SSJ3 */ - CAPAB_NICK2, /* NICK2 */ - CAPAB_VL, /* VL */ - CAPAB_TLKEXT, /* TLKEXT */ - 0, /* DODKEY */ - 0, /* DOZIP */ - CAPAB_CHANMODE, /* CHANMODE */ - CAPAB_SJB64, - CAPAB_NICKCHARS, - } -}; - /* svswatch * parv[0] - sender * parv[1] - target nick @@ -611,6 +574,9 @@ int anope_event_capab(const char *source, int ac, const char **av) } } } + + CapabParse(ac, av); + return MOD_CONT; } @@ -1398,10 +1364,13 @@ class ProtoUnreal : public Module this->SetType(PROTOCOL); pmodule_ircd_version("UnrealIRCd 3.2+"); - pmodule_ircd_cap(myIrcdcap); pmodule_ircd_var(myIrcd); pmodule_ircd_useTSMode(0); + CapabType c[] = { CAPAB_NOQUIT, CAPAB_NICKIP, CAPAB_ZIP, CAPAB_TOKEN, CAPAB_SSJ3, CAPAB_NICK2, CAPAB_VL, CAPAB_TLKEXT, CAPAB_CHANMODE, CAPAB_SJB64, CAPAB_NICKCHARS }; + for (unsigned i = 0; i < 11; ++i) + Capab.SetFlag(c[i]); + AddModes(); pmodule_ircd_proto(&ircd_proto); diff --git a/src/servers.c b/src/servers.c index 474f4f3e1..959e2be2d 100644 --- a/src/servers.c +++ b/src/servers.c @@ -18,7 +18,7 @@ Server *servlist = NULL; Server *me_server = NULL; /* This are we */ Server *serv_uplink = NULL; /* This is our uplink */ -uint32 uplink_capab; +Flags<CapabType> Capab; char *uplink; char *TS6UPLINK; char *TS6SID; @@ -26,7 +26,7 @@ char *TS6SID; /* For first_server / next_server */ static Server *server_cur; -CapabInfo capab_info[] = { +CapabInfo Capab_Info[] = { {"NOQUIT", CAPAB_NOQUIT}, {"TSMODE", CAPAB_TSMODE}, {"UNCONNECT", CAPAB_UNCONNECT}, @@ -53,7 +53,7 @@ CapabInfo capab_info[] = { {"SJB64", CAPAB_SJB64}, {"CHANMODES", CAPAB_CHANMODE}, {"NICKCHARS", CAPAB_NICKCHARS}, - {NULL, CAPAB_END} + {"", CAPAB_END} }; /*************************************************************************/ @@ -204,33 +204,30 @@ static void delete_server(Server * serv, const char *quitreason) << (serv->uplink ? serv->uplink->name : "NOTHING") << "(" << (serv->uplink ? serv->uplink->suid : "NOSUIDUPLINK") << ")"; - if (ircdcap->noquit || ircdcap->qs) { - if ((uplink_capab & ircdcap->noquit) - || (uplink_capab & ircdcap->qs)) { - u = firstuser(); - while (u) { - unext = nextuser(); - if (u->server == serv) - { - if ((na = findnick(u->nick)) && !na->HasFlag(NS_FORBIDDEN) - && (!na->nc->HasFlag(NI_SUSPENDED)) - && (u->IsRecognized() || u->IsIdentified())) { - na->last_seen = time(NULL); - if (na->last_quit) - delete [] na->last_quit; - na->last_quit = - (quitreason ? sstrdup(quitreason) : NULL); - } - + if (Capab.HasFlag(CAPAB_NOQUIT) || Capab.HasFlag(CAPAB_QS)) + { + u = firstuser(); + while (u) + { + unext = nextuser(); + if (u->server == serv) + { + if ((na = findnick(u->nick)) && !na->HasFlag(NS_FORBIDDEN) + && (!na->nc->HasFlag(NI_SUSPENDED)) + && (u->IsRecognized() || u->IsIdentified())) { + na->last_seen = time(NULL); + if (na->last_quit) + delete [] na->last_quit; + na->last_quit = (quitreason ? sstrdup(quitreason) : NULL); + } if (Config.LimitSessions && !is_ulined(u->server->name)) { - del_session(u->host); - } - delete u; + del_session(u->host); } - u = unext; + delete u; } - Alog(LOG_DEBUG) << "delete_server() cleared all users"; + u = unext; } + Alog(LOG_DEBUG) << "delete_server() cleared all users"; } s = serv->links; @@ -445,13 +442,11 @@ void do_squit(const char *source, int ac, const char **av) snprintf(buf, sizeof(buf), "%s %s", s->name, (s->uplink ? s->uplink->name : "")); - if (ircdcap->unconnect) { - if ((s->uplink == me_server) - && (uplink_capab & ircdcap->unconnect)) { - Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->name; - /* need to fix */ - ircdproto->SendSquit(s->name, buf); - } + if (s->uplink == me_server && Capab.HasFlag(CAPAB_UNCONNECT)) + { + Alog(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->name; + /* need to fix */ + ircdproto->SendSquit(s->name, buf); } delete_server(s, buf); @@ -459,6 +454,30 @@ void do_squit(const char *source, int ac, const char **av) /*************************************************************************/ +/** Handle parsing the CAPAB/PROTOCTL messages + * @param ac Number of args + * @param av Args + */ +void CapabParse(int ac, const char **av) +{ + for (int i = 0; i < ac; ++i) + { + for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j) + { + if (av[i] == Capab_Info[j].Token) + { + Capab.SetFlag(Capab_Info[j].Flag); + + if (Capab_Info[j].Token == "NICKIP" && !ircd->nickip) + ircd->nickip = 1; + break; + } + } + } +} + +/*************************************************************************/ + /** * Search the uline servers array to find out if the server that just set the * mode is in our uline list |