diff options
author | Adam <Adam@anope.org> | 2012-02-14 15:13:27 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-02-14 15:13:27 -0500 |
commit | a9772cde21407c89abd161d51aff45267f87b1fb (patch) | |
tree | 9e57ba6c121d3843888917d968dd4f5d030b57cf /src | |
parent | 086790d6331357022f4da17c76b26b9fc6e2ad90 (diff) |
Clean up and reorganize our header files
Diffstat (limited to 'src')
50 files changed, 816 insertions, 299 deletions
diff --git a/src/access.cpp b/src/access.cpp index 32c648857..4ed19c7fe 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -9,8 +9,11 @@ * Based on the original code of Services by Andy Church. */ -#include "services.h" -#include "modules.h" +#include "service.h" +#include "access.h" +#include "regchannel.h" +#include "users.h" +#include "account.h" Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r) { diff --git a/src/actions.cpp b/src/actions.cpp index 01c8bf918..5536596e6 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -10,6 +10,10 @@ */ #include "services.h" +#include "users.h" +#include "config.h" +#include "regchannel.h" +#include "channels.h" /*************************************************************************/ diff --git a/src/base.cpp b/src/base.cpp index f8b393774..492ef4628 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -1,10 +1,10 @@ #include "services.h" #include "modules.h" #include "oper.h" - -std::vector<Anope::string> SerializeType::type_order; -Anope::map<SerializeType *> SerializeType::types; -std::list<Serializable *> *Serializable::serizliable_items; +#include "account.h" +#include "regchannel.h" +#include "access.h" +#include "bots.h" Anope::map<Anope::map<Service *> > Service::services; diff --git a/src/base64.cpp b/src/base64.cpp index b8f4b9de6..df4189547 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -10,6 +10,7 @@ */ #include "services.h" +#include "anope.h" static const Anope::string Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; diff --git a/src/bots.cpp b/src/bots.cpp index a6cc1c06f..30df962d8 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -6,9 +6,16 @@ */ #include "services.h" -#include "modules.h" -#include "commands.h" +#include "anope.h" +#include "bots.h" +#include "servers.h" +#include "protocol.h" #include "oper.h" +#include "regchannel.h" +#include "channels.h" +#include "config.h" +#include "language.h" +#include "extern.h" Anope::insensitive_map<BotInfo *> BotListByNick; Anope::map<BotInfo *> BotListByUID; diff --git a/src/botserv.cpp b/src/botserv.cpp index 4007bb355..962f2b80e 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -12,7 +12,14 @@ /*************************************************************************/ #include "services.h" -#include "modules.h" +#include "anope.h" +#include "protocol.h" +#include "bots.h" +#include "regchannel.h" +#include "language.h" +#include "extern.h" +#include "access.h" +#include "channels.h" BotInfo *findbot(const Anope::string &nick) { diff --git a/src/channels.cpp b/src/channels.cpp index ef74edcec..a04abff52 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -10,7 +10,19 @@ */ #include "services.h" +#include "channels.h" +#include "regchannel.h" +#include "logger.h" #include "modules.h" +#include "users.h" +#include "bots.h" +#include "servers.h" +#include "protocol.h" +#include "users.h" +#include "config.h" +#include "access.h" +#include "extern.h" +#include "sockets.h" channel_map ChannelList; @@ -91,7 +103,7 @@ void Channel::Sync() { if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi == this->users.front()->user))) { - new ChanServTimer(this); + this->Hold(); } if (this->ci) { @@ -863,6 +875,56 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop } } +/** A timer used to keep the BotServ bot/ChanServ in the channel + * after kicking the last user in a channel + */ +class CoreExport ChanServTimer : public Timer +{ + private: + dynamic_reference<Channel> c; + + public: + /** Default constructor + * @param chan The channel + */ + ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) + { + BotInfo *bi = findbot(Config->ChanServ); + if (!bi || !c) + return; + c->SetFlag(CH_INHABIT); + if (!c->ci || !c->ci->bi) + bi->Join(c); + else if (!c->FindUser(c->ci->bi)) + c->ci->bi->Join(c); + } + + /** Called when the delay is up + * @param The current time + */ + void Tick(time_t) + { + if (!c) + return; + + c->UnsetFlag(CH_INHABIT); + + if (!c->ci || !c->ci->bi) + { + BotInfo *bi = findbot(Config->ChanServ); + if (bi) + bi->Part(c); + } + else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers) + c->ci->bi->Part(c); + } +}; + +void Channel::Hold() +{ + new ChanServTimer(this); +} + /*************************************************************************/ Channel *findchan(const Anope::string &chan) @@ -1198,9 +1260,7 @@ Entry::Entry(ChannelModeName mode, const Anope::string &_host) : Flags<EntryType { try { - sockaddrs addr; - bool ipv6 = _realhost.substr(0, sl).find(':') != Anope::string::npos; - addr.pton(ipv6 ? AF_INET6 : AF_INET, _realhost.substr(0, sl)); + sockaddrs addr(_realhost.substr(0, sl)); /* If we got here, _realhost is a valid IP */ Anope::string cidr_range = _realhost.substr(sl + 1); @@ -1248,11 +1308,15 @@ bool Entry::Matches(User *u, bool full) const { try { - cidr cidr_mask(this->host, this->cidr_len); - if (!u->ip() || !cidr_mask.match(u->ip)) - ret = false; + if (full) + { + cidr cidr_mask(this->host, this->cidr_len); + sockaddrs addr(u->ip); + if (!cidr_mask.match(addr)) + ret = false; + } /* If we're not matching fully and their displayed host isnt their IP */ - else if (!full && u->ip.addr() != u->GetDisplayedHost()) + else if (u->ip != u->GetDisplayedHost()) ret = false; } catch (const SocketException &) @@ -1267,7 +1331,7 @@ bool Entry::Matches(User *u, bool full) const ret = false; if (this->HasFlag(ENTRYTYPE_HOST) && !this->host.equals_ci(u->GetDisplayedHost()) && (!full || (!this->host.equals_ci(u->host) && !this->host.equals_ci(u->chost) && !this->host.equals_ci(u->vhost) && - (!u->ip() || !this->host.equals_ci(u->ip.addr()))))) + !this->host.equals_ci(u->ip)))) ret = false; if (this->HasFlag(ENTRYTYPE_NICK_WILD) && !Anope::Match(u->nick, this->nick)) ret = false; @@ -1276,7 +1340,7 @@ bool Entry::Matches(User *u, bool full) const ret = false; if (this->HasFlag(ENTRYTYPE_HOST_WILD) && !Anope::Match(u->GetDisplayedHost(), this->host) && (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->chost, this->host) && - !Anope::Match(u->vhost, this->host) && (!u->ip() || !Anope::Match(u->ip.addr(), this->host))))) + !Anope::Match(u->vhost, this->host) && !Anope::Match(u->ip, this->host)))) ret = false; ChannelMode *cm = ModeManager::FindChannelModeByName(this->modename); diff --git a/src/chanserv.cpp b/src/chanserv.cpp index 398617fb5..f18c919cc 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -12,7 +12,11 @@ /*************************************************************************/ #include "services.h" -#include "modules.h" +#include "anope.h" +#include "regchannel.h" +#include "users.h" +#include "channels.h" +#include "access.h" registered_channel_map RegisteredChannelList; @@ -184,32 +188,3 @@ int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret) } } -ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) -{ - BotInfo *bi = findbot(Config->ChanServ); - if (!bi || !c) - return; - c->SetFlag(CH_INHABIT); - if (!c->ci || !c->ci->bi) - bi->Join(c); - else if (!c->FindUser(c->ci->bi)) - c->ci->bi->Join(c); -} - -void ChanServTimer::Tick(time_t) -{ - if (!c) - return; - - c->UnsetFlag(CH_INHABIT); - - if (!c->ci || !c->ci->bi) - { - BotInfo *bi = findbot(Config->ChanServ); - if (bi) - bi->Part(c); - } - else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers) - c->ci->bi->Part(c); -} - diff --git a/src/command.cpp b/src/command.cpp index 75271867b..309611a92 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -6,8 +6,12 @@ */ #include "services.h" -#include "modules.h" #include "commands.h" +#include "extern.h" +#include "users.h" +#include "language.h" +#include "config.h" +#include "bots.h" void CommandSource::Reply(const char *message, ...) { diff --git a/src/config.cpp b/src/config.cpp index d35399896..784142556 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -12,6 +12,11 @@ #include "services.h" #include "config.h" #include "module.h" +#include "extern.h" +#include "bots.h" +#include "access.h" +#include "opertype.h" +#include "channels.h" /*************************************************************************/ @@ -510,7 +515,7 @@ bool InitUplinks(ServerConfig *config, const Anope::string &) { if (!config->Uplinks.empty()) { - std::vector<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end(); + std::vector<ServerConfig::Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end(); for (; curr_uplink != end_uplink; ++curr_uplink) delete *curr_uplink; } @@ -535,7 +540,7 @@ static bool DoUplink(ServerConfig *config, const Anope::string &, const Anope::s if (!ValidateNotEmpty(config, "uplink", "password", vi_password)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); // If we get here, all the values are valid, we'll add it to the Uplinks list - config->Uplinks.push_back(new Uplink(host, port, password, ipv6)); + config->Uplinks.push_back(new ServerConfig::Uplink(host, port, password, ipv6)); return true; } diff --git a/src/configreader.cpp b/src/configreader.cpp index 9d6d49c2b..0bbdb0e49 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -24,6 +24,7 @@ */ #include "services.h" +#include "config.h" ConfigReader::ConfigReader() : error(CONF_NO_ERROR) { diff --git a/src/dns.cpp b/src/dns.cpp index fc1ab37df..d9010b8f9 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -1,4 +1,23 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" +#include "anope.h" +#include "dns.h" +#include "sockets.h" +#include "socketengine.h" + +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> DNSManager *DNSEngine = NULL; @@ -320,11 +339,10 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (q.type == DNS_QUERY_PTR) { + sockaddrs ip(q.name); + if (q.name.find(':') != Anope::string::npos) { - sockaddrs ip; - ip.pton(AF_INET6, q.name); - static const char *const hex = "0123456789abcdef"; char reverse_ip[128]; unsigned reverse_ip_count = 0; @@ -342,9 +360,6 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size } else { - sockaddrs ip; - ip.pton(AF_INET, q.name); - unsigned long forward = ip.sa4.sin_addr.s_addr; in_addr reverse; reverse.s_addr = forward << 24 | (forward & 0xFF00) << 8 | (forward & 0xFF0000) >> 8 | forward >> 24; @@ -399,8 +414,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (pos + 6 > output_size) throw SocketException("Unable to pack packet"); - sockaddrs addr; - addr.pton(AF_INET, rr.rdata); + sockaddrs addr(rr.rdata); s = htons(4); memcpy(&output[pos], &s, 2); @@ -415,8 +429,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (pos + 18 > output_size) throw SocketException("Unable to pack packet"); - sockaddrs addr; - addr.pton(AF_INET6, rr.rdata); + sockaddrs addr(rr.rdata); s = htons(16); memcpy(&output[pos], &s, 2); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 94b899536..84773b369 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -9,6 +9,8 @@ */ #include "services.h" +#include "hashcomp.h" +#include "anope.h" /* * diff --git a/src/hostserv.cpp b/src/hostserv.cpp deleted file mode 100644 index dde6d44ce..000000000 --- a/src/hostserv.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* HostServ functions - * - * (C) 2003-2012 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -#include "services.h" -#include "modules.h" - - -/** Set a vhost for the user - * @param ident The ident - * @param host The host - * @param creator Who created the vhost - * @param time When the vhost was craated - */ -void HostInfo::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created) -{ - Ident = ident; - Host = host; - Creator = creator; - Time = created; -} - -/** Remove a users vhost - **/ -void HostInfo::RemoveVhost() -{ - Ident.clear(); - Host.clear(); - Creator.clear(); - Time = 0; -} - -/** Check if the user has a vhost - * @return true or false - */ -bool HostInfo::HasVhost() const -{ - return !Host.empty(); -} - -/** Retrieve the vhost ident - * @return the ident - */ -const Anope::string &HostInfo::GetIdent() const -{ - return Ident; -} - -/** Retrieve the vhost host - * @return the host - */ -const Anope::string &HostInfo::GetHost() const -{ - return Host; -} - -/** Retrieve the vhost creator - * @return the creator - */ -const Anope::string &HostInfo::GetCreator() const -{ - return Creator; -} - -/** Retrieve when the vhost was crated - * @return the time it was created - */ -time_t HostInfo::GetTime() const -{ - return Time; -} - diff --git a/src/init.cpp b/src/init.cpp index 2a87ade9c..a161f9c6f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -10,10 +10,21 @@ */ #include "services.h" -#include "modules.h" +#include "config.h" +#include "extern.h" +#include "users.h" +#include "protocol.h" +#include "bots.h" #include "oper.h" +#include "signals.h" +#include "socketengine.h" +#include "servers.h" -Uplink *uplink_server; +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/stat.h> + +ServerConfig::Uplink *uplink_server; void introduce_user(const Anope::string &user) { diff --git a/src/language.cpp b/src/language.cpp index 222008b8c..1a374c0bc 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -1,6 +1,23 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" #include "modules.h" #include "commands.h" +#include "config.h" +#include "extern.h" + +#if GETTEXT_FOUND +# include <libintl.h> +#endif std::vector<Anope::string> languages; std::vector<Anope::string> domains; diff --git a/src/logger.cpp b/src/logger.cpp index 978c9cd44..508fa7b0c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -12,6 +12,17 @@ #include "services.h" #include "modules.h" #include "commands.h" +#include "channels.h" +#include "users.h" +#include "logger.h" +#include "extern.h" +#include "config.h" +#include "bots.h" +#include "servers.h" +#include "uplink.h" +#include "protocol.h" + +#include <sys/time.h> static Anope::string GetTimeStamp() { diff --git a/src/mail.cpp b/src/mail.cpp index dcf9dea5e..cc1541640 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -1,4 +1,18 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + + #include "services.h" +#include "mail.h" +#include "config.h" MailThread::MailThread(const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message) : Thread(), MailTo(mailto), Addr(addr), Subject(subject), Message(message), DontQuoteAddresses(Config->DontQuoteAddresses), Success(false) { diff --git a/src/main.cpp b/src/main.cpp index 87cf8532c..55f185057 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,12 +25,18 @@ #include "services.h" #include "timers.h" -#include "modules.h" - -#ifdef _WIN32 -# include <process.h> -# define execve _execve -#endif +#include "extern.h" +#include "uplink.h" +#include "config.h" +#include "protocol.h" +#include "servers.h" +#include "bots.h" +#include "dns.h" +#include "signals.h" +#include "socketengine.h" + +#include <unistd.h> +#include <limits.h> /******** Global variables! ********/ @@ -229,7 +235,7 @@ static void Connect() if (static_cast<unsigned>(++CurrentUplink) >= Config->Uplinks.size()) CurrentUplink = 0; - Uplink *u = Config->Uplinks[CurrentUplink]; + ServerConfig::Uplink *u = Config->Uplinks[CurrentUplink]; new UplinkSocket(); if (!Config->LocalHost.empty()) @@ -340,9 +346,9 @@ int main(int ac, char **av, char **envp) /* If we're root, issue a warning now */ if (!getuid() && !getgid()) { - std::cout << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; - std::cout << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; - std::cout << " as the root superuser." << std::endl; + std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; + std::cerr << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; + std::cerr << " as the root superuser." << std::endl; sleep(3); } #endif diff --git a/src/memoserv.cpp b/src/memoserv.cpp index bb168b939..1407e8521 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -9,9 +9,14 @@ * Based on the original code of Services by Andy Church. */ + #include "services.h" #include "modules.h" +#include "service.h" #include "memoserv.h" +#include "memo.h" +#include "users.h" +#include "account.h" Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { } diff --git a/src/messages.cpp b/src/messages.cpp index a3032e79a..fa93e528c 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -11,6 +11,12 @@ #include "services.h" #include "modules.h" +#include "users.h" +#include "protocol.h" +#include "config.h" +#include "extern.h" +#include "uplink.h" +#include "opertype.h" bool OnStats(const Anope::string &source, const std::vector<Anope::string> ¶ms) { diff --git a/src/misc.cpp b/src/misc.cpp index 524095d88..bb8658a56 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -13,6 +13,15 @@ #include "services.h" #include "version.h" #include "modules.h" +#include "extern.h" +#include "lists.h" +#include "config.h" +#include "bots.h" +#include "language.h" + +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> ExtensibleItem::ExtensibleItem() { @@ -758,9 +767,9 @@ const Anope::string Anope::LastError() #endif } -Version Module::GetVersion() const +ModuleVersion Module::GetVersion() const { - return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); + return ModuleVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); } Anope::string Anope::Version() diff --git a/src/modes.cpp b/src/modes.cpp index d64d60fd8..0b61440a5 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -8,8 +8,12 @@ #include "services.h" #include "modules.h" +#include "extern.h" +#include "config.h" +#include "sockets.h" +#include "protocol.h" +#include "channels.h" -ModeManager::ModePipe *ModeManager::mpipe = NULL; /* List of pairs of user/channels and their stacker info */ std::list<std::pair<Base *, StackerInfo *> > ModeManager::StackerObjects; @@ -346,12 +350,14 @@ void StackerInfo::AddMode(Mode *mode, bool Set, const Anope::string &Param) list->push_back(std::make_pair(mode, Param)); } -/** Called when there are modes to be set - */ -void ModeManager::ModePipe::OnNotify() +class ModePipe : public Pipe { - ModeManager::ProcessModes(); -} + public: + void OnNotify() + { + ModeManager::ProcessModes(); + } +}; /** Get the stacker info for an item, if one doesnt exist it is created * @param Item The user/channel etc @@ -467,9 +473,8 @@ void ModeManager::StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool else if (Type == ST_USER) s->bi = NULL; - if (mpipe == NULL) - mpipe = new ModePipe(); - mpipe->Notify(); + static ModePipe mpipe; + mpipe.Notify(); } /** Add a user mode to Anope diff --git a/src/module.cpp b/src/module.cpp index 6fb6fff9a..d3406ec22 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -6,7 +6,11 @@ * Please read COPYING and README for further details. */ + +#include "services.h" #include "modules.h" +#include "extern.h" +#include "dns.h" #ifdef GETTEXT_FOUND # include <libintl.h> @@ -80,25 +84,25 @@ void Module::SetAuthor(const Anope::string &nauthor) this->author = nauthor; } -Version::Version(int vMajor, int vMinor, int vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild) +ModuleVersion::ModuleVersion(int vMajor, int vMinor, int vBuild) : Major(vMajor), Minor(vMinor), Build(vBuild) { } -Version::~Version() +ModuleVersion::~ModuleVersion() { } -int Version::GetMajor() const +int ModuleVersion::GetMajor() const { return this->Major; } -int Version::GetMinor() const +int ModuleVersion::GetMinor() const { return this->Minor; } -int Version::GetBuild() const +int ModuleVersion::GetBuild() const { return this->Build; } diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index f56a3171a..39a4fcc45 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -6,8 +6,17 @@ * Please read COPYING and README for further details. */ +#include "services.h" #include "modules.h" -#include <algorithm> // std::find +#include "extern.h" +#include "users.h" + +#include <sys/types.h> +#include <dirent.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dlfcn.h> std::vector<Module *> ModuleManager::EventHandlers[I_END]; @@ -174,7 +183,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) m->filename = pbuf; m->handle = handle; - Version v = m->GetVersion(); + ModuleVersion v = m->GetVersion(); if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor())) { Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionMajor() << "." << Anope::VersionMinor(); diff --git a/src/modules.cpp b/src/modules.cpp index c978fdf16..e34c3597d 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -9,11 +9,24 @@ * Based on the original code of Services by Andy Church. */ + +#include "services.h" #include "modules.h" message_map MessageMap; std::list<Module *> Modules; +CallBack::CallBack(Module *mod, long time_from_now, time_t now, bool repeating) : Timer(time_from_now, now, repeating), m(mod) +{ +} + +CallBack::~CallBack() +{ + std::list<CallBack *>::iterator it = std::find(m->CallBacks.begin(), m->CallBacks.end(), this); + if (it != m->CallBacks.end()) + m->CallBacks.erase(it); +} + /** Message constructor, adds the message to Anope * @param n The message name * @param f A callback function diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 43a35d448..586add90e 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -1,5 +1,28 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + + #include "services.h" +#include "account.h" #include "modules.h" +#include "opertype.h" +#include "protocol.h" +#include "users.h" +#include "servers.h" +#include "config.h" + +class NickServHeld; + +typedef std::map<Anope::string, NickServHeld *> nickservheld_map; +static nickservheld_map NickServHelds; /** Default constructor * @param nick The nick @@ -83,6 +106,81 @@ void NickAlias::Release() } } +/** Timers for removing HELD status from nicks. + */ +class NickServHeld : public Timer +{ + dynamic_reference<NickAlias> na; + Anope::string nick; + public: + NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick) + { + nickservheld_map::iterator nit = NickServHelds.find(na->nick); + if (nit != NickServHelds.end()) + delete nit->second; + + NickServHelds[na->nick] = this; + } + + ~NickServHeld() + { + NickServHelds.erase(this->nick); + } + + void Tick(time_t) + { + if (na) + na->UnsetFlag(NS_HELD); + } +}; + +/** Timers for releasing nicks to be available for use + */ +class CoreExport NickServRelease : public User, public Timer +{ + static std::map<Anope::string, NickServRelease *> NickServReleases; + Anope::string nick; + + public: + /** Default constructor + * @param na The nick + * @param delay The delay before the nick is released + */ + NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick) + { + this->realname = "Services Enforcer"; + this->server = Me; + + /* Erase the current release timer and use the new one */ + std::map<Anope::string, NickServRelease *>::iterator nit = NickServReleases.find(this->nick); + if (nit != NickServReleases.end()) + { + ircdproto->SendQuit(nit->second, ""); + delete nit->second; + } + + NickServReleases.insert(std::make_pair(this->nick, this)); + + ircdproto->SendClientIntroduction(this); + } + + /** Default destructor + */ + virtual ~NickServRelease() + { + NickServReleases.erase(this->nick); + } + + /** Called when the delay is up + * @param t The current time + */ + void Tick(time_t t) + { + ircdproto->SendQuit(this, ""); + } +}; +std::map<Anope::string, NickServRelease *> NickServRelease::NickServReleases; + /** Called when a user gets off this nick * See the comment in users.cpp for User::Collide() * @param u The user @@ -103,6 +201,47 @@ void NickAlias::OnCancel(User *) } } +void NickAlias::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created) +{ + this->vhost_ident = ident; + this->vhost_host = host; + this->vhost_creator = creator; + this->vhost_created = created; +} + +void NickAlias::RemoveVhost() +{ + this->vhost_ident.clear(); + this->vhost_host.clear(); + this->vhost_creator.clear(); + this->vhost_created = 0; +} + +bool NickAlias::HasVhost() const +{ + return !this->vhost_host.empty(); +} + +const Anope::string &NickAlias::GetVhostIdent() const +{ + return this->vhost_ident; +} + +const Anope::string &NickAlias::GetVhostHost() const +{ + return this->vhost_host; +} + +const Anope::string &NickAlias::GetVhostCreator() const +{ + return this->vhost_creator; +} + +time_t NickAlias::GetVhostCreated() const +{ + return this->vhost_created; +} + Anope::string NickAlias::serialize_name() const { return "NickAlias"; @@ -122,12 +261,12 @@ Serializable::serialized_data NickAlias::serialize() data["nc"] << this->nc->display; data["flags"] << this->ToString(); - if (this->hostinfo.HasVhost()) + if (this->HasVhost()) { - data["vhost_ident"] << this->hostinfo.GetIdent(); - data["vhost_host"] << this->hostinfo.GetHost(); - data["vhost_creator"] << this->hostinfo.GetCreator(); - data["vhost_time"] << this->hostinfo.GetTime(); + data["vhost_ident"] << this->GetVhostIdent(); + data["vhost_host"] << this->GetVhostHost(); + data["vhost_creator"] << this->GetVhostCreator(); + data["vhost_time"] << this->GetVhostCreated(); } return data; @@ -167,6 +306,6 @@ void NickAlias::unserialize(serialized_data &data) time_t vhost_time; data["vhost_time"] >> vhost_time; - na->hostinfo.SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time); + na->SetVhost(data["vhost_ident"].astr(), data["vhost_host"].astr(), data["vhost_creator"].astr(), vhost_time); } diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 370d6b705..62a3d7006 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -1,5 +1,18 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" #include "modules.h" +#include "account.h" +#include "config.h" /** Default constructor * @param display The display nick diff --git a/src/nickserv.cpp b/src/nickserv.cpp index fde535e7c..011ee685e 100644 --- a/src/nickserv.cpp +++ b/src/nickserv.cpp @@ -10,95 +10,14 @@ */ #include "services.h" +#include "account.h" #include "modules.h" +#include "users.h" +#include "protocol.h" nickalias_map NickAliasList; nickcore_map NickCoreList; -typedef std::map<Anope::string, NickServCollide *> nickservcollides_map; -typedef std::map<Anope::string, NickServHeld *> nickservheld_map; -typedef std::map<Anope::string, NickServRelease *> nickservreleases_map; - -static nickservcollides_map NickServCollides; -static nickservheld_map NickServHelds; -static nickservreleases_map NickServReleases; - -NickServCollide::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)); -} - -NickServCollide::~NickServCollide() -{ - NickServCollides.erase(this->nick); -} - -void NickServCollide::Tick(time_t ctime) -{ - 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); -} - -NickServHeld::NickServHeld(NickAlias *n, long l) : Timer(l), na(n), nick(na->nick) -{ - nickservheld_map::iterator nit = NickServHelds.find(na->nick); - if (nit != NickServHelds.end()) - delete nit->second; - - NickServHelds[na->nick] = this; -} - -NickServHeld::~NickServHeld() -{ - NickServHelds.erase(this->nick); -} - -void NickServHeld::Tick(time_t) -{ - if (na) - na->UnsetFlag(NS_HELD); -} - -NickServRelease::NickServRelease(NickAlias *na, time_t delay) : User(na->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, ts6_uid_retrieve()), Timer(delay), nick(na->nick) -{ - this->realname = "Services Enforcer"; - this->server = Me; - - /* Erase the current release timer and use the new one */ - nickservreleases_map::iterator nit = NickServReleases.find(this->nick); - if (nit != NickServReleases.end()) - delete nit->second; - - NickServReleases.insert(std::make_pair(this->nick, this)); - - ircdproto->SendClientIntroduction(this); -} - -NickServRelease::~NickServRelease() -{ - NickServReleases.erase(this->nick); - - ircdproto->SendQuit(this, ""); -} - -void NickServRelease::Tick(time_t) -{ - /* Do not do anything here, - * The timer manager will delete this timer which will do the necessary cleanup - */ -} - NickAlias *findnick(const Anope::string &nick) { FOREACH_MOD(I_OnFindNick, OnFindNick(nick)); diff --git a/src/operserv.cpp b/src/operserv.cpp index e32937797..6cdbf2ff3 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -9,9 +9,13 @@ * Based on the original code of Services by Andy Church. */ + #include "services.h" #include "modules.h" #include "oper.h" +#include "users.h" +#include "extern.h" +#include "sockets.h" /* List of XLine managers we check users against in XLineManager::CheckAll */ std::list<XLineManager *> XLineManager::XLineManagers; @@ -62,13 +66,6 @@ Anope::string XLine::GetHost() const return this->Mask.substr(host_t + 1); } -sockaddrs XLine::GetIP() const -{ - sockaddrs addr; - addr.pton(this->GetHost().find(':') != Anope::string::npos ? AF_INET6 : AF_INET, this->GetHost()); - return addr; -} - Anope::string XLine::serialize_name() const { return "XLine"; @@ -361,12 +358,13 @@ XLine *XLineManager::Check(User *u) if (!x->GetUser().empty() && !Anope::Match(u->GetIdent(), x->GetUser())) continue; - if (u->ip() && !x->GetHost().empty()) + if (!x->GetHost().empty()) { try { cidr cidr_ip(x->GetHost()); - if (cidr_ip.match(u->ip)) + sockaddrs ip(u->ip); + if (cidr_ip.match(ip)) { OnMatch(u, x); return x; diff --git a/src/opertype.cpp b/src/opertype.cpp index 8c2edb60f..b719b4cc7 100644 --- a/src/opertype.cpp +++ b/src/opertype.cpp @@ -6,7 +6,9 @@ */ #include "services.h" - +#include "anope.h" +#include "opertype.h" +#include "config.h" Oper *Oper::Find(const Anope::string &name) { diff --git a/src/process.cpp b/src/process.cpp index 02be28465..6bfa3fec7 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -11,6 +11,7 @@ #include "services.h" #include "modules.h" +#include "extern.h" /** Main process routine * @param buffer A raw line from the uplink to do things with diff --git a/src/protocol.cpp b/src/protocol.cpp index 1bdebcc79..051f6f2d1 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,5 +1,24 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" #include "modules.h" +#include "protocol.h" +#include "users.h" +#include "servers.h" +#include "config.h" +#include "uplink.h" +#include "bots.h" +#include "extern.h" +#include "channels.h" IRCDProto *ircdproto; IRCDVar *ircd; diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 1ae7115c9..bf85f5809 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -11,6 +11,15 @@ #include "services.h" #include "modules.h" +#include "regchannel.h" +#include "account.h" +#include "access.h" +#include "channels.h" +#include "config.h" +#include "bots.h" +#include "extern.h" +#include "language.h" +#include "servers.h" Anope::string BadWord::serialize_name() const { @@ -1024,7 +1033,7 @@ bool ChannelInfo::CheckKick(User *user) } /* Join ChanServ and set a timer for this channel to part ChanServ later */ - new ChanServTimer(this->c); + this->c->Hold(); } this->c->SetMode(NULL, CMODE_BAN, mask); diff --git a/src/serialize.cpp b/src/serialize.cpp new file mode 100644 index 000000000..beaf5a8cc --- /dev/null +++ b/src/serialize.cpp @@ -0,0 +1,138 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + + +#include "services.h" +#include "anope.h" +#include "serialize.h" + +std::vector<Anope::string> SerializeType::type_order; +Anope::map<SerializeType *> SerializeType::types; +std::list<Serializable *> *Serializable::serizliable_items; + +stringstream::stringstream() : std::stringstream(), type(Serialize::DT_TEXT), key(false), _max(0) +{ +} + +stringstream::stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(Serialize::DT_TEXT), key(false), _max(0) +{ +} + +Anope::string stringstream::astr() const +{ + return this->str(); +} + +std::istream &stringstream::operator>>(Anope::string &val) +{ + val = this->str(); + return *this; +} + +stringstream &stringstream::setType(Serialize::DataType t) +{ + this->type = t; + return *this; +} + +Serialize::DataType stringstream::getType() const +{ + return this->type; +} + +stringstream &stringstream::setKey() +{ + this->key = true; + return *this; +} + +bool stringstream::getKey() const +{ + return this->key; +} + +stringstream &stringstream::setMax(unsigned m) +{ + this->_max = m; + return *this; +} + +unsigned stringstream::getMax() const +{ + return this->_max; +} + +Serializable::Serializable() +{ + if (serizliable_items == NULL) + serizliable_items = new std::list<Serializable *>(); + serizliable_items->push_front(this); + this->s_iter = serizliable_items->begin(); +} + +Serializable::Serializable(const Serializable &) +{ + serizliable_items->push_front(this); + this->s_iter = serizliable_items->begin(); +} + +Serializable::~Serializable() +{ + serizliable_items->erase(this->s_iter); +} + +Serializable &Serializable::operator=(const Serializable &) +{ + return *this; +} + +const std::list<Serializable *> &Serializable::GetItems() +{ + return *serizliable_items; +} + +SerializeType::SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f) +{ + type_order.push_back(this->name); + types[this->name] = this; +} + +SerializeType::~SerializeType() +{ + std::vector<Anope::string>::iterator it = std::find(type_order.begin(), type_order.end(), this->name); + if (it != type_order.end()) + type_order.erase(it); + types.erase(this->name); +} + +const Anope::string &SerializeType::GetName() +{ + return this->name; +} + +void SerializeType::Create(Serializable::serialized_data &data) +{ + this->unserialize(data); +} + +SerializeType *SerializeType::Find(const Anope::string &name) +{ + Anope::map<SerializeType *>::iterator it = types.find(name); + if (it != types.end()) + return it->second; + return NULL; +} + +const std::vector<Anope::string> &SerializeType::GetTypeOrder() +{ + return type_order; +} + diff --git a/src/servers.cpp b/src/servers.cpp index 6aef23ef8..944285c42 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -12,6 +12,13 @@ #include "services.h" #include "modules.h" #include "oper.h" +#include "servers.h" +#include "bots.h" +#include "regchannel.h" +#include "protocol.h" +#include "config.h" +#include "channels.h" +#include "extern.h" /* Anope */ Server *Me = NULL; diff --git a/src/socket_clients.cpp b/src/socket_clients.cpp index c3f7e6367..847981510 100644 --- a/src/socket_clients.cpp +++ b/src/socket_clients.cpp @@ -10,6 +10,11 @@ */ #include "services.h" +#include "anope.h" +#include "logger.h" +#include "sockets.h" + +#include <errno.h> ConnectionSocket::ConnectionSocket() : Socket() { diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp index c2e964271..b524c6a24 100644 --- a/src/socket_transport.cpp +++ b/src/socket_transport.cpp @@ -10,6 +10,8 @@ */ #include "services.h" +#include "sockets.h" +#include "socketengine.h" BufferedSocket::BufferedSocket() { diff --git a/src/socketengines/pipeengine_eventfd.cpp b/src/socketengines/pipeengine_eventfd.cpp index 06102ff20..d1051cc28 100644 --- a/src/socketengines/pipeengine_eventfd.cpp +++ b/src/socketengines/pipeengine_eventfd.cpp @@ -1,4 +1,17 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" +#include "sockets.h" + #include <sys/eventfd.h> Pipe::Pipe() : Socket(eventfd(0, EFD_NONBLOCK)) diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp index 7901931c8..dc7d6918a 100644 --- a/src/socketengines/pipeengine_pipe.cpp +++ b/src/socketengines/pipeengine_pipe.cpp @@ -1,4 +1,20 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" +#include "sockets.h" +#include "socketengine.h" + +#include <unistd.h> +#include <fcntl.h> Pipe::Pipe() : Socket(-1), WritePipe(-1) { diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 927d84100..b6dbdc23f 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -1,6 +1,23 @@ -#include "module.h" +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +#include "services.h" +#include "anope.h" +#include "sockets.h" +#include "socketengine.h" +#include "config.h" + #include <sys/epoll.h> #include <ulimit.h> +#include <errno.h> static long max; static int EngineHandle; diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 1c9fe1c2f..7af78bad6 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -1,4 +1,21 @@ -#include "module.h" +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +#include "services.h" +#include "anope.h" +#include "socketengine.h" +#include "sockets.h" +#include "logger.h" +#include "config.h" + #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index a174bf828..8fa666cf3 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -1,4 +1,22 @@ -#include "module.h" +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +#include "services.h" +#include "anope.h" +#include "socketengine.h" +#include "sockets.h" +#include "config.h" +#include "logger.h" + +#include <errno.h> #ifndef _WIN32 # include <sys/poll.h> diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index 89a5c47c3..e3393fdea 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -1,4 +1,20 @@ -#include "module.h" +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +#include "services.h" +#include "anope.h" +#include "socketengine.h" +#include "sockets.h" +#include "logger.h" +#include "config.h" #ifdef _AIX # undef FD_ZERO diff --git a/src/sockets.cpp b/src/sockets.cpp index 9b985a504..ebaf8f5a3 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -1,17 +1,38 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" +#include "sockets.h" +#include "socketengine.h" +#include "logger.h" + +#include <arpa/inet.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> std::map<int, Socket *> SocketEngine::Sockets; -int32_t TotalRead = 0; -int32_t TotalWritten = 0; +uint32_t TotalRead = 0; +uint32_t TotalWritten = 0; SocketIO normalSocketIO; /** Construct the object, sets everything to 0 */ -sockaddrs::sockaddrs() +sockaddrs::sockaddrs(const Anope::string &address) { this->clear(); + if (!address.empty()) + this->pton(address.find(':') != Anope::string::npos ? AF_INET6 : AF_INET, address); } /** Memset the object to 0 diff --git a/src/threadengine.cpp b/src/threadengine.cpp index c186e49a2..d45686586 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -1,4 +1,19 @@ +/* + * + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + #include "services.h" +#include "threadengine.h" +#include "anope.h" + +#include <pthread.h> static inline pthread_attr_t *get_engine_attr() { diff --git a/src/timers.cpp b/src/timers.cpp index a0f707bc9..267629aee 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -8,7 +8,9 @@ * Based on the original code of Services by Andy Church. */ + #include "services.h" +#include "timers.h" std::vector<Timer *> TimerManager::Timers; diff --git a/src/users.cpp b/src/users.cpp index f15754b28..c85aadd5b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -9,8 +9,18 @@ * Based on the original code of Services by Andy Church. */ + #include "services.h" #include "modules.h" +#include "users.h" +#include "account.h" +#include "protocol.h" +#include "servers.h" +#include "channels.h" +#include "bots.h" +#include "config.h" +#include "opertype.h" +#include "extern.h" Anope::insensitive_map<User *> UserListByNick; Anope::map<User *> UserListByUID; @@ -814,6 +824,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop /* Allocate User structure and fill it in. */ dynamic_reference<User> user = new User(nick, username, host, uid); + user->ip = ip; user->server = serv; user->realname = realname; user->timestamp = ts; @@ -822,23 +833,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop user->SetVIdent(username); user->SetModesInternal(modes.c_str()); - if (!ip.empty()) - { - try - { - if (ip.find(':') != Anope::string::npos) - user->ip.pton(AF_INET6, ip); - else - user->ip.pton(AF_INET, ip); - } - catch (const SocketException &ex) - { - Log() << "Received an invalid IP for user " << user->nick << " (" << ip << ")"; - Log() << ex.GetReason(); - } - } - - Log(user, "connect") << (!vhost.empty() ? Anope::string("(") + vhost + ")" : "") << " (" << user->realname << ") " << (user->ip() ? Anope::string("[") + user->ip.addr() + "] " : "") << "connected to the network (" << serv->GetName() << ")"; + Log(user, "connect") << (!vhost.empty() ? Anope::string("(") + vhost + ")" : "") << " (" << user->realname << ") " << user->ip << "connected to the network (" << serv->GetName() << ")"; bool exempt = false; if (user->server && user->server->IsULined()) diff --git a/src/win32/pipe/pipe.cpp b/src/win32/pipe/pipe.cpp index 849517b94..f46094c80 100644 --- a/src/win32/pipe/pipe.cpp +++ b/src/win32/pipe/pipe.cpp @@ -9,9 +9,7 @@ int pipe(int fds[2]) { - sockaddrs localhost; - - localhost.pton(AF_INET, "127.0.0.1"); + sockaddrs localhost("127.0.0.1"); int cfd = socket(AF_INET, SOCK_STREAM, 0), lfd = socket(AF_INET, SOCK_STREAM, 0); if (cfd == -1 || lfd == -1) diff --git a/src/win32/resource.h b/src/win32/resource.h new file mode 100644 index 000000000..cccb0b4f5 --- /dev/null +++ b/src/win32/resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Win32GUI.rc +// +#define VER_ANOPE 1 +#define MANIFEST_RESOURCE_ID 2 +#define ICON_APP 129 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 152 +#define _APS_NEXT_COMMAND_VALUE 40061 +#define _APS_NEXT_CONTROL_VALUE 1167 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif |