diff options
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 5 | ||||
-rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 33 |
3 files changed, 33 insertions, 13 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 4f22a5e70..0006c9de9 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -445,7 +445,10 @@ class ModuleSSLGnuTLS : public Module } virtual int OnRawSocketWrite(int fd, const char* buffer, int count) - { + { + if (!count) + return 0; + issl_session* session = &sessions[fd]; const char* sendbuffer = buffer; diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 0da67d677..06708ff54 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -296,16 +296,19 @@ class ModuleSSLOpenSSL : public Module virtual char* OnRequest(Request* request) { ISHRequest* ISR = (ISHRequest*)request; + ServerInstance->Log(DEBUG, "hook OnRequest"); if (strcmp("IS_NAME", request->GetId()) == 0) { return "openssl"; } else if (strcmp("IS_HOOK", request->GetId()) == 0) { + ServerInstance->Log(DEBUG, "Hooking socket %08x", ISR->Sock); return ServerInstance->Config->AddIOHook((Module*)this, (InspSocket*)ISR->Sock) ? (char*)"OK" : NULL; } else if (strcmp("IS_UNHOOK", request->GetId()) == 0) { + ServerInstance->Log(DEBUG, "Unhooking socket %08x", ISR->Sock); return ServerInstance->Config->DelIOHook((InspSocket*)ISR->Sock) ? (char*)"OK" : NULL; } return NULL; @@ -314,6 +317,7 @@ class ModuleSSLOpenSSL : public Module virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport) { + ServerInstance->Log(DEBUG, "Hook accept %d", fd); issl_session* session = &sessions[fd]; session->fd = fd; @@ -515,6 +519,10 @@ class ModuleSSLOpenSSL : public Module int DoWrite(issl_session* session) { + if (!session->outbuf.size()) + return -1; + + ServerInstance->Log(DEBUG, "m_ssl_openssl.so: To write: %d", session->outbuf.size()); int ret = SSL_write(session->sess, session->outbuf.data(), session->outbuf.size()); if (ret == 0) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index a0563c255..e96656910 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -680,8 +680,10 @@ class TreeSocket : public InspSocket this->ctx_in = NULL; this->ctx_out = NULL; - if (Hook) - InspSocketHookRequest(this, Hook, (Module*)Utils->Creator).Send(); + Instance->Log(DEBUG, "HOOK = %08x", Hook); + + if (listening && Hook) + InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); } TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, std::string ServerName, Module* HookMod = NULL) @@ -691,9 +693,6 @@ class TreeSocket : public InspSocket this->LinkState = CONNECTING; this->ctx_in = NULL; this->ctx_out = NULL; - - if (Hook) - InspSocketHookRequest(this, Hook, (Module*)Utils->Creator).Send(); } /** When a listening socket gives us a new file descriptor, @@ -701,16 +700,18 @@ class TreeSocket : public InspSocket * connection. This constructor is used for this purpose. */ TreeSocket(SpanningTreeUtilities* Util, InspIRCd* SI, int newfd, char* ip, Module* HookMod = NULL) - : InspSocket(SI, newfd, ip), Utils(Util) + : InspSocket(SI, newfd, ip), Utils(Util), Hook(HookMod) { this->LinkState = WAIT_AUTH_1; this->ctx_in = NULL; this->ctx_out = NULL; + Instance->Log(DEBUG, "HOOK = %08x", Hook); + if (Hook) - InspSocketHookRequest(this, Hook, (Module*)Utils->Creator).Send(); + InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); - this->SendCapabilities(); + //this->SendCapabilities(); } ~TreeSocket() @@ -721,7 +722,7 @@ class TreeSocket : public InspSocket DELETE(ctx_out); if (Hook) - InspSocketUnhookRequest(this, Hook, (Module*)Utils->Creator).Send(); + InspSocketUnhookRequest(this, (Module*)Utils->Creator, Hook).Send(); } void InitAES(std::string key,std::string SName) @@ -768,7 +769,11 @@ class TreeSocket : public InspSocket if (x->Name == this->myhost) { this->Instance->SNO->WriteToSnoMask('l',"Connection to \2"+myhost+"\2["+(x->HiddenFromStats ? "<hidden>" : this->GetIP())+"] started."); - this->SendCapabilities(); + + if (Hook) + InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); + + //this->SendCapabilities(); if (x->EncryptionKey != "") { if (!(x->EncryptionKey.length() == 16 || x->EncryptionKey.length() == 24 || x->EncryptionKey.length() == 32)) @@ -4100,8 +4105,12 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind) if (IP == "*") IP = ""; - if ((!transport.empty()) && (hooks.find(transport.c_str()) == hooks.end())) - return; + if ((!transport.empty()) && (hooks.find(transport.c_str()) == hooks.end())) + { + ServerInstance->Log(DEFAULT,"m_spanningtree: WARNING: Can't find transport type '%s' - maybe you forgot to load it BEFORE m_spanningtree in your config file?", + transport.c_str()); + continue; + } TreeSocket* listener = new TreeSocket(this, ServerInstance, IP.c_str(), portno, true, 10, transport.empty() ? NULL : hooks[transport.c_str()]); if (listener->GetState() == I_LISTENING) |