public-ip-tracker/tracker/ip/test/ip.go
Melora Hugues 3a1bb20a1f
All checks were successful
continuous-integration/drone/push Build is passing
Add monitoring of the current public IP
Ref #4

This commit adds an active monitoring of the current public IP. If a
change is detected, then a message is sent to the given Telegram
channel. Add a few tests for the main monitoring logic.
2023-01-28 14:29:39 +01:00

18 lines
322 B
Go

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)
}