[cfg] Add websocket_interface option

This commit is contained in:
ejurgensen
2021-02-27 23:01:26 +01:00
parent e5fcfc6574
commit c423f3af91
3 changed files with 8 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ static cfg_opt_t sec_general[] =
CFG_INT_CB("loglevel", E_LOG, CFGF_NONE, &cb_loglevel),
CFG_STR("admin_password", NULL, CFGF_NONE),
CFG_INT("websocket_port", 3688, CFGF_NONE),
CFG_STR("websocket_interface", NULL, CFGF_NONE),
CFG_STR_LIST("trusted_networks", "{localhost,192.168,fd}", CFGF_NONE),
CFG_BOOL("ipv6", cfg_true, CFGF_NONE),
CFG_STR("bind_address", NULL, CFGF_NONE),

View File

@@ -39,6 +39,7 @@
static struct lws_context *context;
static pthread_t tid_websocket;
static const char *websocket_interface;
static int websocket_port;
static bool websocket_exit = false;
@@ -377,6 +378,7 @@ websocket_init(void)
struct lws_context_creation_info info;
int ret;
websocket_interface = cfg_getstr(cfg_getsec(cfg, "general"), "websocket_interface");
websocket_port = cfg_getint(cfg_getsec(cfg, "general"), "websocket_port");
if (websocket_port <= 0)
@@ -387,6 +389,7 @@ websocket_init(void)
memset(&info, 0, sizeof(info));
info.port = websocket_port;
info.iface = websocket_interface;
info.protocols = protocols;
if (!cfg_getbool(cfg_getsec(cfg, "general"), "ipv6"))
info.options |= LWS_SERVER_OPTION_DISABLE_IPV6;