Fix #261 add variable HTTP_CONTROL_SERVER_PORT
This commit is contained in:
30
internal/settings/server.go
Normal file
30
internal/settings/server.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/params"
|
||||
)
|
||||
|
||||
// ControlServer contains settings to customize the control server operation
|
||||
type ControlServer struct {
|
||||
Port uint16
|
||||
}
|
||||
|
||||
func (c *ControlServer) String() string {
|
||||
settingsList := []string{
|
||||
"HTTP Control server:",
|
||||
fmt.Sprintf("Listening port: %d", c.Port),
|
||||
}
|
||||
return strings.Join(settingsList, "\n |--")
|
||||
}
|
||||
|
||||
// GetControlServerSettings obtains the HTTP control server settings from environment variables using the params package.
|
||||
func GetControlServerSettings(paramsReader params.Reader) (settings ControlServer, err error) {
|
||||
settings.Port, err = paramsReader.GetControlServerPort()
|
||||
if err != nil {
|
||||
return settings, err
|
||||
}
|
||||
return settings, nil
|
||||
}
|
||||
@@ -26,6 +26,7 @@ type Settings struct {
|
||||
PublicIPPeriod time.Duration
|
||||
UpdaterPeriod time.Duration
|
||||
VersionInformation bool
|
||||
ControlServer ControlServer
|
||||
}
|
||||
|
||||
func (s *Settings) String() string {
|
||||
@@ -45,6 +46,7 @@ func (s *Settings) String() string {
|
||||
s.Firewall.String(),
|
||||
s.TinyProxy.String(),
|
||||
s.ShadowSocks.String(),
|
||||
s.ControlServer.String(),
|
||||
"Public IP check period: " + s.PublicIPPeriod.String(), // TODO print disabled if 0
|
||||
"Version information: " + versionInformation,
|
||||
updaterLine,
|
||||
@@ -95,5 +97,9 @@ func GetAllSettings(paramsReader params.Reader) (settings Settings, err error) {
|
||||
if err != nil {
|
||||
return settings, err
|
||||
}
|
||||
settings.ControlServer, err = GetControlServerSettings(paramsReader)
|
||||
if err != nil {
|
||||
return settings, err
|
||||
}
|
||||
return settings, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user