From 3aadef3cd9141dcb368b2de86201c487fa4a5edf Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Mon, 31 Oct 2022 10:17:32 -0500 Subject: [PATCH] Add systemd-resolved Advertiser to UI See-also: homebridge/homebridge#3224 See-also: homebridge/HAP-NodeJS#965 --- src/core/config/config.service.ts | 2 +- src/modules/server/server.dto.ts | 4 ++-- test/e2e/server.e2e-spec.ts | 17 +++++++++++++++++ .../modules/settings/settings.component.html | 3 ++- .../modules/settings/settings.component.ts | 19 +++++++++++++------ 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/core/config/config.service.ts b/src/core/config/config.service.ts index 59f9987d6..76d198eca 100644 --- a/src/core/config/config.service.ts +++ b/src/core/config/config.service.ts @@ -12,7 +12,7 @@ export interface HomebridgeConfig { pin: string; name: string; port: number; - advertiser?: 'avahi' | 'ciao' | 'bonjour-hap'; + advertiser?: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; bind?: string | string[]; }; mdns?: { diff --git a/src/modules/server/server.dto.ts b/src/modules/server/server.dto.ts index f49b0d3b4..b8e4eaaf4 100644 --- a/src/modules/server/server.dto.ts +++ b/src/modules/server/server.dto.ts @@ -11,7 +11,7 @@ export class HomebridgeNetworkInterfacesDto { export class HomebridgeMdnsSettingDto { @IsString() @IsDefined() - @IsIn(['avahi', 'ciao', 'bonjour-hap']) + @IsIn(['avahi', 'resolved', 'ciao', 'bonjour-hap']) @ApiProperty() - advertiser: 'avahi' | 'ciao' | 'bonjour-hap'; + advertiser: 'avahi' | 'resolved' | 'ciao' | 'bonjour-hap'; } diff --git a/test/e2e/server.e2e-spec.ts b/test/e2e/server.e2e-spec.ts index b8ea09a2c..a2e608930 100644 --- a/test/e2e/server.e2e-spec.ts +++ b/test/e2e/server.e2e-spec.ts @@ -406,6 +406,23 @@ describe('ServerController (e2e)', () => { expect(res.json()).toEqual({ advertiser: 'avahi' }); }); + it('GET /server/mdns-advertiser (when set to resolved)', async () => { + const config: HomebridgeConfig = await fs.readJson(configService.configPath); + config.bridge.advertiser = 'resolved'; + await fs.writeJson(configService.configPath, config); + + const res = await app.inject({ + method: 'GET', + path: '/server/mdns-advertiser', + headers: { + authorization, + }, + }); + + expect(res.statusCode).toBe(200); + expect(res.json()).toEqual({ advertiser: 'resolved' }); + }); + it('PUT /server/mdns-advertiser (bonjour-hap)', async () => { const initialConfig: HomebridgeConfig = await fs.readJson(configService.configPath); delete initialConfig.bridge.advertiser; diff --git a/ui/src/app/modules/settings/settings.component.html b/ui/src/app/modules/settings/settings.component.html index a9a82a1d9..279298968 100644 --- a/ui/src/app/modules/settings/settings.component.html +++ b/ui/src/app/modules/settings/settings.component.html @@ -46,6 +46,7 @@
[attr.aria-label]=" 'settings.mdns_advertiser' | translate"> + @@ -206,4 +207,4 @@
{{ 'settings.title_actions' | translate }}
- \ No newline at end of file + diff --git a/ui/src/app/modules/settings/settings.component.ts b/ui/src/app/modules/settings/settings.component.ts index ae23c7d87..5573f4421 100644 --- a/ui/src/app/modules/settings/settings.component.ts +++ b/ui/src/app/modules/settings/settings.component.ts @@ -40,6 +40,7 @@ export class SettingsComponent implements OnInit { public showNetworking = false; public showAvahiMdnsOption = false; + public showResolvedMdnsOption = false; public availableNetworkAdapters: Record = []; public bridgeNetworkAdapters: Record = []; @@ -123,16 +124,22 @@ export class SettingsComponent implements OnInit { this.showNetworking = true; this.getNetworkSettings(); } + const onLinux = ( + this.$settings.env.runningInLinux || + this.$settings.env.runningInDocker || + this.$settings.env.runningInSynologyPackage || + this.$settings.env.runningInPackageMode + ); if (semver.gte(homebridgePackage.installedVersion, '1.4.0-beta.0', { includePrerelease: true })) { - if ( - this.$settings.env.runningInLinux || - this.$settings.env.runningInDocker || - this.$settings.env.runningInSynologyPackage || - this.$settings.env.runningInPackageMode - ) { + if (onLinux) { this.showAvahiMdnsOption = true; } } + if (semver.gte(homebridgePackage.installedVersion, '1.6.0-beta.0', { includePrerelease: true })) { + if (onLinux) { + this.showResolvedMdnsOption = true; + } + } } catch (e) { }