public-ip-tracker/tracker/ip/test/ip.go

19 lines
322 B
Go
Raw Normal View History

package test
import (
"context"
"net"
)
type TestIPGetter struct {
PublicIPProp net.IP
PublicIPFunc func(ctx context.Context) (net.IP, error)
}
func (g *TestIPGetter) GetCurrentPublicIP(ctx context.Context) (net.IP, error) {
if g.PublicIPFunc == nil {
return g.PublicIPProp, nil
}
return g.PublicIPFunc(ctx)
}