Fix to avoid crash when option -a is not provided plus cosmetic changes.

This commit is contained in:
Andrea Bondavalli 2024-03-23 15:07:02 +01:00
parent f05f40c2ad
commit 45a39a4d2e
4 changed files with 15 additions and 12 deletions

View File

@ -87,7 +87,7 @@ The daemon should work on all Ubuntu starting from 18.04 onward, it's possible t
cd daemon cd daemon
./aes67-daemon -c daemon.conf ./aes67-daemon -c daemon.conf
* use the daemon option _-a_ if you want to bind the daemon HTTP server to another addrress. For example _-a 0.0.0.0_ to bind the daemon HTTP server to all the local network interfaces. * use the daemon option _-a_ if you want to bind the daemon HTTP server to another address. For example _-a 0.0.0.0_ to bind the daemon HTTP server to all the local network interfaces.
* open a browser and load the daemon configuration WebUI at http://[your_ip]:8080 * open a browser and load the daemon configuration WebUI at http://[your_ip]:8080
* on the WebUI use the Browser tab to see the other ASE67 Sources advertised on the network. * on the WebUI use the Browser tab to see the other ASE67 Sources advertised on the network.
* on the WebUI use the Sinks tab to create a receiver by specifying a remote Source manually or by selecting one of the remote Source discovered (check the Use SDP option to enable this). * on the WebUI use the Sinks tab to create a receiver by specifying a remote Source manually or by selecting one of the remote Source discovered (check the Use SDP option to enable this).

View File

@ -71,7 +71,7 @@ class Config {
} }
void set_http_addr_str(std::string_view http_addr_str) { void set_http_addr_str(std::string_view http_addr_str) {
http_addr_str_ = http_addr_str; http_addr_str_ = http_addr_str;
}; };
void set_http_port(uint16_t http_port) { http_port_ = http_port; }; void set_http_port(uint16_t http_port) { http_port_ = http_port; };
void set_rtsp_port(uint16_t rtsp_port) { rtsp_port_ = rtsp_port; }; void set_rtsp_port(uint16_t rtsp_port) { rtsp_port_ = rtsp_port; };

View File

@ -333,19 +333,20 @@ bool HttpServer::init() {
} }
}); });
/* start http server on a separate thread */ std::string http_addr = config_->get_http_addr_str();
auto http_addr=config_->get_http_addr_str(); if (http_addr.empty())
if(http_addr.empty()) http_addr = config_->get_ip_addr_str();
http_addr=config_->get_ip_addr_str(); BOOST_LOG_TRIVIAL(info) << "http_server:: binding to " << http_addr << ":"
<< config_->get_http_port();
/* start http server on a separate thread */
res_ = std::async(std::launch::async, [&]() { res_ = std::async(std::launch::async, [&]() {
try { try {
svr_.listen(http_addr.c_str(), config_->get_http_port()); svr_.listen(http_addr.c_str(), config_->get_http_port());
} catch (...) { } catch (...) {
BOOST_LOG_TRIVIAL(fatal) BOOST_LOG_TRIVIAL(fatal) << "http_server:: "
<< "http_server:: " << "failed to listen to " << http_addr << ":"
<< "failed to listen to " << http_addr << ":" << config_->get_http_port();
<< config_->get_http_port();
return false; return false;
} }
return true; return true;

View File

@ -127,7 +127,9 @@ int main(int argc, char* argv[]) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
config->set_http_addr_str(vm["http_addr"].as<std::string>()); if (vm.count("http_addr")) {
config->set_http_addr_str(vm["http_addr"].as<std::string>());
}
/* override configuration according to command line args */ /* override configuration according to command line args */
if (vm.count("http_port")) { if (vm.count("http_port")) {
config->set_http_port(vm["http_port"].as<int>()); config->set_http_port(vm["http_port"].as<int>());