#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);

		sslContext.use_certificate_chain_file("server.crt");

		sslContext.use_private_key_file("server.key", boost::asio::ssl::context::pem);

		sslContext.use_tmp_dh_file("dh2048.pem");


		// Initialise the server.
		http::server::server s("0.0.0.0", "8043", "./html/", sslContext);

		// Run the server until stopped.
		s.run();
	}
	catch (std::exception& e)
	{
		std::cerr << "exception: " << e.what() << "\n";
	}

	return 0;
}



