From 88e30e7289e7d9bbe46eea8c9b31073d9c4cb53e Mon Sep 17 00:00:00 2001 From: Bin Yong Date: Thu, 11 Jan 2024 14:25:17 +0100 Subject: [PATCH] Update server.cpp --- proxy/src/server.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/proxy/src/server.cpp b/proxy/src/server.cpp index b3a485f..d1b0410 100644 --- a/proxy/src/server.cpp +++ b/proxy/src/server.cpp @@ -34,8 +34,7 @@ Server::Server() listen_port_(Configuration::get("listen-port").as()), tls_proxy_acceptor_(io_context_), tls_proxy_address_( - make_address(Configuration::get("tls-proxy-address").as())), - tls_proxy_port_(Configuration::get("tls-proxy-port").as()), + make_address(Configuration::get("tls-proxy-address").as())) stop_(false) {} void Server::Run() { io_context_.run(); } @@ -59,15 +58,18 @@ void Server::StartTcp() { } void Server::StartTls() { - auto tls_endpoint = tcp::endpoint(tls_proxy_address_, tls_proxy_port_); - tls_proxy_acceptor_.open(tls_endpoint.protocol()); - tls_proxy_acceptor_.set_option( + auto& ports = Configuration::get("tls-proxy-port").as>(); + for (auto port : ports) { + auto tls_endpoint = tcp::endpoint(tls_proxy_address_, tls_proxy_port_); + tls_proxy_acceptor_.open(tls_endpoint.protocol()); + tls_proxy_acceptor_.set_option( boost::asio::ip::tcp::acceptor::reuse_address(true)); - tls_proxy_acceptor_.bind(tls_endpoint); - tls_proxy_acceptor_.listen(); - DoAcceptTls(); - LOG_INFO("Listening on " << tls_proxy_address_ << ":" << tls_proxy_port_ - << " TLS TCP"); + tls_proxy_acceptor_.bind(tls_endpoint); + tls_proxy_acceptor_.listen(); + DoAcceptTls(); + LOG_INFO("Listening on " << tls_proxy_address_ << ":" << tls_proxy_port_ + << " TLS TCP"); + } } void Server::DoAcceptTls() {