diff options
Diffstat (limited to 'src/protocol')
| -rw-r--r-- | src/protocol/bahamut.c | 46 | ||||
| -rw-r--r-- | src/protocol/inspircd11.c | 43 | ||||
| -rw-r--r-- | src/protocol/inspircd12.cpp | 50 | ||||
| -rw-r--r-- | src/protocol/ratbox.c | 41 | ||||
| -rw-r--r-- | src/protocol/unreal32.c | 54 |
5 files changed, 220 insertions, 14 deletions
diff --git a/src/protocol/bahamut.c b/src/protocol/bahamut.c index bc1a7b01f..7ebdae106 100644 --- a/src/protocol/bahamut.c +++ b/src/protocol/bahamut.c @@ -75,9 +75,7 @@ IRCDVar myIrcd[] = { NULL, /* Mode to unset for an owner */ NULL, /* Mode to set for channel admin */ NULL, /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - "-r+d", /* Mode on UnReg */ - "+d", /* Mode on Nick Change */ + "-r+d", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -709,6 +707,29 @@ class BahamutIRCdProto : public IRCDProto bahamut_cmd_svinfo(); bahamut_cmd_burst(); } + + void SetAutoIdentificationToken(User *u) + { + int *c; + char svidbuf[15]; + + if (!u->nc) + return; + + srand(time(NULL)); + snprintf(svidbuf, sizeof(svidbuf), "%i", rand()); + + if (u->nc->GetExt("authenticationtoken", c)) + { + delete [] c; + u->nc->Shrink("authenticationtoken"); + } + + u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + + common_svsmode(u, "+rd", svidbuf); + } + } ircd_proto; @@ -746,6 +767,11 @@ int anope_event_nick(const char *source, int ac, const char **av) strtoul(av[2], NULL, 10), strtoul(av[8], NULL, 0), NULL, NULL); if (user) { + /* Check to see if the user should be identified because their + * services id matches the one in their nickcore + */ + user->CheckAuthenticationToken(av[7]); + ircdproto->ProcessUsermodes(user, 1, &av[3]); } } else { @@ -1046,7 +1072,21 @@ class ProtoBahamut : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); + + ModuleManager::Attach(I_OnDelCore, this); } + + void OnDelCore(NickCore *nc) + { + char *c; + + if (nc->GetExt("authenticationtoken", c)) + { + delete [] c; + nc->Shrink("authenticationtoken"); + } + } + }; MODULE_INIT("bahamut", ProtoBahamut) diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 0aa2321b4..b4f811e36 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -84,9 +84,7 @@ IRCDVar myIrcd[] = { "-q", /* Mode to unset for an owner */ "+a", /* Mode to set for channel admin */ "-a", /* Mode to unset for channel admin */ - "+r", /* Mode On Reg */ - "-r", /* Mode on UnReg */ - "-r", /* Mode on Nick Change */ + "-r", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -678,6 +676,26 @@ class InspIRCdProto : public IRCDProto if (value && *value != ':' && strtoul((*value == '*' ? value + 1 : value), &dp, 10) > 0 && *dp == ':' && *(++dp) && strtoul(dp, &end, 10) > 0 && !*end) return 1; else return 0; } + + void SetAutoIdentificationToken(User *u) + { + int *c; + char svidbuf[15]; + + if (!u->nc) + return; + + snprintf(svidbuf, sizeof(svidbuf), "%ld", u->timestamp); + + if (u->nc->GetExt("authenticationtoken", c)) + { + delete [] c; + u->nc->Shrink("authenticationtoken"); + } + + u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + } + } ircd_proto; @@ -1080,6 +1098,11 @@ int anope_event_nick(const char *source, int ac, const char **av) av[7], /* realname */ ts, htonl(*ad), av[3], NULL); if (user) { + /* InspIRCd1.1 has no user mode +d so we + * use nick timestamp to check for auth - Adam + */ + user->CheckAuthenticationToken(av[0]); + ircdproto->ProcessUsermodes(user, 1, &av[5]); user->chost = av[3]; } @@ -1348,7 +1371,21 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); + + ModuleManager::Attach(I_OnDelCore, this); } + + void OnDelCore(NickCore *nc) + { + char *c; + + if (nc->GetExt("authenticationtoken", c)) + { + delete [] c; + nc->Shrink("authenticationtoken"); + } + } + }; MODULE_INIT("inspircd11", ProtoInspIRCd) diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 7f1262df1..6be11646a 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -84,9 +84,7 @@ IRCDVar myIrcd[] = { "-q", /* Mode to unset for an owner */ "+a", /* Mode to set for channel admin */ "-a", /* Mode to unset for channel admin */ - "+r", /* Mode On Reg */ "-r", /* Mode on UnReg */ - "-r", /* Mode on Nick Change */ 0, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -709,7 +707,19 @@ class InspIRCdProto : public IRCDProto void SendAccountLogin(User *u, NickCore *account) { + char *c; + send_cmd(TS6SID, "METADATA %s accountname :%s", u->GetUID().c_str(), account->display); + + if (account->GetExt("authenticationtoken", c)) + { + delete [] c; + account->Shrink("authenticationtoken"); + } + + account->Extend("authenticationtoken", sstrdup(account->display)); + + common_svsmode(u, "+rd", account->display); } void SendAccountLogout(User *u, NickCore *account) @@ -724,6 +734,7 @@ class InspIRCdProto : public IRCDProto return 0; return 1; } + } ircd_proto; @@ -1210,6 +1221,27 @@ int anope_event_whois(const char *source, int ac, const char **av) return MOD_CONT; } +int anope_event_metadata(const char *source, int ac, const char **av) +{ + User *u; + + if (ac < 3) + return MOD_CONT; + else if (!strcmp(av[1], "accountname")) + { + if ((u = find_byuid(av[0]))) + { + /* Check to see if the account name is the same + * as the one saved for this nick, if so identify + * them - Adam + */ + u->CheckAuthenticationToken(av[2]); + } + } + + return MOD_CONT; +} + int anope_event_capab(const char *source, int ac, const char **av) { int argc; @@ -1378,6 +1410,7 @@ void moduleAddIRCDMsgs() { m = createMessage("FTOPIC", anope_event_ftopic); addCoreMessage(IRCD,m); m = createMessage("OPERTYPE", anope_event_opertype); addCoreMessage(IRCD,m); m = createMessage("IDLE", anope_event_idle); addCoreMessage(IRCD,m); + m = createMessage("METADATA", anope_event_metadata); addCoreMessage(IRCD,m); } class ProtoInspIRCd : public Module @@ -1415,12 +1448,25 @@ class ProtoInspIRCd : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); + + ModuleManager::Attach(I_OnDelCore, this); } ~ProtoInspIRCd() { delete [] TS6SID; } + + void OnDelCore(NickCore *nc) + { + char *c; + + if (nc->GetExt("authenticationtoken", c)) + { + delete [] c; + nc->Shrink("authenticationtoken"); + } + } }; MODULE_INIT("inspircd12", ProtoInspIRCd) diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c index ba560d115..c989dc004 100644 --- a/src/protocol/ratbox.c +++ b/src/protocol/ratbox.c @@ -60,9 +60,7 @@ IRCDVar myIrcd[] = { NULL, /* Mode to unset for an owner */ NULL, /* Mode to set for chan admin */ NULL, /* Mode to unset for chan admin */ - NULL, /* Mode On Reg */ - NULL, /* Mode on UnReg */ - NULL, /* Mode on Nick Change */ + NULL, /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 0, /* Supports SZlines */ @@ -684,6 +682,25 @@ class RatboxProto : public IRCDTS6Proto { send_cmd(bi->uid, "TOPIC %s :%s", chan, topic); } + + void SetAutoIdentificationToken(User *u) + { + char svidbuf[15], *c; + + if (!u->nc) + return; + + snprintf(svidbuf, sizeof(svidbuf), "%ld", u->timestamp); + + if (u->nc->GetExt("authenticationtoken", c)) + { + delete [] c; + u->nc->Shrink("authenticationtoken"); + } + + u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + } + } ircd_proto; @@ -732,6 +749,11 @@ int anope_event_nick(const char *source, int ac, const char **av) strtoul(av[2], NULL, 10), 0, "*", av[7]); if (user) { + /* No usermode +d on ratbox so we use + * nick timestamp to check for auth - Adam + */ + user->CheckAuthenticationToken(av[2]); + ircdproto->ProcessUsermodes(user, 1, &av[3]); } } else { @@ -1174,6 +1196,8 @@ class ProtoRatbox : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); + + ModuleManager::Attach(I_OnDelCore, this); } ~ProtoRatbox() @@ -1181,6 +1205,17 @@ class ProtoRatbox : public Module delete [] TS6SID; } + void OnDelCore(NickCore *nc) + { + char *c; + + if (nc->GetExt("authenticationtoken", c)) + { + delete [] c; + nc->Shrink("authenticationtoken"); + } + } + }; MODULE_INIT("ratbox", ProtoRatbox) diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index 773717495..b47b22368 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -97,9 +97,7 @@ IRCDVar myIrcd[] = { "-q", /* Mode to unset for an owner */ "+a", /* Mode to set for channel admin */ "-a", /* Mode to unset for channel admin */ - "+rd", /* Mode On Reg */ - "-r+d", /* Mode on UnReg */ - "-r+d", /* Mode on Nick Change */ + "-r+d", /* Mode on UnReg */ 1, /* Supports SGlines */ 1, /* Supports SQlines */ 1, /* Supports SZlines */ @@ -903,6 +901,28 @@ class UnrealIRCdProto : public IRCDProto return 1; } + void SetAutoIdentificationToken(User *u) + { + int *c; + char svidbuf[15]; + + if (!u->nc) + return; + + srand(time(NULL)); + snprintf(svidbuf, sizeof(svidbuf), "%i", rand()); + + if (u->nc->GetExt("authenticationtoken", c)) + { + delete [] c; + u->nc->Shrink("authenticationtoken"); + } + + u->nc->Extend("authenticationtoken", sstrdup(svidbuf)); + + common_svsmode(u, "+rd", svidbuf); + } + } ircd_proto; @@ -1223,7 +1243,14 @@ int anope_event_nick(const char *source, int ac, const char **av) user = do_nick(source, av[0], av[3], av[4], av[5], av[10], strtoul(av[2], NULL, 10), ntohl(decode_ip(av[9])), av[8], NULL); if (user) + { + /* Check to see if the user should be identified because their + * services id matches the one in their nickcore + */ + user->CheckAuthenticationToken(av[6]); + ircdproto->ProcessUsermodes(user, 1, &av[7]); + } } else { /* NON NICKIP */ @@ -1231,7 +1258,14 @@ int anope_event_nick(const char *source, int ac, const char **av) strtoul(av[2], NULL, 10), 0, av[8], NULL); if (user) + { + /* Check to see if the user should be identified because their + * services id matches the one in their nickcore + */ + user->CheckAuthenticationToken(av[6]); + ircdproto->ProcessUsermodes(user, 1, &av[7]); + } } } else { do_nick(source, av[0], NULL, NULL, NULL, NULL, @@ -1446,7 +1480,21 @@ class ProtoUnreal : public Module pmodule_ircd_proto(&ircd_proto); moduleAddIRCDMsgs(); + + ModuleManager::Attach(I_OnDelCore, this); + } + + void OnDelCore(NickCore *nc) + { + char *c; + + if (nc->GetExt("authenticationtoken", c)) + { + delete [] c; + nc->Shrink("authenticationtoken"); + } } + }; MODULE_INIT("unreal32", ProtoUnreal) |
