From af969f602c8ce6bb417eba3ba2908e74f4da5854 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 25 Nov 2024 10:03:47 +0100 Subject: [PATCH] add node hasip Signed-off-by: Kristoffer Dalby --- hscontrol/types/node.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hscontrol/types/node.go b/hscontrol/types/node.go index c8558993..885f7238 100644 --- a/hscontrol/types/node.go +++ b/hscontrol/types/node.go @@ -135,6 +135,16 @@ func (node *Node) IPs() []netip.Addr { return ret } +// HasIP reports if a node has a given IP address. +func (node *Node) HasIP(i netip.Addr) bool { + for _, ip := range node.IPs() { + if ip.Compare(i) == 0 { + return true + } + } + return false +} + // IsTagged reports if a device is tagged // and therefore should not be treated as a // user owned device.