mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
wip refactor
This commit is contained in:
@@ -5,11 +5,11 @@ export type DerivedAddressInfo = {
|
||||
/**
|
||||
* User-controlled: private addresses the user has disabled
|
||||
*/
|
||||
privateDisabled: Array<HostnameInfo>
|
||||
enabled: Array<HostnameInfo>
|
||||
/**
|
||||
* User-controlled: public addresses the user has enabled
|
||||
*/
|
||||
publicEnabled: Array<HostnameInfo>
|
||||
disabled: Array<HostnameInfo>
|
||||
/**
|
||||
* COMPUTED: NetServiceData::update — all possible addresses for this binding
|
||||
*/
|
||||
|
||||
@@ -226,12 +226,16 @@ function filterRec(
|
||||
return hostnames
|
||||
}
|
||||
|
||||
function isDefaultEnabled(h: HostnameInfo): boolean {
|
||||
return !(h.public && (h.hostname.kind === 'ipv4' || h.hostname.kind === 'ipv6'))
|
||||
}
|
||||
|
||||
function enabledAddresses(addr: DerivedAddressInfo): HostnameInfo[] {
|
||||
return addr.possible.filter((h) =>
|
||||
h.public
|
||||
? addr.publicEnabled.some((e) => deepEqual(e, h))
|
||||
: !addr.privateDisabled.some((d) => deepEqual(d, h)),
|
||||
)
|
||||
return addr.possible.filter((h) => {
|
||||
if (addr.enabled.some((e) => deepEqual(e, h))) return true
|
||||
if (addr.disabled.some((d) => deepEqual(d, h))) return false
|
||||
return isDefaultEnabled(h)
|
||||
})
|
||||
}
|
||||
|
||||
export const filledAddress = (
|
||||
|
||||
Reference in New Issue
Block a user