2022-01-07 09:37:31 +00:00
|
|
|
package env
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-26 15:16:51 +00:00
|
|
|
func (s *Source) readControlServer() (controlServer settings.ControlServer, err error) {
|
2023-06-01 08:22:55 +00:00
|
|
|
controlServer.Log, err = s.env.BoolPtr("HTTP_CONTROL_SERVER_LOG")
|
2022-01-07 09:37:31 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return controlServer, err
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-26 15:16:51 +00:00
|
|
|
controlServer.Address = s.readControlServerAddress()
|
2022-01-07 09:37:31 +00:00
|
|
|
|
|
|
|
|
return controlServer, nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-26 15:16:51 +00:00
|
|
|
func (s *Source) readControlServerAddress() (address *string) {
|
2023-06-05 16:25:52 +00:00
|
|
|
const currentKey = "HTTP_CONTROL_SERVER_ADDRESS"
|
|
|
|
|
key := firstKeySet(s.env, "CONTROL_SERVER_ADDRESS", currentKey)
|
|
|
|
|
if key == currentKey {
|
|
|
|
|
return s.env.Get(key)
|
2022-01-07 09:37:31 +00:00
|
|
|
}
|
2022-01-29 14:55:56 +00:00
|
|
|
|
2023-06-05 16:25:52 +00:00
|
|
|
s.handleDeprecatedKey(key, currentKey)
|
|
|
|
|
value := s.env.Get("CONTROL_SERVER_ADDRESS")
|
|
|
|
|
if value == nil {
|
|
|
|
|
return nil
|
2022-01-29 14:55:56 +00:00
|
|
|
}
|
2023-06-05 16:25:52 +00:00
|
|
|
return ptrTo(":" + *value)
|
2022-01-07 09:37:31 +00:00
|
|
|
}
|