proxyServerTest/main.cpp

71 lines
1.9 KiB
C++
Executable File

#include <iostream>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
#include <thread>
#include <array>
#include <iomanip>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include "http/server.hpp"
int main()
{
try
{
boost::asio::ssl::context sslContext(boost::asio::ssl::context::tls_server);
SSL_CTX_set_cipher_list(sslContext.native_handle(), "EECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS");
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
);
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);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
sslContext.use_certificate_chain_file("../linux/fullchain1.pem");
sslContext.use_private_key_file("../linux/privkey1.pem", boost::asio::ssl::context::pem);
#else
sslContext.use_certificate_chain_file("/home/ubuntu/work/proxyServerTest/linux/fullchain1.pem");
sslContext.use_private_key_file("/home/ubuntu/work/proxyServerTest/linux/privkey1.pem", boost::asio::ssl::context::pem);
#endif
sslContext.use_tmp_dh_file("dh2048.pem");
// Initialise the server.
#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
// Run the server until stopped.
s.run();
}
catch (std::exception& e)
{
std::cerr << "exception: " << e.what() << "\n";
}
return 0;
}