chore(settings): refactor settings processing (#756)
- Better settings tree structure logged using `qdm12/gotree` - Read settings from environment variables, then files, then secret files - Settings methods to default them, merge them and override them - `DNS_PLAINTEXT_ADDRESS` default changed to `127.0.0.1` to use DoT. Warning added if set to something else. - `HTTPPROXY_LISTENING_ADDRESS` instead of `HTTPPROXY_PORT` (with retro-compatibility)
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
shadowsockslib "github.com/qdm12/ss-server/pkg/tcpudp"
|
||||
@@ -17,8 +17,8 @@ type Looper interface {
|
||||
SetStatus(ctx context.Context, status models.LoopStatus) (
|
||||
outcome string, err error)
|
||||
GetStatus() (status models.LoopStatus)
|
||||
GetSettings() (settings configuration.ShadowSocks)
|
||||
SetSettings(ctx context.Context, settings configuration.ShadowSocks) (
|
||||
GetSettings() (settings settings.Shadowsocks)
|
||||
SetSettings(ctx context.Context, settings settings.Shadowsocks) (
|
||||
outcome string)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (l *looper) logAndWait(ctx context.Context, err error) {
|
||||
|
||||
const defaultBackoffTime = 10 * time.Second
|
||||
|
||||
func NewLooper(settings configuration.ShadowSocks, logger Logger) Looper {
|
||||
func NewLooper(settings settings.Shadowsocks, logger Logger) Looper {
|
||||
return &looper{
|
||||
state: state{
|
||||
status: constants.Stopped,
|
||||
@@ -72,7 +72,7 @@ func (l *looper) Run(ctx context.Context, done chan<- struct{}) {
|
||||
|
||||
crashed := false
|
||||
|
||||
if l.GetSettings().Enabled {
|
||||
if *l.GetSettings().Enabled {
|
||||
go func() {
|
||||
_, _ = l.SetStatus(ctx, constants.Running)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user