diff options
author | Mattes D <github@xoft.cz> | 2015-01-24 23:17:13 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-01-27 14:53:31 +0100 |
commit | 86f2f82d2a81bac4739d135959b08c011d007303 (patch) | |
tree | 614dc16d6665575915d819cbc01ed35167ef9200 /src/PolarSSL++/BlockingSslClientSocket.h | |
parent | Converted cServer to use the cNetwork API. (diff) | |
download | cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar.gz cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar.bz2 cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar.lz cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar.xz cuberite-86f2f82d2a81bac4739d135959b08c011d007303.tar.zst cuberite-86f2f82d2a81bac4739d135959b08c011d007303.zip |
Diffstat (limited to 'src/PolarSSL++/BlockingSslClientSocket.h')
-rw-r--r-- | src/PolarSSL++/BlockingSslClientSocket.h | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/PolarSSL++/BlockingSslClientSocket.h b/src/PolarSSL++/BlockingSslClientSocket.h index 7af897582..319e82bf2 100644 --- a/src/PolarSSL++/BlockingSslClientSocket.h +++ b/src/PolarSSL++/BlockingSslClientSocket.h @@ -9,8 +9,8 @@ #pragma once +#include "OSSupport/Network.h" #include "CallbackSslContext.h" -#include "../OSSupport/Socket.h" @@ -51,25 +51,56 @@ public: const AString & GetLastErrorText(void) const { return m_LastErrorText; } protected: + friend class cBlockingSslClientSocketConnectCallbacks; + friend class cBlockingSslClientSocketLinkCallbacks; + /** The SSL context used for the socket */ cCallbackSslContext m_Ssl; /** The underlying socket to the SSL server */ - cSocket m_Socket; + cTCPLinkPtr m_Socket; + + /** The object used to signal state changes in the socket (the cause of the blocking). */ + cEvent m_Event; /** The trusted CA root cert store, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */ cX509CertPtr m_CACerts; /** The expected SSL peer's name, if we are to verify the cert strictly. Set by SetTrustedRootCertsFromString(). */ AString m_ExpectedPeerName; + + /** The hostname to which the socket is connecting (stored for error reporting). */ + AString m_ServerName; /** Text of the last error that has occurred. */ AString m_LastErrorText; /** Set to true if the connection established successfully. */ bool m_IsConnected; + + /** Protects m_IncomingData against multithreaded access. */ + cCriticalSection m_CSIncomingData; + + /** Buffer for the data incoming on the network socket. + Protected by m_CSIncomingData. */ + AString m_IncomingData; + /** Called when the connection is established successfully. */ + void OnConnected(void); + + /** Called when an error occurs while connecting the socket. */ + void OnConnectError(const AString & a_ErrorMsg); + + /** Called when there's incoming data from the socket. */ + void OnReceivedData(const char * a_Data, size_t a_Size); + + /** Called when the link for the connection is created. */ + void SetLink(cTCPLinkPtr a_Link); + + /** Called when the link is disconnected, either gracefully or by an error. */ + void OnDisconnected(void); + // cCallbackSslContext::cDataCallbacks overrides: virtual int ReceiveEncrypted(unsigned char * a_Buffer, size_t a_NumBytes) override; virtual int SendEncrypted(const unsigned char * a_Buffer, size_t a_NumBytes) override; |