Files
cunicu/pkg/core/interface_list.go
Steffen Vogel 72dc2ef04e simplify and fix shutdown of daemon
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2022-08-25 18:55:53 +02:00

33 lines
559 B
Go

package core
import (
"riasc.eu/wice/pkg/crypto"
)
// InterfaceList stores all WireGuard interfaces indexed by their unique ifindex
type InterfaceList map[string]*Interface
func (l *InterfaceList) ByIndex(index int) *Interface {
for _, i := range *l {
if i.KernelDevice.Index() == index {
return i
}
}
return nil
}
func (l *InterfaceList) ByName(name string) *Interface {
return (*l)[name]
}
func (l *InterfaceList) ByPublicKey(pk crypto.Key) *Interface {
for _, i := range *l {
if i.PublicKey() == pk {
return i
}
}
return nil
}