X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fextra%2Fm_ssl_gnutls.cpp;h=e142ead1188ae39be7b72081ba0c858f9bdb59f2;hb=1f0485039a276ad1c2fa3d53d284e3a87940ec77;hp=a2bdb76eebdfa8133cdf21db9617662df608109c;hpb=8f5efbc7aa33b792e02d01e3288f553e6e98ccaa;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index a2bdb76ee..e142ead11 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -968,7 +968,7 @@ info_done_dealloc: } } - int OnStreamSocketWrite(StreamSocket* user, std::string& sendq) CXX11_OVERRIDE + int OnStreamSocketWrite(StreamSocket* user) CXX11_OVERRIDE { // Finish handshake if needed int prepret = PrepareIO(user); @@ -976,19 +976,21 @@ info_done_dealloc: return prepret; // Session is ready for transferring application data + StreamSocket::SendQueue& sendq = user->GetSendQ(); int ret = 0; { - ret = gnutls_record_send(this->sess, sendq.data(), sendq.length()); + const StreamSocket::SendQueue::Element& buffer = sendq.front(); + ret = gnutls_record_send(this->sess, buffer.data(), buffer.length()); - if (ret == (int)sendq.length()) + if (ret == (int)buffer.length()) { SocketEngine::ChangeEventMask(user, FD_WANT_NO_WRITE); return 1; } else if (ret > 0) { - sendq.erase(0, ret); + sendq.erase_front(ret); SocketEngine::ChangeEventMask(user, FD_WANT_SINGLE_WRITE); return 0; } @@ -1029,6 +1031,7 @@ info_done_dealloc: } GnuTLS::Profile* GetProfile() { return profile; } + bool IsHandshakeDone() const { return (status == ISSL_HANDSHAKEN); } }; int GnuTLS::X509Credentials::cert_callback(gnutls_session_t sess, const gnutls_datum_t* req_ca_rdn, int nreqs, const gnutls_pk_algorithm_t* sign_algos, int sign_algos_length, cert_cb_last_param_type* st) @@ -1204,6 +1207,18 @@ class ModuleSSLGnuTLS : public Module if (hook && hook->prov->creator == this) static_cast(hook)->TellCiphersAndFingerprint(user); } + + ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE + { + if ((user->eh.GetIOHook()) && (user->eh.GetIOHook()->prov->creator == this)) + { + GnuTLSIOHook* iohook = static_cast(user->eh.GetIOHook()); + if (!iohook->IsHandshakeDone()) + return MOD_RES_DENY; + } + + return MOD_RES_PASSTHRU; + } }; MODULE_INIT(ModuleSSLGnuTLS)