X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fconfigreader.cpp;h=b0106eb5edf465147a8efe13b16a49cbdb4b7f7c;hb=ed105d7fef72b5bb5f23e72fae40d6b4ffdcb5b8;hp=73a0e25b1cc0fcb643368f8ed1eeb5ac93e94c0d;hpb=463bb4410aba2541c1289f95336dea938656f8c5;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/configreader.cpp b/src/configreader.cpp index 73a0e25b1..b0106eb5e 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -57,6 +57,12 @@ Module* ServerConfig::GetIOHook(int port) return (x != IOHookModule.end() ? x->second : NULL); } +Module* ServerConfig::GetIOHook(InspSocket* is) +{ + std::map::iterator x = SocketIOHookModule.find(is); + return (x != SocketIOHookModule.end() ? x->second : NULL); +} + bool ServerConfig::AddIOHook(int port, Module* iomod) { if (!GetIOHook(port)) @@ -66,8 +72,23 @@ bool ServerConfig::AddIOHook(int port, Module* iomod) } else { - ModuleException err("Port already hooked by another module"); - throw(err); + throw ModuleException("Port already hooked by another module"); + return false; + } +} + +bool ServerConfig::AddIOHook(Module* iomod, InspSocket* is) +{ + if (!GetIOHook(is)) + { + ServerInstance->Log(DEBUG,"Hooked inspsocket %08x", is); + SocketIOHookModule[is] = iomod; + is->IsIOHooked = true; + return true; + } + else + { + throw ModuleException("InspSocket derived class already hooked by another module"); return false; } } @@ -83,6 +104,17 @@ bool ServerConfig::DelIOHook(int port) return false; } +bool ServerConfig::DelIOHook(InspSocket* is) +{ + std::map::iterator x = SocketIOHookModule.find(is); + if (x != SocketIOHookModule.end()) + { + SocketIOHookModule.erase(x); + return true; + } + return false; +} + bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user) { int count = ConfValueEnum(this->config_data, tag);