diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-25 17:30:43 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-05-25 17:30:43 +0000 |
commit | 7d7250484c352c13830e63ae41ee8faae40a9bd5 (patch) | |
tree | 0fdf4941b4d72469a18eec97506f06f6e94e86e9 /src/modules/m_spanningtree | |
parent | e7b837ec5f120f928a0dc321fa918bdd01ab0c02 (diff) |
First phase of conversion to dynamic limits on all the lengths, configured via the <limits> tag
(the tag isnt there yet, these all just run on defaults in the class constructor)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9802 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 40 | ||||
-rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/ftopic.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/netburst.cpp | 24 | ||||
-rw-r--r-- | src/modules/m_spanningtree/opertype.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/svsjoin.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/svspart.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 19 |
8 files changed, 30 insertions, 67 deletions
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 5919c65bb..9a45b8131 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -81,16 +81,16 @@ void TreeSocket::SendCapabilities() } this->WriteLine("CAPAB CAPABILITIES " /* Preprocessor does this one. */ - ":NICKMAX="+ConvToStr(NICKMAX)+ - " HALFOP="+ConvToStr(this->Instance->Config->AllowHalfop)+ - " CHANMAX="+ConvToStr(CHANMAX)+ - " MAXMODES="+ConvToStr(MAXMODES)+ - " IDENTMAX="+ConvToStr(IDENTMAX)+ - " MAXQUIT="+ConvToStr(MAXQUIT)+ - " MAXTOPIC="+ConvToStr(MAXTOPIC)+ - " MAXKICK="+ConvToStr(MAXKICK)+ - " MAXGECOS="+ConvToStr(MAXGECOS)+ - " MAXAWAY="+ConvToStr(MAXAWAY)+ + ":NICKMAX="+ConvToStr(Instance->Config->Limits.NickMax)+ + " HALFOP="+ConvToStr(Instance->Config->AllowHalfop)+ + " CHANMAX="+ConvToStr(Instance->Config->Limits.ChanMax)+ + " MAXMODES="+ConvToStr(Instance->Config->Limits.MaxModes)+ + " IDENTMAX="+ConvToStr(Instance->Config->Limits.IdentMax)+ + " MAXQUIT="+ConvToStr(Instance->Config->Limits.MaxQuit)+ + " MAXTOPIC="+ConvToStr(Instance->Config->Limits.MaxTopic)+ + " MAXKICK="+ConvToStr(Instance->Config->Limits.MaxKick)+ + " MAXGECOS="+ConvToStr(Instance->Config->Limits.MaxGecos)+ + " MAXAWAY="+ConvToStr(Instance->Config->Limits.MaxAway)+ " IP6NATIVE="+ConvToStr(ip6)+ " IP6SUPPORT="+ConvToStr(ip6support)+ " PROTOCOL="+ConvToStr(ProtocolVersion)+extra+ @@ -171,19 +171,6 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) reason = "Modules loaded on these servers are not correctly matched, these modules are not loaded on " + diff; } - cap_validation valid_capab[] = { - {"Maximum nickname lengths differ or remote nickname length not specified", "NICKMAX", NICKMAX}, - {"Maximum ident lengths differ or remote ident length not specified", "IDENTMAX", IDENTMAX}, - {"Maximum channel lengths differ or remote channel length not specified", "CHANMAX", CHANMAX}, - {"Maximum modes per line differ or remote modes per line not specified", "MAXMODES", MAXMODES}, - {"Maximum quit lengths differ or remote quit length not specified", "MAXQUIT", MAXQUIT}, - {"Maximum topic lengths differ or remote topic length not specified", "MAXTOPIC", MAXTOPIC}, - {"Maximum kick lengths differ or remote kick length not specified", "MAXKICK", MAXKICK}, - {"Maximum GECOS (fullname) lengths differ or remote GECOS length not specified", "MAXGECOS", MAXGECOS}, - {"Maximum awaymessage lengths differ or remote awaymessage length not specified", "MAXAWAY", MAXAWAY}, - {"", "", 0} - }; - if (((this->CapKeys.find("IP6SUPPORT") == this->CapKeys.end()) && (ip6support)) || ((this->CapKeys.find("IP6SUPPORT") != this->CapKeys.end()) && (this->CapKeys.find("IP6SUPPORT")->second != ConvToStr(ip6support)))) reason = "We don't both support linking to IPV6 servers"; if (((this->CapKeys.find("IP6NATIVE") != this->CapKeys.end()) && (this->CapKeys.find("IP6NATIVE")->second == "1")) && (!ip6support)) @@ -201,13 +188,6 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) if (((this->CapKeys.find("HALFOP") == this->CapKeys.end()) && (Instance->Config->AllowHalfop)) || ((this->CapKeys.find("HALFOP") != this->CapKeys.end()) && (this->CapKeys.find("HALFOP")->second != ConvToStr(Instance->Config->AllowHalfop)))) reason = "We don't both have halfop support enabled/disabled identically"; - - for (int x = 0; valid_capab[x].size; ++x) - { - if (((this->CapKeys.find(valid_capab[x].key) == this->CapKeys.end()) || ((this->CapKeys.find(valid_capab[x].key) != this->CapKeys.end()) && - (this->CapKeys.find(valid_capab[x].key)->second != ConvToStr(valid_capab[x].size))))) - reason = valid_capab[x].reason; - } /* Challenge response, store their challenge for our password */ std::map<std::string,std::string>::iterator n = this->CapKeys.find("CHALLENGE"); diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 985c86143..4ef8d2d4f 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -60,7 +60,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p if (params.size() < 3) return true; - irc::modestacker modestack(true); /* Modes to apply from the users in the user list */ + irc::modestacker modestack(Instance, true); /* Modes to apply from the users in the user list */ User* who = NULL; /* User we are currently checking */ std::string channel = params[0]; /* Channel name, as a string */ time_t TS = atoi(params[1].c_str()); /* Timestamp given to us for remote side */ diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 3ea775112..e18187087 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -34,7 +34,7 @@ bool TreeSocket::ForceTopic(const std::string &source, std::deque<std::string> & if ((ts >= c->topicset) || (c->topic.empty())) { std::string oldtopic = c->topic; - c->topic.assign(params[3], 0, MAXTOPIC); + c->topic.assign(params[3], 0, Instance->Config->Limits.MaxTopic); c->setby.assign(params[2], 0, 127); c->topicset = ts; /* if the topic text is the same as the current topic, diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 8444bbec6..793a3cf9a 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -96,8 +96,19 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { + size_t ptrlen = 0; + std::string modestr = this->Instance->Modes->ModeString(i->first, c, false); + + if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480) + { + buffer.append(list).append("\r\n"); + dlen = curlen = snprintf(list, MAXBUF, ":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true)); + ptr = list + dlen; + numusers = 0; + } + // The first parameter gets a : before it - size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", this->Instance->Modes->ModeString(i->first, c, false).c_str(), i->first->uuid.c_str()); + ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", modestr.c_str(), i->first->uuid.c_str()); looped_once = true; @@ -105,15 +116,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) ptr += ptrlen; numusers++; - - if (curlen > (480-NICKMAX)) - { - buffer.append(list).append("\r\n"); - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true)); - ptr = list + dlen; - ptrlen = 0; - numusers = 0; - } } // Okay, permanent channels will (of course) need this \r\n anyway, numusers check is if there @@ -132,7 +134,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) params.append(" ").append(b->data); linesize += size; } - if ((params.length() >= MAXMODES) || (currsize > 350)) + if ((params.length() >= Instance->Config->Limits.MaxModes) || (currsize > 350)) { /* Wrap at MAXMODES */ buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n"); diff --git a/src/modules/m_spanningtree/opertype.cpp b/src/modules/m_spanningtree/opertype.cpp index a2aff74f9..01638f9ac 100644 --- a/src/modules/m_spanningtree/opertype.cpp +++ b/src/modules/m_spanningtree/opertype.cpp @@ -35,8 +35,8 @@ bool TreeSocket::OperType(const std::string &prefix, std::deque<std::string> &pa if (!u->IsModeSet('o')) this->Instance->Users->all_opers.push_back(u); u->modes[UM_OPERATOR] = 1; - u->oper.assign(opertype, 0, NICKMAX - 1); - Utils->DoOneToAllButSender(u->uuid,"OPERTYPE",params,u->server); + u->oper.assign(opertype, 0, Instance->Config->Limits.NickMax); + Utils->DoOneToAllButSender(u->uuid, "OPERTYPE", params, u->server); TreeServer* remoteserver = Utils->FindServer(u->server); bool dosend = true; diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp index ee4addb74..5f9f94e95 100644 --- a/src/modules/m_spanningtree/svsjoin.cpp +++ b/src/modules/m_spanningtree/svsjoin.cpp @@ -35,9 +35,6 @@ bool TreeSocket::ServiceJoin(const std::string &prefix, std::deque<std::string> if (params.size() < 2) return true; - if (!this->Instance->IsChannel(params[1].c_str())) - return true; - User* u = this->Instance->FindNick(params[0]); if (u) diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp index 00fd9eb3a..639792be9 100644 --- a/src/modules/m_spanningtree/svspart.cpp +++ b/src/modules/m_spanningtree/svspart.cpp @@ -35,9 +35,6 @@ bool TreeSocket::ServicePart(const std::string &prefix, std::deque<std::string> if (params.size() < 2) return true; - if (!this->Instance->IsChannel(params[1].c_str())) - return true; - User* u = this->Instance->FindNick(params[0]); Channel* c = this->Instance->FindChan(params[1]); diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 70f7b874c..d84ee2a04 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -48,9 +48,6 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa time_t signon = ConvToInt(params[8]); std::string empty; - /* XXX probably validate UID length too -- w00t */ - cmd_validation valid[] = { {"Nickname", 2, NICKMAX}, {"Hostname", 3, 64}, {"Displayed hostname", 4, 64}, {"Ident", 5, IDENTMAX + 1}, {"GECOS", 9, MAXGECOS}, {"", 0, 0} }; - TreeServer* remoteserver = Utils->FindServer(source); if (!remoteserver) @@ -66,16 +63,6 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa return true; } - for (size_t x = 0; valid[x].length; ++x) - { - if (params[valid[x].param].length() > valid[x].length) - { - this->WriteLine(std::string(":")+this->Instance->Config->GetSID()+" KILL "+params[0]+" :Invalid client introduction (" + valid[x].item + " > " + ConvToStr(valid[x].length) + ")"); - return true; - } - } - - /* check for collision */ user_hash::iterator iter = this->Instance->Users->clientlist->find(params[2]); @@ -109,12 +96,12 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa } (*(this->Instance->Users->clientlist))[params[2]] = _new; _new->SetFd(FD_MAGIC_NUMBER); - _new->nick.assign(params[2], 0, NICKMAX - 1); + _new->nick.assign(params[2], 0, MAXBUF); _new->host.assign(params[3], 0, 64); _new->dhost.assign(params[4], 0, 64); _new->server = this->Instance->FindServerNamePtr(remoteserver->GetName().c_str()); - _new->ident.assign(params[5], 0, IDENTMAX + 1); - _new->fullname.assign(params[9], 0, MAXGECOS); + _new->ident.assign(params[5], 0, MAXBUF); + _new->fullname.assign(params[9], 0, MAXBUF); _new->registered = REG_ALL; _new->signon = signon; _new->age = age_t; |