Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Oct 9, 2023
1 parent 043ac59 commit 74ce016
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/cnf/cnf_file/rules_parse_test.go
Expand Up @@ -105,15 +105,15 @@ func TestVars(t *testing.T) {
Vars: []cnf.Var{testVarFP, testVar1, testVar2},
}

vf, vn, v := usedVar("no-var")
vf, _, _ := usedVar("no-var")
if vf == true {
t.Error("Var #1")
}
vf, vn, v = usedVar("$non-existent-var")
vf, _, _ = usedVar("$non-existent-var")
if vf == true {
t.Error("Var #2")
}
vf, vn, v = usedVar("$test1")
vf, vn, v := usedVar("$test1")
if vf == false || vn == true || v.Name != testVar1.Name {
t.Error("Var #3")
}
Expand Down
8 changes: 2 additions & 6 deletions lib/main/service.go
@@ -1,7 +1,6 @@
package main

import (
"context"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -36,9 +35,7 @@ func (svc *service) signalHandler() {

case syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM:
log.Warn("service", "Received shutdown signal")
_, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
svc.shutdown(cancel)
svc.shutdown()
}
}
}
Expand All @@ -52,8 +49,7 @@ func (svc *service) start() {
log.Info("service", "Started")
}

func (svc *service) shutdown(cancel context.CancelFunc) {
cancel()
func (svc *service) shutdown() {
for _, srv := range svc.servers {
srv.Listener.Close()
}
Expand Down
11 changes: 9 additions & 2 deletions lib/proc/fwd/util_test.go
@@ -1,6 +1,7 @@
package fwd

import (
"fmt"
"net"
"testing"

Expand All @@ -11,7 +12,10 @@ import (

func TestTargetReachable(t *testing.T) {
cnf.C = &cnf.Config{}
defaults.Set(cnf.C) // probe timeout
err := defaults.Set(cnf.C) // probe timeout
if err != nil {
fmt.Printf("Failed to set default probe-timeout: %v", err)
}

testTarget := net.ParseIP("1.1.1.1")
if !TargetIsReachable("tcp", testTarget, 53) {
Expand All @@ -24,7 +28,10 @@ func TestTargetReachable(t *testing.T) {

func TestFirstReachableTarget(t *testing.T) {
cnf.C = &cnf.Config{}
defaults.Set(cnf.C) // probe timeout
err := defaults.Set(cnf.C) // probe timeout
if err != nil {
fmt.Printf("Failed to set default probe-timeout: %v", err)
}

testTarget1 := net.ParseIP("135.181.170.219")
testTarget2 := net.ParseIP("1.1.1.1")
Expand Down
2 changes: 1 addition & 1 deletion lib/u/helpers_test.go
Expand Up @@ -126,7 +126,7 @@ func TestIsIP(t *testing.T) {
t.Errorf("Failed to check for IP #1")
}

valid, ip = IsIP("test.at")
valid, _ = IsIP("test.at")
if valid {
t.Errorf("Failed to check for IP #2")
}
Expand Down

0 comments on commit 74ce016

Please sign in to comment.