2017-08-06 18:36:14 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <boost/asio.hpp>
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
#include <thread>
|
|
|
|
#include <array>
|
|
|
|
#include <iomanip>
|
|
|
|
|
2017-08-06 19:54:41 +00:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2017-08-07 00:37:08 +00:00
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
|
2017-08-06 18:36:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
#include "http/server.hpp"
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
int main()
|
2017-08-06 18:36:14 +00:00
|
|
|
{
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
try
|
2017-08-06 18:36:14 +00:00
|
|
|
{
|
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
boost::asio::ssl::context sslContext(boost::asio::ssl::context::tls_server);
|
2017-08-07 02:26:32 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
SSL_CTX_set_cipher_list(sslContext.native_handle(), "EECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS");
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.set_options(boost::asio::ssl::context::default_workarounds
|
|
|
|
| boost::asio::ssl::context::verify_none
|
|
|
|
| boost::asio::ssl::context::no_sslv2
|
|
|
|
| boost::asio::ssl::context::no_sslv3
|
|
|
|
| boost::asio::ssl::context::no_tlsv1
|
|
|
|
| boost::asio::ssl::context::single_dh_use
|
|
|
|
);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
std::function<std::string(std::size_t, boost::asio::ssl::context_base::password_purpose)> f = [](std::size_t, boost::asio::ssl::context_base::password_purpose) -> std::string { return ""; };
|
|
|
|
sslContext.set_password_callback(f);
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-26 11:41:10 +00:00
|
|
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
|
|
|
sslContext.use_certificate_chain_file("../linux/fullchain1.pem");
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-26 11:41:10 +00:00
|
|
|
sslContext.use_private_key_file("../linux/privkey1.pem", boost::asio::ssl::context::pem);
|
|
|
|
#else
|
2018-08-26 11:32:48 +00:00
|
|
|
sslContext.use_certificate_chain_file("/home/ubuntu/work/proxyServerTest/linux/fullchain1.pem");
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-26 11:32:48 +00:00
|
|
|
sslContext.use_private_key_file("/home/ubuntu/work/proxyServerTest/linux/privkey1.pem", boost::asio::ssl::context::pem);
|
2018-08-26 11:41:10 +00:00
|
|
|
#endif
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 19:32:06 +00:00
|
|
|
sslContext.use_tmp_dh_file("dh2048.pem");
|
2018-08-25 18:23:54 +00:00
|
|
|
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
// Initialise the server.
|
2018-08-26 11:41:10 +00:00
|
|
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
|
|
|
http::server::server s("0.0.0.0", "", "../html/", sslContext);
|
|
|
|
#else
|
|
|
|
http::server::server s("0.0.0.0", "", "/home/ubuntu/work/proxyServerTest/html/", sslContext);
|
|
|
|
#endif
|
2018-08-25 18:23:54 +00:00
|
|
|
// Run the server until stopped.
|
|
|
|
s.run();
|
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
|
|
|
std::cerr << "exception: " << e.what() << "\n";
|
|
|
|
}
|
2017-08-06 18:36:14 +00:00
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2017-08-06 19:54:41 +00:00
|
|
|
|
|
|
|
|
2018-08-25 18:23:54 +00:00
|
|
|
|