Skip to content

Commit

Permalink
Use null instead of default, to avoid stomping on netmask
Browse files Browse the repository at this point in the history
  • Loading branch information
marksteward committed Dec 22, 2024
1 parent e58bef7 commit 5aecae1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/data/hassio/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ export const accesspointScan = async (
};

export const parseAddress = (address: string) => {
const isIPv6 = address.includes(":");
const [ip, cidr] = address.includes("/")
? address.split("/")
: [address, isIPv6 ? "64" : "24"];
return { ip, mask: cidrToNetmask(cidr, isIPv6) };
const [ip, cidr] = address.split("/");
const isIPv6 = ip.includes(":");
const mask = cidr ? cidrToNetmask(cidr, isIPv6) : null;
return { ip, mask };
};

export const formatAddress = (ip: string, mask: string) =>
Expand Down
6 changes: 4 additions & 2 deletions src/panels/config/network/supervisor-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,10 @@ export class HassioNetwork extends LitElement {
if (id === "address") {
const index = (ev.target as any).index as number;
const { mask } = parseAddress(value);
this._interface[version]!.address![index] = formatAddress(value, mask);
this.requestUpdate("_interface");
if (mask) {
this._interface[version]!.address![index] = formatAddress(value, mask);
this.requestUpdate("_interface");
}
} else if (id === "netmask") {
const index = (ev.target as any).index as number;
const { ip } = parseAddress(this._interface![version]!.address![index]);
Expand Down

0 comments on commit 5aecae1

Please sign in to comment.