diff options
Diffstat (limited to 'modules')
30 files changed, 143 insertions, 109 deletions
diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index b8362cdda..44b2bf5e6 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -31,7 +31,7 @@ class CommandHSDel : public Command { Log(LOG_ADMIN, u, this) << "for user " << na->nick; FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); - na->hostinfo.RemoveVhost(); + na->RemoveVhost(); source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str()); } else @@ -69,7 +69,7 @@ class CommandHSDelAll : public Command for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it) { na = *it; - na->hostinfo.RemoveVhost(); + na->RemoveVhost(); } Log(LOG_ADMIN, u, this) << "for all nicks in group " << nc->display; source.Reply(_("vhosts for group \002%s\002 have been removed."), nc->display.c_str()); diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index 53efd3094..78c863a51 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -17,13 +17,13 @@ class CommandHSGroup : public Command { void Sync(NickAlias *na) { - if (!na || !na->hostinfo.HasVhost()) + if (!na || !na->HasVhost()) return; for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it) { NickAlias *nick = *it; - nick->hostinfo.SetVhost(na->hostinfo.GetIdent(), na->hostinfo.GetHost(), na->hostinfo.GetCreator()); + nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); } } @@ -38,13 +38,13 @@ class CommandHSGroup : public Command { User *u = source.u; NickAlias *na = findnick(u->nick); - if (na && u->Account() == na->nc && na->hostinfo.HasVhost()) + if (na && u->Account() == na->nc && na->HasVhost()) { this->Sync(na); - if (!na->hostinfo.GetIdent().empty()) - source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); + if (!na->GetVhostIdent().empty()) + source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), u->Account()->display.c_str(), na->hostinfo.GetHost().c_str()); + source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002"), u->Account()->display.c_str(), na->GetVhostHost().c_str()); } else source.Reply(HOST_NOT_ASSIGNED); diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 54295f52f..acba0528f 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -63,24 +63,24 @@ class CommandHSList : public Command { NickAlias *na = it->second; - if (!na->hostinfo.HasVhost()) + if (!na->HasVhost()) continue; if (!key.empty() && key[0] != '#') { - if ((Anope::Match(na->nick, key) || Anope::Match(na->hostinfo.GetHost(), key)) && display_counter < Config->NSListMax) + if ((Anope::Match(na->nick, key) || Anope::Match(na->GetVhostHost(), key)) && display_counter < Config->NSListMax) { ++display_counter; ListFormatter::ListEntry entry; entry["Number"] = stringify(display_counter); entry["Nick"] = na->nick; - if (!na->hostinfo.GetIdent().empty()) - entry["Vhost"] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost(); + if (!na->GetVhostIdent().empty()) + entry["Vhost"] = na->GetVhostIdent() + "@" + na->GetVhostHost(); else - entry["Vhost"] = na->hostinfo.GetHost(); - entry["Creator"] = na->hostinfo.GetCreator(); - entry["Created"] = do_strftime(na->hostinfo.GetTime()); + entry["Vhost"] = na->GetVhostHost(); + entry["Creator"] = na->GetVhostCreator(); + entry["Created"] = do_strftime(na->GetVhostCreated()); list.addEntry(entry); } } @@ -96,12 +96,12 @@ class CommandHSList : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(display_counter); entry["Nick"] = na->nick; - if (!na->hostinfo.GetIdent().empty()) - entry["Vhost"] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost(); + if (!na->GetVhostIdent().empty()) + entry["Vhost"] = na->GetVhostIdent() + "@" + na->GetVhostHost(); else - entry["Vhost"] = na->hostinfo.GetHost(); - entry["Creator"] = na->hostinfo.GetCreator(); - entry["Created"] = do_strftime(na->hostinfo.GetTime()); + entry["Vhost"] = na->GetVhostHost(); + entry["Creator"] = na->GetVhostCreator(); + entry["Created"] = do_strftime(na->GetVhostCreated()); list.addEntry(entry); } } diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 46a83a4e5..45a8befd3 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -27,7 +27,7 @@ class CommandHSOff : public Command User *u = source.u; NickAlias *na = findnick(u->nick); - if (!na || !na->hostinfo.HasVhost()) + if (!na || !na->HasVhost()) source.Reply(HOST_NOT_ASSIGNED); else { diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 788808e7c..2c7d12f41 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -26,20 +26,20 @@ class CommandHSOn : public Command { User *u = source.u; NickAlias *na = findnick(u->nick); - if (na && u->Account() == na->nc && na->hostinfo.HasVhost()) + if (na && u->Account() == na->nc && na->HasVhost()) { - if (!na->hostinfo.GetIdent().empty()) - source.Reply(_("Your vhost of \002%s\002@\002%s\002 is now activated."), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); + if (!na->GetVhostIdent().empty()) + source.Reply(_("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - source.Reply(_("Your vhost of \002%s\002 is now activated."), na->hostinfo.GetHost().c_str()); - Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->hostinfo.GetIdent().empty() ? na->hostinfo.GetIdent() + "@" : "") << na->hostinfo.GetHost(); - ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost()); + source.Reply(_("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); + Log(LOG_COMMAND, u, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost(); + ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); if (ircd->vhost) - u->vhost = na->hostinfo.GetHost(); + u->vhost = na->GetVhostHost(); if (ircd->vident) { - if (!na->hostinfo.GetIdent().empty()) - u->SetVIdent(na->hostinfo.GetIdent()); + if (!na->GetVhostIdent().empty()) + u->SetVIdent(na->GetVhostIdent()); } u->UpdateHost(); } diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 634dec06c..d5f63d175 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -192,7 +192,7 @@ class CommandHSActivate : public Command HostRequest *req = na ? na->GetExt<HostRequest *>("hs_request") : NULL; if (req) { - na->hostinfo.SetVhost(req->ident, req->host, u->nick, req->time); + na->SetVhost(req->ident, req->host, u->nick, req->time); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (HSRequestMemoUser && memoserv) diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index e305c3b33..d648952f7 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -82,7 +82,7 @@ class CommandHSSet : public Command Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; - na->hostinfo.SetVhost(user, host, u->nick); + na->SetVhost(user, host, u->nick); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (!user.empty()) source.Reply(_("VHost for \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); @@ -106,13 +106,13 @@ class CommandHSSetAll : public Command { void Sync(NickAlias *na) { - if (!na || !na->hostinfo.HasVhost()) + if (!na || !na->HasVhost()) return; for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it) { NickAlias *nick = *it; - nick->hostinfo.SetVhost(na->hostinfo.GetIdent(), na->hostinfo.GetHost(), na->hostinfo.GetCreator()); + nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); } } @@ -183,7 +183,7 @@ class CommandHSSetAll : public Command Log(LOG_ADMIN, u, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; - na->hostinfo.SetVhost(user, host, u->nick); + na->SetVhost(user, host, u->nick); this->Sync(na); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); if (!user.empty()) diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 2acbcb91f..a58cb5248 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -11,6 +11,7 @@ /*************************************************************************/ + #include "module.h" #include "memoserv.h" diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 065762f8b..514757037 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -101,12 +101,12 @@ class CommandNSInfo : public Command if (show_hidden) { - if (na->hostinfo.HasVhost()) + if (na->HasVhost()) { - if (ircd->vident && !na->hostinfo.GetIdent().empty()) - info[_("VHost")] = na->hostinfo.GetIdent() + "@" + na->hostinfo.GetHost(); + if (ircd->vident && !na->GetVhostIdent().empty()) + info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost(); else - info[_("VHost")] = na->hostinfo.GetHost(); + info[_("VHost")] = na->GetVhostHost(); } if (!na->nc->greet.empty()) diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 7d20c5539..b5b184740 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -277,7 +277,7 @@ class OSForbid : public Module if (!c->HasFlag(CH_INHABIT)) { /* Join ChanServ and set a timer for this channel to part ChanServ later */ - new ChanServTimer(c); + c->Hold(); /* Set +si to prevent rejoin */ c->SetMode(NULL, CMODE_NOEXTERNAL); diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index 2e7573674..26d11c047 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -157,7 +157,7 @@ class CommandOSUserList : public Command if (!pattern.empty()) { - Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + (u2->ip() ? u2->ip.addr() : u2->host); + Anope::string mask = u2->nick + "!" + u2->GetIdent() + "@" + u2->GetDisplayedHost(), mask2 = u2->nick + "!" + u2->GetIdent() + "@" + u2->host, mask3 = u2->nick + "!" + u2->GetIdent() + "@" + (!u2->ip.empty() ? u2->ip : u2->host); if (!Anope::Match(mask, pattern) && !Anope::Match(mask2, pattern) && !Anope::Match(mask3, pattern)) continue; if (!Modes.empty()) diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 12267b651..d89fbe1a6 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -38,7 +38,7 @@ class MySessionService : public SessionService for (std::vector<Exception *>::const_iterator it = this->Exceptions.begin(), it_end = this->Exceptions.end(); it != it_end; ++it) { Exception *e = *it; - if (Anope::Match(u->host, e->mask) || (u->ip() && Anope::Match(u->ip.addr(), e->mask))) + if (Anope::Match(u->host, e->mask) || Anope::Match(u->ip, e->mask)) return e; } return NULL; diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h index 67927410d..0d2cee9ad 100644 --- a/modules/commands/os_session.h +++ b/modules/commands/os_session.h @@ -1,6 +1,13 @@ #ifndef OS_SESSION_H #define OS_SESSION_H +struct Session +{ + Anope::string host; /* Host of the session */ + unsigned count; /* Number of clients with this host */ + unsigned hits; /* Number of subsequent kills for a host */ +}; + struct Exception : Serializable { Anope::string mask; /* Hosts to which this exception applies */ @@ -15,7 +22,6 @@ struct Exception : Serializable static void unserialize(serialized_data &data); }; - class SessionService : public Service { public: diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index e7a6fa390..d699e1a5f 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -591,7 +591,7 @@ static void LoadVHosts() continue; } - na->hostinfo.SetVhost(ident, host, creator, vtime); + na->SetVhost(ident, host, creator, vtime); Log() << "Loaded vhost for " << na->nick; } diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index 7c7721f7c..7f88ae9c1 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -117,7 +117,7 @@ EventReturn OnDatabaseReadMetadata(NickAlias *na, const Anope::string &key, cons else if (key.equals_ci("FLAGS")) na->FromVector(params); else if (key.equals_ci("VHOST")) - na->hostinfo.SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0); + na->SetVhost(params.size() > 3 ? params[3] : "", params[2], params[0], params[1].is_pos_number_only() ? convertTo<time_t>(params[1]) : 0); return EVENT_CONTINUE; } @@ -722,8 +722,8 @@ class DBPlain : public Module db_buffer << "MD LAST_QUIT :" << na->last_quit << endl; if (na->FlagCount()) db_buffer << "MD FLAGS " << na->ToString() << endl; - if (na->hostinfo.HasVhost()) - db_buffer << "MD VHOST " << na->hostinfo.GetCreator() << " " << na->hostinfo.GetTime() << " " << na->hostinfo.GetHost() << " :" << na->hostinfo.GetIdent() << endl; + if (na->HasVhost()) + db_buffer << "MD VHOST " << na->GetVhostCreator() << " " << na->GetVhostCreated() << " " << na->GetVhostHost() << " :" << na->GetVhostIdent() << endl; //FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, na)); } diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp index 285871cc6..0d863ad8d 100644 --- a/modules/extra/m_dnsbl.cpp +++ b/modules/extra/m_dnsbl.cpp @@ -43,7 +43,7 @@ class DNSBLResolver : public DNSRequest { sockaddrs sresult; sresult.pton(AF_INET, ans_record.rdata); - int result = (sresult.sa4.sin_addr.s_addr & 0xFF000000) >> 24; + int result = sresult.sa4.sin_addr.s_addr >> 24; if (!this->blacklist.replies.count(result)) return; @@ -57,13 +57,13 @@ class DNSBLResolver : public DNSRequest reason = reason.replace_all_cs("%u", user->GetIdent()); reason = reason.replace_all_cs("%g", user->realname); reason = reason.replace_all_cs("%h", user->host); - reason = reason.replace_all_cs("%i", user->ip.addr()); + reason = reason.replace_all_cs("%i", user->ip); reason = reason.replace_all_cs("%r", record_reason); reason = reason.replace_all_cs("%N", Config->NetworkName); BotInfo *operserv = findbot(Config->OperServ); - Log(operserv) << "DNSBL: " << user->GetMask() << " (" << user->ip.addr() << ") appears in " << this->blacklist.name; - XLine *x = new XLine("*@" + user->ip.addr(), Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID()); + Log(operserv) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name; + XLine *x = new XLine("*@" + user->ip, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID()); if (this->add_to_akill && akills) { akills->AddXLine(x); @@ -133,15 +133,15 @@ class ModuleDNSBL : public Module if (!this->check_on_netburst && !user->server->IsSynced()) return; + /* At this time we only support IPv4 */ - if (user->ip.sa.sa_family != AF_INET) + sockaddrs user_ip(user->ip); + if (user_ip.sa.sa_family != AF_INET) return; - unsigned long ip = user->ip.sa4.sin_addr.s_addr; - unsigned long reverse_ip = ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip & 0xFF000000) >> 24); + const unsigned long &ip = user_ip.sa4.sin_addr.s_addr; + unsigned long reverse_ip = (ip << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | (ip >> 24); - sockaddrs user_ip; - user_ip.sa4.sin_family = AF_INET; user_ip.sa4.sin_addr.s_addr = reverse_ip; for (unsigned i = 0; i < this->blacklists.size(); ++i) diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index 6b3153e32..37fd7c432 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -343,11 +343,12 @@ class ModuleProxyScan : public Module void OnUserConnect(dynamic_reference<User> &user, bool &exempt) { - if (exempt || !user || !user->ip() || !Me->IsSynced() || !user->server->IsSynced()) + if (exempt || !user || !Me->IsSynced() || !user->server->IsSynced()) return; + sockaddrs user_ip(user->ip); /* At this time we only support IPv4 */ - if (user->ip.sa.sa_family != AF_INET) + if (user_ip.sa.sa_family != AF_INET) return; if (!this->con_notice.empty() && !this->con_source.empty()) @@ -374,7 +375,7 @@ class ModuleProxyScan : public Module con = new SOCKS5ProxyConnect(p, p.ports[k]); else continue; - con->Connect(user->ip.addr(), p.ports[k]); + con->Connect(user->ip, p.ports[k]); } catch (const SocketException &ex) { diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 2d89c078d..829d3e532 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -102,7 +102,6 @@ class SSLModule : public Module SSL_library_init(); SSL_load_error_strings(); - SSLeay_add_ssl_algorithms(); client_ctx = SSL_CTX_new(SSLv23_client_method()); server_ctx = SSL_CTX_new(SSLv23_server_method()); diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp index 215be9d77..40a032092 100644 --- a/modules/extra/m_xmlrpc.cpp +++ b/modules/extra/m_xmlrpc.cpp @@ -1,3 +1,4 @@ + #include "module.h" #include "ssl.h" #include "xmlrpc.h" diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 7498a3059..8762872ad 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -215,8 +215,8 @@ class MyXMLRPCEvent : public XMLRPCEvent request->reply("vhost", iface->Sanitize(u->vhost)); if (!u->chost.empty()) request->reply("chost", iface->Sanitize(u->chost)); - if (u->ip()) - request->reply("ip", u->ip.addr()); + if (!u->ip.empty()) + request->reply("ip", u->ip); request->reply("timestamp", stringify(u->timestamp)); request->reply("signon", stringify(u->my_signon)); if (u->Account()) diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 3a7d655f3..b83afa686 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -11,10 +11,7 @@ /*************************************************************************/ -#include "services.h" -#include "modules.h" -#include "oper.h" -#include "nickserv.h" +#include "module.h" IRCDVar myIrcd[] = { {"Bahamut 1.8.x", /* ircd name */ diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 003f1bb68..d984e597e 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -11,10 +11,7 @@ /*************************************************************************/ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" IRCDVar myIrcd[] = { {"InspIRCd 1.1", /* ircd name */ diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 346e2b0e3..8fd29c7e8 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -11,10 +11,7 @@ /*************************************************************************/ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" /* inspircd-ts6.h uses these */ static bool has_globopsmod = false; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 30f8e2da3..8af8a999b 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -11,10 +11,7 @@ /*************************************************************************/ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" /* inspircd-ts6.h uses these */ static bool has_chghostmod = false; diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index c920babf3..16e6d3753 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -9,10 +9,7 @@ * Based on the original code of Services by Andy Church. */ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" static Anope::string TS6UPLINK; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 016a364ca..16ac806be 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -9,10 +9,7 @@ * Based on the original code of Services by Andy Church. */ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" static Anope::string TS6UPLINK; diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 101e803f4..4f45893c8 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -11,10 +11,7 @@ /*************************************************************************/ -#include "services.h" -#include "modules.h" -#include "nickserv.h" -#include "oper.h" +#include "module.h" IRCDVar myIrcd[] = { {"UnrealIRCd 3.2.x", /* ircd name */ diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index 717b117f3..ecf0ecb47 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -33,37 +33,30 @@ class HostServCore : public Module void OnNickIdentify(User *u) { - HostInfo *ho = NULL; NickAlias *na = findnick(u->nick); - if (na && na->hostinfo.HasVhost()) - ho = &na->hostinfo; - else - { + if (!na || !na->HasVhost()) na = findnick(u->Account()->display); - if (na && na->hostinfo.HasVhost()) - ho = &na->hostinfo; - } - if (ho == NULL) + if (!na) return; - if (u->vhost.empty() || !u->vhost.equals_cs(na->hostinfo.GetHost()) || (!na->hostinfo.GetIdent().empty() && !u->GetVIdent().equals_cs(na->hostinfo.GetIdent()))) + if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent()))) { - ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost()); + ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); if (ircd->vhost) { - u->vhost = na->hostinfo.GetHost(); + u->vhost = na->GetVhostHost(); u->UpdateHost(); } - if (ircd->vident && !na->hostinfo.GetIdent().empty()) - u->SetVIdent(na->hostinfo.GetIdent()); + if (ircd->vident && !na->GetVhostIdent().empty()) + u->SetVIdent(na->GetVhostIdent()); BotInfo *bi = findbot(Config->HostServ); if (bi) { - if (!na->hostinfo.GetIdent().empty()) - u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); + if (!na->GetVhostIdent().empty()) + u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->hostinfo.GetHost().c_str()); + u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); } } } diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index c486c2e0b..163fcc6af 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -16,6 +16,60 @@ static BotInfo *NickServ; +class NickServCollide; +class NickServRelease; + +typedef std::map<Anope::string, NickServCollide *> nickservcollides_map; +typedef std::map<Anope::string, NickServRelease *> nickservreleases_map; + +static nickservcollides_map NickServCollides; +static nickservreleases_map NickServReleases; + +/** Timer for colliding nicks to force people off of nicknames + */ +class CoreExport NickServCollide : public Timer +{ + dynamic_reference<User> u; + Anope::string nick; + + public: + /** Default constructor + * @param nick The nick we're colliding + * @param delay How long to delay before kicking the user off the nick + */ + NickServCollide(User *user, time_t delay) : Timer(delay), u(user), nick(u->nick) + { + /* Erase the current collide and use the new one */ + nickservcollides_map::iterator nit = NickServCollides.find(user->nick); + if (nit != NickServCollides.end()) + delete nit->second; + + NickServCollides.insert(std::make_pair(nick, this)); + } + + /** Default destructor + */ + virtual ~NickServCollide() + { + NickServCollides.erase(this->nick); + } + + /** Called when the delay is up + * @param t The current time + */ + void Tick(time_t t) + { + if (!u) + return; + /* If they identified or don't exist anymore, don't kill them. */ + NickAlias *na = findnick(u->nick); + if (!na || u->Account() == na->nc || u->my_signon > this->GetSetTime()) + return; + + u->Collide(na); + } +}; + class MyNickServService : public NickServService { public: diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 7dfaf40bb..813d9f098 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -40,7 +40,7 @@ class SGLineManager : public XLineManager throw SocketException("SZLine is not supported"); else if (x->GetUser() != "*") throw SocketException("Can not ZLine a username"); - x->GetIP(); + sockaddrs(x->GetHost()); ircdproto->SendSZLine(u, x); } catch (const SocketException &) @@ -57,7 +57,7 @@ class SGLineManager : public XLineManager throw SocketException("SZLine is not supported"); else if (x->GetUser() != "*") throw SocketException("Can not ZLine a username"); - x->GetIP(); + sockaddrs(x->GetHost()); ircdproto->SendSZLineDel(x); } catch (const SocketException &) |