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,7 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"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/qdm12/gluetun/internal/openvpn/extract"
|
||||
@@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
// GetConnection gets the connection from the OpenVPN configuration file.
|
||||
func (p *Provider) GetConnection(selection configuration.ServerSelection) (
|
||||
func (p *Provider) GetConnection(selection settings.ServerSelection) (
|
||||
connection models.Connection, err error) {
|
||||
switch selection.VPN {
|
||||
case constants.OpenVPN:
|
||||
@@ -30,9 +30,9 @@ func (p *Provider) GetConnection(selection configuration.ServerSelection) (
|
||||
}
|
||||
|
||||
func getOpenVPNConnection(extractor extract.Interface,
|
||||
selection configuration.ServerSelection) (
|
||||
selection settings.ServerSelection) (
|
||||
connection models.Connection, err error) {
|
||||
_, connection, err = extractor.Data(selection.OpenVPN.ConfFile)
|
||||
_, connection, err = extractor.Data(*selection.OpenVPN.ConfFile)
|
||||
if err != nil {
|
||||
return connection, fmt.Errorf("%w: %s", ErrExtractConnection, err)
|
||||
}
|
||||
@@ -41,9 +41,9 @@ func getOpenVPNConnection(extractor extract.Interface,
|
||||
return connection, nil
|
||||
}
|
||||
|
||||
func getWireguardConnection(selection configuration.ServerSelection) (
|
||||
func getWireguardConnection(selection settings.ServerSelection) (
|
||||
connection models.Connection) {
|
||||
port := getPort(selection.Wireguard.EndpointPort, selection)
|
||||
port := getPort(*selection.Wireguard.EndpointPort, selection)
|
||||
return models.Connection{
|
||||
Type: constants.Wireguard,
|
||||
IP: selection.Wireguard.EndpointIP,
|
||||
@@ -54,6 +54,6 @@ func getWireguardConnection(selection configuration.ServerSelection) (
|
||||
}
|
||||
|
||||
// Port found is overridden by custom port set with `PORT` or `WIREGUARD_ENDPOINT_PORT`.
|
||||
func getPort(foundPort uint16, selection configuration.ServerSelection) (port uint16) {
|
||||
func getPort(foundPort uint16, selection settings.ServerSelection) (port uint16) {
|
||||
return utils.GetPort(selection, foundPort, foundPort, foundPort)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user