SSLConnectionManager.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2002-2009 Moxie Marlinspike
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 3 of the
  7. * License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  17. * USA
  18. */
  19. #ifndef __CONNECTION_MANAGER_H__
  20. #define __CONNECTION_MANAGER_H__
  21. #include "certificate/CertificateManager.hpp"
  22. #include "http/HttpConnectionManager.hpp"
  23. #include <boost/asio.hpp>
  24. #include <boost/shared_ptr.hpp>
  25. using namespace boost::asio;
  26. class SSLConnectionManager {
  27. private:
  28. static const short HTTPS_PORT = 443;
  29. CertificateManager &certificateManager;
  30. ip::tcp::acceptor acceptor;
  31. void acceptIncomingConnection();
  32. void handleClientConnection(boost::shared_ptr<ip::tcp::socket> socket,
  33. const boost::system::error_code &error);
  34. void interceptSSL(boost::shared_ptr<ip::tcp::socket> clientSocket,
  35. ip::tcp::endpoint &destination,
  36. bool wildcardOK);
  37. void interceptUpdate(boost::shared_ptr<ip::tcp::socket> clientSocket,
  38. ip::tcp::endpoint &destination,
  39. bool wildcardOK);
  40. void interceptAddon(boost::shared_ptr<ip::tcp::socket> clientSocket,
  41. ip::tcp::endpoint &destination,
  42. bool wildcardOK);
  43. void interceptConnection(boost::shared_ptr<ip::tcp::socket> clientSocket,
  44. ip::tcp::endpoint destination,
  45. bool wildcardOK);
  46. void shuttleConnection(boost::shared_ptr<ip::tcp::socket> clientSocket,
  47. ip::tcp::endpoint &destination);
  48. public:
  49. SSLConnectionManager(io_service &io_service,
  50. CertificateManager &certificateManager,
  51. int sslPort);
  52. };
  53. #endif