summaryrefslogtreecommitdiff
path: root/src/modules/extra
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-03-05 16:52:06 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-03-05 16:52:06 +0100
commitbbbd6c9ac46c040b9769c227f0f3ffbfcd43b0e7 (patch)
tree3573335c16bcc7808321d09db29c1a1bb1ae9142 /src/modules/extra
parente9b021cc990deaf3028cb09efa3db0040b0d62a9 (diff)
m_ssl_gnutls, m_ssl_openssl Simplify status handling in IOHook read/write handlers
Remove states ISSL_CLOSING and ISSL_CLOSED from m_ssl_gnutls
Diffstat (limited to 'src/modules/extra')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp13
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp11
2 files changed, 5 insertions, 19 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 0b22788fd..30b54ff8b 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -70,7 +70,7 @@ typedef gnutls_certificate_credentials_t gnutls_certificate_credentials;
typedef gnutls_dh_params_t gnutls_dh_params;
#endif
-enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_HANDSHAKEN, ISSL_CLOSING, ISSL_CLOSED };
+enum issl_status { ISSL_NONE, ISSL_HANDSHAKING, ISSL_HANDSHAKEN };
#if INSPIRCD_GNUTLS_HAS_VERSION(2, 12, 0)
#define GNUTLS_NEW_CERT_CALLBACK_API
@@ -657,7 +657,6 @@ class GnuTLSIOHook : public SSLIOHook
{
user->SetError("Handshake Failed - " + std::string(gnutls_strerror(ret)));
CloseSession();
- this->status = ISSL_CLOSING;
return -1;
}
}
@@ -891,8 +890,6 @@ info_done_dealloc:
}
// If we resumed the handshake then this->status will be ISSL_HANDSHAKEN.
-
- if (this->status == ISSL_HANDSHAKEN)
{
GnuTLS::DataReader reader(sess);
int ret = reader.ret();
@@ -918,10 +915,6 @@ info_done_dealloc:
return -1;
}
}
- else if (this->status == ISSL_CLOSING)
- return -1;
-
- return 0;
}
int OnStreamSocketWrite(StreamSocket* user, std::string& sendq) CXX11_OVERRIDE
@@ -941,9 +934,9 @@ info_done_dealloc:
return ret;
}
+ // Session is ready for transferring application data
int ret = 0;
- if (this->status == ISSL_HANDSHAKEN)
{
ret = gnutls_record_send(this->sess, sendq.data(), sendq.length());
@@ -970,8 +963,6 @@ info_done_dealloc:
return -1;
}
}
-
- return 0;
}
void TellCiphersAndFingerprint(LocalUser* user)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 21227fe6d..c0ab862d2 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -546,8 +546,6 @@ class OpenSSLIOHook : public SSLIOHook
}
// If we resumed the handshake then this->status will be ISSL_OPEN
-
- if (status == ISSL_OPEN)
{
ERR_clear_error();
char* buffer = ServerInstance->GetReadBuffer();
@@ -573,7 +571,7 @@ class OpenSSLIOHook : public SSLIOHook
user->SetError("Connection closed");
return -1;
}
- else if (ret < 0)
+ else // if (ret < 0)
{
int err = SSL_get_error(sess, ret);
@@ -594,8 +592,6 @@ class OpenSSLIOHook : public SSLIOHook
}
}
}
-
- return 0;
}
int OnStreamSocketWrite(StreamSocket* user, std::string& buffer) CXX11_OVERRIDE
@@ -615,7 +611,7 @@ class OpenSSLIOHook : public SSLIOHook
return ret;
}
- if (status == ISSL_OPEN)
+ // Session is ready for transferring application data
{
ERR_clear_error();
int ret = SSL_write(sess, buffer.data(), buffer.size());
@@ -642,7 +638,7 @@ class OpenSSLIOHook : public SSLIOHook
CloseSession();
return -1;
}
- else if (ret < 0)
+ else // if (ret < 0)
{
int err = SSL_get_error(sess, ret);
@@ -663,7 +659,6 @@ class OpenSSLIOHook : public SSLIOHook
}
}
}
- return 0;
}
void TellCiphersAndFingerprint(LocalUser* user)