Skip to content
Snippets Groups Projects
Commit 577f2a06 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy server: allow to configure address to bind

parent 48e718ff
Branches
Tags
No related merge requests found
...@@ -63,6 +63,7 @@ using RestRouter = restinio::router::express_router_t<>; ...@@ -63,6 +63,7 @@ using RestRouter = restinio::router::express_router_t<>;
using RequestStatus = restinio::request_handling_status_t; using RequestStatus = restinio::request_handling_status_t;
struct ProxyServerConfig { struct ProxyServerConfig {
std::string address {};
in_port_t port {8000}; in_port_t port {8000};
std::string pushServer {}; std::string pushServer {};
std::string persistStatePath {}; std::string persistStatePath {};
......
...@@ -265,6 +265,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht, ...@@ -265,6 +265,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht,
// build http server // build http server
auto settings = restinio::run_on_this_thread_settings_t<RestRouterTraitsTls>(); auto settings = restinio::run_on_this_thread_settings_t<RestRouterTraitsTls>();
addServerSettings(settings); addServerSettings(settings);
if (not config.address.empty())
settings.address(config.address);
settings.port(config.port); settings.port(config.port);
settings.tls_context(std::move(tls_context)); settings.tls_context(std::move(tls_context));
httpsServer_ = std::make_unique<restinio::http_server_t<RestRouterTraitsTls>>( httpsServer_ = std::make_unique<restinio::http_server_t<RestRouterTraitsTls>>(
...@@ -282,6 +284,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht, ...@@ -282,6 +284,8 @@ DhtProxyServer::DhtProxyServer(const std::shared_ptr<DhtRunner>& dht,
else { else {
auto settings = restinio::run_on_this_thread_settings_t<RestRouterTraits>(); auto settings = restinio::run_on_this_thread_settings_t<RestRouterTraits>();
addServerSettings(settings); addServerSettings(settings);
if (not config.address.empty())
settings.address(config.address);
settings.port(config.port); settings.port(config.port);
httpServer_ = std::make_unique<restinio::http_server_t<RestRouterTraits>>( httpServer_ = std::make_unique<restinio::http_server_t<RestRouterTraits>>(
ioContext_, ioContext_,
......
...@@ -551,6 +551,7 @@ main(int argc, char **argv) ...@@ -551,6 +551,7 @@ main(int argc, char **argv)
ProxyServerConfig serverConfig; ProxyServerConfig serverConfig;
serverConfig.pushServer = params.pushserver; serverConfig.pushServer = params.pushserver;
serverConfig.bundleId = params.bundle_id; serverConfig.bundleId = params.bundle_id;
serverConfig.address = params.proxy_address;
if (params.proxyserverssl and params.proxy_id.first and params.proxy_id.second){ if (params.proxyserverssl and params.proxy_id.first and params.proxy_id.second){
serverConfig.identity = params.proxy_id; serverConfig.identity = params.proxy_id;
serverConfig.port = params.proxyserverssl; serverConfig.port = params.proxyserverssl;
......
...@@ -131,6 +131,7 @@ struct dht_params { ...@@ -131,6 +131,7 @@ struct dht_params {
in_port_t proxyserver {0}; in_port_t proxyserver {0};
in_port_t proxyserverssl {0}; in_port_t proxyserverssl {0};
std::string proxyclient {}; std::string proxyclient {};
std::string proxy_address {};
std::string pushserver {}; std::string pushserver {};
std::string devicekey {}; std::string devicekey {};
std::string bundle_id {}; std::string bundle_id {};
...@@ -224,6 +225,7 @@ static const constexpr struct option long_options[] = { ...@@ -224,6 +225,7 @@ static const constexpr struct option long_options[] = {
{"syslog", no_argument , nullptr, 'L'}, {"syslog", no_argument , nullptr, 'L'},
{"proxyserver", required_argument, nullptr, 'S'}, {"proxyserver", required_argument, nullptr, 'S'},
{"proxyserverssl", required_argument, nullptr, 'e'}, {"proxyserverssl", required_argument, nullptr, 'e'},
{"proxy-addr", required_argument, nullptr, 'a'},
{"proxy-certificate", required_argument, nullptr, 'w'}, {"proxy-certificate", required_argument, nullptr, 'w'},
{"proxy-privkey", required_argument, nullptr, 'K'}, {"proxy-privkey", required_argument, nullptr, 'K'},
{"proxy-privkey-password", required_argument, nullptr, 'M'}, {"proxy-privkey-password", required_argument, nullptr, 'M'},
...@@ -270,6 +272,9 @@ parseArgs(int argc, char **argv) { ...@@ -270,6 +272,9 @@ parseArgs(int argc, char **argv) {
case 'D': case 'D':
params.peer_discovery = true; params.peer_discovery = true;
break; break;
case 'a':
params.proxy_address = optarg;
break;
case 'y': case 'y':
params.pushserver = optarg; params.pushserver = optarg;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment