package lookup import ( "context" "net" "time" "dnsupdater/ip" ) type Service interface { Name() string Lookup(ctx context.Context) (net.IP, error) } const WAN_IFACE = "wan" func LookupWrapper(service Service) ip.NetInterfaceIPResolver { return func(iface_name string) (net.IP, error) { if iface_name == WAN_IFACE { ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() return service.Lookup(ctx) } return ip.GetInterfaceIP(iface_name) } }