diff options
Diffstat (limited to 'src/modules/m_spanningtree')
37 files changed, 48 insertions, 278 deletions
diff --git a/src/modules/m_spanningtree/cachetimer.cpp b/src/modules/m_spanningtree/cachetimer.cpp index 989ed565f..7b5478b13 100644 --- a/src/modules/m_spanningtree/cachetimer.cpp +++ b/src/modules/m_spanningtree/cachetimer.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "cachetimer.h" #include "main.h" diff --git a/src/modules/m_spanningtree/handshaketimer.cpp b/src/modules/m_spanningtree/handshaketimer.cpp deleted file mode 100644 index b264a4c2f..000000000 --- a/src/modules/m_spanningtree/handshaketimer.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" -#include "../transport.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "link.h" -#include "treesocket.h" -#include "handshaketimer.h" - -/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */ - -HandshakeTimer::HandshakeTimer(TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay) - : Timer(delay, ServerInstance->Time(), true), sock(s), lnk(l), Utils(u) -{ - thefd = sock->GetFd(); -} - -HandshakeTimer::~HandshakeTimer() -{ - sock->hstimer = NULL; -} - -void HandshakeTimer::Tick(time_t TIME) -{ - if (!sock->GetIOHook()) - { - CancelRepeat(); - sock->SendCapabilities(1); - } - else if (BufferedSocketHSCompleteRequest(sock, Utils->Creator, sock->GetIOHook()).Send()) - { - CancelRepeat(); - BufferedSocketAttachCertRequest(sock, Utils->Creator, sock->GetIOHook()).Send(); - sock->SendCapabilities(1); - } - // otherwise, try again later -} - diff --git a/src/modules/m_spanningtree/handshaketimer.h b/src/modules/m_spanningtree/handshaketimer.h deleted file mode 100644 index 527b056bc..000000000 --- a/src/modules/m_spanningtree/handshaketimer.h +++ /dev/null @@ -1,37 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#ifndef __HANDSHAKE_TIMER_H__ -#define __HANDSHAKE_TIMER_H__ - -#include "inspircd.h" -#include "timer.h" - -class SpanningTreeUtilities; -class TreeSocket; -class Link; - -class HandshakeTimer : public Timer -{ - private: - TreeSocket* sock; - reference<Link> lnk; - SpanningTreeUtilities* Utils; - int thefd; - public: - HandshakeTimer(TreeSocket* s, Link* l, SpanningTreeUtilities* u, int delay); - ~HandshakeTimer(); - virtual void Tick(time_t TIME); -}; - -#endif diff --git a/src/modules/m_spanningtree/hmac.cpp b/src/modules/m_spanningtree/hmac.cpp index b7cddc47a..ad35a585f 100644 --- a/src/modules/m_spanningtree/hmac.cpp +++ b/src/modules/m_spanningtree/hmac.cpp @@ -14,8 +14,8 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "../m_hash.h" +#include "../ssl.h" #include "socketengine.h" #include "main.h" @@ -24,7 +24,6 @@ #include "link.h" #include "treesocket.h" #include "resolvers.h" -#include "handshaketimer.h" /* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h */ @@ -78,12 +77,10 @@ std::string TreeSocket::MakePass(const std::string &password, const std::string } hmac2 += challenge; - HashResetRequest(Utils->Creator, sha256).Send(); - hmac2 = HashSumRequest(Utils->Creator, sha256, hmac2).Send(); - - HashResetRequest(Utils->Creator, sha256).Send(); + hmac2 = HashRequest(Utils->Creator, sha256, hmac2).result; + std::string hmac = hmac1 + hmac2; - hmac = HashSumRequest(Utils->Creator, sha256, hmac).Send(); + hmac = HashRequest(Utils->Creator, sha256, hmac).result; return "HMAC-SHA256:"+ hmac; } @@ -131,8 +128,7 @@ bool TreeSocket::ComparePass(const Link& link, const std::string &theirs) std::string fp; if (GetIOHook()) { - BufferedSocketCertificateRequest req(this, Utils->Creator, GetIOHook()); - req.Send(); + SSLCertificateRequest req(this, Utils->Creator); if (req.cert) { fp = req.cert->GetFingerprint(); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 7d6974cf0..23523107a 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "cachetimer.h" #include "resolvers.h" @@ -49,7 +48,7 @@ ModuleSpanningTree::ModuleSpanningTree() I_OnWallops, I_OnUserNotice, I_OnUserMessage, I_OnBackgroundTimer, I_OnUserJoin, I_OnChangeLocalUserHost, I_OnChangeName, I_OnChangeIdent, I_OnUserPart, I_OnUnloadModule, I_OnUserQuit, I_OnUserPostNick, I_OnUserKick, I_OnRemoteKill, I_OnRehash, I_OnPreRehash, - I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnEvent, + I_OnOper, I_OnAddLine, I_OnDelLine, I_OnMode, I_OnLoadModule, I_OnStats, I_OnSetAway, I_OnPostCommand, I_OnUserConnect }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); @@ -294,9 +293,8 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) if (ipvalid) { /* Gave a hook, but it wasnt one we know */ - if ((!x->Hook.empty()) && (Utils->hooks.find(x->Hook.c_str()) == Utils->hooks.end())) - return; - TreeSocket* newsocket = new TreeSocket(Utils, x->IPAddr,x->Port, x->Timeout ? x->Timeout : 10,x->Name.c_str(), x->Bind, y, x->Hook.empty() ? NULL : Utils->hooks[x->Hook.c_str()]); + TreeSocket* newsocket = new TreeSocket(Utils, x->IPAddr, x->Port, x->Timeout ? x->Timeout : 10, + x->Name.c_str(), x->Bind, y, x->Hook); if (newsocket->GetFd() > -1) { /* Handled automatically on success */ @@ -313,7 +311,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y) try { bool cached; - ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, x->IPAddr, x, cached, start_type, y); + ServernameResolver* snr = new ServernameResolver(Utils, x->IPAddr, x, cached, start_type, y); ServerInstance->AddResolver(snr, cached); } catch (ModuleException& e) @@ -953,15 +951,6 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con s->WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" METADATA * "+extname+" :"+extdata); } -void ModuleSpanningTree::OnEvent(Event* event) -{ - if ((event->GetEventID() == "send_encap") || (event->GetEventID() == "send_metadata") || (event->GetEventID() == "send_topic") || (event->GetEventID() == "send_mode") || (event->GetEventID() == "send_mode_explicit") || (event->GetEventID() == "send_opers") - || (event->GetEventID() == "send_modeset") || (event->GetEventID() == "send_snoset") || (event->GetEventID() == "send_push")) - { - ServerInstance->Logs->Log("m_spanningtree", DEBUG, "WARNING: Deprecated use of old 1.1 style m_spanningtree event ignored, type '"+event->GetEventID()+"'!"); - } -} - bool ModuleSpanningTree::cull() { Utils->cull(); diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 59d40eca4..1057fcdfc 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -188,7 +188,6 @@ class ModuleSpanningTree : public Module ModResult OnSetAway(User* user, const std::string &awaymsg); void ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const std::vector<std::string> &modeline, const std::vector<TranslateType> &translate); void ProtoSendMetaData(void* opaque, Extensible* target, const std::string &extname, const std::string &extdata); - void OnEvent(Event* event); void OnLoadModule(Module* mod,const std::string &name); void OnUnloadModule(Module* mod,const std::string &name); bool cull(); diff --git a/src/modules/m_spanningtree/override_admin.cpp b/src/modules/m_spanningtree/override_admin.cpp index 2a5cfcdab..293768759 100644 --- a/src/modules/m_spanningtree/override_admin.cpp +++ b/src/modules/m_spanningtree/override_admin.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/override_motd.cpp b/src/modules/m_spanningtree/override_motd.cpp index 270608062..a5f4e684e 100644 --- a/src/modules/m_spanningtree/override_motd.cpp +++ b/src/modules/m_spanningtree/override_motd.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/override_squit.cpp b/src/modules/m_spanningtree/override_squit.cpp index 5360f176c..e30c9ba50 100644 --- a/src/modules/m_spanningtree/override_squit.cpp +++ b/src/modules/m_spanningtree/override_squit.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp index 93190a978..09d0a691d 100644 --- a/src/modules/m_spanningtree/override_stats.cpp +++ b/src/modules/m_spanningtree/override_stats.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" @@ -77,11 +76,9 @@ ModResult ModuleSpanningTree::OnStats(char statschar, User* user, string_list &r if (ip.empty()) ip = "*"; - std::string transport("plaintext"); - if (Utils->Bindings[i]->Hook) - transport = BufferedSocketNameRequest(this, Utils->Bindings[i]->Hook).Send(); + std::string transport(Utils->Bindings[i]->Hook); - results.push_back(ConvToStr(ServerInstance->Config->ServerName) + " 249 "+user->nick+" :" + ip + ":" + ConvToStr(Utils->Bindings[i]->GetPort())+ + results.push_back(ServerInstance->Config->ServerName + " 249 "+user->nick+" :" + ip + ":" + ConvToStr(Utils->Bindings[i]->GetPort())+ " (server, " + transport + ")"); } } diff --git a/src/modules/m_spanningtree/override_time.cpp b/src/modules/m_spanningtree/override_time.cpp index 54a2870bd..b3384720e 100644 --- a/src/modules/m_spanningtree/override_time.cpp +++ b/src/modules/m_spanningtree/override_time.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/override_whois.cpp b/src/modules/m_spanningtree/override_whois.cpp index 84bf8ce77..ee3be53fd 100644 --- a/src/modules/m_spanningtree/override_whois.cpp +++ b/src/modules/m_spanningtree/override_whois.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/ping.cpp b/src/modules/m_spanningtree/ping.cpp index c3467c984..2d468916d 100644 --- a/src/modules/m_spanningtree/ping.cpp +++ b/src/modules/m_spanningtree/ping.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/pong.cpp b/src/modules/m_spanningtree/pong.cpp index 274641897..675e17f45 100644 --- a/src/modules/m_spanningtree/pong.cpp +++ b/src/modules/m_spanningtree/pong.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index fbac46faa..84ca342ec 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp index a024a4901..c43e4e927 100644 --- a/src/modules/m_spanningtree/precommand.cpp +++ b/src/modules/m_spanningtree/precommand.cpp @@ -16,7 +16,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/push.cpp b/src/modules/m_spanningtree/push.cpp index 778c2291c..e67b926c8 100644 --- a/src/modules/m_spanningtree/push.cpp +++ b/src/modules/m_spanningtree/push.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp index 422a4b428..5a4c71c3c 100644 --- a/src/modules/m_spanningtree/rconnect.cpp +++ b/src/modules/m_spanningtree/rconnect.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "resolvers.h" #include "main.h" diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp index e168b98f5..b95ba79c3 100644 --- a/src/modules/m_spanningtree/resolvers.cpp +++ b/src/modules/m_spanningtree/resolvers.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "resolvers.h" #include "main.h" @@ -31,10 +30,9 @@ * callback to OnLookupComplete or OnError when completed. Once it has completed we * will have an IP address which we can then use to continue our connection. */ -ServernameResolver::ServernameResolver(Module* me, SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac) - : Resolver(hostname, qt, cached, me), Utils(Util), query(qt), host(hostname), mine(me), MyLink(x), myautoconnect(myac) +ServernameResolver::ServernameResolver(SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac) + : Resolver(hostname, qt, cached, Util->Creator), Utils(Util), query(qt), host(hostname), MyLink(x), myautoconnect(myac) { - /* Nothing in here, folks */ } void ServernameResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bool cached) @@ -46,12 +44,8 @@ void ServernameResolver::OnLookupComplete(const std::string &result, unsigned in TreeServer* CheckDupe = Utils->FindServer(MyLink->Name.c_str()); if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */ { - - if ((!MyLink->Hook.empty()) && (Utils->hooks.find(MyLink->Hook.c_str()) == Utils->hooks.end())) - return; - - TreeSocket* newsocket = new TreeSocket(this->Utils, result,MyLink->Port,MyLink->Timeout ? MyLink->Timeout : 10,MyLink->Name.c_str(), - MyLink->Bind, myautoconnect, MyLink->Hook.empty() ? NULL : Utils->hooks[MyLink->Hook.c_str()]); + TreeSocket* newsocket = new TreeSocket(Utils, result, MyLink->Port, MyLink->Timeout ? MyLink->Timeout : 10, + MyLink->Name.c_str(), MyLink->Bind, myautoconnect, MyLink->Hook); if (newsocket->GetFd() > -1) { /* We're all OK */ @@ -72,7 +66,7 @@ void ServernameResolver::OnError(ResolverError e, const std::string &errormessag if (query == DNS_QUERY_AAAA) { bool cached; - ServernameResolver* snr = new ServernameResolver(mine, Utils, host, MyLink, cached, DNS_QUERY_A, myautoconnect); + ServernameResolver* snr = new ServernameResolver(Utils, host, MyLink, cached, DNS_QUERY_A, myautoconnect); ServerInstance->AddResolver(snr, cached); return; } diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h index 29ead13de..5d4386c4b 100644 --- a/src/modules/m_spanningtree/resolvers.h +++ b/src/modules/m_spanningtree/resolvers.h @@ -17,7 +17,6 @@ #include "socket.h" #include "inspircd.h" #include "xline.h" -#include "../transport.h" #include "utils.h" #include "link.h" @@ -69,13 +68,12 @@ class ServernameResolver : public Resolver SpanningTreeUtilities* Utils; QueryType query; std::string host; - Module* mine; reference<Link> MyLink; reference<Autoconnect> myautoconnect; public: - ServernameResolver(Module* me, SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac); - void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached); - void OnError(ResolverError e, const std::string &errormessage); + ServernameResolver(SpanningTreeUtilities* Util, const std::string &hostname, Link* x, bool &cached, QueryType qt, Autoconnect* myac); + void OnLookupComplete(const std::string &result, unsigned int ttl, bool cached); + void OnError(ResolverError e, const std::string &errormessage); }; #endif diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index 194536c47..271e845d5 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "main.h" #include "utils.h" diff --git a/src/modules/m_spanningtree/save.cpp b/src/modules/m_spanningtree/save.cpp index cfa8dc794..1fbea0052 100644 --- a/src/modules/m_spanningtree/save.cpp +++ b/src/modules/m_spanningtree/save.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 900aceb9d..6fda446ea 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" @@ -251,11 +250,6 @@ bool TreeSocket::Inbound_Server(parameterlist ¶ms) ServerInstance->SNO->WriteToSnoMask('l',"Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] ("+description+")"); - if (this->GetIOHook()) - { - std::string name = BufferedSocketNameRequest(Utils->Creator, this->GetIOHook()).Send(); - ServerInstance->SNO->WriteToSnoMask('l',"Connection from \2"+sname+"\2["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] using transport \2"+name+"\2"); - } // this is good. Send our details: Our server name and description and hopcount of 0, // along with the sendpass from this block. diff --git a/src/modules/m_spanningtree/stats.cpp b/src/modules/m_spanningtree/stats.cpp index 71f12d50b..bc568de26 100644 --- a/src/modules/m_spanningtree/stats.cpp +++ b/src/modules/m_spanningtree/stats.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp index dff882f62..4fdc05dea 100644 --- a/src/modules/m_spanningtree/svsjoin.cpp +++ b/src/modules/m_spanningtree/svsjoin.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp index 7a723a36d..87b63ec26 100644 --- a/src/modules/m_spanningtree/svsnick.cpp +++ b/src/modules/m_spanningtree/svsnick.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp index 1e26c90d9..cc49aa72e 100644 --- a/src/modules/m_spanningtree/svspart.cpp +++ b/src/modules/m_spanningtree/svspart.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/time.cpp b/src/modules/m_spanningtree/time.cpp index 6fdcf8b53..f44a08e5c 100644 --- a/src/modules/m_spanningtree/time.cpp +++ b/src/modules/m_spanningtree/time.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 95f686698..5c7162094 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -14,7 +14,8 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" +#include "main.h" +#include "../spanningtree.h" #include "utils.h" #include "treeserver.h" @@ -147,8 +148,7 @@ void TreeServer::FinishBurst() 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)", ServerName.c_str(), (bursttime > 10000 ? bursttime / 1000 : bursttime), (bursttime > 10000 ? "secs" : "msecs")); - Event rmode((char*)ServerName.c_str(), (Module*)Utils->Creator, "new_server"); - rmode.Send(); + AddServerEvent(Utils->Creator, ServerName.c_str()); } void TreeServer::SetID(const std::string &id) diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index b29a0480c..a0f0e5d88 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -17,10 +17,8 @@ #include "socket.h" #include "inspircd.h" #include "xline.h" -#include "../transport.h" #include "utils.h" -#include "handshaketimer.h" /* * The server list in InspIRCd is maintained as two structures @@ -91,7 +89,6 @@ class TreeSocket : public BufferedSocket bool auth_challenge; /* Did we auth using challenge/response */ int proto_version; /* Remote protocol version */ public: - HandshakeTimer* hstimer; /* Handshake timer, needed to work around I/O hook buffering */ reference<Autoconnect> myautoconnect; /* Autoconnect used to cause this connection, if any */ time_t age; @@ -100,13 +97,13 @@ class TreeSocket : public BufferedSocket * most of the action, and append a few of our own values * to it. */ - TreeSocket(SpanningTreeUtilities* Util, std::string host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, Module* HookMod = NULL); + TreeSocket(SpanningTreeUtilities* Util, const std::string& host, int port, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, const std::string& Hook); /** 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. */ - TreeSocket(SpanningTreeUtilities* Util, int newfd, char* ip, Autoconnect* myac, Module* HookMod = NULL); + TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocketBase* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server); /** Get link state */ diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 70046d774..2c845bbd4 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -14,27 +14,23 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "../m_hash.h" #include "socketengine.h" #include "main.h" +#include "../spanningtree.h" #include "utils.h" #include "treeserver.h" #include "link.h" #include "treesocket.h" #include "resolvers.h" -#include "handshaketimer.h" - -/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h m_spanningtree/handshaketimer.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. */ -TreeSocket::TreeSocket(SpanningTreeUtilities* Util, std::string shost, int iport, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, Module* HookMod) +TreeSocket::TreeSocket(SpanningTreeUtilities* Util, const std::string& shost, int iport, unsigned long maxtime, const std::string &ServerName, const std::string &bindto, Autoconnect* myac, const std::string& hook) : Utils(Util), IP(shost), myautoconnect(myac) { age = ServerInstance->Time(); @@ -44,33 +40,31 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, std::string shost, int iport LinkState = CONNECTING; DoConnect(shost, iport, maxtime, bindto); Utils->timeoutlist[this] = std::pair<std::string, int>(ServerName, maxtime); - if (HookMod) - BufferedSocketHookRequest(this, Utils->Creator, HookMod).Send(); - hstimer = NULL; + // TODO AddIOHook using the given hook + 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. */ -TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, char* ip, Autoconnect* myac, Module* HookMod) - : BufferedSocket(newfd), Utils(Util), IP(ip), myautoconnect(myac) +TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocketBase* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) + : BufferedSocket(newfd), Utils(Util) { + int dummy; + irc::sockets::satoap(client, IP, dummy); age = ServerInstance->Time(); LinkState = WAIT_AUTH_1; capab_phase = 0; proto_version = 0; - /* If we have a transport module hooked to the parent, hook the same module to this - * socket, and set a timer waiting for handshake before we send CAPAB etc. - */ - if (HookMod) - BufferedSocketHookRequest(this, Utils->Creator, HookMod).Send(); - hstimer = new HandshakeTimer(this, Utils->LinkBlocks[0], this->Utils, 1); - ServerInstance->Timers->AddTimer(hstimer); + FOREACH_MOD(I_OnHookIO, OnHookIO(this, via)); + if (GetIOHook()) + GetIOHook()->OnStreamSocketAccept(this, client, server); + SendCapabilities(1); /* Fix by Brain - inbound sockets need a timeout, too. 30 secs should be pleanty */ - Utils->timeoutlist[this] = std::pair<std::string, int>("<from " + std::string(ip) + ">", 30); + Utils->timeoutlist[this] = std::pair<std::string, int>("<from " + IP + ">", 30); } ServerState TreeSocket::GetLinkState() @@ -90,16 +84,12 @@ void TreeSocket::CleanNegotiationInfo() bool TreeSocket::cull() { - if (GetIOHook()) - BufferedSocketUnhookRequest(this, Utils->Creator, GetIOHook()).Send(); Utils->timeoutlist.erase(this); return this->BufferedSocket::cull(); } TreeSocket::~TreeSocket() { - if (hstimer) - ServerInstance->Timers->DelTimer(hstimer); } /** When an outbound connection finishes connecting, we receive @@ -120,14 +110,7 @@ void TreeSocket::OnConnected() { ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] started.", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->IP.c_str())); this->OutboundPass = x->SendPass; - if (GetIOHook()) - { - ServerInstance->SNO->WriteToSnoMask('l', "Connection to \2%s\2[%s] using transport \2%s\2", myhost.c_str(), (x->HiddenFromStats ? "<hidden>" : this->IP.c_str()), x->Hook.c_str()); - hstimer = new HandshakeTimer(this, &(*x), this->Utils, 1); - ServerInstance->Timers->AddTimer(hstimer); - } - else - this->SendCapabilities(1); + this->SendCapabilities(1); return; } } @@ -209,8 +192,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) if ((Current) && (Current != Utils->TreeRoot)) { - Event rmode((char*)Current->GetName().c_str(), (Module*)Utils->Creator, "lost_server"); - rmode.Send(); + DelServerEvent(Utils->Creator, Current->GetName()); parameterlist params; params.push_back(Current->GetName()); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index bdda77ee1..c670e4b9a 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" @@ -23,9 +22,6 @@ #include "link.h" #include "treesocket.h" #include "resolvers.h" -#include "handshaketimer.h" - -/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/handshaketimer.h */ /* Handle ERROR command */ bool TreeSocket::Error(parameterlist ¶ms) diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 6279564df..4e3b07eea 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -19,7 +19,6 @@ #include "link.h" #include "treesocket.h" #include "resolvers.h" -#include "handshaketimer.h" /* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_hash.h m_spanningtree/handshaketimer.h */ diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 3cdd495aa..3b70fce31 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" @@ -33,14 +32,13 @@ void ServerSocketListener::OnAcceptReady(int newsock) int port; std::string incomingip; irc::sockets::satoap(&client, incomingip, port); - char *ip = const_cast<char*>(incomingip.c_str()); - found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end()); + found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), incomingip) != Utils->ValidIPs.end()); if (!found) { for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++) { - if (*i == "*" || irc::sockets::MatchCIDR(ip, *i)) + if (*i == "*" || irc::sockets::MatchCIDR(incomingip, *i)) { found = true; break; @@ -49,19 +47,15 @@ void ServerSocketListener::OnAcceptReady(int newsock) if (!found) { - ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip); + ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", incomingip.c_str()); ServerInstance->SE->Close(newsock); return; } } /* we don't need to do anything with the pointer, creating it stores it in the necessary places */ - TreeSocket* ts = new TreeSocket(Utils, newsock, ip, NULL, Hook); - if (Hook) - Hook->OnStreamSocketAccept(ts, &client, &server); - - return; + new TreeSocket(Utils, newsock, this, &client, &server); } /** Yay for fast searches! @@ -387,29 +381,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) { ConfigReader* Conf = new ConfigReader; - /* We don't need to worry about these being *unloaded* on the fly, only loaded, - * because we 'use' the interface locking the module in memory. - */ - hooks.clear(); - hooknames.clear(); - modulelist* ml = ServerInstance->Modules->FindInterface("BufferedSocketHook"); - - /* Did we find any modules? */ - if (ml) - { - /* Yes, enumerate them all to find out the hook name */ - for (modulelist::iterator m = ml->begin(); m != ml->end(); m++) - { - /* Make a request to it for its name, its implementing - * BufferedSocketHook so we know its safe to do this - */ - std::string name = BufferedSocketNameRequest((Module*)Creator, *m).Send(); - /* Build a map of them */ - hooks[name.c_str()] = *m; - hooknames.push_back(name); - } - } - if (rebind) { for (unsigned int i = 0; i < Bindings.size(); i++) @@ -423,7 +394,7 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) std::string Type = Conf->ReadValue("bind","type",j); std::string IP = Conf->ReadValue("bind","address",j); std::string Port = Conf->ReadValue("bind","port",j); - std::string transport = Conf->ReadValue("bind","transport",j); + std::string ssl = Conf->ReadValue("bind","ssl",j); if (Type == "servers") { irc::portparser portrange(Port, false); @@ -434,22 +405,13 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) while ((portno = portrange.GetToken())) { - if ((!transport.empty()) && (hooks.find(transport.c_str()) == hooks.end())) - { - throw CoreException("Can't find transport type '"+transport+"' for port "+IP+":"+Port+" - maybe you forgot to load it BEFORE m_spanningtree in your config file?"); - break; - } - - ServerSocketListener *listener = new ServerSocketListener(this, portno, (char *)IP.c_str()); + ServerSocketListener *listener = new ServerSocketListener(this, portno, IP, ssl); if (listener->GetFd() == -1) { delete listener; continue; } - if (!transport.empty()) - listener->Hook = hooks[transport.c_str()]; - Bindings.push_back(listener); } } @@ -490,13 +452,6 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) L->Bind = Conf->ReadValue("link", "bind", j); L->Hidden = Conf->ReadFlag("link", "hidden", j); - if ((!L->Hook.empty()) && (hooks.find(L->Hook.c_str()) == hooks.end())) - { - throw CoreException("Can't find transport type '"+L->Hook+"' for link '"+assign(L->Name)+"' - maybe you forgot to load it BEFORE m_spanningtree in your config file? Skipping <link> tag completely."); - continue; - - } - if (L->Name.find('.') == std::string::npos) throw CoreException("The link name '"+assign(L->Name)+"' is invalid and must contain at least one '.' character"); diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index d8bf765b5..7c15b2839 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -45,24 +45,18 @@ class ServerSocketListener : public ListenSocketBase SpanningTreeUtilities *Utils; public: - ServerSocketListener(SpanningTreeUtilities *u, int port, char* addr) : ListenSocketBase(port, addr) + ServerSocketListener(SpanningTreeUtilities *u, int port, const std::string& addr, const std::string& hook) + : ListenSocketBase(port, addr), Utils(u), Hook(hook) { - this->Utils = u; - Hook = NULL; } - Module* Hook; + std::string Hook; virtual void OnAcceptReady(int nfd); }; typedef std::map<TreeServer*,TreeServer*> TreeServerList; -/** A group of modules that implement BufferedSocketHook - * that we can use to hook our server to server connections. - */ -typedef std::map<irc::string, Module*> hookmodules; - /** Contains helper functions and variables for this module, * and keeps them out of the global namespace */ @@ -126,14 +120,6 @@ class SpanningTreeUtilities : public classbase */ std::vector<reference<Autoconnect> > AutoconnectBlocks; - /** List of module pointers which can provide I/O abstraction - */ - hookmodules hooks; - - /** List of module names which can provide I/O abstraction - */ - std::vector<std::string> hooknames; - /** True (default) if we are to use challenge-response HMAC * to authenticate passwords. * diff --git a/src/modules/m_spanningtree/version.cpp b/src/modules/m_spanningtree/version.cpp index 6cec7baf9..ba5386ffb 100644 --- a/src/modules/m_spanningtree/version.cpp +++ b/src/modules/m_spanningtree/version.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" diff --git a/src/modules/m_spanningtree/whois.cpp b/src/modules/m_spanningtree/whois.cpp index 79e2d7355..03fb5f923 100644 --- a/src/modules/m_spanningtree/whois.cpp +++ b/src/modules/m_spanningtree/whois.cpp @@ -14,7 +14,6 @@ #include "inspircd.h" #include "socket.h" #include "xline.h" -#include "../transport.h" #include "socketengine.h" #include "main.h" |