Add linters and fix lint issues

This commit is contained in:
Quentin McGaw
2020-10-20 02:45:28 +00:00
parent f9bef8ecda
commit 9c73faaaeb
107 changed files with 739 additions and 422 deletions

View File

@@ -11,7 +11,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// DNS contains settings to configure Unbound for DNS over TLS operation
// DNS contains settings to configure Unbound for DNS over TLS operation.
type DNS struct {
Enabled bool
KeepNameserver bool

View File

@@ -8,7 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// Firewall contains settings to customize the firewall operation
// Firewall contains settings to customize the firewall operation.
type Firewall struct {
AllowedSubnets []net.IPNet
VPNInputPorts []uint16

View File

@@ -9,7 +9,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// OpenVPN contains settings to configure the OpenVPN client
// OpenVPN contains settings to configure the OpenVPN client.
type OpenVPN struct {
User string `json:"user"`
Password string `json:"-"`
@@ -20,7 +20,7 @@ type OpenVPN struct {
Provider models.ProviderSettings `json:"provider"`
}
// GetOpenVPNSettings obtains the OpenVPN settings using the params functions
// GetOpenVPNSettings obtains the OpenVPN settings using the params functions.
func GetOpenVPNSettings(paramsReader params.Reader, vpnProvider models.VPNProvider) (settings OpenVPN, err error) {
settings.User, err = paramsReader.GetUser()
if err != nil {

View File

@@ -19,6 +19,7 @@ func Test_OpenVPN_JSON(t *testing.T) {
}
data, err := json.Marshal(in)
require.NoError(t, err)
//nolint:lll
assert.Equal(t, `{"user":"","verbosity":0,"runAsRoot":true,"cipher":"","auth":"","provider":{"name":"name","serverSelection":{"networkProtocol":"","regions":null,"group":"","countries":null,"cities":null,"isps":null,"owned":false,"customPort":0,"numbers":null,"encryptionPreset":""},"extraConfig":{"encryptionPreset":"","openvpnIPv6":false},"portForwarding":{"enabled":false,"filepath":""}}}`, string(data))
var out OpenVPN
err = json.Unmarshal(data, &out)

View File

@@ -13,7 +13,8 @@ func GetPIASettings(paramsReader params.Reader) (settings models.ProviderSetting
return getPIASettings(paramsReader, constants.PrivateInternetAccess)
}
// GetPIAOldSettings obtains PIA settings for the older PIA servers (pre summer 2020) from environment variables using the params package.
// GetPIAOldSettings obtains PIA settings for the older PIA servers (pre summer 2020)
// from environment variables using the params package.
func GetPIAOldSettings(paramsReader params.Reader) (settings models.ProviderSettings, err error) {
return getPIASettings(paramsReader, constants.PrivateInternetAccessOld)
}
@@ -80,13 +81,13 @@ func GetMullvadSettings(paramsReader params.Reader) (settings models.ProviderSet
}
if settings.ServerSelection.Protocol == constants.TCP {
switch settings.ServerSelection.CustomPort {
case 0, 80, 443, 1401:
case 0, 80, 443, 1401: //nolint:gomnd
default:
return settings, fmt.Errorf("port %d is not valid for TCP protocol", settings.ServerSelection.CustomPort)
}
} else {
switch settings.ServerSelection.CustomPort {
case 0, 53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400:
case 0, 53, 1194, 1195, 1196, 1197, 1300, 1301, 1302, 1303, 1400: //nolint:gomnd
default:
return settings, fmt.Errorf("port %d is not valid for UDP protocol", settings.ServerSelection.CustomPort)
}

View File

@@ -7,7 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// ControlServer contains settings to customize the control server operation
// ControlServer contains settings to customize the control server operation.
type ControlServer struct {
Port uint16
Log bool
@@ -22,7 +22,8 @@ func (c *ControlServer) String() string {
return strings.Join(settingsList, "\n |--")
}
// GetControlServerSettings obtains the HTTP control server settings from environment variables using the params package.
// GetControlServerSettings obtains the HTTP control server settings from
// environment variables using the params package.
func GetControlServerSettings(paramsReader params.Reader) (settings ControlServer, err error) {
settings.Port, err = paramsReader.GetControlServerPort()
if err != nil {

View File

@@ -14,7 +14,7 @@ const (
disabled = "disabled"
)
// Settings contains all settings for the program to run
// Settings contains all settings for the program to run.
type Settings struct {
VPNSP models.VPNProvider
OpenVPN OpenVPN

View File

@@ -7,7 +7,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// ShadowSocks contains settings to configure the Shadowsocks server
// ShadowSocks contains settings to configure the Shadowsocks server.
type ShadowSocks struct {
Method string
Password string

View File

@@ -8,7 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// System contains settings to configure system related elements
// System contains settings to configure system related elements.
type System struct {
UID int
GID int
@@ -16,7 +16,7 @@ type System struct {
IPStatusFilepath models.Filepath
}
// GetSystemSettings obtains the System settings using the params functions
// GetSystemSettings obtains the System settings using the params functions.
func GetSystemSettings(paramsReader params.Reader) (settings System, err error) {
settings.UID, err = paramsReader.GetUID()
if err != nil {

View File

@@ -8,7 +8,7 @@ import (
"github.com/qdm12/gluetun/internal/params"
)
// TinyProxy contains settings to configure TinyProxy
// TinyProxy contains settings to configure TinyProxy.
type TinyProxy struct {
User string
Password string