1
0
Fork 0

ip/resolver/resolver.go: move WAN_IFACE constant to app/app.go

resolver.go is library code and should not define (or care) about what is a "WAN" interface or not.
This commit is contained in:
Henrik Hautakoski 2023-12-07 20:43:48 +01:00
parent 4d1103e133
commit 9961cec561
2 changed files with 4 additions and 4 deletions

View file

@ -12,6 +12,9 @@ import (
"dnsupdater/ip/resolver" "dnsupdater/ip/resolver"
) )
// Constant name for the virtual WAN interface
const WAN_IFACE = "wan"
type App struct { type App struct {
cache *ip.Cache cache *ip.Cache
@ -23,7 +26,7 @@ type App struct {
func makeCacheCallback(service resolver.Service) ip.CacheDefaultCallback { func makeCacheCallback(service resolver.Service) ip.CacheDefaultCallback {
return func(name string) (net.IP, error) { return func(name string) (net.IP, error) {
if name == resolver.WAN_IFACE { if name == WAN_IFACE {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel() defer cancel()
return service.Lookup(ctx) return service.Lookup(ctx)

View file

@ -13,6 +13,3 @@ type Service interface {
// Lookup the public ip. // Lookup the public ip.
Lookup(ctx context.Context) (net.IP, error) Lookup(ctx context.Context) (net.IP, error)
} }
// Constant name for the virtual WAN interface
const WAN_IFACE = "wan"