Files
gluetun/internal/params/publicip.go

29 lines
928 B
Go
Raw Normal View History

2020-07-16 01:12:54 +00:00
package params
import (
"time"
2020-12-28 01:51:55 +00:00
"github.com/qdm12/gluetun/internal/models"
2020-07-16 01:12:54 +00:00
libparams "github.com/qdm12/golibs/params"
)
// GetPublicIPPeriod obtains the period to fetch the IP address periodically.
2020-10-20 02:45:28 +00:00
// Set to 0 to disable.
2020-07-16 01:12:54 +00:00
func (r *reader) GetPublicIPPeriod() (period time.Duration, err error) {
s, err := r.envParams.GetEnv("PUBLICIP_PERIOD", libparams.Default("12h"))
if err != nil {
return 0, err
}
return time.ParseDuration(s)
}
2020-12-28 01:51:55 +00:00
// GetPublicIPFilepath obtains the public IP filepath
// from the environment variable PUBLICIP_FILE with retro-compatible
// environment variable IP_STATUS_FILE.
func (r *reader) GetPublicIPFilepath() (filepath models.Filepath, err error) {
filepathStr, err := r.envParams.GetPath("PUBLICIP_FILE",
libparams.RetroKeys([]string{"IP_STATUS_FILE"}, r.onRetroActive),
libparams.Default("/tmp/gluetun/ip"), libparams.CaseSensitiveValue())
return models.Filepath(filepathStr), err
}