WebUI listening addr can be configured separately from AES67 interface
This commit is contained in:
parent
ac6cab0076
commit
80cf4efd8d
@ -33,6 +33,7 @@ class Config {
|
||||
bool driver_restart);
|
||||
|
||||
/* attributes retrieved from config json */
|
||||
const std::string& get_http_addr_str() const { return http_addr_str_; };
|
||||
uint16_t get_http_port() const { return http_port_; };
|
||||
uint16_t get_rtsp_port() const { return rtsp_port_; };
|
||||
const std::string& get_http_base_dir() const { return http_base_dir_; };
|
||||
@ -69,6 +70,9 @@ class Config {
|
||||
return ptp_status_script_;
|
||||
}
|
||||
|
||||
void set_http_addr_str(std::string_view http_addr_str) {
|
||||
http_addr_str_ = http_addr_str;
|
||||
};
|
||||
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_http_base_dir(std::string_view http_base_dir) {
|
||||
@ -129,7 +133,8 @@ class Config {
|
||||
void set_driver_restart(bool restart) { driver_restart_ = restart; }
|
||||
|
||||
friend bool operator!=(const Config& lhs, const Config& rhs) {
|
||||
return lhs.get_http_port() != rhs.get_http_port() ||
|
||||
return lhs.get_http_addr_str() != rhs.get_http_addr_str() ||
|
||||
lhs.get_http_port() != rhs.get_http_port() ||
|
||||
lhs.get_rtsp_port() != rhs.get_rtsp_port() ||
|
||||
lhs.get_http_base_dir() != rhs.get_http_base_dir() ||
|
||||
lhs.get_log_severity() != rhs.get_log_severity() ||
|
||||
@ -157,6 +162,7 @@ class Config {
|
||||
|
||||
private:
|
||||
/* from json */
|
||||
std::string http_addr_str_{""};
|
||||
uint16_t http_port_{8080};
|
||||
uint16_t rtsp_port_{8854};
|
||||
std::string http_base_dir_{"../webui/dist"};
|
||||
|
@ -334,13 +334,17 @@ bool HttpServer::init() {
|
||||
});
|
||||
|
||||
/* start http server on a separate thread */
|
||||
auto http_addr=config_->get_http_addr_str();
|
||||
if(http_addr.empty())
|
||||
http_addr=config_->get_ip_addr_str();
|
||||
|
||||
res_ = std::async(std::launch::async, [&]() {
|
||||
try {
|
||||
svr_.listen(config_->get_ip_addr_str().c_str(), config_->get_http_port());
|
||||
svr_.listen(http_addr.c_str(), config_->get_http_port());
|
||||
} catch (...) {
|
||||
BOOST_LOG_TRIVIAL(fatal)
|
||||
<< "http_server:: "
|
||||
<< "failed to listen to " << config_->get_ip_addr_str() << ":"
|
||||
<< "failed to listen to " << http_addr << ":"
|
||||
<< config_->get_http_port();
|
||||
return false;
|
||||
}
|
||||
|
@ -61,7 +61,9 @@ int main(int argc, char* argv[]) {
|
||||
po::options_description desc("Options");
|
||||
desc.add_options()("version,v", "Print daemon version and exit")(
|
||||
"config,c", po::value<std::string>()->default_value("/etc/daemon.conf"),
|
||||
"daemon configuration file")("http_port,p", po::value<int>(),
|
||||
"daemon configuration file")(
|
||||
"http_addr,a",po::value<std::string>(),
|
||||
"HTTP server addr")("http_port,p", po::value<int>(),
|
||||
"HTTP server port")("help,h",
|
||||
"Print this help "
|
||||
"message");
|
||||
@ -124,6 +126,8 @@ int main(int argc, char* argv[]) {
|
||||
if (config == nullptr) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
config->set_http_addr_str(vm["http_addr"].as<std::string>());
|
||||
/* override configuration according to command line args */
|
||||
if (vm.count("http_port")) {
|
||||
config->set_http_port(vm["http_port"].as<int>());
|
||||
|
Loading…
x
Reference in New Issue
Block a user