Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore(deps): Bump DavidAnson/markdownlint-cli2-action from 14 to 15 #2052

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: DavidAnson/markdownlint-cli2-action@v14
- uses: DavidAnson/markdownlint-cli2-action@v15
with:
globs: "**.md"
config: .markdownlint.json
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"go.useLanguageServer": true,
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"go.lintTool": "golangci-lint",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/breml/rootcerts v0.2.16
github.com/fatih/color v1.16.0
github.com/golang/mock v1.6.0
github.com/klauspost/compress v1.17.4
github.com/klauspost/compress v1.17.7
github.com/klauspost/pgzip v1.2.6
github.com/qdm12/dns v1.11.0
github.com/qdm12/golibs v0.0.0-20210822203818-5c568b0777b6
Expand All @@ -23,7 +23,7 @@ require (
github.com/vishvananda/netlink v1.2.1-beta.2
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
golang.org/x/net v0.19.0
golang.org/x/sys v0.15.0
golang.org/x/sys v0.18.0
golang.org/x/text v0.14.0
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230215201556-9c5414ab4bde
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand Down Expand Up @@ -204,8 +204,8 @@ golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
8 changes: 0 additions & 8 deletions internal/configuration/settings/helpers/string.go

This file was deleted.

28 changes: 17 additions & 11 deletions internal/configuration/settings/openvpnselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/qdm12/gluetun/internal/configuration/settings/helpers"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/provider/privateinternetaccess/presets"
"github.com/qdm12/gosettings"
Expand All @@ -17,10 +18,10 @@ type OpenVPNSelection struct {
// NOT use a custom configuration file.
// It cannot be nil in the internal state.
ConfFile *string `json:"config_file_path"`
// TCP is true if the OpenVPN protocol is TCP,
// and false for UDP.
// It cannot be nil in the internal state.
TCP *bool `json:"tcp"`
// Protocol is the OpenVPN network protocol to use,
// and can be udp or tcp. It cannot be the empty string
// in the internal state.
Protocol string `json:"protocol"`
// CustomPort is the OpenVPN server endpoint port.
// It can be set to 0 to indicate no custom port should
// be used. It cannot be nil in the internal state.
Expand All @@ -40,8 +41,13 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
}
}

err = validate.IsOneOf(o.Protocol, constants.UDP, constants.TCP)
if err != nil {
return fmt.Errorf("network protocol: %w", err)
}

