2 * @file sslproxysession.h
3 * @brief SSLproxy session Header
5 * Copyright (C) 2008 NTT COMWARE Corporation.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 **********************************************************************
24 * Distributed under the Boost Software Licence, Version 1.0
25 * http://www.boost.org/LICENSE_1_0.txt
27 **********************************************************************/
29 #ifndef __SSLPROXYSESSION_H__
30 #define __SSLPROXYSESSION_H__
32 #include <boost/asio.hpp>
33 #include <boost/asio/ssl.hpp>
34 #include <boost/thread.hpp>
36 //! SSL socket for client.
37 typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
39 //! TCP socket for server. (target)
40 typedef boost::asio::ip::tcp::socket nomal_socket;
42 class sslproxy_session
45 nomal_socket server_socket;
46 ssl_socket client_socket;
47 boost::asio::ip::tcp::resolver::iterator endpoint_iterator;
48 boost::asio::deadline_timer timer;
50 char client_buffer[MAX_BUFFER_SIZE];
51 char server_buffer[MAX_BUFFER_SIZE];
59 pthread_mutex_t client_socket_mutex;
60 boost::asio::deadline_timer cache_timer;
64 sslproxy_session(boost::asio::io_service& ioservice,
65 boost::asio::ssl::context& context,
66 boost::asio::ip::tcp::resolver::iterator itr);
69 // Low level socket getting function.
70 ssl_socket::lowest_layer_type& low_socket();
71 // Get remote endpoint (client address:port) function.
72 std::string get_remote_endpoint() const;
73 // Session start function
75 // Timer cancel function.
76 void cancel(const boost::system::error_code& error);
77 // Cache expire function.
78 void cache_expire(const boost::system::error_code& error);
79 // Session destroy function.
80 void destroy_session(sslproxy_session* session);
81 // Handshake handling function.
82 void handle_handshake(const boost::system::error_code& error);
83 // Connect handling function.
84 void handle_connect(const boost::system::error_code& error);
85 // Client read handling function.
86 void handle_client_read(const boost::system::error_code& error, size_t bytes_transferred);
87 // Server write handling function.
88 void handle_server_write(const boost::system::error_code& error, size_t bytes_transferred);
89 // Server read handling function.
90 void handle_server_read(const boost::system::error_code& error, size_t bytes_transferred);
91 // Client write handling function.
92 void handle_client_write(const boost::system::error_code& error, size_t bytes_transferred);
93 // Edit client message function.
94 void edit_client_message(size_t& bytes_transferred);
95 // Edit server message function.
96 void edit_server_message(size_t& bytes_transferred);
99 #endif //__SSLPROXYSESSION_H__