Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint error #335

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/test-companion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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!`))
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/services/dhcp/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions pkg/services/forwarder/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
},
})
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/forwarder/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sshclient/bastion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/transport/dial_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
12 changes: 6 additions & 6 deletions pkg/virtualnetwork/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
},
}
Expand Down
6 changes: 3 additions & 3 deletions test/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand All @@ -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)
},
},
Expand Down Expand Up @@ -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)
},
},
Expand Down
14 changes: 7 additions & 7 deletions test/port_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
},
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
},
},
Expand All @@ -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)
},
},
Expand Down Expand Up @@ -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)
},
},
Expand Down Expand Up @@ -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)
},
},
Expand Down
Loading