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:
@@ -3,7 +3,7 @@ package utils
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration"
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -12,29 +12,32 @@ func Test_GetProtocol(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := map[string]struct {
|
||||
selection configuration.ServerSelection
|
||||
selection settings.ServerSelection
|
||||
protocol string
|
||||
}{
|
||||
"default": {
|
||||
protocol: constants.UDP,
|
||||
},
|
||||
"OpenVPN UDP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(false),
|
||||
},
|
||||
},
|
||||
protocol: constants.UDP,
|
||||
},
|
||||
"OpenVPN TCP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: true,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(true),
|
||||
},
|
||||
},
|
||||
protocol: constants.TCP,
|
||||
},
|
||||
"Wireguard": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.Wireguard,
|
||||
},
|
||||
protocol: constants.UDP,
|
||||
@@ -57,60 +60,60 @@ func Test_FilterByProtocol(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := map[string]struct {
|
||||
selection configuration.ServerSelection
|
||||
selection settings.ServerSelection
|
||||
serverTCP bool
|
||||
serverUDP bool
|
||||
filtered bool
|
||||
}{
|
||||
"Wireguard and server has UDP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.Wireguard,
|
||||
},
|
||||
serverUDP: true,
|
||||
filtered: false,
|
||||
},
|
||||
"Wireguard and server has not UDP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.Wireguard,
|
||||
},
|
||||
serverUDP: false,
|
||||
filtered: true,
|
||||
},
|
||||
"OpenVPN UDP and server has UDP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: false,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(false),
|
||||
},
|
||||
},
|
||||
serverUDP: true,
|
||||
filtered: false,
|
||||
},
|
||||
"OpenVPN UDP and server has not UDP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: false,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(false),
|
||||
},
|
||||
},
|
||||
serverUDP: false,
|
||||
filtered: true,
|
||||
},
|
||||
"OpenVPN TCP and server has TCP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: true,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(true),
|
||||
},
|
||||
},
|
||||
serverTCP: true,
|
||||
filtered: false,
|
||||
},
|
||||
"OpenVPN TCP and server has not TCP": {
|
||||
selection: configuration.ServerSelection{
|
||||
selection: settings.ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
TCP: true,
|
||||
OpenVPN: settings.OpenVPNSelection{
|
||||
TCP: boolPtr(true),
|
||||
},
|
||||
},
|
||||
serverTCP: false,
|
||||
|
||||
Reference in New Issue
Block a user