Skip to content

Commit

Permalink
Add systemd-resolved Advertiser to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker authored and elyscape committed Nov 9, 2022
1 parent 31dabe4 commit 3aadef3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/server/server.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
17 changes: 17 additions & 0 deletions test/e2e/server.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/modules/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ <h5 class="primary-text mt-3" translate="settings.network.title_network"></h5>
[attr.aria-label]=" 'settings.mdns_advertiser' | translate">
<option value="bonjour-hap">Bonjour HAP</option>
<option value="avahi" *ngIf="showAvahiMdnsOption">Avahi</option>
<option value="resolved" *ngIf="showResolvedMdnsOption">systemd-resolved (experimental)</option>
<option value="ciao">Ciao</option>
</select>
</div>
Expand Down Expand Up @@ -206,4 +207,4 @@ <h5 class="primary-text mt-3">{{ 'settings.title_actions' | translate }}</h5>
</button>
</li>
</ul>
</div>
</div>
19 changes: 13 additions & 6 deletions ui/src/app/modules/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class SettingsComponent implements OnInit {

public showNetworking = false;
public showAvahiMdnsOption = false;
public showResolvedMdnsOption = false;
public availableNetworkAdapters: Record<string, any> = [];
public bridgeNetworkAdapters: Record<string, any> = [];

Expand Down Expand Up @@ -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) {

}
Expand Down

0 comments on commit 3aadef3

Please sign in to comment.