]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixified some more
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 31 Oct 2007 17:22:02 +0000 (17:22 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 31 Oct 2007 17:22:02 +0000 (17:22 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8428 e03df62e-2008-0410-955e-edbf42e46eb7

include/xline.h
src/configreader.cpp
src/userprocess.cpp
src/xline.cpp

index 5b81eef828926528527e370a900c7e250a4fa0b9..cca0e9b764561db1ca04fa35917ed67fa6da60ad 100644 (file)
@@ -69,9 +69,9 @@ class CoreExport XLine : public classbase
        /** Returns true wether or not the given string exactly matches the gline
         * (no wildcard use in this method) -- used for removal of a line
         */
-       virtual bool MatchesLiteral(std::string &str) = 0;
+       virtual bool MatchesLiteral(const std::string &str) = 0;
 
-       virtual bool Matches(const std::string &str);
+       virtual bool Matches(const std::string &str) = 0;
 
        virtual void Apply(User* u);
 
@@ -123,6 +123,8 @@ class CoreExport KLine : public XLine
        {
                identmask = strdup(ident);
                hostmask = strdup(host);
+               matchtext = this->identmask;
+               matchtext.append("@").append(this->hostmask);
        }
 
        /** Destructor
@@ -135,6 +137,8 @@ class CoreExport KLine : public XLine
 
        virtual bool Matches(User *u);
 
+       virtual bool Matches(const std::string &str);
+
        virtual bool MatchesLiteral(const std::string &str);
 
        virtual void Apply(User* u);
@@ -147,6 +151,8 @@ class CoreExport KLine : public XLine
        /** Host mask
         */
        char* hostmask;
+
+       std::string matchtext;
 };
 
 /** GLine class
@@ -166,6 +172,8 @@ class CoreExport GLine : public XLine
        {
                identmask = strdup(ident);
                hostmask = strdup(host);
+               matchtext = this->identmask;
+               matchtext.append("@").append(this->hostmask);
        }
 
        /** Destructor
@@ -178,6 +186,8 @@ class CoreExport GLine : public XLine
 
        virtual bool Matches(User *u);
 
+       virtual bool Matches(const std::string &str);
+
        virtual bool MatchesLiteral(const std::string &str);
 
        virtual void Apply(User* u);
@@ -190,6 +200,8 @@ class CoreExport GLine : public XLine
        /** Host mask
         */
        char* hostmask;
+
+       std::string matchtext;
 };
 
 /** ELine class
@@ -209,6 +221,8 @@ class CoreExport ELine : public XLine
        {
                identmask = strdup(ident);
                hostmask = strdup(host);
+               matchtext = this->identmask;
+               matchtext.append("@").append(this->hostmask);
        }
 
        ~ELine()
@@ -219,6 +233,8 @@ class CoreExport ELine : public XLine
 
        virtual bool Matches(User *u);
 
+       virtual bool Matches(const std::string &str);
+
        virtual bool MatchesLiteral(const std::string &str);
 
        virtual void Unset();
@@ -233,6 +249,8 @@ class CoreExport ELine : public XLine
        /** Host mask
         */
        char* hostmask;
