summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_dns.cpp26
-rw-r--r--src/coremods/core_info/cmd_modules.cpp12
-rw-r--r--src/modules.cpp6
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp13
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp14
-rw-r--r--src/modules/m_restrictmsg.cpp3
-rw-r--r--src/modules/m_spanningtree/cachetimer.h4
-rw-r--r--src/modules/m_spanningtree/compat.cpp2
-rw-r--r--src/modules/m_spanningtree/delline.cpp2
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp9
-rw-r--r--src/modules/m_spanningtree/fmode.cpp4
-rw-r--r--src/modules/m_spanningtree/main.cpp16
-rw-r--r--src/modules/m_spanningtree/netburst.cpp15
-rw-r--r--src/modules/m_spanningtree/override_map.cpp2
-rw-r--r--src/modules/m_spanningtree/server.cpp6
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp2
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp14
-rw-r--r--src/modules/m_spanningtree/treeserver.h4
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp16
-rw-r--r--src/modules/m_spanningtree/uid.cpp10
-rw-r--r--src/modules/m_spanningtree/utils.cpp14
-rw-r--r--src/modules/m_spanningtree/utils.h6
22 files changed, 110 insertions, 90 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index b332368fc..01e911efb 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -27,6 +27,13 @@
#pragma comment(lib, "Iphlpapi.lib")
#endif
+namespace DNS
+{
+ /** Maximum value of a dns request id, 16 bits wide, 0xFFFF.
+ */
+ const unsigned int MAX_REQUEST_ID = 0xFFFF;
+}
+
using namespace DNS;
/** A full packet sent or recieved to/from the nameserver
@@ -367,7 +374,18 @@ class MyManager : public Manager, public Timer, public EventHandler
*/
void AddCache(Query& r)
{
- const ResourceRecord& rr = r.answers[0];
+ // Determine the lowest TTL value and use that as the TTL of the cache entry
+ unsigned int cachettl = UINT_MAX;
+ for (std::vector<ResourceRecord>::const_iterator i = r.answers.begin(); i != r.answers.end(); ++i)
+ {
+ const ResourceRecord& rr = *i;
+ if (rr.ttl < cachettl)
+ cachettl = rr.ttl;
+ }
+
+ ResourceRecord& rr = r.answers.front();
+ // Set TTL to what we've determined to be the lowest
+ rr.ttl = cachettl;
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "cache: added cache for " + rr.name + " -> " + rr.rdata + " ttl: " + ConvToStr(rr.ttl));
this->cache[r.question] = r;
}
@@ -457,11 +475,15 @@ class MyManager : public Manager, public Timer, public EventHandler
if (SocketEngine::SendTo(this, buffer, len, 0, &this->myserver.sa, this->myserver.sa_size()) != len)
throw Exception("DNS: Unable to send query");
+
+ // Add timer for timeout
+ ServerInstance->Timers.AddTimer(req);
}
void RemoveRequest(DNS::Request* req)
{
- this->requests[req->id] = NULL;
+ if (requests[req->id] == req)
+ requests[req->id] = NULL;
}
std::string GetErrorStr(Error e)
diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp
index cee370870..0a1420e13 100644
--- a/src/coremods/core_info/cmd_modules.cpp
+++ b/src/coremods/core_info/cmd_modules.cpp
@@ -58,19 +58,19 @@ CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, Us
if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
{
- std::string flags("SvcC");
+ std::string flags("vcC");
int pos = 0;
- for (int mult = 1; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
+ for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
if (!(V.Flags & mult))
flags[pos] = '-';
#ifdef PURE_STATIC
- user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
- user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
+ user->SendText(":%s 702 %s :%s %s :%s", ServerInstance->Config->ServerName.c_str(),
+ user->nick.c_str(), m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
#else
std::string srcrev = m->ModuleDLLManager->GetVersion();
- user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
- user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
+ user->SendText(":%s 702 %s :%s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
+ user->nick.c_str(), m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
#endif
}
else
diff --git a/src/modules.cpp b/src/modules.cpp
index a7acb24d0..b8982579c 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -337,12 +337,6 @@ bool ModuleManager::CanUnload(Module* mod)
ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, LastModuleError);
return false;
}
- if (mod->GetVersion().Flags & VF_STATIC)
- {
- LastModuleError = "Module " + mod->ModuleSourceFile + " not unloadable (marked static)";
- ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, LastModuleError);
- return false;
- }
mod->dying = true;
return true;
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index a2bdb76ee..d33403aba 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -1029,6 +1029,7 @@ info_done_dealloc:
}
GnuTLS::Profile* GetProfile() { return profile; }
+ bool IsHandshakeDone() const { return (status == ISSL_HANDSHAKEN); }
};
int GnuTLS::X509Credentials::cert_callback(gnutls_session_t sess, const gnutls_datum_t* req_ca_rdn, int nreqs, const gnutls_pk_algorithm_t* sign_algos, int sign_algos_length, cert_cb_last_param_type* st)
@@ -1204,6 +1205,18 @@ class ModuleSSLGnuTLS : public Module
if (hook && hook->prov->creator == this)
static_cast<GnuTLSIOHook*>(hook)->TellCiphersAndFingerprint(user);
}
+
+ ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
+ {
+ if ((user->eh.GetIOHook()) && (user->eh.GetIOHook()->prov->creator == this))
+ {
+ GnuTLSIOHook* iohook = static_cast<GnuTLSIOHook*>(user->eh.GetIOHook());
+ if (!iohook->IsHandshakeDone())
+ return MOD_RES_DENY;
+ }
+
+ return MOD_RES_PASSTHRU;
+ }
};
MODULE_INIT(ModuleSSLGnuTLS)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 0fd4608be..c8a035fac 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -680,6 +680,8 @@ class OpenSSLIOHook : public SSLIOHook
out.append(SSL_get_version(sess)).push_back('-');
out.append(SSL_get_cipher(sess));
}
+
+ bool IsHandshakeDone() const { return (status == ISSL_OPEN); }
};
static void StaticSSLInfoCallback(const SSL* ssl, int where, int rc)
@@ -831,6 +833,18 @@ class ModuleSSLOpenSSL : public Module
}
}
+ ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
+ {
+ if ((user->eh.GetIOHook()) && (user->eh.GetIOHook()->prov->creator == this))
+ {
+ OpenSSLIOHook* iohook = static_cast<OpenSSLIOHook*>(user->eh.GetIOHook());
+ if (!iohook->IsHandshakeDone())
+ return MOD_RES_DENY;
+ }
+
+ return MOD_RES_PASSTHRU;
+ }
+
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides SSL support for clients", VF_VENDOR);
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
index e0887e587..279775d48 100644
--- a/src/modules/m_restrictmsg.cpp
+++ b/src/modules/m_restrictmsg.cpp
@@ -33,8 +33,9 @@ class ModuleRestrictMsg : public Module
// message allowed if:
// (1) the sender is opered
// (2) the recipient is opered
+ // (3) the recipient is on a ulined server
// anything else, blocked.
- if (u->IsOper() || user->IsOper())
+ if (u->IsOper() || user->IsOper() || u->server->IsULine())
{
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_spanningtree/cachetimer.h b/src/modules/m_spanningtree/cachetimer.h
index 89933cc4b..cffbe3578 100644
--- a/src/modules/m_spanningtree/cachetimer.h
+++ b/src/modules/m_spanningtree/cachetimer.h
@@ -19,9 +19,7 @@
#pragma once
-/** Create a timer which recurs every second, we inherit from Timer.
- * Timer is only one-shot however, so at the end of each Tick() we simply
- * insert another of ourselves into the pending queue :)
+/** Timer that fires when we need to refresh the IP cache of servers
*/
class CacheRefreshTimer : public Timer
{
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index c2ee940fc..ab5ee269e 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -473,7 +473,7 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std:
// If the source of this SERVER message is not bursting, then new servers it introduces are bursting
TreeServer* server = TreeServer::Get(who);
if (!server->IsBursting())
- params.insert(params.begin()+2, "burst=" + ConvToStr(ServerInstance->Time()*1000));
+ params.insert(params.begin()+2, "burst=" + ConvToStr(((uint64_t)ServerInstance->Time())*1000));
}
else if (cmd == "BURST")
{
diff --git a/src/modules/m_spanningtree/delline.cpp b/src/modules/m_spanningtree/delline.cpp
index c76af2fb7..f790dc885 100644
--- a/src/modules/m_spanningtree/delline.cpp
+++ b/src/modules/m_spanningtree/delline.cpp
@@ -26,7 +26,7 @@ CmdResult CommandDelLine::Handle(User* user, std::vector<std::string>& params)
{
const std::string& setter = user->nick;
- /* NOTE: No check needed on 'user', this function safely handles NULL */
+ // XLineManager::DelLine() returns true if the xline existed, false if it didn't
if (ServerInstance->XLines->DelLine(params[1].c_str(), params[0], user))
{
ServerInstance->SNO->WriteToSnoMask('X',"%s removed %s%s on %s", setter.c_str(),
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index e29aa09d7..687bf305e 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -152,7 +152,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params)
}
}
- /* First up, apply their channel modes if they won the TS war */
+ // Apply their channel modes if we have to
Modes::ChangeList modechangelist;
if (apply_other_sides_modes)
{
@@ -168,7 +168,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params)
// after applying theirs. If they lost, the prefix modes from their message are not forwarded.
FwdFJoinBuilder fwdfjoin(chan, sourceserver);
- /* Now, process every 'modes,uuid' pair */
+ // Process every member in the message
irc::tokenstream users(params.back());
std::string item;
Modes::ChangeList* modechangelistptr = (apply_other_sides_modes ? &modechangelist : NULL);
@@ -256,10 +256,7 @@ void CommandFJoin::RemoveStatus(Channel* c)
{
ModeHandler* mh = i->second;
- /* Passing a pointer to a modestacker here causes the mode to be put onto the mode stack,
- * rather than applied immediately. Module unloads require this to be done immediately,
- * for this function we require tidyness instead. Fixes bug #493
- */
+ // Add the removal of this mode to the changelist. This handles all kinds of modes, including prefix modes.
mh->RemoveMode(c, changelist);
}
diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp
index 52e512d92..e6f49c5b9 100644
--- a/src/modules/m_spanningtree/fmode.cpp
+++ b/src/modules/m_spanningtree/fmode.cpp
@@ -21,7 +21,7 @@
#include "inspircd.h"
#include "commands.h"
-/** FMODE command - server mode with timestamp checks */
+/** FMODE command - channel mode change with timestamp checks */
CmdResult CommandFMode::Handle(User* who, std::vector<std::string>& params)
{
time_t TS = ServerCommand::ExtractTS(params[1]);
@@ -39,7 +39,7 @@ CmdResult CommandFMode::Handle(User* who, std::vector<std::string>& params)
if (TS > ourTS)
return CMD_FAILURE;
- /* TS is equal or less: Merge the mode changes into ours and pass on.
+ /* TS is equal or less: apply the mode change locally and forward the message
*/
// Turn modes into a Modes::ChangeList; may have more elements than max modes
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index e5e6e522b..98cf3188f 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -218,7 +218,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
/* Do we already have an IP? If so, no need to resolve it. */
if (ipvalid)
{
- /* Gave a hook, but it wasnt one we know */
+ // Create a TreeServer object that will start connecting immediately in the background
TreeSocket* newsocket = new TreeSocket(x, y, x->IPAddr);
if (newsocket->GetFd() > -1)
{
@@ -289,7 +289,7 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
{
- // we've already checked if pcnt > 0, so this is safe
+ // We've already confirmed that !parameters.empty(), so this is safe
TreeServer* found = Utils->FindServerMask(parameters[0]);
if (found)
{
@@ -527,7 +527,7 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const
}
}
- // Regardless, We need to modify the user Counts..
+ // Regardless, update the UserCount
TreeServer::Get(user)->UserCount--;
}
@@ -651,13 +651,13 @@ restart:
}
}
-// note: the protocol does not allow direct umode +o except
-// via NICK with 8 params. sending OPERTYPE infers +o modechange
-// locally.
void ModuleSpanningTree::OnOper(User* user, const std::string &opertype)
{
if (user->registered != REG_ALL || !IS_LOCAL(user))
return;
+
+ // Note: The protocol does not allow direct umode +o;
+ // sending OPERTYPE infers +o modechange locally.
CommandOpertype::Builder(user).Broadcast();
}
@@ -735,9 +735,7 @@ ModuleSpanningTree::~ModuleSpanningTree()
Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);
SetLocalUsersServer(newsrv);
- /* This will also free the listeners */
delete Utils;
-
delete commands;
}
@@ -750,7 +748,7 @@ Version ModuleSpanningTree::GetVersion()
* so that any activity it sees is FINAL, e.g. we arent going to send out
* a NICK message before m_cloaking has finished putting the +x on the user,
* etc etc.
- * Therefore, we return PRIORITY_LAST to make sure we end up at the END of
+ * Therefore, we set our priority to PRIORITY_LAST to make sure we end up at the END of
* the module call queue.
*/
void ModuleSpanningTree::Prioritize()
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index b81a285b5..cdafa9ded 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -108,17 +108,19 @@ void TreeSocket::DoBurst(TreeServer* s)
capab->auth_challenge ? "challenge-response" : "plaintext password");
this->CleanNegotiationInfo();
this->WriteLine(CmdBuilder("BURST").push_int(ServerInstance->Time()));
- /* Send server tree */
+ // Introduce all servers behind us
this->SendServers(Utils->TreeRoot, s);
BurstState bs(this);
- /* Send users and their oper status */
+ // Introduce all users
this->SendUsers(bs);
+ // Sync all channels
const chan_hash& chans = ServerInstance->GetChans();
for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i)
SyncChannel(i->second, bs);
+ // Send all xlines
this->SendXLines();
FOREACH_MOD(OnSyncNetwork, (bs.server));
this->WriteLine(CmdBuilder("ENDBURST"));
@@ -160,10 +162,7 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s)
}
/** Send one or more FJOINs for a channel of users.
- * If the length of a single line is more than 480-NICKMAX
- * in length, it is split over multiple lines.
- * Send one or more FMODEs for a channel with the
- * channel bans, if there's any.
+ * If the length of a single line is too long, it is split over multiple lines.
*/
void TreeSocket::SendFJoins(Channel* c)
{
@@ -242,7 +241,7 @@ void TreeSocket::SendListModes(Channel* chan)
this->WriteLine(fmode.finalize());
}
-/** Send channel topic, modes and metadata */
+/** Send channel users, topic, modes and global metadata */
void TreeSocket::SyncChannel(Channel* chan, BurstState& bs)
{
SendFJoins(chan);
@@ -271,7 +270,7 @@ void TreeSocket::SyncChannel(Channel* chan)
SyncChannel(chan, bs);
}
-/** send all users and their oper state/modes */
+/** Send all users and their state, including oper and away status and global metadata */
void TreeSocket::SendUsers(BurstState& bs)
{
ProtocolInterface::Server& piserver = bs.server;
diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp
index 68551e84f..612df80f3 100644
--- a/src/modules/m_spanningtree/override_map.cpp
+++ b/src/modules/m_spanningtree/override_map.cpp
@@ -168,7 +168,7 @@ CmdResult CommandMap::Handle(const std::vector<std::string>& parameters, User* u
{
if (parameters.size() > 0)
{
- /* Remote MAP, the server is within the 1st parameter */
+ // Remote MAP, the target server is the 1st parameter
TreeServer* s = Utils->FindServerMask(parameters[0]);
if (!s)
{
diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp
index 1c624f5c4..bc43841c1 100644
--- a/src/modules/m_spanningtree/server.cpp
+++ b/src/modules/m_spanningtree/server.cpp
@@ -85,7 +85,7 @@ void CommandServer::HandleExtra(TreeServer* newserver, const std::vector<std::st
}
if (key == "burst")
- newserver->BeginBurst(ConvToInt(val));
+ newserver->BeginBurst(ConvToUInt64(val));
}
}
@@ -162,7 +162,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
bool TreeSocket::CheckDuplicate(const std::string& sname, const std::string& sid)
{
- /* Check for fully initialized instances of the server by name */
+ // Check if the server name is not in use by a server that's already fully connected
TreeServer* CheckDupe = Utils->FindServer(sname);
if (CheckDupe)
{
@@ -172,7 +172,7 @@ bool TreeSocket::CheckDuplicate(const std::string& sname, const std::string& sid
return false;
}
- /* Check for fully initialized instances of the server by id */
+ // Check if the id is not in use by a server that's already fully connected
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Looking for dupe SID %s", sid.c_str());
CheckDupe = Utils->FindServerID(sid);
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index bb21fc54d..b3a612ca3 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -62,7 +62,7 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
if (!u->ChangeNick(nick, NickTS))
{
- /* buh. UID them */
+ // Changing to 'nick' failed (it may already be in use), change to the uuid
u->ChangeNick(u->uuid);
}
}
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index afd86c0ce..0750e755c 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -48,7 +48,7 @@ TreeServer::TreeServer()
/** When we create a new server, we call this constructor to initialize it.
* This constructor initializes the server's Route and Parent, and sets up
- * its ping counters so that it will be pinged one minute from now.
+ * the ping timer for the server.
*/
TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide)
: Server(Name, Desc)
@@ -117,16 +117,16 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s
Parent->Children.push_back(this);
}
-void TreeServer::BeginBurst(unsigned long startms)
+void TreeServer::BeginBurst(uint64_t startms)
{
behind_bursting++;
- unsigned long now = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
+ uint64_t now = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
// If the start time is in the future (clocks are not synced) then use current time
if ((!startms) || (startms > now))
startms = now;
this->StartBurst = startms;
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %lu behind_bursting %u", sid.c_str(), startms, behind_bursting);
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %s behind_bursting %u", sid.c_str(), ConvToStr(startms).c_str(), behind_bursting);
}
void TreeServer::FinishBurstInternal()
@@ -147,7 +147,7 @@ void TreeServer::FinishBurstInternal()
void TreeServer::FinishBurst()
{
ServerInstance->XLines->ApplyLines();
- long ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
+ uint64_t ts = ServerInstance->Time() * 1000 + (ServerInstance->Time_ns() / 1000000);
unsigned long bursttime = ts - this->StartBurst;
ServerInstance->SNO->WriteToSnoMask(Parent == Utils->TreeRoot ? 'l' : 'L', "Received end of netburst from \2%s\2 (burst time: %lu %s)",
GetName().c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs"));
@@ -248,8 +248,8 @@ void TreeServer::CheckULine()
}
}
-/** This method is used to add the structure to the
- * hash_map for linear searches. It is only called
+/** This method is used to add the server to the
+ * maps for linear searches. It is only called
* by the constructors.
*/
void TreeServer::AddHashEntry()
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 1a0203ba0..b7e9ee9d9 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -150,7 +150,7 @@ class TreeServer : public Server
/** When we recieved BURST from this server, used to calculate total burst time at ENDBURST.
*/
- unsigned long StartBurst;
+ uint64_t StartBurst;
/** True if this server is hidden
*/
@@ -213,7 +213,7 @@ class TreeServer : public Server
/** Set the bursting state of the server
* @param startms Time the server started bursting, if 0 or omitted, use current time
*/
- void BeginBurst(unsigned long startms = 0);
+ void BeginBurst(uint64_t startms = 0);
/** Register a PONG from the server
*/
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 025bd1e61..2198d6208 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -31,10 +31,10 @@
#include "treesocket.h"
#include "commands.h"
-/** Because most of the I/O gubbins are encapsulated within
- * BufferedSocket, we just call the superclass constructor for
- * most of the action, and append a few of our own values
- * to it.
+/** Constructor for outgoing connections.
+ * Because most of the I/O gubbins are encapsulated within
+ * BufferedSocket, we just call DoConnect() for most of the action,
+ * and only do minor initialization tasks ourselves.
*/
TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr)
: linkID(assign(link->Name)), LinkState(CONNECTING), MyRoot(NULL), proto_version(0)
@@ -50,9 +50,7 @@ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const std::string& ipaddr)
SendCapabilities(1);
}
-/** When a listening socket gives us a new file descriptor,
- * we must associate it with a socket without creating a new
- * connection. This constructor is used for this purpose.
+/** Constructor for incoming connections
*/
TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
: BufferedSocket(newfd)
@@ -92,10 +90,10 @@ TreeSocket::~TreeSocket()
}
/** When an outbound connection finishes connecting, we receive
- * this event, and must send our SERVER string to the other
+ * this event, and must do CAPAB negotiation with the other
* side. If the other side is happy, as outlined in the server
* to server docs on the inspircd.org site, the other side
- * will then send back its own server string.
+ * will then send back its own SERVER string eventually.
*/
void TreeSocket::OnConnected()
{
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 398573616..72361af38 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -27,7 +27,7 @@
CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::string>& params)
{
- /** Do we have enough parameters:
+ /**
* 0 1 2 3 4 5 6 7 8 9 (n-1)
* UID uuid age nick host dhost ident ip.string signon +modes (modepara) :gecos
*/
@@ -36,10 +36,10 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
std::string empty;
const std::string& modestr = params[8];
- /* Is this a valid UID, and not misrouted? */
+ // Check if the length of the uuid is correct and confirm the sid portion of the uuid matches the sid of the server introducing the user
if (params[0].length() != UIDGenerator::UUID_LENGTH || params[0].compare(0, 3, remoteserver->GetID()))
throw ProtocolException("Bogus UUID");
- /* Check parameters for validity before introducing the client, discovered by dmb */
+ // Sanity check on mode string: must begin with '+'
if (modestr[0] != '+')
throw ProtocolException("Invalid mode string");
@@ -72,9 +72,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st
}
}
- /* IMPORTANT NOTE: For remote users, we pass the UUID in the constructor. This automatically
- * sets it up in the UUID hash for us.
- *
+ /* For remote users, we pass the UUID they sent to the constructor.
* If the UUID already exists User::User() throws an exception which causes this connection to be closed.
*/
RemoteUser* _new = new RemoteUser(params[0], remoteserver);
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index d81bfa934..0cd6c76c2 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -31,7 +31,6 @@
SpanningTreeUtilities* Utils = NULL;
-/* Create server sockets off a listener. */
ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
{
if (from->bind_tag->getString("type") != "servers")
@@ -52,12 +51,6 @@ ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from
return MOD_RES_DENY;
}
-/** Yay for fast searches!
- * This is hundreds of times faster than recursion
- * or even scanning a linked list, especially when
- * there are more than a few servers to deal with.
- * (read as: lots).
- */
TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
{
if (InspIRCd::IsSID(ServerName))
@@ -101,10 +94,7 @@ TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
}
/** Find the first server matching a given glob mask.
- * Theres no find-using-glob method of hash_map [awwww :-(]
- * so instead, we iterate over the list using an iterator
- * and match each one until we get a hit. Yes its slow,
- * deal with it.
+ * We iterate over the list and match each one until we get a hit.
*/
TreeServer* SpanningTreeUtilities::FindServerMask(const std::string &ServerName)
{
@@ -155,7 +145,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities()
delete TreeRoot;
}
-/* returns a list of DIRECT servernames for a specific channel */
+// Returns a list of DIRECT servers for a specific channel
void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list)
{
unsigned int minrank = 0;
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 3a419e2a4..5aa8e925e 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -25,7 +25,6 @@
#include "inspircd.h"
#include "cachetimer.h"
-/* Foward declarations */
class TreeServer;
class TreeSocket;
class Link;
@@ -36,8 +35,7 @@ class CmdBuilder;
extern SpanningTreeUtilities* Utils;
-/* This hash_map holds the hash equivalent of the server
- * tree, used for rapid linear lookups.
+/** Associative container type, mapping server names/ids to TreeServers
*/
typedef TR1NS::unordered_map<std::string, TreeServer*, irc::insensitive, irc::StrHashComp> server_hash;
@@ -143,7 +141,7 @@ class SpanningTreeUtilities : public classbase
*/
void GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list);
- /** Find a server by name
+ /** Find a server by name or SID
*/
TreeServer* FindServer(const std::string &ServerName);