diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-09-12 03:32:47 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-09-12 03:32:47 +0000 |
commit | 7ea66a37d56ef46726bcca6c8a6f2685cbbceafb (patch) | |
tree | 257f249009bf07167645d679049bbca2d55cabf4 | |
parent | 46030bbc7e4ca72fd35dd1d5fa272c3c91d8324a (diff) |
Fixes bugs #1105 and #1106
Now properly track users host changes and keep users cloaked hosts saved in memory
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2498 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/users.h | 9 | ||||
-rw-r--r-- | lang/cat.l | 2 | ||||
-rw-r--r-- | lang/de.l | 2 | ||||
-rw-r--r-- | lang/en_us.l | 2 | ||||
-rw-r--r-- | lang/es.l | 2 | ||||
-rw-r--r-- | lang/fr.l | 2 | ||||
-rw-r--r-- | lang/gr.l | 2 | ||||
-rw-r--r-- | lang/hun.l | 3 | ||||
-rw-r--r-- | lang/it.l | 2 | ||||
-rw-r--r-- | lang/nl.l | 2 | ||||
-rw-r--r-- | lang/pl.l | 2 | ||||
-rw-r--r-- | lang/pt.l | 2 | ||||
-rw-r--r-- | lang/ru.l | 2 | ||||
-rw-r--r-- | lang/tr.l | 2 | ||||
-rw-r--r-- | src/actions.c | 2 | ||||
-rw-r--r-- | src/core/hs_off.c | 3 | ||||
-rw-r--r-- | src/nickserv.c | 14 | ||||
-rw-r--r-- | src/protocol/inspircd11.c | 21 | ||||
-rw-r--r-- | src/protocol/inspircd12.cpp | 21 | ||||
-rw-r--r-- | src/protocol/unreal32.c | 75 | ||||
-rw-r--r-- | src/users.c | 45 |
21 files changed, 164 insertions, 53 deletions
diff --git a/include/users.h b/include/users.h index 360dfeec5..585c15529 100644 --- a/include/users.h +++ b/include/users.h @@ -87,6 +87,15 @@ public: // XXX: exposing a tiny bit too much */ const std::string GetDisplayedHost() const; + /** Update the cloaked host of a user + * @param host The cloaked host + */ + void SetCloakedHost(const std::string &newhost); + + /** Get the cloaked host of a user + * @return The cloaked host + */ + const std::string &GetCloakedHost() const; /** Retrieves the UID of the user, where applicable, if set. * This is not used on some IRCds, but is for a lot e.g. P10, TS6 protocols. diff --git a/lang/cat.l b/lang/cat.l index 03f606ed8..dd446f223 100644 --- a/lang/cat.l +++ b/lang/cat.l @@ -6456,8 +6456,6 @@ HOST_DEL_SYNTAX ########################################################################### HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Your vhost was removed. To re-enable the standard host cloaking, type /mode %s +%s HOST_NO_VIDENT Your IRCD does not support vIdent's, if this is incorrect, please report this as a possible bug @@ -6483,8 +6483,6 @@ HOST_DEL_SYNTAX DEL Nickname. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Dein vHost wurde gelöscht. Um die normale Host-Verschlüsselung zu reaktivieren, tippe /mode %s +%s HOST_NO_VIDENT Dein IRCd unterstützt keine vIdents. Falls das inkorrekt sein sollte, melde das bitte als einen Bug. HOST_GROUP diff --git a/lang/en_us.l b/lang/en_us.l index b2d3201a0..678f57e9b 100644 --- a/lang/en_us.l +++ b/lang/en_us.l @@ -6146,8 +6146,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Your vhost was removed. To re-enable the standard host cloaking, type /mode %s +%s HOST_NO_VIDENT Your IRCD does not support vIdent's, if this is incorrect, please report this as a possible bug HOST_GROUP @@ -6427,8 +6427,6 @@ HOST_DEL_SYNTAX ########################################################################### HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Tu vhost ha sido removido. Para habilitar nuevamente el enmascaramiento de hosts tipea /mode %s +%s HOST_NO_VIDENT Tu IRCD no soporta vIdent's. Si esto es incorrecto, por favor reportalo como un posible bug. @@ -6474,8 +6474,6 @@ HOST_DEL_SYNTAX ########################################################################### HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Votre vhost a été enlevée. Pour réactiver la protection de votre IP, tapez /mode %s +%s HOST_NO_VIDENT L'IRCD utilisé ne support par la modification de l'ident. @@ -6346,8 +6346,6 @@ HOST_DEL_SYNTAX ########################################################################### HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Your vhost was removed. To re-enable the standard host cloaking, type /mode %s +%s HOST_NO_VIDENT Your IRCD does not support vIdent's, if this is incorrect, please report this as a possible bug diff --git a/lang/hun.l b/lang/hun.l index e5a50bda3..edfd55a59 100644 --- a/lang/hun.l +++ b/lang/hun.l @@ -6251,9 +6251,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - A vhostod kikapcsolva. Hogy újra használd az alap - hosztrejtést írd be /mode %s +%s HOST_NO_VIDENT Ön ircdje nem támogatja a videnteket, ha ez nem igaz, akkor kérem jelentse ezt, mint lehetséges hibát. @@ -6240,8 +6240,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Il tuo vhost è stato rimosso. Per riattivare il mascheramento standard del tuo host o IP, digita /mode %s +%s HOST_NO_VIDENT Il tuo IRCD non supporta i vIdent; se li supporta, invia un messaggio al team di sviluppo dei Services indicandolo come possibile bug. HOST_GROUP @@ -6314,8 +6314,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Je vhost is verwijderd. Om standaard host verberging weer aan te schakelen, type je /mode %s +%s HOST_NO_VIDENT Je IRCD ondersteunt geen vIdent's. Als dit niet klopt, rapporteer dit dan als een mogelijke bug HOST_GROUP @@ -7318,8 +7318,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Twój vhost zosta³ usuniêty i zosta³o w³±czone normalne ukrywanie hosta. -HOST_OFF_UNREAL - Twój vhost zosta³ usuniêty. Aby w³±czyæ standardowe ukrywanie hosta wpisz /mode %s +%s HOST_NO_VIDENT Twoje IRCD nie obs³uguje vIdentów, je¶li nie jest to prawda zg³o¶ b³±d. @@ -6173,8 +6173,6 @@ HOST_DEL_SYNTAX DEL <nick>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Seu vhost foi removido. Para reabilitar a encriptação padrão de host, digite /mode %s +%s HOST_NO_VIDENT Seu IRCD não suporta vIdent's, se isto não está certo, por favor reporte isso como um possível bug. HOST_GROUP @@ -6420,8 +6420,6 @@ HOST_DEL_SYNTAX DEL <íèê>. HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Âàø âèðòóàëüíûé õîñò äåàêòèâèðîâàí. Äëÿ ðå-àêòèâàöèè èñïîëüçóéòå: /MODE %s +%s HOST_NO_VIDENT IRCd âàøåé ñåòè íå ïîääåðæèâàåò âèðòóàëüíûå èäåíòû. Åñëè ýòî íå òàê, ñîîáùèòå íàì (ðàçðàáîò÷êàì) î äàííîì ôàêòå. HOST_GROUP @@ -6279,8 +6279,6 @@ HOST_DEL_SYNTAX ########################################################################### HOST_OFF Your vhost was removed and the normal cloaking restored. -HOST_OFF_UNREAL - Your vhost was removed. To re-enable the standard host cloaking, type /mode %s +%s HOST_NO_VIDENT Your IRCD does not support vIdent's, if this is incorrect, please report this as a possible bug diff --git a/src/actions.c b/src/actions.c index 4f2d047d2..f6b8c7675 100644 --- a/src/actions.c +++ b/src/actions.c @@ -181,7 +181,7 @@ void common_unban(ChannelInfo * ci, char *nick) for (ban = ci->c->bans->entries; ban; ban = next) { next = ban->next; if (entry_match(ban, u->nick, u->GetIdent().c_str(), u->host, ip) || - entry_match(ban, u->nick, u->GetIdent().c_str(), u->vhost, ip)) { + entry_match(ban, u->nick, u->GetIdent().c_str(), u->GetDisplayedHost().c_str(), ip)) { ircdproto->SendMode(whosends(ci), ci->name, "-b %s", ban->mask); if (ircdcap->tsmode) av[3] = ban->mask; diff --git a/src/core/hs_off.c b/src/core/hs_off.c index b8aabfcc2..ec83c97bc 100644 --- a/src/core/hs_off.c +++ b/src/core/hs_off.c @@ -32,7 +32,10 @@ class CommandHSOff : public Command if (!vhost && !vident) notice_lang(s_HostServ, u, HOST_NOT_ASSIGNED); else + { ircdproto->SendVhostDel(u); + notice_lang(s_HostServ, u, HOST_OFF); + } return MOD_CONT; } diff --git a/src/nickserv.c b/src/nickserv.c index 555c18de1..01c90a07e 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -949,6 +949,7 @@ int is_on_access(User * u, NickCore * nc) unsigned i; char *buf; char *buf2 = NULL; + char *buf3 = NULL; if (nc->access.empty()) return 0; @@ -962,13 +963,17 @@ int is_on_access(User * u, NickCore * nc) buf2 = new char[u->GetIdent().length() + strlen(u->vhost) + 2]; sprintf(buf2, "%s@%s", u->GetIdent().c_str(), u->vhost); } + if (!u->GetCloakedHost().empty()) + { + buf3 = new char[u->GetIdent().length() + u->GetCloakedHost().length() + 2]; + sprintf(buf3, "%s@%s", u->GetIdent().c_str(), u->GetCloakedHost().c_str()); + } } for (i = 0; i < nc->access.size(); i++) { std::string access = nc->GetAccess(i); - if (Anope::Match(buf, access, false) - || (ircd->vhost ? Anope::Match(buf2, access, false) : 0)) + if (Anope::Match(buf, access, false) || (buf2 && Anope::Match(buf2, access, false)) || (buf3 && Anope::Match(buf3, access, false))) { delete [] buf; if (ircd->vhost) @@ -977,6 +982,10 @@ int is_on_access(User * u, NickCore * nc) { delete [] buf2; } + if (!u->GetCloakedHost().empty()) + { + delete [] buf3; + } } return 1; } @@ -985,6 +994,7 @@ int is_on_access(User * u, NickCore * nc) if (ircd->vhost) { delete [] buf2; + delete [] buf3; } return 0; } diff --git a/src/protocol/inspircd11.c b/src/protocol/inspircd11.c index 7d3d2f287..977f05f1e 100644 --- a/src/protocol/inspircd11.c +++ b/src/protocol/inspircd11.c @@ -469,7 +469,21 @@ class InspIRCdProto : public IRCDProto } break; case 'x': - if (add) user->chost = user->vhost; + 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; + } update_host(user); } } @@ -489,8 +503,7 @@ class InspIRCdProto : public IRCDProto void SendVhostDel(User *u) { - inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->chost.c_str() : u->host)); - notice_lang(s_HostServ, u, HOST_OFF); + inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->GetCloakedHost().c_str() : u->host)); if (has_chgidentmod && u->GetIdent() != u->GetVIdent()) { @@ -1102,7 +1115,7 @@ int anope_event_nick(const char *source, int ac, const char **av) user->CheckAuthenticationToken(av[0]); ircdproto->ProcessUsermodes(user, 1, &av[5]); - user->chost = av[3]; + user->SetCloakedHost(av[3]); } } } else { diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp index 39abcfcb7..70afbfec4 100644 --- a/src/protocol/inspircd12.cpp +++ b/src/protocol/inspircd12.cpp @@ -471,7 +471,21 @@ class InspIRCdProto : public IRCDProto } break; case 'x': - if (add) user->chost = user->vhost; + 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; + } update_host(user); } } @@ -492,8 +506,7 @@ class InspIRCdProto : public IRCDProto void SendVhostDel(User *u) { - inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->chost.c_str() : u->host)); - notice_lang(s_HostServ, u, HOST_OFF); + inspircd_cmd_chghost(u->nick, (u->mode & umodes[static_cast<int>('x')] ? u->GetCloakedHost().c_str() : u->host)); if (has_chgidentmod && u->GetIdent() != u->GetVIdent()) { @@ -1161,7 +1174,7 @@ int anope_event_uid(const char *source, int ac, const char **av) if (user) { ircdproto->ProcessUsermodes(user, 1, &av[8]); - user->chost = av[4]; + user->SetCloakedHost(av[4]); } return MOD_CONT; diff --git a/src/protocol/unreal32.c b/src/protocol/unreal32.c index ee97a8ca6..6bad8959e 100644 --- a/src/protocol/unreal32.c +++ b/src/protocol/unreal32.c @@ -575,7 +575,30 @@ class UnrealIRCdProto : public IRCDProto user->mode &= ~UMODE_r; } 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; + } update_host(user); break; default: @@ -603,9 +626,8 @@ class UnrealIRCdProto : public IRCDProto void SendVhostDel(User *u) { - send_cmd(s_HostServ, "v %s -xt", u->nick); - send_cmd(s_HostServ, "v %s +x", u->nick); - notice_lang(s_HostServ, u, HOST_OFF); + common_svsmode(u, "-xt", NULL); + common_svsmode(u, "+x", NULL); } void SendAkill(const char *user, const char *host, const char *who, time_t when, time_t expires, const char *reason) @@ -1187,7 +1209,25 @@ int anope_event_sethost(const char *source, int ac, const char **av) return MOD_CONT; } - u->SetDisplayedHost(av[0]); + /* If a user has a custom host and a server splits and reconnects + * Unreal does not send the users cloaked host to Anope.. so we do not know it. + * However, they will be +t if this is the case, so we will set their vhost + * to the sethost value (which really is their vhost) and clear the chost. + * The chost will be request later (if needed) - Adam + */ + if (u->mode & UMODE_t) + { + u->SetDisplayedHost(av[0]); + u->chost.clear(); + } + /* If the new host doesn't match the real host or ip.. set it + * else we will not set a cloaked host, and request it later if needed + */ + else if ((u->host && strcmp(av[0], u->host)) || (u->hostip && strcmp(av[0], u->hostip))) + { + u->SetCloakedHost(av[0]); + } + return MOD_CONT; } @@ -1365,6 +1405,32 @@ int anope_event_sdesc(const char *source, int ac, const char **av) return MOD_CONT; } +int anope_event_userhost(const char *source, int ac, const char **av) +{ + /** Hack to get around Unreal: + * This is the USERHOST reply, we only send a request if we do not know the users cloaked host + * (they got introducted using a vhost) - Adam + */ + if (ac < 2) + return MOD_CONT; + + std::string reply = av[1]; + std::string user = std::string(reply.begin(), std::find(reply.begin(), reply.end(), '=')); + if (user[user.length() - 1] == '*') + user.erase(user.length() - 1); + std::string host = std::string(std::find(reply.begin(), reply.end(), '@'), reply.end()); + host.erase(host.begin()); + + User *u = finduser(user.c_str()); + if (u) + { + u->SetCloakedHost(host); + update_host(u); + } + + return MOD_CONT; +} + int anope_event_sjoin(const char *source, int ac, const char **av) { do_sjoin(source, ac, av); @@ -1438,6 +1504,7 @@ void moduleAddIRCDMsgs() { m = createMessage("~", anope_event_sjoin); addCoreMessage(IRCD,m); m = createMessage("SDESC", anope_event_sdesc); addCoreMessage(IRCD,m); m = createMessage("AG", anope_event_sdesc); addCoreMessage(IRCD,m); + m = createMessage("302", anope_event_userhost); addCoreMessage(IRCD,m); /* The non token version of these is in messages.c */ m = createMessage("2", m_stats); addCoreMessage(IRCD,m); diff --git a/src/users.c b/src/users.c index c019c136b..1431363ae 100644 --- a/src/users.c +++ b/src/users.c @@ -117,19 +117,42 @@ void User::SetDisplayedHost(const std::string &shost) update_host(this); } - +/** Get the displayed vhost of a user record. + * @return The displayed vhost of the user, where ircd-supported, or the user's real host. + */ const std::string User::GetDisplayedHost() const { - if (ircd->vhostmode && (this->mode & ircd->vhostmode)) - return this->vhost; - else if (ircd->vhost && this->vhost) + if (ircd->vhost && this->vhost) return this->vhost; + else if (ircd->vhostmode && (this->mode & ircd->vhostmode) && !this->GetCloakedHost().empty()) + return this->GetCloakedHost(); else return this->host; } +/** Update the cloaked host of a user + * @param host The cloaked host + */ +void User::SetCloakedHost(const std::string &newhost) +{ + if (newhost.empty()) + throw "empty host in User::SetCloakedHost"; + + chost = newhost; + if (debug) + alog("debug: %s changed cloaked host to %s", this->nick, newhost.c_str()); + + update_host(this); +} +/** Get the cloaked host of a user + * @return The cloaked host + */ +const std::string &User::GetCloakedHost() const +{ + return chost; +} const std::string &User::GetUID() const { @@ -208,7 +231,7 @@ User::~User() { alog("LOGUSERS: %s (%s@%s => %s) (%s) left the network (%s).", this->nick, this->GetIdent().c_str(), this->host, - (this->vhost ? this->vhost : "(none)"), srealname, this->server->name); + this->GetDisplayedHost().c_str(), srealname, this->server->name); } else { @@ -232,9 +255,9 @@ User::~User() if (debug >= 2) alog("debug: User::~User(): free user data"); - + delete [] this->host; - + if (this->vhost) delete [] this->vhost; @@ -599,7 +622,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const user->realname = sstrdup(realname); user->timestamp = ts; user->my_signon = time(NULL); - user->vhost = vhost ? sstrdup(vhost) : sstrdup(host); + user->SetCloakedHost(vhost); user->SetVIdent(username); /* We now store the user's ip in the user_ struct, * because we will use it in serveral places -- DrStein */ @@ -693,7 +716,7 @@ User *do_nick(const char *source, const char *nick, const char *username, const if (LogUsers) { logrealname = normalizeBuffer(user->realname); if (ircd->vhost) { - alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->GetIdent().c_str(), user->host, (user->vhost ? user->vhost : "(none)"), logrealname, nick, user->server->name); + alog("LOGUSERS: %s (%s@%s => %s) (%s) changed nick to %s (%s).", user->nick, user->GetIdent().c_str(), user->host, user->GetDisplayedHost().c_str(), logrealname, nick, user->server->name); } else { alog("LOGUSERS: %s (%s@%s) (%s) changed nick to %s (%s).", user->nick, user->GetIdent().c_str(), user->host, logrealname, @@ -979,11 +1002,11 @@ int match_usermask(const char *mask, User * user) result = Anope::Match(user->nick, nick, false) && Anope::Match(user->GetIdent().c_str(), username, false) && (Anope::Match(user->host, host, false) - || Anope::Match(user->vhost, host, false)); + || Anope::Match(user->GetDisplayedHost().c_str(), host, false)); } else { result = Anope::Match(user->GetIdent().c_str(), username, false) && (Anope::Match(user->host, host, false) - || Anope::Match(user->vhost, host, false)); + || Anope::Match(user->GetDisplayedHost().c_str(), host, false)); } delete [] mask2; |