Maintenance: add revive linter
This commit is contained in:
@@ -17,6 +17,9 @@ issues:
|
||||
- path: internal/configuration/
|
||||
linters:
|
||||
- dupl
|
||||
- text: "exported: exported var Err*"
|
||||
linters:
|
||||
- revive
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
@@ -55,6 +58,7 @@ linters:
|
||||
- nolintlint
|
||||
- prealloc
|
||||
- predeclared
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
|
||||
@@ -29,11 +29,7 @@ func (settings *DNS) readBlacklistBuilding(r reader) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := settings.readBlacklistUnblockedHostnames(r); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.readBlacklistUnblockedHostnames(r)
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -69,11 +69,7 @@ func (settings *Firewall) read(r reader) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := settings.readOutboundSubnets(r); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return settings.readOutboundSubnets(r)
|
||||
}
|
||||
|
||||
func (settings *Firewall) readVPNInputPorts(env params.Env) (err error) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package configuration
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/golibs/logging"
|
||||
@@ -43,6 +45,18 @@ func (settings *Settings) lines() (lines []string) {
|
||||
return lines
|
||||
}
|
||||
|
||||
var (
|
||||
ErrOpenvpn = errors.New("cannot read Openvpn settings")
|
||||
ErrSystem = errors.New("cannot read System settings")
|
||||
ErrDNS = errors.New("cannot read DNS settings")
|
||||
ErrFirewall = errors.New("cannot read firewall settings")
|
||||
ErrHTTPProxy = errors.New("cannot read HTTP proxy settings")
|
||||
ErrShadowsocks = errors.New("cannot read Shadowsocks settings")
|
||||
ErrControlServer = errors.New("cannot read control server settings")
|
||||
ErrUpdater = errors.New("cannot read Updater settings")
|
||||
ErrPublicIP = errors.New("cannot read Public IP getter settings")
|
||||
)
|
||||
|
||||
// Read obtains all configuration options for the program and returns an error as soon
|
||||
// as an error is encountered reading them.
|
||||
func (settings *Settings) Read(env params.Env, os os.OS, logger logging.Logger) (err error) {
|
||||
@@ -54,35 +68,35 @@ func (settings *Settings) Read(env params.Env, os os.OS, logger logging.Logger)
|
||||
}
|
||||
|
||||
if err := settings.OpenVPN.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrOpenvpn, err)
|
||||
}
|
||||
|
||||
if err := settings.System.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrSystem, err)
|
||||
}
|
||||
|
||||
if err := settings.DNS.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrDNS, err)
|
||||
}
|
||||
|
||||
if err := settings.Firewall.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrFirewall, err)
|
||||
}
|
||||
|
||||
if err := settings.HTTPProxy.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrHTTPProxy, err)
|
||||
}
|
||||
|
||||
if err := settings.ShadowSocks.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrShadowsocks, err)
|
||||
}
|
||||
|
||||
if err := settings.ControlServer.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrControlServer, err)
|
||||
}
|
||||
|
||||
if err := settings.Updater.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrUpdater, err)
|
||||
}
|
||||
|
||||
if ip := settings.DNS.PlaintextAddress; ip != nil {
|
||||
@@ -90,7 +104,7 @@ func (settings *Settings) Read(env params.Env, os os.OS, logger logging.Logger)
|
||||
}
|
||||
|
||||
if err := settings.PublicIP.read(r); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%w: %s", ErrPublicIP, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
// HealthcheckAddress is the default listening address for the healthcheck server.
|
||||
HealthcheckAddress = "127.0.0.1:9999"
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//nolint:revive
|
||||
package constants
|
||||
|
||||
const (
|
||||
|
||||
@@ -21,10 +21,10 @@ const (
|
||||
RootHints string = "/etc/unbound/root.hints"
|
||||
// RootKey is the filepath to the root.key file used by Unbound.
|
||||
RootKey string = "/etc/unbound/root.key"
|
||||
// Client key filepath, used by Cyberghost.
|
||||
// ClientKey is the client key filepath.
|
||||
ClientKey string = "/gluetun/client.key"
|
||||
// Client certificate filepath, used by Cyberghost.
|
||||
// ClientCertificate is the client certificate filepath.
|
||||
ClientCertificate string = "/gluetun/client.crt"
|
||||
// Servers information filepath.
|
||||
// ServersData is the server information filepath.
|
||||
ServersData = "/gluetun/servers.json"
|
||||
)
|
||||
|
||||
@@ -48,6 +48,7 @@ func PrivadoHostnameChoices() (choices []string) {
|
||||
}
|
||||
|
||||
//nolint:lll
|
||||
// PrivadoServers returns a slice of all the Privado servers.
|
||||
func PrivadoServers() []models.PrivadoServer {
|
||||
return []models.PrivadoServer{
|
||||
{Country: "Argentina", Region: "Buenos Aires F.D.", City: "Buenos Aires", Hostname: "eze-001.vpn.privado.io", IP: net.IP{168, 205, 93, 211}},
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//nolint:revive
|
||||
package constants
|
||||
|
||||
import (
|
||||
|
||||
@@ -11,7 +11,7 @@ const (
|
||||
Ivpn = "ivpn"
|
||||
// Mullvad is a VPN provider.
|
||||
Mullvad = "mullvad"
|
||||
// NordVPN is a VPN provider.
|
||||
// Nordvpn is a VPN provider.
|
||||
Nordvpn = "nordvpn"
|
||||
// Privado is a VPN provider.
|
||||
Privado = "privado"
|
||||
@@ -21,7 +21,7 @@ const (
|
||||
Privatevpn = "privatevpn"
|
||||
// Protonvpn is a VPN provider.
|
||||
Protonvpn = "protonvpn"
|
||||
// PureVPN is a VPN provider.
|
||||
// Purevpn is a VPN provider.
|
||||
Purevpn = "purevpn"
|
||||
// Surfshark is a VPN provider.
|
||||
Surfshark = "surfshark"
|
||||
|
||||
@@ -21,6 +21,7 @@ func VyprvpnRegionChoices() (choices []string) {
|
||||
}
|
||||
|
||||
//nolint:lll
|
||||
// VyprvpnServers returns a slice of all the VyprVPN servers.
|
||||
func VyprvpnServers() []models.VyprvpnServer {
|
||||
return []models.VyprvpnServer{
|
||||
{Region: "Algeria", Hostname: "dz1.vyprvpn.com", TCP: false, UDP: true, IPs: []net.IP{{209, 99, 75, 20}}},
|
||||
|
||||
@@ -40,6 +40,7 @@ func WindscribeHostnameChoices() (choices []string) {
|
||||
}
|
||||
|
||||
//nolint:lll
|
||||
// WindscribeServers returns a slice of all the Windscribe servers.
|
||||
func WindscribeServers() []models.WindscribeServer {
|
||||
return []models.WindscribeServer{
|
||||
{Region: "Albania", City: "Tirana", Hostname: "al-002.whiskergalaxy.com", IPs: []net.IP{{31, 171, 152, 178}, {31, 171, 152, 179}, {31, 171, 152, 180}}},
|
||||
|
||||
@@ -327,8 +327,5 @@ func writeOpenvpnConf(lines []string, openFile os.OpenFileFunc) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := file.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return file.Close()
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ var (
|
||||
ErrBindPort = errors.New("cannot bind port")
|
||||
)
|
||||
|
||||
// PortForward obtains a VPN server side port forwarded from PIA.
|
||||
//nolint:gocognit
|
||||
func (p *PIA) PortForward(ctx context.Context, client *http.Client,
|
||||
openFile os.OpenFileFunc, logger logging.Logger, gateway net.IP, fw firewall.Configurator,
|
||||
|
||||
@@ -31,11 +31,7 @@ func (r *routing) setOutboundRoutes(outboundSubnets []net.IPNet,
|
||||
}
|
||||
|
||||
r.removeOutboundSubnets(subnetsToRemove, defaultInterfaceName, defaultGateway)
|
||||
if err := r.addOutboundSubnets(subnetsToAdd, defaultInterfaceName, defaultGateway); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return r.addOutboundSubnets(subnetsToAdd, defaultInterfaceName, defaultGateway)
|
||||
}
|
||||
|
||||
func (r *routing) removeOutboundSubnets(subnets []net.IPNet,
|
||||
|
||||
@@ -5,5 +5,5 @@ import sysunix "golang.org/x/sys/unix"
|
||||
// Constants used for convenience so "os" does not have to be imported
|
||||
|
||||
const (
|
||||
S_IFCHR = sysunix.S_IFCHR //nolint:golint
|
||||
S_IFCHR = sysunix.S_IFCHR //nolint:revive
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user