Melora Hugues
3a1bb20a1f
All checks were successful
continuous-integration/drone/push Build is passing
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.
18 lines
322 B
Go
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)
|
|
}
|