工具项目

HPSocket-SSL.cpp 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Author : Bruce Liang
  5. * Website : http://www.jessma.org
  6. * Project : https://github.com/ldcsaa
  7. * Blog : http://www.cnblogs.com/ldcsaa
  8. * Wiki : http://www.oschina.net/p/hp-socket
  9. * QQ Group : 75375912, 44636872
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. #include "stdafx.h"
  24. #include "HPSocket-SSL.h"
  25. #ifdef _SSL_SUPPORT
  26. #include "TcpServer.h"
  27. #include "TcpAgent.h"
  28. #include "TcpClient.h"
  29. #include "TcpPullServer.h"
  30. #include "TcpPullClient.h"
  31. #include "TcpPullAgent.h"
  32. #include "TcpPackServer.h"
  33. #include "TcpPackClient.h"
  34. #include "TcpPackAgent.h"
  35. #ifdef _HTTP_SUPPORT
  36. #include "HttpServer.h"
  37. #include "HttpAgent.h"
  38. #include "HttpClient.h"
  39. #endif
  40. /*****************************************************************************************************************************************************/
  41. /******************************************************************** SSL Exports ********************************************************************/
  42. /*****************************************************************************************************************************************************/
  43. HPSOCKET_API ITcpServer* HP_Create_SSLServer(ITcpServerListener* pListener)
  44. {
  45. return new CSSLServer(pListener);
  46. }
  47. HPSOCKET_API ITcpAgent* HP_Create_SSLAgent(ITcpAgentListener* pListener)
  48. {
  49. return new CSSLAgent(pListener);
  50. }
  51. HPSOCKET_API ITcpClient* HP_Create_SSLClient(ITcpClientListener* pListener)
  52. {
  53. return new CSSLClient(pListener);
  54. }
  55. HPSOCKET_API ITcpPullServer* HP_Create_SSLPullServer(ITcpServerListener* pListener)
  56. {
  57. return (ITcpPullServer*)(new CSSLPullServer(pListener));
  58. }
  59. HPSOCKET_API ITcpPullAgent* HP_Create_SSLPullAgent(ITcpAgentListener* pListener)
  60. {
  61. return (ITcpPullAgent*)(new CSSLPullAgent(pListener));
  62. }
  63. HPSOCKET_API ITcpPullClient* HP_Create_SSLPullClient(ITcpClientListener* pListener)
  64. {
  65. return (ITcpPullClient*)(new CSSLPullClient(pListener));
  66. }
  67. HPSOCKET_API ITcpPackServer* HP_Create_SSLPackServer(ITcpServerListener* pListener)
  68. {
  69. return (ITcpPackServer*)(new CSSLPackServer(pListener));
  70. }
  71. HPSOCKET_API ITcpPackAgent* HP_Create_SSLPackAgent(ITcpAgentListener* pListener)
  72. {
  73. return (ITcpPackAgent*)(new CSSLPackAgent(pListener));
  74. }
  75. HPSOCKET_API ITcpPackClient* HP_Create_SSLPackClient(ITcpClientListener* pListener)
  76. {
  77. return (ITcpPackClient*)(new CSSLPackClient(pListener));
  78. }
  79. HPSOCKET_API void HP_Destroy_SSLServer(ITcpServer* pServer)
  80. {
  81. delete pServer;
  82. }
  83. HPSOCKET_API void HP_Destroy_SSLAgent(ITcpAgent* pAgent)
  84. {
  85. delete pAgent;
  86. }
  87. HPSOCKET_API void HP_Destroy_SSLClient(ITcpClient* pClient)
  88. {
  89. delete pClient;
  90. }
  91. HPSOCKET_API void HP_Destroy_SSLPullServer(ITcpPullServer* pServer)
  92. {
  93. delete pServer;
  94. }
  95. HPSOCKET_API void HP_Destroy_SSLPullAgent(ITcpPullAgent* pAgent)
  96. {
  97. delete pAgent;
  98. }
  99. HPSOCKET_API void HP_Destroy_SSLPullClient(ITcpPullClient* pClient)
  100. {
  101. delete pClient;
  102. }
  103. HPSOCKET_API void HP_Destroy_SSLPackServer(ITcpPackServer* pServer)
  104. {
  105. delete pServer;
  106. }
  107. HPSOCKET_API void HP_Destroy_SSLPackAgent(ITcpPackAgent* pAgent)
  108. {
  109. delete pAgent;
  110. }
  111. HPSOCKET_API void HP_Destroy_SSLPackClient(ITcpPackClient* pClient)
  112. {
  113. delete pClient;
  114. }
  115. /*****************************************************************************************************************************************************/
  116. /*************************************************************** Global Function Exports *************************************************************/
  117. /*****************************************************************************************************************************************************/
  118. HPSOCKET_API void HP_SSL_RemoveThreadLocalState(DWORD dwThreadID)
  119. {
  120. CSSLContext::RemoveThreadLocalState(dwThreadID);
  121. }
  122. /*****************************************************************************************************************************************************/
  123. /******************************************************************** HTTPS Exports ******************************************************************/
  124. /*****************************************************************************************************************************************************/
  125. #ifdef _HTTP_SUPPORT
  126. HPSOCKET_API IHttpServer* HP_Create_HttpsServer(IHttpServerListener* pListener)
  127. {
  128. return (IHttpServer*)(new CHttpsServer(pListener));
  129. }
  130. HPSOCKET_API IHttpAgent* HP_Create_HttpsAgent(IHttpAgentListener* pListener)
  131. {
  132. return (IHttpAgent*)(new CHttpsAgent(pListener));
  133. }
  134. HPSOCKET_API IHttpClient* HP_Create_HttpsClient(IHttpClientListener* pListener)
  135. {
  136. return (IHttpClient*)(new CHttpsClient(pListener));
  137. }
  138. HPSOCKET_API IHttpSyncClient* HP_Create_HttpsSyncClient(IHttpClientListener* pListener)
  139. {
  140. return (IHttpSyncClient*)(new CHttpsSyncClient(pListener));
  141. }
  142. HPSOCKET_API void HP_Destroy_HttpsServer(IHttpServer* pServer)
  143. {
  144. delete pServer;
  145. }
  146. HPSOCKET_API void HP_Destroy_HttpsAgent(IHttpAgent* pAgent)
  147. {
  148. delete pAgent;
  149. }
  150. HPSOCKET_API void HP_Destroy_HttpsClient(IHttpClient* pClient)
  151. {
  152. delete pClient;
  153. }
  154. HPSOCKET_API void HP_Destroy_HttpsSyncClient(IHttpSyncClient* pClient)
  155. {
  156. delete pClient;
  157. }
  158. #endif
  159. #endif