mirror of
https://github.com/koush/scrypted.git
synced 2026-05-05 22:00:27 +01:00
fix: add type guard filter for network interfaces
Filter undefined values after flat() to prevent runtime errors when accessing ni.address.
This commit is contained in:
@@ -34,7 +34,7 @@ export class AddressSettings {
|
||||
const ret: string[] = [];
|
||||
const networkInterfaces = os.networkInterfaces();
|
||||
const allAddresses = new Set(Object.values(networkInterfaces)
|
||||
.flat().map(ni => ni.address));
|
||||
.flat().filter((ni): ni is os.NetworkInterfaceInfo => ni !== undefined).map(ni => ni.address));
|
||||
for (const addressOrInterface of settings.value) {
|
||||
const nif = networkInterfaces[addressOrInterface];
|
||||
if (raw) {
|
||||
|
||||
Reference in New Issue
Block a user