diff --git a/forked-daapd.conf.in b/forked-daapd.conf.in index d3221528..b0208d64 100644 --- a/forked-daapd.conf.in +++ b/forked-daapd.conf.in @@ -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 diff --git a/src/conffile.c b/src/conffile.c index abb436bf..41a13fcd 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -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), diff --git a/src/websocket.c b/src/websocket.c index 29c17de8..0d531d9d 100644 --- a/src/websocket.c +++ b/src/websocket.c @@ -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;