+
+       std::string matchtext;
 };
 
 /** ZLine class
index e0d66d525846e92e97f9ba8c8c136d6d93d3a3f3..96f46116239cdd655b0ca875ea9c81d8a02db219 100644 (file)
@@ -1924,7 +1924,10 @@ bool DoZLine(ServerConfig* conf, const char* tag, char** entries, ValueList &val
        const char* reason = values[0].GetString();
        const char* ipmask = values[1].GetString();
 
-       conf->GetInstance()->XLines->AddZLine(0,"<Config>",reason,ipmask);
+       ZLine* zl = new ZLine(conf->GetInstance(), conf->GetInstance()->Time(), 0, "<Config>", reason, ipmask);
+       if (!conf->GetInstance()->XLines->AddLine(zl))
+               delete zl;
+
        return true;
 }
 
@@ -1933,7 +1936,10 @@ bool DoQLine(ServerConfig* conf, const char* tag, char** entries, ValueList &val
        const char* reason = values[0].GetString();
        const char* nick = values[1].GetString();
 
-       conf->GetInstance()->XLines->AddQLine(0,"<Config>",reason,nick);
+       QLine* ql = new QLine(conf->GetInstance(), conf->GetInstance()->Time(), 0, "<Config>", reason, nick);
+       if (!conf->GetInstance()->XLines->AddLine(ql))
+               delete ql;
+
        return true;
 }
 
@@ -1942,7 +1948,13 @@ bool DoKLine(ServerConfig* conf, const char* tag, char** entries, ValueList &val
        const char* reason = values[0].GetString();
        const char* host = values[1].GetString();
 
-       conf->GetInstance()->XLines->AddKLine(0,"<Config>",reason,host);
+       XLineManager* xlm = conf->GetInstance()->XLines;
+
+       IdentHostPair ih = xlm->IdentSplit(host);
+
+       KLine* kl = new KLine(conf->GetInstance(), conf->GetInstance()->Time(), 0, "<Config>", reason, ih.first.c_str(), ih.second.c_str());
+       if (!xlm->AddLine(kl))
+               delete kl;
        return true;
 }
 
@@ -1951,7 +1963,13 @@ bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &val
        const char* reason = values[0].GetString();
        const char* host = values[1].GetString();
 
-       conf->GetInstance()->XLines->AddELine(0,"<Config>",reason,host);
+       XLineManager* xlm = conf->GetInstance()->XLines;
+
+       IdentHostPair ih = xlm->IdentSplit(host);
+
+       ELine* el = new ELine(conf->GetInstance(), conf->GetInstance()->Time(), 0, "<Config>", reason, ih.first.c_str(), ih.second.c_str());
+       if (!xlm->AddLine(el))
+               delete el;
        return true;
 }
 
index 066800409ca7a300e47c865921df4afed6837aec..39d3ad0ecc30147ed7574597033c0db330eeb9ef 100644 (file)
@@ -29,8 +29,11 @@ void FloodQuitUserHandler::Call(User* current)
 
        if (current->registered != REG_ALL)
        {
-               Server->XLines->AddZLine(120, Server->Config->ServerName, "Flood from unregistered connection", current->GetIPString());
-               Server->XLines->ApplyLines();
+               ZLine* zl = new ZLine(Server, Server->Time(), 0, Server->Config->ServerName, "Flood from unregistered connection", current->GetIPString());
+               if (Server->XLines->AddLine(zl))
+                       Server->XLines->ApplyLines();
+               else
+                       delete zl;
        }
 }
 
index 9a56450ff7073fe05c072ccf8506216eaa55de73..bc505dcc5391448d82d17cdd82453a558d6b0456 100644 (file)
@@ -428,11 +428,6 @@ XLineManager::XLineManager(InspIRCd* Instance) : ServerInstance(Instance)
 {
 }
 
-bool XLine::Matches(const std::string &str)
-{
-       return false;
-}
-
 void XLine::Apply(User* u)
 {
 }
@@ -558,6 +553,21 @@ bool QLine::Matches(const std::string &str)
        return false;
 }
 
+bool ELine::Matches(const std::string &str)
+{
+       return ((match(str.c_str(), matchtext.c_str(), true)));
+}
+
+bool KLine::Matches(const std::string &str)
+{
+       return ((match(str.c_str(), matchtext.c_str(), true)));
+}
+
+bool GLine::Matches(const std::string &str)
+{
+       return ((match(str.c_str(), matchtext.c_str(), true)));
+}
+
 virtual bool ELine::MatchesLiteral(const std::string &str)
 {
        return (assign(str) == irc::string(this->identmask) + '@' + this->hostmask);