1
0
Fork 0
mirror of https://gitlab.com/pnx-tools/dns-updater.git synced 2026-06-16 05:54:56 +02:00
dns-updater/ip/lookup.go
2023-12-07 19:45:29 +01:00

23 lines
535 B
Go

package ip
import (
"context"
"net"
"time"
"dnsupdater/ip/resolver"
)
// Resolver is a function that gets the ip from a interface name
type NetInterfaceIPResolver func(iface string) (net.IP, error)
func LookupWrapper(service resolver.Service) NetInterfaceIPResolver {
return func(iface_name string) (net.IP, error) {
if iface_name == resolver.WAN_IFACE {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
return service.Lookup(ctx)
}
return GetInterfaceIP(iface_name)
}
}