diff options
Diffstat (limited to 'src')
62 files changed, 275 insertions, 241 deletions
diff --git a/src/access.cpp b/src/access.cpp index 007e6d281..5b994e916 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -84,7 +84,7 @@ void PrivilegeManager::AddPrivilege(Privilege p) if (priv.rank > p.rank) break; } - + Privileges.insert(Privileges.begin() + i, p); } @@ -265,7 +265,7 @@ bool ChanAccess::Matches(const User *u, const NickCore *acc, ChannelInfo* &next) else if (Anope::Match(u->GetDisplayedMask(), this->mask)) return true; } - + if (acc) { for (unsigned i = 0; i < acc->aliases->size(); ++i) @@ -275,12 +275,12 @@ bool ChanAccess::Matches(const User *u, const NickCore *acc, ChannelInfo* &next) return true; } } - + if (IRCD->IsChannelValid(this->mask)) { next = ChannelInfo::Find(this->mask); } - + return false; } @@ -313,7 +313,7 @@ bool ChanAccess::operator<(const ChanAccess &other) const continue; return !this_p && other_p; - } + } return false; } @@ -473,4 +473,3 @@ bool AccessGroup::operator<=(const AccessGroup &other) const { return !(*this > other); } - diff --git a/src/account.cpp b/src/account.cpp index f23f81242..6ced69bc9 100644 --- a/src/account.cpp +++ b/src/account.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/base.cpp b/src/base.cpp index 5e4ecc9e3..6dfd7ff22 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -46,4 +46,3 @@ void Base::DelReference(ReferenceBase *r) } } } - diff --git a/src/base64.cpp b/src/base64.cpp index 3096d9c3f..2ca476494 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -1,6 +1,6 @@ /* base64 routines. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -161,4 +161,3 @@ void Anope::B64Decode(const Anope::string &src, Anope::string &target) if (!target.empty() && !target[target.length() - 1]) target.erase(target.length() - 1); } - diff --git a/src/bots.cpp b/src/bots.cpp index 7654bb247..512de4c46 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -1,7 +1,7 @@ /* * * (C) 2008-2011 Robin Burchell <w00t@inspircd.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. */ @@ -29,7 +29,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A (*BotListByNick)[this->nick] = this; if (!this->uid.empty()) (*BotListByUID)[this->uid] = this; - + FOREACH_MOD(OnCreateBot, (this)); // If we're synchronised with the uplink already, send the bot. @@ -160,7 +160,7 @@ void BotInfo::Assign(User *u, ChannelInfo *ci) if (ci->bi) ci->bi->UnAssign(u, ci); - + ci->bi = this; this->channels->insert(ci); @@ -275,4 +275,3 @@ BotInfo* BotInfo::Find(const Anope::string &nick, bool nick_only) return NULL; } - diff --git a/src/channels.cpp b/src/channels.cpp index 3d824f0d8..184a7deb1 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -1,6 +1,6 @@ /* Channel-handling routines. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -90,7 +90,7 @@ void Channel::Reset() for (ChanUserList::const_iterator it = this->users.begin(), it_end = this->users.end(); it != it_end; ++it) this->SetCorrectModes(it->second->user, true); - + // If the channel is syncing now, do not force a sync due to Reset(), as we are probably iterating over users in Message::SJoin // A sync will come soon if (!syncing) @@ -128,7 +128,7 @@ bool Channel::CheckDelete() */ if (this->syncing) return false; - + /* Permanent channels never get deleted */ if (this->HasMode("PERM")) return false; @@ -162,10 +162,10 @@ void Channel::DeleteUser(User *user) ChanUserContainer *cu = user->FindChannel(this); if (!this->users.erase(user)) - Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent user " << user->nick << " from channel " << this->name; + Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistent user " << user->nick << " from channel " << this->name; if (!user->chans.erase(this)) - Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete non-existent channel " << this->name << " from " << user->nick << "'s channel list"; + Log(LOG_DEBUG) << "Channel::DeleteUser() tried to delete nonexistent channel " << this->name << " from " << user->nick << "'s channel list"; delete cu; QueueForDeletion(); @@ -280,7 +280,7 @@ void Channel::SetModeInternal(MessageSource &setter, ChannelMode *ocm, const Ano if (!u) { - Log() << "MODE " << this->name << " +" << cm->mchar << " for non-existent user " << param; + Log(LOG_DEBUG) << "MODE " << this->name << " +" << cm->mchar << " for nonexistent user " << param; return; } @@ -351,7 +351,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const if (!u) { - Log() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for non-existent user " << param; + Log(LOG_DEBUG) << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->mchar << " for nonexistent user " << param; return; } @@ -381,7 +381,7 @@ void Channel::RemoveModeInternal(MessageSource &setter, ChannelMode *ocm, const } else this->modes.erase(cm->name); - + if (cm->type == MODE_LIST) { ChannelModeList *cml = anope_dynamic_static_cast<ChannelModeList *>(cm); @@ -464,15 +464,21 @@ void Channel::SetMode(BotInfo *bi, const Anope::string &mname, const Anope::stri SetMode(bi, ModeManager::FindChannelModeByName(mname), param, enforce_mlock); } -void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶m, bool enforce_mlock) +void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &wparam, bool enforce_mlock) { if (!cm) return; + /* Don't unset modes that arent set */ if ((cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && !HasMode(cm->name)) return; + + /* Unwrap to be sure we have the internal representation */ + Anope::string param = wparam; + cm = cm->Unwrap(param); + /* Don't unset status that aren't set */ - else if (cm->type == MODE_STATUS) + if (cm->type == MODE_STATUS) { User *u = User::Find(param); if (!u || !HasUserStatus(u, anope_dynamic_static_cast<ChannelModeStatus *>(cm))) @@ -485,13 +491,12 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶ } /* Get the param to send, if we need it */ - Anope::string realparam = param; if (cm->type == MODE_PARAM) { - realparam.clear(); + param.clear(); ChannelModeParam *cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); if (!cmp->minus_no_arg) - this->GetParam(cmp->name, realparam); + this->GetParam(cmp->name, param); } if (Me->IsSynced()) @@ -505,12 +510,12 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string ¶ this->chanserv_modecount++; } - Anope::string wparam = realparam; - ChannelMode *wcm = cm->Wrap(wparam); + /* Wrap to get ircd representation */ + ChannelMode *wcm = cm->Wrap(param); - ModeManager::StackerAdd(bi, this, wcm, false, wparam); + ModeManager::StackerAdd(bi, this, wcm, false, param); MessageSource ms(bi); - RemoveModeInternal(ms, wcm, wparam, enforce_mlock); + RemoveModeInternal(ms, wcm, param, enforce_mlock); } void Channel::RemoveMode(BotInfo *bi, const Anope::string &mname, const Anope::string ¶m, bool enforce_mlock) @@ -713,7 +718,7 @@ void Channel::SetModesInternal(MessageSource &source, const Anope::string &mode, Log(setter, this, "mode") << modestring << paramstring; else Log(LOG_DEBUG) << source.GetName() << " is setting " << this->name << " to " << modestring << paramstring; - + if (enforce_mlock) this->CheckModes(); } @@ -776,7 +781,7 @@ bool Channel::Kick(BotInfo *bi, User *u, const char *reason, ...) /* Do not kick protected clients or Ulines */ if (u->IsProtected()) return false; - + if (bi == NULL) bi = this->ci->WhoSends(); @@ -819,7 +824,7 @@ void Channel::SetCorrectModes(User *user, bool give_modes) { if (user == NULL) return; - + if (!this->ci) return; @@ -905,7 +910,7 @@ bool Channel::CheckKick(User *user) FOREACH_RESULT(OnCheckKick, MOD_RESULT, (user, this, mask, reason)); if (MOD_RESULT != EVENT_STOP) return false; - + if (mask.empty()) mask = this->ci->GetIdealBan(user); if (reason.empty()) @@ -954,4 +959,3 @@ void Channel::DeleteChannels() } deleting.clear(); } - diff --git a/src/command.cpp b/src/command.cpp index 35a99eb80..5cfdf2833 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1,7 +1,7 @@ /* * * (C) 2008-2011 Robin Burchell <w00t@inspircd.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. */ @@ -309,7 +309,6 @@ bool Command::FindCommandFromService(const Anope::string &command_service, BotIn return true; } } - + return false; } - diff --git a/src/config.cpp b/src/config.cpp index c9a4a53c8..03ee9feb6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,6 +1,6 @@ /* Configuration file handling. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -35,7 +35,7 @@ int Block::CountBlock(const Anope::string &bname) { if (!this) return 0; - + return blocks.count(bname); } @@ -43,7 +43,7 @@ Block* Block::GetBlock(const Anope::string &bname, int num) { if (!this) return NULL; - + std::pair<block_map::iterator, block_map::iterator> it = blocks.equal_range(bname); for (int i = 0; it.first != it.second; ++it.first, ++i) @@ -157,7 +157,13 @@ Conf::Conf() : Block("") Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"), *mail = this->GetBlock("mail"), *networkinfo = this->GetBlock("networkinfo"); - ValidateNotEmpty("serverinfo", "name", serverinfo->Get<const Anope::string>("name")); + const Anope::string &servername = serverinfo->Get<Anope::string>("name"); + + ValidateNotEmpty("serverinfo", "name", servername); + + if (servername.find(' ') != Anope::string::npos || servername.find('.') == Anope::string::npos) + throw ConfigException("serverinfo:name is not a valid server name"); + ValidateNotEmpty("serverinfo", "description", serverinfo->Get<const Anope::string>("description")); ValidateNotEmpty("serverinfo", "pid", serverinfo->Get<const Anope::string>("pid")); ValidateNotEmpty("serverinfo", "motd", serverinfo->Get<const Anope::string>("motd")); @@ -205,6 +211,9 @@ Conf::Conf() : Block("") ValidateNotZero("uplink", "port", port); ValidateNotEmpty("uplink", "password", password); + if (password.find(' ') != Anope::string::npos || password[0] == ':') + throw ConfigException("uplink:password is not valid"); + this->Uplinks.push_back(Uplink(host, port, password, ipv6)); } @@ -278,7 +287,7 @@ Conf::Conf() : Block("") ValidateNotEmpty("oper", "name", nname); ValidateNotEmpty("oper", "type", type); - + OperType *ot = NULL; for (unsigned j = 0; j < this->MyOperTypes.size(); ++j) if (this->MyOperTypes[j]->GetName() == type) @@ -588,7 +597,7 @@ Block *Conf::GetModule(Module *m) { if (!m) return NULL; - + return GetModule(m->name); } @@ -599,7 +608,7 @@ Block *Conf::GetModule(const Anope::string &mname) return it->second; Block* &block = modules[mname]; - + /* Search for the block */ for (std::pair<block_map::iterator, block_map::iterator> iters = blocks.equal_range("module"); iters.first != iters.second; ++iters.first) { @@ -709,6 +718,9 @@ Anope::string File::Read() void Conf::LoadConf(File &file) { + if (file.GetName().empty()) + return; + if (!file.Open()) throw ConfigException("File " + file.GetName() + " could not be opened."); @@ -720,10 +732,10 @@ void Conf::LoadConf(File &file) Log(LOG_DEBUG) << "Start to read conf " << file.GetName(); // Start reading characters... while (!file.End()) - { + { Anope::string line = file.Read(); ++linenumber; - + /* If this line is completely empty and we are in a quote, just append a newline */ if (line.empty() && in_quote) wordbuffer += "\n"; @@ -922,4 +934,3 @@ void Conf::LoadConf(File &file) if (!block_stack.empty()) throw ConfigException("Unterminated block at end of file: " + file.GetName() + ". Block was opened on line " + stringify(block_stack.top()->linenum)); } - diff --git a/src/extensible.cpp b/src/extensible.cpp index 4079290ff..332df6673 100644 --- a/src/extensible.cpp +++ b/src/extensible.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -66,7 +66,6 @@ bool* Extensible::Extend(const Anope::string &name, const bool &what) if (ref) return ref->Set(this); - Log(LOG_DEBUG) << "Extend for non-existent type " << name << " on " << static_cast<void *>(this); + Log(LOG_DEBUG) << "Extend for nonexistent type " << name << " on " << static_cast<void *>(this); return NULL; } - diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 6374639d8..4fb1cfa98 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -1,7 +1,7 @@ /* * * (C) 2002-2011 InspIRCd Development Team - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. */ @@ -43,7 +43,7 @@ unsigned char Anope::toupper(unsigned char c) * which is a case-insensitive equivalent to std::string. * */ - + bool ci::ci_char_traits::eq(char c1st, char c2nd) { return case_map_upper[static_cast<unsigned char>(c1st)] == case_map_upper[static_cast<unsigned char>(c2nd)]; @@ -161,4 +161,3 @@ bool sepstream::StreamEnd() { return this->pos > this->tokens.length(); } - diff --git a/src/init.cpp b/src/init.cpp index 7e5722603..515f610f2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,6 +1,6 @@ /* Initialization and related routines. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -105,7 +105,7 @@ void Anope::Fork() { #ifndef _WIN32 kill(getppid(), SIGUSR2); - + freopen("/dev/null", "r", stdin); freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr); @@ -558,4 +558,3 @@ void Anope::Init(int ac, char **av) Serialize::CheckTypes(); } - diff --git a/src/language.cpp b/src/language.cpp index 0a19729b1..8b7b0ee37 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -125,4 +125,3 @@ const char *Language::Translate(const char *lang, const char *string) return string != NULL ? string : ""; } #endif - diff --git a/src/logger.cpp b/src/logger.cpp index c681e42fa..4bfd35b2f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -1,6 +1,6 @@ /* Logging routines. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -82,7 +82,7 @@ Log::Log(LogType t, CommandSource &src, Command *_c, ChannelInfo *_ci) : u(src.G { if (!c) throw CoreException("Invalid pointers passed to Log::Log"); - + if (type != LOG_COMMAND && type != LOG_OVERRIDE && type != LOG_ADMIN) throw CoreException("This constructor does not support this log type"); @@ -129,7 +129,7 @@ Log::~Log() std::cout << this->BuildPrefix() << this->buf.str() << std::endl; FOREACH_MOD(OnLog, (this)); - + if (Config) for (unsigned i = 0; i < Config->LogInfos.size(); ++i) if (Config->LogInfos[i].HasType(this->type, this->category)) @@ -145,6 +145,13 @@ Anope::string Log::FormatSource() const return this->u->GetMask(); else if (nc) return nc->display; + else if (source) + { + Anope::string nickbuf = source->GetNick(); + if (!nickbuf.empty() && !source->ip.empty()) + nickbuf += " (" + source->ip + ")"; + return nickbuf; + } return ""; } @@ -375,7 +382,7 @@ void LogInfo::ProcessMessage(const Log *l) } } } - + tm *tm = localtime(&Anope::CurTime); if (tm->tm_mday != this->last_day) { @@ -405,4 +412,3 @@ void LogInfo::ProcessMessage(const Log *l) lf->stream << GetTimeStamp() << " " << buffer << std::endl; } } - diff --git a/src/mail.cpp b/src/mail.cpp index f909fa5a3..80a80d6d7 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -56,7 +56,7 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su return false; Configuration::Block *b = Config->GetBlock("mail"); - + if (!u) { if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty()) diff --git a/src/main.cpp b/src/main.cpp index bbcccee27..a7814a8c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ /* Services -- main source file. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/memos.cpp b/src/memos.cpp index bf8f0eb73..b04a385ca 100644 --- a/src/memos.cpp +++ b/src/memos.cpp @@ -1,6 +1,6 @@ /* MemoServ functions. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -49,7 +49,7 @@ Serializable* Memo::Unserialize(Serializable *obj, Serialize::Data &data) Anope::string owner; data["owner"] >> owner; - + bool ischan; MemoInfo *mi = MemoInfo::GetMemoInfo(owner, ischan); if (!mi) @@ -138,4 +138,3 @@ MemoInfo *MemoInfo::GetMemoInfo(const Anope::string &target, bool &ischan) return NULL; } - diff --git a/src/messages.cpp b/src/messages.cpp index ee02cc473..93c45ea87 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -1,6 +1,6 @@ /* Common message handlers * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -61,7 +61,7 @@ void Invite::Run(MessageSource &source, const std::vector<Anope::string> ¶ms if (!targ || targ->server != Me || !c || c->FindUser(targ)) return; - + FOREACH_MOD(OnInvite, (source.GetUser(), c, targ)); } @@ -119,14 +119,14 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co /* Their TS is newer, don't accept any modes from them */ else if (ts > c->creation_time) keep_their_modes = false; - + /* Update the modes for the channel */ if (keep_their_modes && !modes.empty()) /* If we are syncing, mlock is checked later in Channel::Sync. It is important to not check it here * so that Channel::SetCorrectModes can correctly detect the presence of channel mode +r. */ c->SetModesInternal(source, modes, ts, !c->syncing); - + for (std::list<SJoinUser>::const_iterator it = users.begin(), it_end = users.end(); it != it_end; ++it) { const ChannelStatus &status = it->first; @@ -147,7 +147,7 @@ void Join::SJoin(MessageSource &source, const Anope::string &chan, time_t ts, co * they aren't allowed to have (secureops etc). */ c->SetCorrectModes(u, true); - + FOREACH_MOD(OnJoinChannel, (u, c)); } @@ -365,7 +365,7 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶m FOREACH_RESULT(OnBotPrivmsg, MOD_RESULT, (u, bi, message)); if (MOD_RESULT == EVENT_STOP) return; - + bi->OnMessage(u, message); } } @@ -499,4 +499,3 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) else IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str()); } - diff --git a/src/misc.cpp b/src/misc.cpp index 0938a033c..2c879365d 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -1,6 +1,6 @@ /* Miscellaneous routines. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -651,7 +651,7 @@ Anope::string Anope::VersionBuildString() if (!flags.empty()) s += ", flags " + flags; - + return s; } @@ -763,4 +763,3 @@ Anope::string Anope::Random(size_t len) buf.append(chars[rand() % sizeof(chars)]); return buf; } - diff --git a/src/modes.cpp b/src/modes.cpp index 229945b7d..c9dfe00b6 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -1,7 +1,7 @@ /* Mode support * * (C) 2008-2011 Adam <Adam@anope.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. */ @@ -397,7 +397,7 @@ bool ModeManager::AddUserMode(UserMode *um) return false; if (ModeManager::FindUserModeByName(um->name) != NULL) return false; - + if (um->name.empty()) { um->name = stringify(++GenericUserModes); @@ -470,10 +470,10 @@ void ModeManager::RemoveUserMode(UserMode *um) unsigned want = um->mchar; if (want >= UserModesIdx.size()) return; - + if (UserModesIdx[want] != um) return; - + UserModesIdx[want] = NULL; UserModesByName.erase(um->name); @@ -495,10 +495,10 @@ void ModeManager::RemoveChannelMode(ChannelMode *cm) unsigned want = cm->mchar; if (want >= ChannelModesIdx.size()) return; - + if (ChannelModesIdx[want] != cm) return; - + ChannelModesIdx[want] = NULL; } @@ -532,7 +532,7 @@ ChannelMode *ModeManager::FindChannelModeByChar(char mode) unsigned want = mode; if (want >= ChannelModesIdx.size()) return NULL; - + return ChannelModesIdx[want]; } @@ -541,7 +541,7 @@ UserMode *ModeManager::FindUserModeByChar(char mode) unsigned want = mode; if (want >= UserModesIdx.size()) return NULL; - + return UserModesIdx[want]; } @@ -566,11 +566,11 @@ char ModeManager::GetStatusChar(char value) unsigned want = value; if (want >= ChannelModesIdx.size()) return 0; - + ChannelMode *cm = ChannelModesIdx[want]; if (cm == NULL || cm->type != MODE_STATUS || cm->mchar == value) return 0; - + return cm->mchar; } @@ -647,7 +647,7 @@ void ModeManager::ProcessModes() std::list<Anope::string> ModeStrings = BuildModeStrings(s); for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit) - IRCD->SendMode(s->bi, u, lit->c_str()); + IRCD->SendMode(s->bi, u, "%s", lit->c_str()); delete it->second; } UserStackerObjects.clear(); @@ -662,7 +662,7 @@ void ModeManager::ProcessModes() std::list<Anope::string> ModeStrings = BuildModeStrings(s); for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit) - IRCD->SendMode(s->bi, c, lit->c_str()); + IRCD->SendMode(s->bi, c, "%s", lit->c_str()); delete it->second; } ChannelStackerObjects.clear(); @@ -678,7 +678,7 @@ static void StackerDel(std::map<T *, StackerInfo *> &map, T *obj) StackerInfo *si = it->second; std::list<Anope::string> ModeStrings = BuildModeStrings(si); for (std::list<Anope::string>::iterator lit = ModeStrings.begin(), lit_end = ModeStrings.end(); lit != lit_end; ++lit) - IRCD->SendMode(si->bi, obj, lit->c_str()); + IRCD->SendMode(si->bi, obj, "%s", lit->c_str()); delete si; map.erase(it); @@ -769,21 +769,21 @@ Entry::Entry(const Anope::string &m, const Anope::string &fh) : name(m), mask(fh else this->nick = fh; } - + at = this->host.find('#'); if (at != Anope::string::npos) { this->real = this->host.substr(at + 1); this->host = this->host.substr(0, at); } - + /* If the mask is all *'s it will match anything, so just clear it */ if (this->nick.find_first_not_of("*") == Anope::string::npos) this->nick.clear(); - + if (this->user.find_first_not_of("*") == Anope::string::npos) this->user.clear(); - + if (this->host.find_first_not_of("*") == Anope::string::npos) this->host.clear(); else @@ -888,10 +888,9 @@ bool Entry::Matches(User *u, bool full) const else if (!this->host.empty() && !Anope::Match(u->GetDisplayedHost(), this->host) && !Anope::Match(u->GetCloakedHost(), this->host) && (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->ip.addr(), this->host)))) ret = false; - + if (!this->real.empty() && !Anope::Match(u->realname, this->real)) ret = false; - + return ret; } - diff --git a/src/module.cpp b/src/module.cpp index 3e377efec..0fcf8687f 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -1,6 +1,6 @@ /* Modular support * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -33,7 +33,7 @@ Module::Module(const Anope::string &modname, const Anope::string &, ModType modt if (ModuleManager::FindModule(this->name)) throw CoreException("Module already exists!"); - + if (Anope::NoThird && type & THIRD) throw ModuleException("Third party modules may not be loaded"); @@ -127,4 +127,3 @@ int ModuleVersion::GetPatch() const { return this->version_patch; } - diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 2cda9e256..ce17e61ae 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -1,6 +1,6 @@ /* Modular support * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -28,7 +28,7 @@ void ModuleManager::CleanupRuntimeDirectory() { Anope::string dirbuf = Anope::DataDir + "/runtime"; - Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; + Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment, please wait"; DIR *dirp = opendir(dirbuf.c_str()); if (!dirp) @@ -36,7 +36,7 @@ void ModuleManager::CleanupRuntimeDirectory() Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; return; } - + for (dirent *dp; (dp = readdir(dirp));) { if (!dp->d_ino) @@ -62,17 +62,17 @@ void ModuleManager::CleanupRuntimeDirectory() static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &output) { Anope::string input = Anope::ModuleDir + "/modules/" + name + ".so"; - + struct stat s; if (stat(input.c_str(), &s) == -1) return MOD_ERR_NOEXIST; else if (!S_ISREG(s.st_mode)) return MOD_ERR_NOEXIST; - + std::ifstream source(input.c_str(), std::ios_base::in | std::ios_base::binary); if (!source.is_open()) return MOD_ERR_NOEXIST; - + char *tmp_output = strdup(output.c_str()); int target_fd = mkstemp(tmp_output); if (target_fd == -1 || close(target_fd) == -1) @@ -85,7 +85,7 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out free(tmp_output); Log(LOG_DEBUG_2) << "Runtime module location: " << output; - + std::ofstream target(output.c_str(), std::ios_base::in | std::ios_base::binary); if (!target.is_open()) { @@ -103,7 +103,7 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out target.write(buffer, read_len); want -= read_len; } - + source.close(); target.close(); @@ -216,7 +216,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) dlclose(handle); return MOD_ERR_NOLOAD; } - + /* Create module. */ Anope::string nick; if (u) @@ -234,7 +234,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) Log() << "Error while loading " << modname << ": " << ex.GetReason(); moderr = MOD_ERR_EXCEPTION; } - + if (moderr != MOD_ERR_OK) { if (dlclose(handle)) @@ -263,7 +263,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) catch (const NotImplementedException &ex) { } - + if (moderr != MOD_ERR_OK) { DeleteModule(m); @@ -389,7 +389,7 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) if (!filename.empty()) unlink(filename.c_str()); #endif - + return MOD_ERR_OK; } @@ -516,7 +516,7 @@ void ModuleManager::UnloadAll() if ((m->type & j) == m->type) modules.push_back(m->name); } - + for (unsigned i = 0; i < modules.size(); ++i) { Module *m = FindModule(modules[i]); @@ -524,4 +524,3 @@ void ModuleManager::UnloadAll() UnloadModule(m, NULL); } } - diff --git a/src/nickalias.cpp b/src/nickalias.cpp index 795298cba..653e9461b 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -214,4 +214,3 @@ Serializable* NickAlias::Unserialize(Serializable *obj, Serialize::Data &data) return na; } - diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 633f5a7cb..cede8b6e4 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -31,7 +31,7 @@ NickCore::NickCore(const Anope::string &coredisplay) : Serializable("NickCore"), (*NickCoreList)[this->display] = this; if (old == NickCoreList->size()) Log(LOG_DEBUG) << "Duplicate account " << coredisplay << " in nickcore table?"; - + FOREACH_MOD(OnNickCoreCreate, (this)); } @@ -267,4 +267,3 @@ NickCore* NickCore::Find(const Anope::string &nick) return NULL; } - diff --git a/src/opertype.cpp b/src/opertype.cpp index 9438c2ff5..d7bce5df1 100644 --- a/src/opertype.cpp +++ b/src/opertype.cpp @@ -1,7 +1,7 @@ /* * * (C) 2008-2011 Robin Burchell <w00t@inspircd.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. */ @@ -145,4 +145,3 @@ const std::list<Anope::string> OperType::GetPrivs() const } return priv_list; } - diff --git a/src/pipeengine.cpp b/src/pipeengine.cpp index 0953387c1..51dfa2955 100644 --- a/src/pipeengine.cpp +++ b/src/pipeengine.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -78,4 +78,3 @@ void Pipe::Notify() { this->Write("\0", 1); } - diff --git a/src/process.cpp b/src/process.cpp index b095ab40b..6430fac46 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -1,6 +1,6 @@ /* Main processing code for Services. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -50,7 +50,7 @@ void Anope::Process(const Anope::string &buffer) static const Anope::string proto_name = ModuleManager::FindFirstOf(PROTOCOL) ? ModuleManager::FindFirstOf(PROTOCOL)->name : ""; MessageSource src(source); - + EventReturn MOD_RESULT; FOREACH_RESULT(OnMessage, MOD_RESULT, (src, command, params)); if (MOD_RESULT == EVENT_STOP) @@ -84,7 +84,7 @@ void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope: } sep.GetToken(command); - + for (Anope::string token; sep.GetToken(token);) { if (token[0] == ':') @@ -107,4 +107,3 @@ Anope::string IRCDProto::Format(const Anope::string &source, const Anope::string else return message; } - diff --git a/src/protocol.cpp b/src/protocol.cpp index c8320e25a..47a6dceee 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -360,16 +360,16 @@ bool IRCDProto::IsNickValid(const Anope::string &nick) if (nick.empty()) return false; - + Anope::string special = "[]\\`_^{|}"; - + for (unsigned i = 0; i < nick.length(); ++i) if (!(nick[i] >= 'A' && nick[i] <= 'Z') && !(nick[i] >= 'a' && nick[i] <= 'z') && special.find(nick[i]) == Anope::string::npos && (Config && Config->NickChars.find(nick[i]) == Anope::string::npos) && (!i || (!(nick[i] >= '0' && nick[i] <= '9') && nick[i] != '-'))) return false; - + return true; } @@ -502,4 +502,3 @@ unsigned IRCDMessage::GetParamCount() const { return this->param_count; } - diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 356ceb093..9502d2116 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -1,6 +1,6 @@ /* Registered channel functions * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -33,9 +33,8 @@ AutoKick::~AutoKick() if (it != this->ci->akick->end()) this->ci->akick->erase(it); - const NickAlias *na = NickAlias::Find(this->mask); - if (na != NULL) - na->nc->RemoveChannelReference(this->ci); + if (nc) + nc->RemoveChannelReference(this->ci); } } @@ -62,7 +61,7 @@ Serializable* AutoKick::Unserialize(Serializable *obj, Serialize::Data &data) ChannelInfo *ci = ChannelInfo::Find(sci); if (!ci) return NULL; - + AutoKick *ak; NickCore *nc = NickCore::Find(snc); if (obj) @@ -87,7 +86,7 @@ Serializable* AutoKick::Unserialize(Serializable *obj, Serialize::Data &data) data["reason"] >> sreason; data["mask"] >> smask; - if (nc) + if (nc) ak = ci->AddAkick(screator, nc, sreason, addtime, lastused); else ak = ci->AddAkick(screator, smask, sreason, addtime, lastused); @@ -358,7 +357,7 @@ BotInfo *ChannelInfo::WhoSends() const { if (this && this->bi) return this->bi; - + BotInfo *ChanServ = Config->GetClient("ChanServ"); if (ChanServ) return ChanServ; @@ -578,7 +577,7 @@ void ChannelInfo::EraseAkick(unsigned index) { if (this->akick->empty() || index >= this->akick->size()) return; - + delete this->GetAkick(index); } diff --git a/src/serialize.cpp b/src/serialize.cpp index 3c54b933d..6a315641d 100644 --- a/src/serialize.cpp +++ b/src/serialize.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -175,4 +175,3 @@ const std::map<Anope::string, Serialize::Type *>& Type::GetTypes() { return Types; } - diff --git a/src/servers.cpp b/src/servers.cpp index b78cd19f7..ffba8ecb1 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -1,6 +1,6 @@ /* Routines to maintain a list of connected servers * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -80,7 +80,7 @@ Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Ano } IRCD->SendBOB(); - + for (unsigned i = 0; i < Me->GetLinks().size(); ++i) { Server *s = Me->GetLinks()[i]; @@ -157,7 +157,7 @@ Server::~Server() for (unsigned i = this->links.size(); i > 0; --i) this->links[i - 1]->Delete(this->quit_reason); - + Servers::ByName.erase(this->name); if (!this->sid.empty()) Servers::ByID.erase(this->sid); @@ -336,18 +336,18 @@ void Server::Notice(BotInfo *source, const Anope::string &message) Server *Server::Find(const Anope::string &name, bool name_only) { Anope::map<Server *>::iterator it; - + if (!name_only) { it = Servers::ByID.find(name); if (it != Servers::ByID.end()) return it->second; } - + it = Servers::ByName.find(name); if (it != Servers::ByName.end()) return it->second; - + return NULL; } @@ -358,4 +358,3 @@ Server* Servers::GetUplink() return Me->GetLinks()[i]; return NULL; } - diff --git a/src/socket_clients.cpp b/src/socket_clients.cpp index bb0618f31..e9c756d76 100644 --- a/src/socket_clients.cpp +++ b/src/socket_clients.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -96,4 +96,3 @@ void ClientSocket::OnError(const Anope::string &error) { Log(LOG_DEBUG) << "Socket error: " << error; } - diff --git a/src/socket_transport.cpp b/src/socket_transport.cpp index 070807264..60f7acbdb 100644 --- a/src/socket_transport.cpp +++ b/src/socket_transport.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -32,7 +32,7 @@ bool BufferedSocket::ProcessRead() return false; if (len < 0) return SocketEngine::IgnoreErrno(); - + tbuffer[len] = 0; this->read_buffer.append(tbuffer); this->recv_len = len; @@ -130,7 +130,7 @@ bool BinarySocket::ProcessRead() int len = this->io->Recv(this, tbuffer, sizeof(tbuffer)); if (len <= 0) return false; - + return this->Read(tbuffer, len); } @@ -196,4 +196,3 @@ bool BinarySocket::Read(const char *buffer, size_t l) { return true; } - diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index f132ba2b9..f20459988 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -28,7 +28,7 @@ void SocketEngine::Init() if (EngineHandle == -1) throw SocketException("Could not initialize epoll socket engine: " + Anope::LastError()); - + events.resize(DefaultSize); } @@ -46,7 +46,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) bool before_registered = s->flags[SF_READABLE] || s->flags[SF_WRITABLE]; s->flags[flag] = set; - + bool now_registered = s->flags[SF_READABLE] || s->flags[SF_WRITABLE]; epoll_event ev; @@ -65,7 +65,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) mod = EPOLL_CTL_MOD; else return; - + if (epoll_ctl(EngineHandle, mod, ev.data.fd, &ev) == -1) throw SocketException("Unable to epoll_ctl() fd " + stringify(ev.data.fd) + " to epoll: " + Anope::LastError()); } @@ -119,4 +119,3 @@ void SocketEngine::Process() delete s; } } - diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 9ccf128d5..a6dd8b571 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -39,7 +39,7 @@ void SocketEngine::Init() if (kq_fd < 0) throw SocketException("Unable to create kqueue engine: " + Anope::LastError()); - + change_events.resize(DefaultSize); event_events.resize(DefaultSize); } @@ -56,7 +56,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) return; s->flags[flag] = set; - + int mod; if (flag == SF_READABLE) mod = EVFILT_READ; @@ -121,4 +121,3 @@ void SocketEngine::Process() delete s; } } - diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 8475dd414..1df4285e6 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -113,7 +113,7 @@ void SocketEngine::Process() for (unsigned i = 0, processed = 0; i < events.size() && processed != static_cast<unsigned>(total); ++i) { pollfd *ev = &events[i]; - + if (ev->revents != 0) ++processed; @@ -146,4 +146,3 @@ void SocketEngine::Process() delete s; } } - diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index 86b2085ea..8853b546a 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -46,7 +46,7 @@ void SocketEngine::Change(Socket *s, bool set, SocketFlag flag) bool before_registered = s->flags[SF_READABLE] || s->flags[SF_WRITABLE]; s->flags[flag] = set; - + bool now_registered = s->flags[SF_READABLE] || s->flags[SF_WRITABLE]; if (!before_registered && now_registered) @@ -146,4 +146,3 @@ void SocketEngine::Process() } } } - diff --git a/src/sockets.cpp b/src/sockets.cpp index f15f0ccbd..e2a55810e 100644 --- a/src/sockets.cpp +++ b/src/sockets.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -95,6 +95,41 @@ Anope::string sockaddrs::addr() const return ""; } +Anope::string sockaddrs::reverse() const +{ + char address[128]; + + switch (sa.sa_family) + { + case AF_INET6: + { + static const char hex[] = "0123456789abcdef"; + unsigned reverse_ip_count = 0; + for (int j = 15; j >= 0; --j) + { + address[reverse_ip_count++] = hex[sa6.sin6_addr.s6_addr[j] & 0xF]; + address[reverse_ip_count++] = '.'; + address[reverse_ip_count++] = hex[sa6.sin6_addr.s6_addr[j] >> 4]; + address[reverse_ip_count++] = '.'; + } + /* Remove the last '.' */ + address[reverse_ip_count - 1] = 0; + return address; + } + case AF_INET: + { + unsigned long forward = sa4.sin_addr.s_addr; + in_addr rev; + rev.s_addr = forward << 24 | (forward & 0xFF00) << 8 | (forward & 0xFF0000) >> 8 | forward >> 24; + if (inet_ntop(AF_INET, &rev, address, sizeof(address))) + return address; + break; + } + } + + return ""; +} + bool sockaddrs::ipv6() const { return sa.sa_family == AF_INET6; @@ -282,7 +317,7 @@ bool cidr::operator<(const cidr &other) const { if (this->addr.sa.sa_family != other.addr.sa.sa_family) return this->addr.sa.sa_family < other.addr.sa.sa_family; - + switch (this->addr.sa.sa_family) { case AF_INET: @@ -574,4 +609,3 @@ bool SocketEngine::IgnoreErrno() || GetLastError() == EINTR || GetLastError() == EINPROGRESS; } - diff --git a/src/threadengine.cpp b/src/threadengine.cpp index f392ac472..b692b75b2 100644 --- a/src/threadengine.cpp +++ b/src/threadengine.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/timers.cpp b/src/timers.cpp index a4538c05d..791666a6b 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -1,6 +1,6 @@ /* Timer stuff. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -124,4 +124,3 @@ void TimerManager::DeleteTimersFor(Module *m) delete it->second; } } - diff --git a/src/tools/anoperc.in b/src/tools/anoperc.in index 2802e57e2..541fb92ff 100644 --- a/src/tools/anoperc.in +++ b/src/tools/anoperc.in @@ -2,7 +2,7 @@ # # Configuration script for Services # -# (C) 2003-2016 Anope Team +# (C) 2003-2017 Anope Team # Contact us at team@anope.org # # Please read COPYING and README for further details. diff --git a/src/tools/anopesmtp.cpp b/src/tools/anopesmtp.cpp index 392c6e627..dd7d1eef1 100644 --- a/src/tools/anopesmtp.cpp +++ b/src/tools/anopesmtp.cpp @@ -1,6 +1,6 @@ /* smtp stuff handler for win32. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -107,6 +107,18 @@ static std::string get_logname(struct tm *tm = NULL) return name; } +/* TimeStamp for Email Header */ +static std::string GetTimeStamp() +{ + char tbuf[256]; + time_t t = time(NULL); + struct tm *tm = localtime(&t); + + strftime(tbuf, sizeof(tbuf) - 1, "%a, %d %b %Y %H:%M:%S %z", tm); + + return tbuf; +} + /* Log stuff to the log file with a datestamp. Note that errno is * preserved by this routine and log_perror(). */ @@ -288,7 +300,7 @@ int smtp_send_email() if (!smtp_send("HELO anope\r\n")) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -311,7 +323,7 @@ int smtp_send_email() if (!smtp_send(buf)) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -331,7 +343,7 @@ int smtp_send_email() if (!smtp_send(buf)) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -350,7 +362,7 @@ int smtp_send_email() if (!smtp_send("DATA\r\n")) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -370,13 +382,13 @@ int smtp_send_email() for (std::vector<std::string>::const_iterator it = smail.smtp_headers.begin(), it_end = smail.smtp_headers.end(); it != it_end; ++it) if (!smtp_send(it->c_str())) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } if (!smtp_send("\r\n")) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -386,7 +398,7 @@ int smtp_send_email() { if (!smtp_send(it->c_str())) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } } @@ -395,7 +407,7 @@ int smtp_send_email() if (!smtp_send("\r\n.\r\n")) { - alog("SMTP: error writting to socket"); + alog("SMTP: error writing to socket"); return 0; } @@ -417,7 +429,7 @@ int main(int argc, char *argv[]) if (argc == 1) return 0; - + if (argc == 3 && !strcmp(argv[2], "--debug")) smtp_debug = 1; @@ -468,6 +480,7 @@ int main(int argc, char *argv[]) break; else { + smail.smtp_headers.push_back("Date: " + GetTimeStamp() + "\r\n"); headers_done = true; smail.smtp_body.push_back(strip(buf) + "\r\n"); } diff --git a/src/uplink.cpp b/src/uplink.cpp index df38f98f2..666c9dfa3 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -1,6 +1,6 @@ /* * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/users.cpp b/src/users.cpp index 264f5ceba..9ccfb1743 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1,6 +1,6 @@ /* Routines to maintain a list of online users. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -141,7 +141,7 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts) /* Sanity check to make sure we don't segfault */ if (newnick.empty()) throw CoreException("User::ChangeNick() got a bad argument"); - + this->super_admin = false; Log(this, "nick") << "(" << this->realname << ") changed nick to " << newnick; @@ -155,7 +155,7 @@ void User::ChangeNick(const Anope::string &newnick, time_t ts) NickAlias *old_na = NickAlias::Find(this->nick); if (old_na && (this->IsIdentified(true) || this->IsRecognized())) old_na->last_seen = Anope::CurTime; - + UserListByNick.erase(this->nick); this->nick = newnick; @@ -401,7 +401,7 @@ void User::Login(NickCore *core) if (this->server->IsSynced()) Log(this, "account") << "is now identified as " << this->nc->display; - + FOREACH_MOD(OnUserLogin, (this)); } @@ -409,7 +409,7 @@ void User::Logout() { if (!this->nc) return; - + Log(this, "account") << "is no longer identified as " << this->nc->display; std::list<User *>::iterator it = std::find(this->nc->users.begin(), this->nc->users.end(), this); @@ -781,7 +781,7 @@ Anope::string User::Mask() const sockaddrs addr(mhost); if (addr.valid() && addr.sa.sa_family == AF_INET) { - size_t dot = mhost.find('.'); + size_t dot = mhost.rfind('.'); mask += mhost.substr(0, dot) + (dot == Anope::string::npos ? "" : ".*"); } else @@ -816,7 +816,7 @@ bool User::BadPassword() User* User::Find(const Anope::string &name, bool nick_only) { - if (!nick_only && IRCD->RequiresID) + if (!nick_only && IRCD && IRCD->RequiresID) { user_map::iterator it = UserListByUID.find(name); if (it != UserListByUID.end()) @@ -839,4 +839,3 @@ void User::QuitUsers() delete *it; quitting_users.clear(); } - diff --git a/src/version.sh b/src/version.sh index cc83d73e7..8fe971e6e 100644 --- a/src/version.sh +++ b/src/version.sh @@ -2,6 +2,5 @@ VERSION_MAJOR=2 VERSION_MINOR=0 -VERSION_PATCH=5 +VERSION_PATCH=6 VERSION_EXTRA="-git" - diff --git a/src/win32/Config.cs b/src/win32/Config.cs index d7c9661ec..a022d5755 100644 --- a/src/win32/Config.cs +++ b/src/win32/Config.cs @@ -1,7 +1,7 @@ /*
* Config.cs - Windows Configuration
*
- * (C) 2003-2016 Anope Team
+ * (C) 2003-2017 Anope Team
* Contact us at team@anope.org
*
* This program is free but copyrighted software; see the file COPYING for
diff --git a/src/win32/anope_windows.h b/src/win32/anope_windows.h index 14c83b4d4..84cd8b382 100644 --- a/src/win32/anope_windows.h +++ b/src/win32/anope_windows.h @@ -1,7 +1,7 @@ /* POSIX emulation layer for Windows. * * (C) 2008-2011 Robin Burchell <w00t@inspircd.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. * diff --git a/src/win32/dir/dir.cpp b/src/win32/dir/dir.cpp index d660c9694..ff1a13934 100644 --- a/src/win32/dir/dir.cpp +++ b/src/win32/dir/dir.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -8,7 +8,7 @@ #include "dir.h" #include <stdio.h> - + DIR *opendir(const char *path) { char real_path[MAX_PATH]; diff --git a/src/win32/dir/dir.h b/src/win32/dir/dir.h index a6c9a055f..9aa5e1b52 100644 --- a/src/win32/dir/dir.h +++ b/src/win32/dir/dir.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -21,7 +21,7 @@ struct DIR WIN32_FIND_DATA data; bool read_first; }; - + DIR *opendir(const char *); dirent *readdir(DIR *); int closedir(DIR *); diff --git a/src/win32/dl/dl.cpp b/src/win32/dl/dl.cpp index bdcbe636c..10dd02358 100644 --- a/src/win32/dl/dl.cpp +++ b/src/win32/dl/dl.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/dl/dl.h b/src/win32/dl/dl.h index 81c115fef..cf724e482 100644 --- a/src/win32/dl/dl.h +++ b/src/win32/dl/dl.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/pipe/pipe.cpp b/src/win32/pipe/pipe.cpp index 70690ab2b..8df71e546 100644 --- a/src/win32/pipe/pipe.cpp +++ b/src/win32/pipe/pipe.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -56,6 +56,6 @@ int pipe(int fds[2]) fds[0] = cfd; fds[1] = afd; - + return 0; } diff --git a/src/win32/pipe/pipe.h b/src/win32/pipe/pipe.h index d77d0706b..42479e08a 100644 --- a/src/win32/pipe/pipe.h +++ b/src/win32/pipe/pipe.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/pthread/pthread.cpp b/src/win32/pthread/pthread.cpp index 36b8cd54d..634735954 100644 --- a/src/win32/pthread/pthread.cpp +++ b/src/win32/pthread/pthread.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/pthread/pthread.h b/src/win32/pthread/pthread.h index 18909a17d..67b11ee82 100644 --- a/src/win32/pthread/pthread.h +++ b/src/win32/pthread/pthread.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/resource.h b/src/win32/resource.h index 0fb755b56..ac74d9d81 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -1,6 +1,6 @@ /* * - * (C) 2005-2016 Anope Team + * (C) 2005-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -10,19 +10,19 @@ // Microsoft Developer Studio generated include file. // Used by Win32GUI.rc // -#define VER_ANOPE 1 -#define MANIFEST_RESOURCE_ID 2 -#define ICON_APP 129 +#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 +#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 diff --git a/src/win32/sigaction/sigaction.cpp b/src/win32/sigaction/sigaction.cpp index 17faaf2fb..552b051a6 100644 --- a/src/win32/sigaction/sigaction.cpp +++ b/src/win32/sigaction/sigaction.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/sigaction/sigaction.h b/src/win32/sigaction/sigaction.h index c517ba16d..c8ec11475 100644 --- a/src/win32/sigaction/sigaction.h +++ b/src/win32/sigaction/sigaction.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/socket.cpp b/src/win32/socket.cpp index 489192679..b4e7efe1a 100644 --- a/src/win32/socket.cpp +++ b/src/win32/socket.cpp @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -86,7 +86,7 @@ int windows_inet_pton(int af, const char *src, void *dst) } return 1; } - + return 0; } diff --git a/src/win32/socket.h b/src/win32/socket.h index a8064589e..7b87b2a11 100644 --- a/src/win32/socket.h +++ b/src/win32/socket.h @@ -1,6 +1,6 @@ /* POSIX emulation layer for Windows. * - * (C) 2008-2016 Anope Team + * (C) 2008-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. diff --git a/src/win32/win32.rc.cmake b/src/win32/win32.rc.cmake index 1e86c7e0d..519b1a7d6 100644 --- a/src/win32/win32.rc.cmake +++ b/src/win32/win32.rc.cmake @@ -54,7 +54,7 @@ BEGIN VALUE "FileDescription", "Anope IRC Services" VALUE "FileVersion", "@VERSION_FULL@" VALUE "InternalName", "Anope" - VALUE "LegalCopyright", "Copyright (C) 2003-2016 Anope Team" + VALUE "LegalCopyright", "Copyright (C) 2003-2017 Anope Team" VALUE "OriginalFilename", "anope.exe" VALUE "ProductName", "Anope" VALUE "ProductVersion", "@VERSION_DOTTED@" diff --git a/src/win32/windows.cpp b/src/win32/windows.cpp index ac6801cba..a4c6eff49 100644 --- a/src/win32/windows.cpp +++ b/src/win32/windows.cpp @@ -1,7 +1,7 @@ /* POSIX emulation layer for Windows. * * (C) 2008-2011 Robin Burchell <w00t@inspircd.org> - * (C) 2008-2016 Anope Team <team@anope.org> + * (C) 2008-2017 Anope Team <team@anope.org> * * Please read COPYING and README for further details. * @@ -56,11 +56,11 @@ USHORT WindowsGetLanguage(const Anope::string &lang) for (int i = 0; i < sizeof(WindowsLanguages) / sizeof(WindowsLanguage); ++i) { WindowsLanguage &l = WindowsLanguages[i]; - + if (lang == l.languageName || !lang.find(l.languageName + ".")) return l.windowsLanguageName; } - + return LANG_NEUTRAL; } @@ -73,10 +73,10 @@ int gettimeofday(timeval *tv, void *) { SYSTEMTIME st; GetSystemTime(&st); - + tv->tv_sec = Anope::CurTime; tv->tv_usec = st.wMilliseconds; - + return 0; } @@ -248,7 +248,7 @@ int mkstemp(char *input) errno = EEXIST; return -1; } - + int fd = open(input, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE); return fd; } diff --git a/src/xline.cpp b/src/xline.cpp index 21cbc2501..e6c8d3eb4 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -1,6 +1,6 @@ /* XLine functions. * - * (C) 2003-2016 Anope Team + * (C) 2003-2017 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. @@ -467,4 +467,3 @@ XLine *XLineManager::CheckAllXLines(User *u) void XLineManager::OnExpire(const XLine *x) { } - |