diff --git a/landing-page/src/components/landing-page-network.ts b/landing-page/src/components/landing-page-network.ts index f4cfadd395..7e32877c84 100644 --- a/landing-page/src/components/landing-page-network.ts +++ b/landing-page/src/components/landing-page-network.ts @@ -33,6 +33,8 @@ class LandingPageNetwork extends LitElement { @state() private _getNetworkInfoError = false; + @state() private _dnsPrimaryInterfaceNameservers?: string; + @state() private _dnsPrimaryInterface?: string; protected render() { @@ -55,11 +57,11 @@ class LandingPageNetwork extends LitElement { >

${this.localize("network_issue.description", { - dns: this._dnsPrimaryInterface || "?", + dns: this._dnsPrimaryInterfaceNameservers || "?", })}

${this.localize("network_issue.resolve_different")}

- ${!this._dnsPrimaryInterface + ${!this._dnsPrimaryInterfaceNameservers ? html`

${this.localize("network_issue.no_primary_interface")} @@ -71,7 +73,7 @@ class LandingPageNetwork extends LitElement { ({ translationKey }, key) => html`${this.localize(translationKey)}` @@ -106,22 +108,30 @@ class LandingPageNetwork extends LitElement { // eslint-disable-next-line no-console console.error(err); this._getNetworkInfoError = true; + this._dnsPrimaryInterfaceNameservers = undefined; + this._dnsPrimaryInterface = undefined; return; } this._getNetworkInfoError = false; + const primaryInterface = data.interfaces.find( + (intf) => intf.primary && intf.enabled + ); + if (primaryInterface) { + this._dnsPrimaryInterfaceNameservers = [ + ...(primaryInterface.ipv4?.nameservers || []), + ...(primaryInterface.ipv6?.nameservers || []), + ].join(", "); + + this._dnsPrimaryInterface = primaryInterface.interface; + } else { + this._dnsPrimaryInterfaceNameservers = undefined; + this._dnsPrimaryInterface = undefined; + } + if (!data.host_internet) { this._networkIssue = true; - const primaryInterface = data.interfaces.find( - (intf) => intf.primary && intf.enabled - ); - if (primaryInterface) { - this._dnsPrimaryInterface = [ - ...(primaryInterface.ipv4?.nameservers || []), - ...(primaryInterface.ipv6?.nameservers || []), - ].join(", "); - } } else { this._networkIssue = false; } @@ -135,7 +145,10 @@ class LandingPageNetwork extends LitElement { private async _setDns(ev) { const index = ev.target?.index; try { - const response = await setSupervisorNetworkDns(index); + const response = await setSupervisorNetworkDns( + index, + this._dnsPrimaryInterface! + ); if (!response.ok) { throw new Error("Failed to set DNS"); } diff --git a/landing-page/src/data/supervisor.ts b/landing-page/src/data/supervisor.ts index a2f78d3676..8b75f3f753 100644 --- a/landing-page/src/data/supervisor.ts +++ b/landing-page/src/data/supervisor.ts @@ -37,8 +37,11 @@ export async function getSupervisorNetworkInfo() { return fetch("/supervisor/network/info"); } -export const setSupervisorNetworkDns = async (dnsServerIndex: number) => - fetch("/supervisor/network/dns", { +export const setSupervisorNetworkDns = async ( + dnsServerIndex: number, + primaryInterface: string +) => + fetch(`/supervisor/network/interface/${primaryInterface}/update`, { method: "POST", body: JSON.stringify({ ipv4: {