mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
m_ssl_gnutls Move logic that reads data from a session into new class GnuTLS::DataReader
This commit is contained in:
parent
7c158dd977
commit
b8d0753b0b
@ -451,6 +451,28 @@ namespace GnuTLS
|
||||
}
|
||||
};
|
||||
|
||||
class DataReader
|
||||
{
|
||||
int retval;
|
||||
char* const buffer;
|
||||
|
||||
public:
|
||||
DataReader(gnutls_session_t sess)
|
||||
: buffer(ServerInstance->GetReadBuffer())
|
||||
{
|
||||
// Read data from GnuTLS buffers into ReadBuffer
|
||||
retval = gnutls_record_recv(sess, buffer, ServerInstance->Config->NetBufferSize);
|
||||
}
|
||||
|
||||
void appendto(std::string& recvq)
|
||||
{
|
||||
// Copy data from ReadBuffer to recvq
|
||||
recvq.append(buffer, retval);
|
||||
}
|
||||
|
||||
int ret() const { return retval; }
|
||||
};
|
||||
|
||||
class Profile : public refcountbase
|
||||
{
|
||||
/** Name of this profile
|
||||
@ -848,12 +870,11 @@ info_done_dealloc:
|
||||
|
||||
if (this->status == ISSL_HANDSHAKEN)
|
||||
{
|
||||
char* buffer = ServerInstance->GetReadBuffer();
|
||||
size_t bufsiz = ServerInstance->Config->NetBufferSize;
|
||||
int ret = gnutls_record_recv(this->sess, buffer, bufsiz);
|
||||
GnuTLS::DataReader reader(sess);
|
||||
int ret = reader.ret();
|
||||
if (ret > 0)
|
||||
{
|
||||
recvq.append(buffer, ret);
|
||||
reader.appendto(recvq);
|
||||
return 1;
|
||||
}
|
||||
else if (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED)
|
||||
|
Loading…
x
Reference in New Issue
Block a user