diff options
-rw-r--r-- | include/xline.h | 25 | ||||
-rw-r--r-- | src/cmd_eline.cpp | 4 | ||||
-rw-r--r-- | src/cmd_kline.cpp | 4 | ||||
-rw-r--r-- | src/cmd_qline.cpp | 4 | ||||
-rw-r--r-- | src/cmd_zline.cpp | 4 | ||||
-rw-r--r-- | src/xline.cpp | 108 |
6 files changed, 103 insertions, 46 deletions
diff --git a/include/xline.h b/include/xline.h index 478a02125..30d8abd3a 100644 --- a/include/xline.h +++ b/include/xline.h @@ -316,34 +316,39 @@ class CoreExport XLineManager bool add_eline(long duration, const char* source, const char* reason, const char* hostmask); /** Delete a GLine - * @return hostmask The host to remove + * @param hostmask The host to remove + * @param simulate If this is true, don't actually remove the line, just return * @return True if the line was deleted successfully */ - bool del_gline(const char* hostmask); + bool del_gline(const char* hostmask, bool simulate = false); /** Delete a QLine - * @return nickname The nick to remove + * @param nickname The nick to remove + * @param simulate If this is true, don't actually remove the line, just return * @return True if the line was deleted successfully */ - bool del_qline(const char* nickname); + bool del_qline(const char* nickname, bool simulate = false); /** Delete a ZLine - * @return ipaddr The IP to remove + * @param ipaddr The IP to remove + * @param simulate If this is true, don't actually remove the line, just return * @return True if the line was deleted successfully */ - bool del_zline(const char* ipaddr); + bool del_zline(const char* ipaddr, bool simulate = false); /** Delete a KLine - * @return hostmask The host to remove + * @param hostmask The host to remove + * @param simulate If this is true, don't actually remove the line, just return * @return True if the line was deleted successfully */ - bool del_kline(const char* hostmask); + bool del_kline(const char* hostmask, bool simulate = false); /** Delete a ELine - * @return hostmask The host to remove + * @param hostmask The host to remove + * @param simulate If this is true, don't actually remove the line, just return * @return True if the line was deleted successfully */ - bool del_eline(const char* hostmask); + bool del_eline(const char* hostmask, bool simulate = false); /** Check if a nickname matches a QLine * @return nick The nick to check against diff --git a/src/cmd_eline.cpp b/src/cmd_eline.cpp index be78e3b35..981a10f32 100644 --- a/src/cmd_eline.cpp +++ b/src/cmd_eline.cpp @@ -54,6 +54,10 @@ CmdResult cmd_eline::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->TimeString(c_requires_crap).c_str()); } } + else + { + user->WriteServ("NOTICE %s :*** E-Line for %s already exists",user->nick,parameters[0]); + } } else { diff --git a/src/cmd_kline.cpp b/src/cmd_kline.cpp index eab027b70..90ddca55c 100644 --- a/src/cmd_kline.cpp +++ b/src/cmd_kline.cpp @@ -64,6 +64,10 @@ CmdResult cmd_kline::Handle (const char** parameters, int pcnt, userrec *user) ServerInstance->XLines->apply_lines(to_apply); } + else + { + user->WriteServ("NOTICE %s :*** K-Line for %s already exists",user->nick,parameters[0]); + } } else { diff --git a/src/cmd_qline.cpp b/src/cmd_qline.cpp index 383f27756..bb1122854 100644 --- a/src/cmd_qline.cpp +++ b/src/cmd_qline.cpp @@ -56,6 +56,10 @@ CmdResult cmd_qline::Handle (const char** parameters, int pcnt, userrec *user) } ServerInstance->XLines->apply_lines(to_apply); } + else + { + user->WriteServ("NOTICE %s :*** Q-Line for %s already exists",user->nick,parameters[0]); + } } else { diff --git a/src/cmd_zline.cpp b/src/cmd_zline.cpp index 443647208..8fea70656 100644 --- a/src/cmd_zline.cpp +++ b/src/cmd_zline.cpp @@ -57,6 +57,10 @@ CmdResult cmd_zline::Handle (const char** parameters, int pcnt, userrec *user) } ServerInstance->XLines->apply_lines(to_apply); } + else + { + user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick,parameters[0]); + } } else { diff --git a/src/xline.cpp b/src/xline.cpp index 7a1b4a8aa..9b05a57f8 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -127,7 +127,8 @@ bool XLineManager::add_gline(long duration, const char* source,const char* reaso { IdentHostPair ih = IdentSplit(hostmask); - bool ret = del_gline(hostmask); + if (del_gline(hostmask, true)) + return false; GLine* item = new GLine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str()); @@ -141,7 +142,7 @@ bool XLineManager::add_gline(long duration, const char* source,const char* reaso pglines.push_back(item); } - return !ret; + return true; } // adds an e:line (exception to bans) @@ -150,7 +151,8 @@ bool XLineManager::add_eline(long duration, const char* source, const char* reas { IdentHostPair ih = IdentSplit(hostmask); - bool ret = del_eline(hostmask); + if (del_eline(hostmask, true)) + return false; ELine* item = new ELine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str()); @@ -163,14 +165,16 @@ bool XLineManager::add_eline(long duration, const char* source, const char* reas { pelines.push_back(item); } - return !ret; + return true; } // adds a q:line bool XLineManager::add_qline(long duration, const char* source, const char* reason, const char* nickname) { - bool ret = del_qline(nickname); + if (del_qline(nickname, true)) + return false; + QLine* item = new QLine(ServerInstance->Time(), duration, source, reason, nickname); if (duration) @@ -182,15 +186,13 @@ bool XLineManager::add_qline(long duration, const char* source, const char* reas { pqlines.push_back(item); } - return !ret; + return true; } // adds a z:line bool XLineManager::add_zline(long duration, const char* source, const char* reason, const char* ipaddr) { - bool ret = del_zline(ipaddr); - if (strchr(ipaddr,'@')) { while (*ipaddr != '@') @@ -198,6 +200,9 @@ bool XLineManager::add_zline(long duration, const char* source, const char* reas ipaddr++; } + if (del_zline(ipaddr, true)) + return false; + ZLine* item = new ZLine(ServerInstance->Time(), duration, source, reason, ipaddr); if (duration) @@ -209,7 +214,7 @@ bool XLineManager::add_zline(long duration, const char* source, const char* reas { pzlines.push_back(item); } - return !ret; + return true; } // adds a k:line @@ -218,7 +223,8 @@ bool XLineManager::add_kline(long duration, const char* source, const char* reas { IdentHostPair ih = IdentSplit(hostmask); - bool ret = del_kline(hostmask); + if (del_kline(hostmask, true)) + return false; KLine* item = new KLine(ServerInstance->Time(), duration, source, reason, ih.first.c_str(), ih.second.c_str()); @@ -231,20 +237,23 @@ bool XLineManager::add_kline(long duration, const char* source, const char* reas { pklines.push_back(item); } - return !ret; + return true; } // deletes a g:line, returns true if the line existed and was removed -bool XLineManager::del_gline(const char* hostmask) +bool XLineManager::del_gline(const char* hostmask, bool simulate) { IdentHostPair ih = IdentSplit(hostmask); for (std::vector<GLine*>::iterator i = glines.begin(); i != glines.end(); i++) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - glines.erase(i); + if (!simulate) + { + delete *i; + glines.erase(i); + } return true; } } @@ -252,8 +261,11 @@ bool XLineManager::del_gline(const char* hostmask) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - pglines.erase(i); + if (!simulate) + { + delete *i; + pglines.erase(i); + } return true; } } @@ -262,15 +274,18 @@ bool XLineManager::del_gline(const char* hostmask) // deletes a e:line, returns true if the line existed and was removed -bool XLineManager::del_eline(const char* hostmask) +bool XLineManager::del_eline(const char* hostmask, bool simulate) { IdentHostPair ih = IdentSplit(hostmask); for (std::vector<ELine*>::iterator i = elines.begin(); i != elines.end(); i++) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - elines.erase(i); + if (!simulate) + { + delete *i; + elines.erase(i); + } return true; } } @@ -278,8 +293,11 @@ bool XLineManager::del_eline(const char* hostmask) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - pelines.erase(i); + if (!simulate) + { + delete *i; + pelines.erase(i); + } return true; } } @@ -288,14 +306,17 @@ bool XLineManager::del_eline(const char* hostmask) // deletes a q:line, returns true if the line existed and was removed -bool XLineManager::del_qline(const char* nickname) +bool XLineManager::del_qline(const char* nickname, bool simulate) { for (std::vector<QLine*>::iterator i = qlines.begin(); i != qlines.end(); i++) { if (!strcasecmp(nickname,(*i)->nick)) { - delete *i; - qlines.erase(i); + if (!simulate) + { + delete *i; + qlines.erase(i); + } return true; } } @@ -303,8 +324,11 @@ bool XLineManager::del_qline(const char* nickname) { if (!strcasecmp(nickname,(*i)->nick)) { - delete *i; - pqlines.erase(i); + if (!simulate) + { + delete *i; + pqlines.erase(i); + } return true; } } @@ -313,14 +337,17 @@ bool XLineManager::del_qline(const char* nickname) // deletes a z:line, returns true if the line existed and was removed -bool XLineManager::del_zline(const char* ipaddr) +bool XLineManager::del_zline(const char* ipaddr, bool simulate) { for (std::vector<ZLine*>::iterator i = zlines.begin(); i != zlines.end(); i++) { if (!strcasecmp(ipaddr,(*i)->ipaddr)) { - delete *i; - zlines.erase(i); + if (!simulate) + { + delete *i; + zlines.erase(i); + } return true; } } @@ -328,8 +355,11 @@ bool XLineManager::del_zline(const char* ipaddr) { if (!strcasecmp(ipaddr,(*i)->ipaddr)) { - delete *i; - pzlines.erase(i); + if (!simulate) + { + delete *i; + pzlines.erase(i); + } return true; } } @@ -338,15 +368,18 @@ bool XLineManager::del_zline(const char* ipaddr) // deletes a k:line, returns true if the line existed and was removed -bool XLineManager::del_kline(const char* hostmask) +bool XLineManager::del_kline(const char* hostmask, bool simulate) { IdentHostPair ih = IdentSplit(hostmask); for (std::vector<KLine*>::iterator i = klines.begin(); i != klines.end(); i++) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - klines.erase(i); + if (!simulate) + { + delete *i; + klines.erase(i); + } return true; } } @@ -354,8 +387,11 @@ bool XLineManager::del_kline(const char* hostmask) { if (!strcasecmp(ih.first.c_str(),(*i)->identmask) && !strcasecmp(ih.second.c_str(),(*i)->hostmask)) { - delete *i; - pklines.erase(i); + if (!simulate) + { + delete *i; + pklines.erase(i); + } return true; } } |