From 9905e916e4321b0b5760e2c372e1f82e122a1fb3 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sun, 17 Jun 2018 08:44:11 +0800 Subject: [PATCH] bindaddr (-x) option added https://github.com/moneroexamples/onion-monero-blockchain-explorer/issues/128 --- main.cpp | 7 +++++-- src/CmdLineOptions.cpp | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 5b89673..d7a169b 100644 --- a/main.cpp +++ b/main.cpp @@ -44,6 +44,7 @@ main(int ac, const char* av[]) } auto port_opt = opts.get_option("port"); + auto bindaddr_opt = opts.get_option("bindaddr"); auto bc_path_opt = opts.get_option("bc-path"); auto deamon_url_opt = opts.get_option("deamon-url"); auto ssl_crt_file_opt = opts.get_option("ssl-crt-file"); @@ -103,6 +104,8 @@ main(int ac, const char* av[]) //cast port number in string to uint uint16_t app_port = boost::lexical_cast(*port_opt); + string bindaddr = *bindaddr_opt; + // cast no_blocks_on_index_opt to uint uint64_t no_blocks_on_index = boost::lexical_cast(*no_blocks_on_index_opt); @@ -766,13 +769,13 @@ main(int ac, const char* av[]) if (use_ssl) { cout << "Staring in ssl mode" << endl; - app.port(app_port).ssl_file(ssl_crt_file, ssl_key_file) + app.bindaddr(bindaddr).port(app_port).ssl_file(ssl_crt_file, ssl_key_file) .multithreaded().run(); } else { cout << "Staring in non-ssl mode" << endl; - app.port(app_port).multithreaded().run(); + app.bindaddr(bindaddr).port(app_port).multithreaded().run(); } diff --git a/src/CmdLineOptions.cpp b/src/CmdLineOptions.cpp index 8bf4fd4..b04fdf8 100644 --- a/src/CmdLineOptions.cpp +++ b/src/CmdLineOptions.cpp @@ -51,6 +51,8 @@ namespace xmreg "enable Monero total emission monitoring thread") ("port,p", value()->default_value("8081"), "default explorer port") + ("bindaddr,x", value()->default_value("0.0.0.0"), + "default bind address for the explorer") ("testnet-url", value()->default_value(""), "you can specify testnet url, if you run it on mainnet or stagenet. link will show on front page to testnet explorer") ("stagenet-url", value()->default_value(""),