From c2a5985dc9b769538d41f138c6250616ae104445 Mon Sep 17 00:00:00 2001 From: Yevhen Vydolob Date: Wed, 6 Mar 2024 11:20:29 +0200 Subject: [PATCH] Fix lint errors Signed-off-by: Yevhen Vydolob --- cmd/test-companion/main.go | 2 +- pkg/services/dhcp/dhcp.go | 2 +- pkg/services/dns/dns.go | 2 +- pkg/services/forwarder/ports.go | 8 ++++---- pkg/services/forwarder/tcp.go | 2 +- pkg/sshclient/bastion.go | 2 +- pkg/transport/dial_darwin.go | 2 +- pkg/virtualnetwork/mux.go | 12 ++++++------ test/basic_test.go | 6 +++--- test/port_forwarding_test.go | 14 +++++++------- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd/test-companion/main.go b/cmd/test-companion/main.go index 397730851..f1773fcda 100644 --- a/cmd/test-companion/main.go +++ b/cmd/test-companion/main.go @@ -39,7 +39,7 @@ func main() { }() mux := http.NewServeMux() - mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { + mux.HandleFunc("/", func(writer http.ResponseWriter, _ *http.Request) { _, _ = writer.Write([]byte(`Hello world!`)) }) diff --git a/pkg/services/dhcp/dhcp.go b/pkg/services/dhcp/dhcp.go index f464a31d6..cfd5370ea 100644 --- a/pkg/services/dhcp/dhcp.go +++ b/pkg/services/dhcp/dhcp.go @@ -120,7 +120,7 @@ func (s *Server) Serve() error { func (s *Server) Mux() http.Handler { mux := http.NewServeMux() - mux.HandleFunc("/leases", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/leases", func(w http.ResponseWriter, _ *http.Request) { _ = json.NewEncoder(w).Encode(s.IPPool.Leases()) }) return mux diff --git a/pkg/services/dns/dns.go b/pkg/services/dns/dns.go index 15ed72f1d..1cfe0b6cb 100644 --- a/pkg/services/dns/dns.go +++ b/pkg/services/dns/dns.go @@ -231,7 +231,7 @@ func (s *Server) ServeTCP() error { func (s *Server) Mux() http.Handler { mux := http.NewServeMux() - mux.HandleFunc("/all", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/all", func(w http.ResponseWriter, _ *http.Request) { s.handler.zonesLock.RLock() _ = json.NewEncoder(w).Encode(s.handler.zones) s.handler.zonesLock.RUnlock() diff --git a/pkg/services/forwarder/ports.go b/pkg/services/forwarder/ports.go index 828c248b5..887092cbd 100644 --- a/pkg/services/forwarder/ports.go +++ b/pkg/services/forwarder/ports.go @@ -117,7 +117,7 @@ func (f *PortsForwarder) Expose(protocol types.TransportProtocol, local, remote var sshForward *sshclient.SSHForward var connLock sync.Mutex - dialFn = func(ctx context.Context, network, addr string) (net.Conn, error) { + dialFn = func(ctx context.Context, _, _ string) (net.Conn, error) { connLock.Lock() defer connLock.Unlock() @@ -145,7 +145,7 @@ func (f *PortsForwarder) Expose(protocol types.TransportProtocol, local, remote return err } - dialFn = func(ctx context.Context, network, addr string) (conn net.Conn, e error) { + dialFn = func(ctx context.Context, _, _ string) (conn net.Conn, e error) { return gonet.DialContextTCP(ctx, f.stack, address, ipv4.ProtocolNumber) } @@ -232,7 +232,7 @@ func (f *PortsForwarder) Expose(protocol types.TransportProtocol, local, remote var p tcpproxy.Proxy p.AddRoute(local, &tcpproxy.DialProxy{ Addr: remote, - DialContext: func(ctx context.Context, network, addr string) (conn net.Conn, e error) { + DialContext: func(ctx context.Context, _, _ string) (conn net.Conn, e error) { return gonet.DialContextTCP(ctx, f.stack, address, ipv4.ProtocolNumber) }, }) @@ -273,7 +273,7 @@ func (f *PortsForwarder) Unexpose(protocol types.TransportProtocol, local string func (f *PortsForwarder) Mux() http.Handler { mux := http.NewServeMux() - mux.HandleFunc("/all", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/all", func(w http.ResponseWriter, _ *http.Request) { f.proxiesLock.Lock() defer f.proxiesLock.Unlock() ret := make([]proxy, 0) diff --git a/pkg/services/forwarder/tcp.go b/pkg/services/forwarder/tcp.go index e60936ec4..9026d662d 100644 --- a/pkg/services/forwarder/tcp.go +++ b/pkg/services/forwarder/tcp.go @@ -47,7 +47,7 @@ func TCP(s *stack.Stack, nat map[tcpip.Address]tcpip.Address, natLock *sync.Mute } remote := tcpproxy.DialProxy{ - DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return outbound, nil }, } diff --git a/pkg/sshclient/bastion.go b/pkg/sshclient/bastion.go index f10bddda0..956e4f458 100644 --- a/pkg/sshclient/bastion.go +++ b/pkg/sshclient/bastion.go @@ -138,7 +138,7 @@ func CreateBastion(_url *url.URL, passPhrase string, identity string, initial ne } if connect == nil { - connect = func(ctx context.Context, bastion *Bastion) (net.Conn, error) { + connect = func(_ context.Context, bastion *Bastion) (net.Conn, error) { conn, err := net.DialTimeout("tcp", net.JoinHostPort(bastion.Host, bastion.Port), bastion.Config.Timeout, diff --git a/pkg/transport/dial_darwin.go b/pkg/transport/dial_darwin.go index 2556a386f..da245a4e3 100644 --- a/pkg/transport/dial_darwin.go +++ b/pkg/transport/dial_darwin.go @@ -6,6 +6,6 @@ import ( "github.com/pkg/errors" ) -func Dial(endpoint string) (net.Conn, string, error) { +func Dial(_ string) (net.Conn, string, error) { return nil, "", errors.New("unsupported") } diff --git a/pkg/virtualnetwork/mux.go b/pkg/virtualnetwork/mux.go index c671177ca..94e89e030 100644 --- a/pkg/virtualnetwork/mux.go +++ b/pkg/virtualnetwork/mux.go @@ -18,16 +18,16 @@ import ( func (n *VirtualNetwork) Mux() *http.ServeMux { mux := http.NewServeMux() mux.Handle("/services/", http.StripPrefix("/services", n.servicesMux)) - mux.HandleFunc("/stats", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/stats", func(w http.ResponseWriter, _ *http.Request) { _ = json.NewEncoder(w).Encode(statsAsJSON(n.networkSwitch.Sent, n.networkSwitch.Received, n.stack.Stats())) }) - mux.HandleFunc("/cam", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/cam", func(w http.ResponseWriter, _ *http.Request) { _ = json.NewEncoder(w).Encode(n.networkSwitch.CAM()) }) - mux.HandleFunc("/leases", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/leases", func(w http.ResponseWriter, _ *http.Request) { _ = json.NewEncoder(w).Encode(n.ipPool.Leases()) }) - mux.HandleFunc(types.ConnectPath, func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc(types.ConnectPath, func(w http.ResponseWriter, _ *http.Request) { hj, ok := w.(http.Hijacker) if !ok { http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError) @@ -83,14 +83,14 @@ func (n *VirtualNetwork) Mux() *http.ServeMux { } remote := tcpproxy.DialProxy{ - DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { + DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { return gonet.DialContextTCP(ctx, n.stack, tcpip.FullAddress{ NIC: 1, Addr: tcpip.AddrFrom4Slice(net.ParseIP(ip).To4()), Port: uint16(port), }, ipv4.ProtocolNumber) }, - OnDialError: func(src net.Conn, dstDialErr error) { + OnDialError: func(_ net.Conn, dstDialErr error) { log.Errorf("cannot dial: %v", dstDialErr) }, } diff --git a/test/basic_test.go b/test/basic_test.go index 9d3faf09b..a1fbd5c2c 100644 --- a/test/basic_test.go +++ b/test/basic_test.go @@ -95,7 +95,7 @@ var _ = ginkgo.Describe("dns", func() { ginkgo.It("should resolve dynamically added dns entry test.dynamic.internal", func() { client := gvproxyclient.New(&http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", sock) }, }, @@ -120,7 +120,7 @@ var _ = ginkgo.Describe("dns", func() { ginkgo.It("should resolve recently added dns entry test.dynamic.internal", func() { client := gvproxyclient.New(&http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", sock) }, }, @@ -156,7 +156,7 @@ var _ = ginkgo.Describe("dns", func() { ginkgo.It("should retain order of existing zone", func() { client := gvproxyclient.New(&http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", sock) }, }, diff --git a/test/port_forwarding_test.go b/test/port_forwarding_test.go index c38e4f6a0..2e32e8f1a 100644 --- a/test/port_forwarding_test.go +++ b/test/port_forwarding_test.go @@ -23,7 +23,7 @@ import ( var _ = ginkgo.Describe("port forwarding", func() { client := gvproxyclient.New(&http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", sock) }, }, @@ -35,7 +35,7 @@ var _ = ginkgo.Describe("port forwarding", func() { defer ln.Close() mux := http.NewServeMux() - mux.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { + mux.HandleFunc("/", func(writer http.ResponseWriter, _ *http.Request) { _, _ = writer.Write([]byte("Hello from the host")) }) go func() { @@ -109,7 +109,7 @@ var _ = ginkgo.Describe("port forwarding", func() { ginkgo.It("should reach a http server in the VM using the tunneling of the daemon", func() { httpClient := &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { conn, err := net.Dial("unix", sock) if err != nil { return nil, err @@ -153,7 +153,7 @@ var _ = ginkgo.Describe("port forwarding", func() { ginkgo.It("should reach rootless podman API using unix socket forwarding over ssh", func() { httpClient := &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", forwardSock) }, }, @@ -176,7 +176,7 @@ var _ = ginkgo.Describe("port forwarding", func() { ginkgo.It("should reach rootful podman API using unix socket forwarding over ssh", func() { httpClient := &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", forwardRootSock) }, }, @@ -215,7 +215,7 @@ var _ = ginkgo.Describe("port forwarding", func() { httpClient := &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", unix2tcpfwdsock) }, }, @@ -247,7 +247,7 @@ var _ = ginkgo.Describe("port forwarding", func() { httpClient := &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { return net.Dial("unix", unix2unixfwdsock) }, },