-/*\r
- * @file sslproxysession.h\r
- * @brief SSLproxy session Header\r
- *\r
- * Copyright (C) 2008 NTT COMWARE Corporation.\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\r
- * 02110-1301 USA\r
- *\r
- **********************************************************************\r
- *\r
- * Distributed under the Boost Software Licence, Version 1.0\r
- * http://www.boost.org/LICENSE_1_0.txt\r
- *\r
- **********************************************************************/\r
-\r
-#ifndef __SSLPROXYSESSION_H__\r
-#define __SSLPROXYSESSION_H__\r
-\r
-#include <boost/asio.hpp>\r
-#include <boost/asio/ssl.hpp>\r
-#include <boost/thread.hpp>\r
-\r
-//! SSL socket for client.\r
-typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;\r
-\r
-//! TCP socket for server. (target)\r
-typedef boost::asio::ip::tcp::socket nomal_socket;\r
-\r
-class sslproxy_session\r
-{\r
-protected:\r
- nomal_socket server_socket;\r
- ssl_socket client_socket;\r
- boost::asio::ip::tcp::resolver::iterator endpoint_iterator;\r
- boost::asio::deadline_timer timer;\r
- int cancel_time;\r
- char client_buffer[MAX_BUFFER_SIZE];\r
- char server_buffer[MAX_BUFFER_SIZE];\r
- bool handshaked;\r
- bool istimeout;\r
- bool c_r_event;\r
- bool c_w_event;\r
- bool s_r_event;\r
- bool s_w_event;\r
- bool finishing;\r
- pthread_mutex_t client_socket_mutex;\r
- boost::asio::deadline_timer cache_timer;\r
-\r
-public:\r
- // constructor\r
- sslproxy_session(boost::asio::io_service& ioservice,\r
- boost::asio::ssl::context& context,\r
- boost::asio::ip::tcp::resolver::iterator itr);\r
- // destructor\r
- ~sslproxy_session();\r
- // Low level socket getting function.\r
- ssl_socket::lowest_layer_type& low_socket();\r
- // Get remote endpoint (client address:port) function.\r
- std::string get_remote_endpoint(ssl_socket& socket);\r
- // Session start function\r
- void start();\r
- // Timer cancel function.\r
- void cancel(const boost::system::error_code& error);\r
- // Cache expire function.\r
- void cache_expire(const boost::system::error_code& error);\r
- // Session destroy function.\r
- void destroy_session(sslproxy_session* session);\r
- // Handshake handling function.\r
- void handle_handshake(const boost::system::error_code& error);\r
- // Connect handling function.\r
- void handle_connect(const boost::system::error_code& error);\r
- // Client read handling function.\r
- void handle_client_read(const boost::system::error_code& error, size_t bytes_transferred);\r
- // Server write handling function.\r
- void handle_server_write(const boost::system::error_code& error, size_t bytes_transferred);\r
- // Server read handling function.\r
- void handle_server_read(const boost::system::error_code& error, size_t bytes_transferred);\r
- // Client write handling function.\r
- void handle_client_write(const boost::system::error_code& error, size_t bytes_transferred);\r
-};\r
-\r
-#endif //__SSLPROXYSESSION_H__\r
+/*
+ * @file sslproxysession.h
+ * @brief SSLproxy session Header
+ *
+ * Copyright (C) 2008 NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************
+ *
+ * Distributed under the Boost Software Licence, Version 1.0
+ * http://www.boost.org/LICENSE_1_0.txt
+ *
+ **********************************************************************/
+
+#ifndef __SSLPROXYSESSION_H__
+#define __SSLPROXYSESSION_H__
+
+#include <boost/asio.hpp>
+#include <boost/asio/ssl.hpp>
+#include <boost/thread.hpp>
+
+//! SSL socket for client.
+typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
+
+//! TCP socket for server. (target)
+typedef boost::asio::ip::tcp::socket nomal_socket;
+
+class sslproxy_session
+{
+protected:
+ nomal_socket server_socket;
+ ssl_socket client_socket;
+ boost::asio::ip::tcp::resolver::iterator endpoint_iterator;
+ boost::asio::deadline_timer timer;
+ int cancel_time;
+ char client_buffer[MAX_BUFFER_SIZE];
+ char server_buffer[MAX_BUFFER_SIZE];
+ bool handshaked;
+ bool istimeout;
+ bool c_r_event;
+ bool c_w_event;
+ bool s_r_event;
+ bool s_w_event;
+ bool finishing;
+ pthread_mutex_t client_socket_mutex;
+ boost::asio::deadline_timer cache_timer;
+
+public:
+ // constructor
+ sslproxy_session(boost::asio::io_service& ioservice,
+ boost::asio::ssl::context& context,
+ boost::asio::ip::tcp::resolver::iterator itr);
+ // destructor
+ ~sslproxy_session();
+ // Low level socket getting function.
+ ssl_socket::lowest_layer_type& low_socket();
+ // Get remote endpoint (client address:port) function.
+ std::string get_remote_endpoint() const;
+ // Session start function
+ void start();
+ // Timer cancel function.
+ void cancel(const boost::system::error_code& error);
+ // Cache expire function.
+ void cache_expire(const boost::system::error_code& error);
+ // Session destroy function.
+ void destroy_session(sslproxy_session* session);
+ // Handshake handling function.
+ void handle_handshake(const boost::system::error_code& error);
+ // Connect handling function.
+ void handle_connect(const boost::system::error_code& error);
+ // Client read handling function.
+ void handle_client_read(const boost::system::error_code& error, size_t bytes_transferred);
+ // Server write handling function.
+ void handle_server_write(const boost::system::error_code& error, size_t bytes_transferred);
+ // Server read handling function.
+ void handle_server_read(const boost::system::error_code& error, size_t bytes_transferred);
+ // Client write handling function.
+ void handle_client_write(const boost::system::error_code& error, size_t bytes_transferred);
+ // Edit client message function.
+ void edit_client_message(size_t& bytes_transferred);
+ // Edit server message function.
+ void edit_server_message(size_t& bytes_transferred);
+};
+
+#endif //__SSLPROXYSESSION_H__