From 8e5a999c8a94e51230c0c9cd30cbb58db73ab82b Mon Sep 17 00:00:00 2001 From: oznu Date: Sat, 20 Apr 2019 22:42:30 +1000 Subject: [PATCH] v4.0.4 --- CHANGELOG.md | 12 +++++++++++- config.schema.json | 4 ++++ package-lock.json | 2 +- package.json | 2 +- src/core/config/config.service.ts | 2 ++ src/core/config/config.startup.ts | 11 +++++++++++ src/main.ts | 4 ++-- 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d72d5be4..80dd390c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,21 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/). +## 4.0.4 (2019-04-20) + +### Bug Fixes + +* Check for IPv6 interfaces before attempting to listen on `::` ([#261](https://github.com/oznu/homebridge-config-ui-x/issues/261)) + +### Other Changes + +* Added `host` config option to allow users to manually specify which interface/ip address the web interface should listen on + ## 4.0.3 (2019-04-20) ### Bug Fixes -* Fixed bug that prevented web service listening on IPv6 interfaces ([#260](https://github.com/oznu/homebridge-config-ui-x/issues/260)) +* Fixed bug that prevented the web service listening on IPv6 interfaces ([#260](https://github.com/oznu/homebridge-config-ui-x/issues/260)) ## 4.0.2 (2019-04-19) diff --git a/config.schema.json b/config.schema.json index 7815fb486..a5163fa9c 100644 --- a/config.schema.json +++ b/config.schema.json @@ -182,6 +182,10 @@ "title": "Do not run the Config UI web server in a seperate process/thread", "type": "boolean" }, + "host": { + "title": "The host ip address to listen on. In most cases this will be '::' or '0.0.0.0'", + "type": "string" + }, "debug": { "title": "Enable / disable debug logging", "type": "boolean" diff --git a/package-lock.json b/package-lock.json index 5aa705aeb..c28cd119b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-config-ui-x", - "version": "4.0.3", + "version": "4.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2cc4fe172..90dfa396d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-config-ui-x", - "version": "4.0.3", + "version": "4.0.4", "description": "Configuration UI plugin for Homebridge", "license": "MIT", "author": "oznu ", diff --git a/src/core/config/config.service.ts b/src/core/config/config.service.ts index c22913405..a5f68b7eb 100644 --- a/src/core/config/config.service.ts +++ b/src/core/config/config.service.ts @@ -47,6 +47,7 @@ export class ConfigService { public ui: { name: string; port: number; + host?: '::' | '0.0.0.0' | string; auth: 'form' | 'none'; theme: string; sudo?: boolean; @@ -71,6 +72,7 @@ export class ConfigService { shutdown?: string; restart?: string; }; + debug?: boolean; proxyHost?: string; sessionTimeout?: number; websocketCompatibilityMode?: boolean; diff --git a/src/core/config/config.startup.ts b/src/core/config/config.startup.ts index 0cc0a03ff..2726c5835 100644 --- a/src/core/config/config.startup.ts +++ b/src/core/config/config.startup.ts @@ -16,6 +16,7 @@ export async function getStartupConfig() { } const config = {} as { + host?: '::' | '0.0.0.0' | string; httpsOptions?: { key?: Buffer, cert?: Buffer, @@ -26,6 +27,14 @@ export async function getStartupConfig() { debug?: boolean; }; + // check if IPv6 is available on this host + const ipv6 = Object.entries(os.networkInterfaces()).filter(([net, addresses]) => { + return addresses.find(x => x.family === 'IPv6'); + }).length; + + config.host = ui.host || (ipv6 ? '::' : '0.0.0.0'); + + // preload ssl settings if (ui.ssl && ((ui.ssl.key && ui.ssl.cert) || ui.ssl.pfx)) { config.httpsOptions = { key: ui.ssl.key ? await fs.readFile(ui.ssl.key) : undefined, @@ -35,10 +44,12 @@ export async function getStartupConfig() { }; } + // preload proxy host settings if (ui.proxyHost) { config.cspWsOveride = `wss://${ui.proxyHost} ws://${ui.proxyHost}`; } + // preload debug settings if (ui.debug) { config.debug = true; } else { diff --git a/src/main.ts b/src/main.ts index 0b06780c4..a5a029775 100644 --- a/src/main.ts +++ b/src/main.ts @@ -106,7 +106,7 @@ async function bootstrap() { // serve spa on all 404 app.useGlobalFilters(new SpaFilter()); - logger.warn(`Console v${configService.package.version} is listening on port ${configService.ui.port}`); - await app.listen(configService.ui.port, '::'); + logger.warn(`Console v${configService.package.version} is listening on ${startupConfig.host} port ${configService.ui.port}`); + await app.listen(configService.ui.port, startupConfig.host); } bootstrap();