[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

@ -34,6 +34,10 @@ general {
# Websocket port for the web interface.
# websocket_port = 3688
# Websocket interface to bind listener to (e.g. "eth0"). Default is
# disabled, which means listen on all interfaces.
# websocket_interface = ""
# Sets who is allowed to connect without authorisation. This applies to
# client types like Remotes, DAAP clients (iTunes) and to the web
# interface. Options are "any", "localhost" or the prefix to one or

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;