// Validate TCP
if *o.TCP && helpers.IsOneOf(vpnProvider,
if o.Protocol == constants.TCP && helpers.IsOneOf(vpnProvider,
providers.Ipvanish,
providers.Perfectprivacy,
providers.Privado,
Expand Down Expand Up @@ -104,7 +110,7 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
}

allowedPorts := allowedUDP
if *o.TCP {
if o.Protocol == constants.TCP {
allowedPorts = allowedTCP
}
err = validate.IsOneOf(*o.CustomPort, allowedPorts...)
Expand Down Expand Up @@ -133,29 +139,29 @@ func (o OpenVPNSelection) validate(vpnProvider string) (err error) {
func (o *OpenVPNSelection) copy() (copied OpenVPNSelection) {
return OpenVPNSelection{
ConfFile: gosettings.CopyPointer(o.ConfFile),
TCP: gosettings.CopyPointer(o.TCP),
Protocol: o.Protocol,
CustomPort: gosettings.CopyPointer(o.CustomPort),
PIAEncPreset: gosettings.CopyPointer(o.PIAEncPreset),
}
}

func (o *OpenVPNSelection) mergeWith(other OpenVPNSelection) {
o.ConfFile = gosettings.MergeWithPointer(o.ConfFile, other.ConfFile)
o.TCP = gosettings.MergeWithPointer(o.TCP, other.TCP)
o.Protocol = gosettings.MergeWithString(o.Protocol, other.Protocol)
o.CustomPort = gosettings.MergeWithPointer(o.CustomPort, other.CustomPort)
o.PIAEncPreset = gosettings.MergeWithPointer(o.PIAEncPreset, other.PIAEncPreset)
}

func (o *OpenVPNSelection) overrideWith(other OpenVPNSelection) {
o.ConfFile = gosettings.OverrideWithPointer(o.ConfFile, other.ConfFile)
o.TCP = gosettings.OverrideWithPointer(o.TCP, other.TCP)
o.Protocol = gosettings.OverrideWithString(o.Protocol, other.Protocol)
o.CustomPort = gosettings.OverrideWithPointer(o.CustomPort, other.CustomPort)
o.PIAEncPreset = gosettings.OverrideWithPointer(o.PIAEncPreset, other.PIAEncPreset)
}

func (o *OpenVPNSelection) setDefaults(vpnProvider string) {
o.ConfFile = gosettings.DefaultPointer(o.ConfFile, "")
o.TCP = gosettings.DefaultPointer(o.TCP, false)
o.Protocol = gosettings.DefaultString(o.Protocol, constants.UDP)
o.CustomPort = gosettings.DefaultPointer(o.CustomPort, 0)

var defaultEncPreset string
Expand All @@ -171,7 +177,7 @@ func (o OpenVPNSelection) String() string {

func (o OpenVPNSelection) toLinesNode() (node *gotree.Node) {
node = gotree.New("OpenVPN server selection settings:")
node.Appendf("Protocol: %s", helpers.TCPPtrToString(o.TCP))
node.Appendf("Protocol: %s", o.Protocol)

if *o.CustomPort != 0 {
node.Appendf("Custom port: %d", *o.CustomPort)
Expand Down
32 changes: 1 addition & 31 deletions internal/configuration/sources/env/openvpnselection.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package env

import (
"errors"
"fmt"
"strings"

"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gosettings/sources/env"
)

func (s *Source) readOpenVPNSelection() (
selection settings.OpenVPNSelection, err error) {
selection.ConfFile = s.env.Get("OPENVPN_CUSTOM_CONFIG", env.ForceLowercase(false))

selection.TCP, err = s.readOpenVPNProtocol()
selection.Protocol = s.env.String("OPENVPN_PROTOCOL", env.RetroKeys("PROTOCOL"))
if err != nil {
return selection, err
}
Expand All @@ -29,28 +24,3 @@ func (s *Source) readOpenVPNSelection() (

return selection, nil
}

var ErrOpenVPNProtocolNotValid = errors.New("OpenVPN protocol is not valid")

func (s *Source) readOpenVPNProtocol() (tcp *bool, err error) {
const currentKey = "OPENVPN_PROTOCOL"
envKey := firstKeySet(s.env, "PROTOCOL", currentKey)
switch envKey {
case "":
return nil, nil //nolint:nilnil
case currentKey:
default: // Retro compatibility
s.handleDeprecatedKey(envKey, currentKey)
}

protocol := s.env.String(envKey)
switch strings.ToLower(protocol) {
case constants.UDP:
return ptrTo(false), nil
case constants.TCP:
return ptrTo(true), nil
default:
return nil, fmt.Errorf("environment variable %s: %w: %s",
envKey, ErrOpenVPNProtocolNotValid, protocol)
}
}
5 changes: 2 additions & 3 deletions internal/provider/expressvpn/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func Test_Provider_GetConnection(t *testing.T) {
const provider = providers.Expressvpn

errTest := errors.New("test error")
boolPtr := func(b bool) *bool { return &b }

testCases := map[string]struct {
filteredServers []models.Server
Expand All @@ -45,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true),
Protocol: constants.TCP,
},
}.WithDefaults(provider),
panicMessage: "no default OpenVPN TCP port is defined!",
Expand All @@ -56,7 +55,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(false),
Protocol: constants.UDP,
},
}.WithDefaults(provider),
connection: models.Connection{
Expand Down
5 changes: 2 additions & 3 deletions internal/provider/ivpn/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func Test_Provider_GetConnection(t *testing.T) {
const provider = providers.Ivpn

errTest := errors.New("test error")
boolPtr := func(b bool) *bool { return &b }

testCases := map[string]struct {
filteredServers []models.Server
Expand All @@ -45,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true),
Protocol: constants.TCP,
},
}.WithDefaults(provider),
connection: models.Connection{
Expand All @@ -61,7 +60,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(false),
Protocol: constants.UDP,
},
}.WithDefaults(provider),
connection: models.Connection{
Expand Down
5 changes: 2 additions & 3 deletions internal/provider/mullvad/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func Test_Provider_GetConnection(t *testing.T) {
const provider = providers.Mullvad

errTest := errors.New("test error")
boolPtr := func(b bool) *bool { return &b }

testCases := map[string]struct {
filteredServers []models.Server
Expand All @@ -45,7 +44,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true),
Protocol: constants.TCP,
},
}.WithDefaults(provider),
connection: models.Connection{
Expand All @@ -61,7 +60,7 @@ func Test_Provider_GetConnection(t *testing.T) {
},
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(false),
Protocol: constants.UDP,
},
}.WithDefaults(provider),
connection: models.Connection{
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/utils/filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/qdm12/gluetun/internal/models"
Expand Down Expand Up @@ -50,7 +51,7 @@ func Test_FilterServers(t *testing.T) {
"filter by network protocol": {
selection: settings.ServerSelection{
OpenVPN: settings.OpenVPNSelection{
TCP: boolPtr(true),
Protocol: constants.TCP,
},
}.WithDefaults(providers.Ivpn),
servers: []models.Server{
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/utils/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/vpn"
)

Expand All @@ -22,7 +23,7 @@ func getPort(selection settings.ServerSelection,
if customPort > 0 {
return customPort
}
if *selection.OpenVPN.TCP {
if selection.OpenVPN.Protocol == constants.TCP {
checkDefined("OpenVPN TCP", defaultOpenVPNTCP)
return defaultOpenVPNTCP
}
Expand Down
9 changes: 5 additions & 4 deletions internal/provider/utils/port_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/qdm12/gluetun/internal/configuration/settings"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/constants/vpn"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -40,7 +41,7 @@ func Test_GetPort(t *testing.T) {
VPN: vpn.OpenVPN,
OpenVPN: settings.OpenVPNSelection{
CustomPort: uint16Ptr(0),
TCP: boolPtr(false),
Protocol: constants.UDP,
},
},
defaultOpenVPNTCP: defaultOpenVPNTCP,
Expand All @@ -53,7 +54,7 @@ func Test_GetPort(t *testing.T) {
VPN: vpn.OpenVPN,
OpenVPN: settings.OpenVPNSelection{
CustomPort: uint16Ptr(0),
TCP: boolPtr(false),
Protocol: constants.UDP,
},
},
panics: "no default OpenVPN UDP port is defined!",
Expand All @@ -63,7 +64,7 @@ func Test_GetPort(t *testing.T) {
VPN: vpn.OpenVPN,
OpenVPN: settings.OpenVPNSelection{
CustomPort: uint16Ptr(0),
TCP: boolPtr(true),
Protocol: constants.TCP,
},
},
defaultOpenVPNTCP: defaultOpenVPNTCP,
Expand All @@ -74,7 +75,7 @@ func Test_GetPort(t *testing.T) {
VPN: vpn.OpenVPN,
OpenVPN: settings.OpenVPNSelection{
CustomPort: uint16Ptr(0),
TCP: boolPtr(true),
Protocol: constants.TCP,
},
},
panics: "no default OpenVPN TCP port is defined!",
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/utils/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func getProtocol(selection settings.ServerSelection) (protocol string) {
if selection.VPN == vpn.OpenVPN && *selection.OpenVPN.TCP {
if selection.VPN == vpn.OpenVPN && selection.OpenVPN.Protocol == constants.TCP {
return constants.TCP
}
return constants.UDP
Expand All @@ -19,7 +19,7 @@ func filterByProtocol(selection settings.ServerSelection,
case vpn.Wireguard:
return !serverUDP
default: // OpenVPN
wantTCP := *selection.OpenVPN.TCP
wantTCP := selection.OpenVPN.Protocol == constants.TCP
wantUDP := !wantTCP
return (wantTCP && !serverTCP) || (wantUDP && !serverUDP)
}
Expand Down
Loading