Configuration package (#369)

This commit is contained in:
Quentin McGaw
2021-02-06 11:05:50 -05:00
committed by GitHub
parent 4f2570865c
commit 90aaf71270
93 changed files with 2371 additions and 2453 deletions

View File

@@ -6,9 +6,9 @@ import (
"sync"
"time"
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/settings"
"github.com/qdm12/golibs/logging"
shadowsockslib "github.com/qdm12/ss-server/pkg"
)
@@ -17,8 +17,8 @@ type Looper interface {
Run(ctx context.Context, wg *sync.WaitGroup)
SetStatus(status models.LoopStatus) (outcome string, err error)
GetStatus() (status models.LoopStatus)
GetSettings() (settings settings.ShadowSocks)
SetSettings(settings settings.ShadowSocks) (outcome string)
GetSettings() (settings configuration.ShadowSocks)
SetSettings(settings configuration.ShadowSocks) (outcome string)
}
type looper struct {
@@ -51,7 +51,7 @@ func (l *looper) logAndWait(ctx context.Context, err error) {
const defaultBackoffTime = 10 * time.Second
func NewLooper(settings settings.ShadowSocks, logger logging.Logger) Looper {
func NewLooper(settings configuration.ShadowSocks, logger logging.Logger) Looper {
return &looper{
state: state{
status: constants.Stopped,

View File

@@ -5,14 +5,14 @@ import (
"reflect"
"sync"
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
"github.com/qdm12/gluetun/internal/settings"
)
type state struct {
status models.LoopStatus
settings settings.ShadowSocks
settings configuration.ShadowSocks
statusMu sync.RWMutex
settingsMu sync.RWMutex
}
@@ -69,13 +69,13 @@ func (l *looper) SetStatus(status models.LoopStatus) (outcome string, err error)
}
}
func (l *looper) GetSettings() (settings settings.ShadowSocks) {
func (l *looper) GetSettings() (settings configuration.ShadowSocks) {
l.state.settingsMu.RLock()
defer l.state.settingsMu.RUnlock()
return l.state.settings
}
func (l *looper) SetSettings(settings settings.ShadowSocks) (outcome string) {
func (l *looper) SetSettings(settings configuration.ShadowSocks) (outcome string) {
l.state.settingsMu.Lock()
settingsUnchanged := reflect.DeepEqual(settings, l.state.settings)
if settingsUnchanged {