util/linuxfw: rename ErrorFWModeNotSupported

Go style is for error variables to start with "err" (or "Err")
and for error types to end in "Error".

Updates #cleanup

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/8842/head
Brad Fitzpatrick 1 year ago committed by Brad Fitzpatrick
parent 3d56cafd7d
commit 7a5263e6d0

@ -49,7 +49,7 @@ func DetectIptables() (int, error) {
case err != nil && ip6err == nil: case err != nil && ip6err == nil:
allLines = ip6lines allLines = ip6lines
default: default:
return 0, ErrorFWModeNotSupported{ return 0, FWModeNotSupportedError{
Mode: FirewallModeIPTables, Mode: FirewallModeIPTables,
Err: fmt.Errorf("iptables command run fail: %w", multierr.New(err, ip6err)), Err: fmt.Errorf("iptables command run fail: %w", multierr.New(err, ip6err)),
} }

@ -29,21 +29,21 @@ const (
Masq Masq
) )
type ErrorFWModeNotSupported struct { type FWModeNotSupportedError struct {
Mode FirewallMode Mode FirewallMode
Err error Err error
} }
func (e ErrorFWModeNotSupported) Error() string { func (e FWModeNotSupportedError) Error() string {
return fmt.Sprintf("firewall mode %q not supported: %v", e.Mode, e.Err) return fmt.Sprintf("firewall mode %q not supported: %v", e.Mode, e.Err)
} }
func (e ErrorFWModeNotSupported) Is(target error) bool { func (e FWModeNotSupportedError) Is(target error) bool {
_, ok := target.(ErrorFWModeNotSupported) _, ok := target.(FWModeNotSupportedError)
return ok return ok
} }
func (e ErrorFWModeNotSupported) Unwrap() error { func (e FWModeNotSupportedError) Unwrap() error {
return e.Err return e.Err
} }

@ -107,7 +107,7 @@ func DebugNetfilter(logf logger.Logf) error {
func DetectNetfilter() (int, error) { func DetectNetfilter() (int, error) {
conn, err := nftables.New() conn, err := nftables.New()
if err != nil { if err != nil {
return 0, ErrorFWModeNotSupported{ return 0, FWModeNotSupportedError{
Mode: FirewallModeNfTables, Mode: FirewallModeNfTables,
Err: err, Err: err,
} }
@ -115,7 +115,7 @@ func DetectNetfilter() (int, error) {
chains, err := conn.ListChains() chains, err := conn.ListChains()
if err != nil { if err != nil {
return 0, ErrorFWModeNotSupported{ return 0, FWModeNotSupportedError{
Mode: FirewallModeNfTables, Mode: FirewallModeNfTables,
Err: fmt.Errorf("cannot list chains: %w", err), Err: fmt.Errorf("cannot list chains: %w", err),
} }

Loading…
Cancel
Save