2022-01-06 06:40:23 -05:00
|
|
|
package env
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
2023-06-05 16:25:52 +00:00
|
|
|
"github.com/qdm12/gosettings/sources/env"
|
2022-01-06 06:40:23 -05:00
|
|
|
)
|
|
|
|
|
|
2022-08-26 15:16:51 +00:00
|
|
|
func (s *Source) ReadHealth() (health settings.Health, err error) {
|
2023-06-01 08:22:55 +00:00
|
|
|
health.ServerAddress = s.env.String("HEALTH_SERVER_ADDRESS")
|
2023-06-05 16:25:52 +00:00
|
|
|
health.TargetAddress = s.env.String("HEALTH_TARGET_ADDRESS",
|
|
|
|
|
env.RetroKeys("HEALTH_ADDRESS_TO_PING"))
|
2022-01-06 06:40:23 -05:00
|
|
|
|
2023-06-01 08:22:55 +00:00
|
|
|
successWaitPtr, err := s.env.DurationPtr("HEALTH_SUCCESS_WAIT_DURATION")
|
2023-05-07 09:35:51 +00:00
|
|
|
if err != nil {
|
2023-05-30 15:21:09 +00:00
|
|
|
return health, err
|
2023-05-07 09:35:51 +00:00
|
|
|
} else if successWaitPtr != nil {
|
|
|
|
|
health.SuccessWait = *successWaitPtr
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-05 16:25:52 +00:00
|
|
|
health.VPN.Initial, err = s.env.DurationPtr(
|
2022-01-06 06:40:23 -05:00
|
|
|
"HEALTH_VPN_DURATION_INITIAL",
|
2023-06-05 16:25:52 +00:00
|
|
|
env.RetroKeys("HEALTH_OPENVPN_DURATION_INITIAL"))
|
2022-01-06 06:40:23 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return health, err
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-05 16:25:52 +00:00
|
|
|
health.VPN.Addition, err = s.env.DurationPtr(
|
2022-01-06 06:40:23 -05:00
|
|
|
"HEALTH_VPN_DURATION_ADDITION",
|
2023-06-05 16:25:52 +00:00
|
|
|
env.RetroKeys("HEALTH_OPENVPN_DURATION_ADDITION"))
|
2022-01-06 06:40:23 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return health, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return health, nil
|
|
|
|
|
}
|