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:
@@ -4,18 +4,23 @@ import (
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"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"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func boolPtr(b bool) *bool { return &b }
|
||||
func intPtr(n int) *int { return &n }
|
||||
func uint16Ptr(n uint16) *uint16 { return &n }
|
||||
func stringPtr(s string) *string { return &s }
|
||||
|
||||
func Test_modifyConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := map[string]struct {
|
||||
lines []string
|
||||
settings configuration.OpenVPN
|
||||
settings settings.OpenVPN
|
||||
connection models.Connection
|
||||
modified []string
|
||||
}{
|
||||
@@ -30,14 +35,16 @@ func Test_modifyConfig(t *testing.T) {
|
||||
"keep me here",
|
||||
"auth bla",
|
||||
},
|
||||
settings: configuration.OpenVPN{
|
||||
settings: settings.OpenVPN{
|
||||
User: "user",
|
||||
Ciphers: []string{"cipher"},
|
||||
Auth: "auth",
|
||||
MSSFix: 1000,
|
||||
Auth: stringPtr("auth"),
|
||||
MSSFix: uint16Ptr(1000),
|
||||
Root: boolPtr(false),
|
||||
ProcUser: "procuser",
|
||||
Interface: "tun3",
|
||||
},
|
||||
Verbosity: intPtr(0),
|
||||
}.WithDefaults(constants.Custom),
|
||||
connection: models.Connection{
|
||||
IP: net.IPv4(1, 2, 3, 4),
|
||||
Port: 1194,
|
||||
|
||||
Reference in New Issue
Block a user