summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-17 12:49:48 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-17 12:49:48 +0200
commitb9e11915a976daaf790ebc763aff56e19fd49e0f (patch)
tree7c69dc9427a8a0470ff12f772846b956e747bf78 /src
parentf9fd78c01623514a060c607534fc52cb73140200 (diff)
parentc7a26bc21629ddd4103dac1ff7f9acf45a2c4d35 (diff)
Merge insp20
Diffstat (limited to 'src')
-rw-r--r--src/configreader.cpp3
-rw-r--r--src/coremods/core_list.cpp3
-rw-r--r--src/coremods/core_oper/cmd_kill.cpp4
-rw-r--r--src/coremods/core_stats.cpp2
-rw-r--r--src/inspircd.cpp10
-rw-r--r--src/mode.cpp19
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp3
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp8
-rw-r--r--src/modules/m_censor.cpp2
-rw-r--r--src/modules/m_dccallow.cpp38
-rw-r--r--src/modules/m_sasl.cpp2
-rw-r--r--src/modules/m_securelist.cpp2
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp2
-rw-r--r--src/usermanager.cpp1
14 files changed, 67 insertions, 32 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp
index e607c6e7d..8a432e82f 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -409,6 +409,7 @@ void ServerConfig::Fill()
HideBans = security->getBool("hidebans");
HideWhoisServer = security->getString("hidewhois");
HideKillsServer = security->getString("hidekills");
+ HideULineKills = security->getBool("hideulinekills");
RestrictBannedUsers = security->getBool("restrictbannedusers", true);
GenericOper = security->getBool("genericoper");
SyntaxHints = options->getBool("syntaxhints");
@@ -567,7 +568,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
// write once here, to try it out and make sure its ok
if (valid)
- ServerInstance->WritePID(this->PID);
+ ServerInstance->WritePID(this->PID, !old);
ConfigTagList binds = ConfTags("bind");
if (binds.first == binds.second)
diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp
index 67829a55e..6a62d122f 100644
--- a/src/coremods/core_list.cpp
+++ b/src/coremods/core_list.cpp
@@ -55,8 +55,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
- /* Work around mIRC suckyness. YOU SUCK, KHALED! */
- if (parameters.size() == 1)
+ if ((parameters.size() == 1) && (!parameters[0].empty()))
{
if (parameters[0][0] == '<')
{
diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp
index 0d111ce02..e75566e2f 100644
--- a/src/coremods/core_oper/cmd_kill.cpp
+++ b/src/coremods/core_oper/cmd_kill.cpp
@@ -93,7 +93,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
if (!IS_LOCAL(u))
{
// remote kill
- if (!user->server->IsULine())
+ if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
ServerInstance->SNO->WriteToSnoMask('K', "Remote kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
this->lastuuid = u->uuid;
}
@@ -104,7 +104,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User
* XXX - this isn't entirely correct, servers A - B - C, oper on A, client on C. Oper kills client, A and B will get remote kill
* snotices, C will get a local kill snotice. this isn't accurate, and needs fixing at some stage. -- w00t
*/
- if (!user->server->IsULine())
+ if ((!ServerInstance->Config->HideULineKills) || (!user->server->IsULine()))
{
if (IS_LOCAL(user))
ServerInstance->SNO->WriteGlobalSno('k',"Local Kill by %s: %s (%s)", user->nick.c_str(), u->GetFullRealHost().c_str(), parameters[1].c_str());
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index d890d19ea..ee0c50db2 100644
--- a/src/coremods/core_stats.cpp
+++ b/src/coremods/core_stats.cpp
@@ -35,7 +35,7 @@ class CommandStats : public Command
public:
/** Constructor for stats.
*/
- CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = "<stats-symbol> [<servername>]"; }
+ CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { allow_empty_last_param = false; syntax = "<stats-symbol> [<servername>]"; }
/** Handle command.
* @param parameters The parameters to the command
* @param user The user issuing the command
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index eb24cdea0..5d4d8081f 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -194,7 +194,7 @@ bool InspIRCd::DaemonSeed()
#endif
}
-void InspIRCd::WritePID(const std::string &filename)
+void InspIRCd::WritePID(const std::string& filename, bool exitonfail)
{
#ifndef _WIN32
std::string fname(filename);
@@ -208,9 +208,11 @@ void InspIRCd::WritePID(const std::string &filename)
}
else
{
- std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl;
- this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s', exiting.",fname.c_str());
- Exit(EXIT_STATUS_PID);
+ if (exitonfail)
+ std::cout << "Failed to write PID-file '" << fname << "', exiting." << std::endl;
+ this->Logs->Log("STARTUP", LOG_DEFAULT, "Failed to write PID-file '%s'%s", fname.c_str(), (exitonfail ? ", exiting." : ""));
+ if (exitonfail)
+ Exit(EXIT_STATUS_PID);
}
#endif
}
diff --git a/src/mode.cpp b/src/mode.cpp
index b29eda828..3762dc52e 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -791,24 +791,33 @@ std::string ModeParser::GiveModeList(ModeType mt)
return type1 + "," + type2 + "," + type3 + "," + type4;
}
+struct PrefixModeSorter
+{
+ bool operator()(PrefixMode* lhs, PrefixMode* rhs)
+ {
+ return lhs->GetPrefixRank() < rhs->GetPrefixRank();
+ }
+};
+
std::string ModeParser::BuildPrefixes(bool lettersAndModes)
{
std::string mletters;
std::string mprefixes;
- insp::flat_map<int, std::pair<char, char> > prefixes;
+ std::vector<PrefixMode*> prefixes;
const PrefixModeList& list = GetPrefixModes();
for (PrefixModeList::const_iterator i = list.begin(); i != list.end(); ++i)
{
PrefixMode* pm = *i;
if (pm->GetPrefix())
- prefixes[pm->GetPrefixRank()] = std::make_pair(pm->GetPrefix(), pm->GetModeChar());
+ prefixes.push_back(pm);
}
- for (insp::flat_map<int, std::pair<char, char> >::reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
+ std::sort(prefixes.begin(), prefixes.end(), PrefixModeSorter());
+ for (std::vector<PrefixMode*>::const_reverse_iterator n = prefixes.rbegin(); n != prefixes.rend(); ++n)
{
- mletters = mletters + n->second.first;
- mprefixes = mprefixes + n->second.second;
+ mletters += (*n)->GetPrefix();
+ mprefixes += (*n)->GetModeChar();
}
return lettersAndModes ? "(" + mprefixes + ")" + mletters : mletters;
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index bda4e6a48..e5cb8ee90 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -1076,6 +1076,9 @@ info_done_dealloc:
if (ret > 0)
{
reader.appendto(recvq);
+ // Schedule a read if there is still data in the GnuTLS buffer
+ if (gnutls_record_check_pending(sess) > 0)
+ SocketEngine::ChangeEventMask(user, FD_ADD_TRIAL_READ);
return 1;
}
else if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 4df0d8962..8467cc6d4 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -631,8 +631,14 @@ class OpenSSLIOHook : public SSLIOHook
if (ret > 0)
{
recvq.append(buffer, ret);
+ int mask = 0;
+ // Schedule a read if there is still data in the OpenSSL buffer
+ if (SSL_pending(sess) > 0)
+ mask |= FD_ADD_TRIAL_READ;
if (data_to_write)
- SocketEngine::ChangeEventMask(user, FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE);
+ mask |= FD_WANT_POLL_READ | FD_WANT_SINGLE_WRITE;
+ if (mask != 0)
+ SocketEngine::ChangeEventMask(user, mask);
return 1;
}
else if (ret == 0)
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 7d8c74024..c8b6b73a8 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -79,7 +79,7 @@ class ModuleCensor : public Module
{
if (index->second.empty())
{
- user->WriteNumeric(ERR_WORDFILTERED, ((Channel*)dest)->name, index->first, "Your message contained a censored word, and was blocked");
+ user->WriteNumeric(ERR_WORDFILTERED, ((target_type == TYPE_CHANNEL) ? ((Channel*)dest)->name : ((User*)dest)->nick), index->first, "Your message contained a censored word, and was blocked");
return MOD_RES_DENY;
}
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 21cc97aa5..d8fbef69a 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -323,29 +323,43 @@ class ModuleDCCAllow : public Module
return MOD_RES_PASSTHRU;
}
- // tokenize
- std::stringstream ss(text);
- std::string buf;
- std::vector<std::string> tokens;
-
- while (ss >> buf)
- tokens.push_back(buf);
-
- if (tokens.size() < 2)
+ std::string buf = text.substr(5);
+ size_t s = buf.find(' ');
+ if (s == std::string::npos)
return MOD_RES_PASSTHRU;
- irc::string type = tokens[1].c_str();
+ irc::string type = assign(buf.substr(0, s));
ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow");
bool blockchat = conftag->getBool("blockchat");
if (type == "SEND")
{
- if (tokens.size() < 3)
+ size_t first;
+
+ buf = buf.substr(s + 1);
+
+ if (!buf.empty() && buf[0] == '"')
+ {
+ s = buf.find('"', 1);
+
+ if (s == std::string::npos || s <= 1)
+ return MOD_RES_PASSTHRU;
+
+ --s;
+ first = 1;
+ }
+ else
+ {
+ s = buf.find(' ');
+ first = 0;
+ }
+
+ if (s == std::string::npos)
return MOD_RES_PASSTHRU;
std::string defaultaction = conftag->getString("action");
- std::string filename = tokens[2];
+ std::string filename = buf.substr(first, s);
bool found = false;
for (unsigned int i = 0; i < bfl.size(); i++)
diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp
index 02a302c11..2b247a198 100644
--- a/src/modules/m_sasl.cpp
+++ b/src/modules/m_sasl.cpp
@@ -245,7 +245,7 @@ class SaslAuthenticator
SendSASL(params);
- if (parameters[0][0] == '*')
+ if (parameters[0].c_str()[0] == '*')
{
this->Abort();
return false;
diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp
index b6c6ce174..b925c3f37 100644
--- a/src/modules/m_securelist.cpp
+++ b/src/modules/m_securelist.cpp
@@ -63,7 +63,7 @@ class ModuleSecureList : public Module
/* Not exempt, BOOK EM DANNO! */
user->WriteNotice("*** You cannot list within the first " + ConvToStr(WaitTime) + " seconds of connecting. Please try again later.");
- /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't
+ /* Some clients (e.g. mIRC, various java chat applets) muck up if they don't
* receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
*/
user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index 7b0478229..64ca72977 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -56,7 +56,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
sdest = FindRouteTarget(routing.serverdest);
if (!sdest)
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistant server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistent server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
return;
}
}
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 7b4bbe281..5891b42f0 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -151,6 +151,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
{
ServerInstance->Logs->Log("USERS", LOG_DEBUG, "Internal error on new connection");
this->QuitUser(New, "Internal error handling connection");
+ return;
}
if (ServerInstance->Config->RawLog)