diff --git a/.github/workflows/build-and-push-image.yml b/.github/workflows/build-and-push-image.yml index 99a9fa9a..9607ba18 100644 --- a/.github/workflows/build-and-push-image.yml +++ b/.github/workflows/build-and-push-image.yml @@ -61,7 +61,7 @@ jobs: echo "TAG_FRPS_GPR=ghcr.io/fatedier/frps:${{ env.TAG_NAME }}" >> $GITHUB_ENV - name: Build and push frpc - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: . file: ./dockerfiles/Dockerfile-for-frpc @@ -72,7 +72,7 @@ jobs: ${{ env.TAG_FRPC_GPR }} - name: Build and push frps - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: context: . file: ./dockerfiles/Dockerfile-for-frps diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0aa1c5dd..fb671e0b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,7 +14,7 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: '1.20' - uses: actions/checkout@v3 @@ -22,7 +22,7 @@ jobs: uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.51 + version: v1.53 # Optional: golangci-lint command line arguments. # args: --issues-exit-code=0 diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 484167aa..08bd8316 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: '1.20' @@ -22,9 +22,9 @@ jobs: ./package.sh - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v4 with: version: latest - args: release --rm-dist --release-notes=./Release.md + args: release --clean --release-notes=./Release.md env: GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c3642d91..cceb40da 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -18,7 +18,7 @@ jobs: pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest steps: - - uses: actions/stale@v6 + - uses: actions/stale@v8 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'Issues go stale after 30d of inactivity. Stale issues rot after an additional 7d of inactivity and eventually close.' diff --git a/client/admin_api.go b/client/admin_api.go index cba2d919..b1d1885c 100644 --- a/client/admin_api.go +++ b/client/admin_api.go @@ -39,12 +39,12 @@ type GeneralResponse struct { } // /healthz -func (svr *Service) healthz(w http.ResponseWriter, r *http.Request) { +func (svr *Service) healthz(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(200) } // GET /api/reload -func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) { +func (svr *Service) apiReload(w http.ResponseWriter, _ *http.Request) { res := GeneralResponse{Code: 200} log.Info("api request [/api/reload]") @@ -74,7 +74,7 @@ func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) { } // POST /api/stop -func (svr *Service) apiStop(w http.ResponseWriter, r *http.Request) { +func (svr *Service) apiStop(w http.ResponseWriter, _ *http.Request) { res := GeneralResponse{Code: 200} log.Info("api request [/api/stop]") @@ -124,7 +124,7 @@ func NewProxyStatusResp(status *proxy.WorkingStatus, serverAddr string) ProxySta } // GET /api/status -func (svr *Service) apiStatus(w http.ResponseWriter, r *http.Request) { +func (svr *Service) apiStatus(w http.ResponseWriter, _ *http.Request) { var ( buf []byte res StatusResp = make(map[string][]ProxyStatusResp) @@ -153,7 +153,7 @@ func (svr *Service) apiStatus(w http.ResponseWriter, r *http.Request) { } // GET /api/config -func (svr *Service) apiGetConfig(w http.ResponseWriter, r *http.Request) { +func (svr *Service) apiGetConfig(w http.ResponseWriter, _ *http.Request) { res := GeneralResponse{Code: 200} log.Info("Http get request [/api/config]") diff --git a/client/control.go b/client/control.go index 95f84f8c..e344046c 100644 --- a/client/control.go +++ b/client/control.go @@ -124,7 +124,7 @@ func (ctl *Control) Run() { go ctl.vm.Run() } -func (ctl *Control) HandleReqWorkConn(inMsg *msg.ReqWorkConn) { +func (ctl *Control) HandleReqWorkConn(_ *msg.ReqWorkConn) { xl := ctl.xl workConn, err := ctl.connectServer() if err != nil { diff --git a/client/proxy/general_tcp.go b/client/proxy/general_tcp.go index 7efe476f..cea9ef5b 100644 --- a/client/proxy/general_tcp.go +++ b/client/proxy/general_tcp.go @@ -40,7 +40,7 @@ type GeneralTCPProxy struct { *BaseProxy } -func NewGeneralTCPProxy(baseProxy *BaseProxy, cfg config.ProxyConf) Proxy { +func NewGeneralTCPProxy(baseProxy *BaseProxy, _ config.ProxyConf) Proxy { return &GeneralTCPProxy{ BaseProxy: baseProxy, } diff --git a/client/proxy/sudp.go b/client/proxy/sudp.go index 0981c656..fbbe87ca 100644 --- a/client/proxy/sudp.go +++ b/client/proxy/sudp.go @@ -77,7 +77,7 @@ func (pxy *SUDPProxy) Close() { } } -func (pxy *SUDPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) { +func (pxy *SUDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn) { xl := pxy.xl xl.Info("incoming a new work connection for sudp proxy, %s", conn.RemoteAddr().String()) diff --git a/client/proxy/udp.go b/client/proxy/udp.go index cc187000..58f30cb2 100644 --- a/client/proxy/udp.go +++ b/client/proxy/udp.go @@ -86,7 +86,7 @@ func (pxy *UDPProxy) Close() { } } -func (pxy *UDPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) { +func (pxy *UDPProxy) InWorkConn(conn net.Conn, _ *msg.StartWorkConn) { xl := pxy.xl xl.Info("incoming a new work connection for udp proxy, %s", conn.RemoteAddr().String()) // close resources releated with old workConn diff --git a/client/visitor/xtcp.go b/client/visitor/xtcp.go index 713ed341..02bc34c4 100644 --- a/client/visitor/xtcp.go +++ b/client/visitor/xtcp.go @@ -370,7 +370,7 @@ func (ks *KCPTunnelSession) Init(listenConn *net.UDPConn, raddr *net.UDPAddr) er return nil } -func (ks *KCPTunnelSession) OpenConn(ctx context.Context) (net.Conn, error) { +func (ks *KCPTunnelSession) OpenConn(_ context.Context) (net.Conn, error) { ks.mu.RLock() defer ks.mu.RUnlock() session := ks.session diff --git a/pkg/config/proxy.go b/pkg/config/proxy.go index ae1d077c..1169fd75 100644 --- a/pkg/config/proxy.go +++ b/pkg/config/proxy.go @@ -527,11 +527,8 @@ func (cfg *TCPProxyConf) ValidateForClient() (err error) { return } -func (cfg *TCPProxyConf) ValidateForServer(serverCfg ServerCommonConf) error { - if err := cfg.BaseProxyConf.validateForServer(); err != nil { - return err - } - return nil +func (cfg *TCPProxyConf) ValidateForServer(_ ServerCommonConf) error { + return cfg.BaseProxyConf.validateForServer() } // TCPMux @@ -644,11 +641,8 @@ func (cfg *UDPProxyConf) ValidateForClient() (err error) { return } -func (cfg *UDPProxyConf) ValidateForServer(serverCfg ServerCommonConf) error { - if err := cfg.BaseProxyConf.validateForServer(); err != nil { - return err - } - return nil +func (cfg *UDPProxyConf) ValidateForServer(_ ServerCommonConf) error { + return cfg.BaseProxyConf.validateForServer() } // HTTP @@ -821,11 +815,8 @@ func (cfg *SUDPProxyConf) ValidateForClient() (err error) { return nil } -func (cfg *SUDPProxyConf) ValidateForServer(serverCfg ServerCommonConf) error { - if err := cfg.BaseProxyConf.validateForServer(); err != nil { - return err - } - return nil +func (cfg *SUDPProxyConf) ValidateForServer(_ ServerCommonConf) error { + return cfg.BaseProxyConf.validateForServer() } // STCP @@ -875,11 +866,8 @@ func (cfg *STCPProxyConf) ValidateForClient() (err error) { return } -func (cfg *STCPProxyConf) ValidateForServer(serverCfg ServerCommonConf) error { - if err := cfg.BaseProxyConf.validateForServer(); err != nil { - return err - } - return nil +func (cfg *STCPProxyConf) ValidateForServer(_ ServerCommonConf) error { + return cfg.BaseProxyConf.validateForServer() } // XTCP @@ -928,9 +916,6 @@ func (cfg *XTCPProxyConf) ValidateForClient() (err error) { return } -func (cfg *XTCPProxyConf) ValidateForServer(serverCfg ServerCommonConf) error { - if err := cfg.BaseProxyConf.validateForServer(); err != nil { - return err - } - return nil +func (cfg *XTCPProxyConf) ValidateForServer(_ ServerCommonConf) error { + return cfg.BaseProxyConf.validateForServer() } diff --git a/pkg/config/proxy_test.go b/pkg/config/proxy_test.go index 9ef6f87c..99d60811 100644 --- a/pkg/config/proxy_test.go +++ b/pkg/config/proxy_test.go @@ -35,7 +35,7 @@ var ( testProxyPrefix = "test." ) -func Test_Proxy_Interface(t *testing.T) { +func Test_Proxy_Interface(_ *testing.T) { for name := range proxyConfTypeMap { NewConfByType(name) } diff --git a/pkg/config/visitor_test.go b/pkg/config/visitor_test.go index 0f4171db..46cbef5a 100644 --- a/pkg/config/visitor_test.go +++ b/pkg/config/visitor_test.go @@ -25,7 +25,7 @@ import ( const testVisitorPrefix = "test." -func Test_Visitor_Interface(t *testing.T) { +func Test_Visitor_Interface(_ *testing.T) { for name := range visitorConfTypeMap { DefaultVisitorConf(name) } diff --git a/pkg/metrics/mem/server.go b/pkg/metrics/mem/server.go index e8ebd9d4..d721090c 100644 --- a/pkg/metrics/mem/server.go +++ b/pkg/metrics/mem/server.go @@ -129,7 +129,7 @@ func (m *serverMetrics) CloseProxy(name string, proxyType string) { } } -func (m *serverMetrics) OpenConnection(name string, proxyType string) { +func (m *serverMetrics) OpenConnection(name string, _ string) { m.info.CurConns.Inc(1) m.mu.Lock() @@ -141,7 +141,7 @@ func (m *serverMetrics) OpenConnection(name string, proxyType string) { } } -func (m *serverMetrics) CloseConnection(name string, proxyType string) { +func (m *serverMetrics) CloseConnection(name string, _ string) { m.info.CurConns.Dec(1) m.mu.Lock() @@ -153,7 +153,7 @@ func (m *serverMetrics) CloseConnection(name string, proxyType string) { } } -func (m *serverMetrics) AddTrafficIn(name string, proxyType string, trafficBytes int64) { +func (m *serverMetrics) AddTrafficIn(name string, _ string, trafficBytes int64) { m.info.TotalTrafficIn.Inc(trafficBytes) m.mu.Lock() @@ -166,7 +166,7 @@ func (m *serverMetrics) AddTrafficIn(name string, proxyType string, trafficBytes } } -func (m *serverMetrics) AddTrafficOut(name string, proxyType string, trafficBytes int64) { +func (m *serverMetrics) AddTrafficOut(name string, _ string, trafficBytes int64) { m.info.TotalTrafficOut.Inc(trafficBytes) m.mu.Lock() diff --git a/pkg/metrics/prometheus/server.go b/pkg/metrics/prometheus/server.go index 19eceb72..56dea6e8 100644 --- a/pkg/metrics/prometheus/server.go +++ b/pkg/metrics/prometheus/server.go @@ -29,11 +29,11 @@ func (m *serverMetrics) CloseClient() { m.clientCount.Dec() } -func (m *serverMetrics) NewProxy(name string, proxyType string) { +func (m *serverMetrics) NewProxy(_ string, proxyType string) { m.proxyCount.WithLabelValues(proxyType).Inc() } -func (m *serverMetrics) CloseProxy(name string, proxyType string) { +func (m *serverMetrics) CloseProxy(_ string, proxyType string) { m.proxyCount.WithLabelValues(proxyType).Dec() } diff --git a/pkg/nathole/utils.go b/pkg/nathole/utils.go index c889c7eb..22ba016f 100644 --- a/pkg/nathole/utils.go +++ b/pkg/nathole/utils.go @@ -45,10 +45,7 @@ func DecodeMessageInto(data, key []byte, m msg.Message) error { return err } - if err := msg.ReadMsgInto(bytes.NewReader(buf), m); err != nil { - return err - } - return nil + return msg.ReadMsgInto(bytes.NewReader(buf), m) } type ChangedAddress struct { diff --git a/pkg/plugin/client/http2https.go b/pkg/plugin/client/http2https.go index f84b0a0c..beacab00 100644 --- a/pkg/plugin/client/http2https.go +++ b/pkg/plugin/client/http2https.go @@ -97,7 +97,7 @@ func NewHTTP2HTTPSPlugin(params map[string]string) (Plugin, error) { return p, nil } -func (p *HTTP2HTTPSPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (p *HTTP2HTTPSPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) _ = p.l.PutConn(wrapConn) } @@ -107,8 +107,5 @@ func (p *HTTP2HTTPSPlugin) Name() string { } func (p *HTTP2HTTPSPlugin) Close() error { - if err := p.s.Close(); err != nil { - return err - } - return nil + return p.s.Close() } diff --git a/pkg/plugin/client/http_proxy.go b/pkg/plugin/client/http_proxy.go index 51a191be..f9e5dae8 100644 --- a/pkg/plugin/client/http_proxy.go +++ b/pkg/plugin/client/http_proxy.go @@ -68,7 +68,7 @@ func (hp *HTTPProxy) Name() string { return PluginHTTPProxy } -func (hp *HTTPProxy) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (hp *HTTPProxy) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) sc, rd := libnet.NewSharedConn(wrapConn) diff --git a/pkg/plugin/client/https2http.go b/pkg/plugin/client/https2http.go index 55edf832..71cc025c 100644 --- a/pkg/plugin/client/https2http.go +++ b/pkg/plugin/client/https2http.go @@ -122,7 +122,7 @@ func (p *HTTPS2HTTPPlugin) genTLSConfig() (*tls.Config, error) { return config, nil } -func (p *HTTPS2HTTPPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (p *HTTPS2HTTPPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) _ = p.l.PutConn(wrapConn) } @@ -132,8 +132,5 @@ func (p *HTTPS2HTTPPlugin) Name() string { } func (p *HTTPS2HTTPPlugin) Close() error { - if err := p.s.Close(); err != nil { - return err - } - return nil + return p.s.Close() } diff --git a/pkg/plugin/client/https2https.go b/pkg/plugin/client/https2https.go index c236c4c8..d925ec24 100644 --- a/pkg/plugin/client/https2https.go +++ b/pkg/plugin/client/https2https.go @@ -127,7 +127,7 @@ func (p *HTTPS2HTTPSPlugin) genTLSConfig() (*tls.Config, error) { return config, nil } -func (p *HTTPS2HTTPSPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (p *HTTPS2HTTPSPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) _ = p.l.PutConn(wrapConn) } @@ -137,8 +137,5 @@ func (p *HTTPS2HTTPSPlugin) Name() string { } func (p *HTTPS2HTTPSPlugin) Close() error { - if err := p.s.Close(); err != nil { - return err - } - return nil + return p.s.Close() } diff --git a/pkg/plugin/client/socks5.go b/pkg/plugin/client/socks5.go index 06a88b64..805f956b 100644 --- a/pkg/plugin/client/socks5.go +++ b/pkg/plugin/client/socks5.go @@ -50,7 +50,7 @@ func NewSocks5Plugin(params map[string]string) (p Plugin, err error) { return } -func (sp *Socks5Plugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (sp *Socks5Plugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { defer conn.Close() wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) _ = sp.Server.ServeConn(wrapConn) diff --git a/pkg/plugin/client/static_file.go b/pkg/plugin/client/static_file.go index 32a888ae..45f731bb 100644 --- a/pkg/plugin/client/static_file.go +++ b/pkg/plugin/client/static_file.go @@ -76,7 +76,7 @@ func NewStaticFilePlugin(params map[string]string) (Plugin, error) { return sp, nil } -func (sp *StaticFilePlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (sp *StaticFilePlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, _ []byte) { wrapConn := utilnet.WrapReadWriteCloserToConn(conn, realConn) _ = sp.l.PutConn(wrapConn) } diff --git a/pkg/plugin/client/unix_domain_socket.go b/pkg/plugin/client/unix_domain_socket.go index 416938b3..03371356 100644 --- a/pkg/plugin/client/unix_domain_socket.go +++ b/pkg/plugin/client/unix_domain_socket.go @@ -51,7 +51,7 @@ func NewUnixDomainSocketPlugin(params map[string]string) (p Plugin, err error) { return } -func (uds *UnixDomainSocketPlugin) Handle(conn io.ReadWriteCloser, realConn net.Conn, extraBufToLocal []byte) { +func (uds *UnixDomainSocketPlugin) Handle(conn io.ReadWriteCloser, _ net.Conn, extraBufToLocal []byte) { localConn, err := net.DialUnix("unix", nil, uds.UnixAddr) if err != nil { return diff --git a/pkg/plugin/server/http.go b/pkg/plugin/server/http.go index b120332d..0f561204 100644 --- a/pkg/plugin/server/http.go +++ b/pkg/plugin/server/http.go @@ -120,8 +120,5 @@ func (p *httpPlugin) do(ctx context.Context, r *Request, res *Response) error { if err != nil { return err } - if err = json.Unmarshal(buf, res); err != nil { - return err - } - return nil + return json.Unmarshal(buf, res) } diff --git a/pkg/transport/tls.go b/pkg/transport/tls.go index 13e241b2..d92b1a82 100644 --- a/pkg/transport/tls.go +++ b/pkg/transport/tls.go @@ -103,9 +103,7 @@ func NewServerTLSConfig(certPath, keyPath, caPath string) (*tls.Config, error) { func NewClientTLSConfig(certPath, keyPath, caPath, serverName string) (*tls.Config, error) { base := &tls.Config{} - if certPath == "" || keyPath == "" { - // client will not generate tls conf by itself - } else { + if certPath != "" && keyPath != "" { cert, err := newCustomTLSKeyPair(certPath, keyPath) if err != nil { return nil, err diff --git a/pkg/util/net/udp.go b/pkg/util/net/udp.go index 599447c3..79ebbb14 100644 --- a/pkg/util/net/udp.go +++ b/pkg/util/net/udp.go @@ -140,15 +140,15 @@ func (c *FakeUDPConn) RemoteAddr() net.Addr { return c.remoteAddr } -func (c *FakeUDPConn) SetDeadline(t time.Time) error { +func (c *FakeUDPConn) SetDeadline(_ time.Time) error { return nil } -func (c *FakeUDPConn) SetReadDeadline(t time.Time) error { +func (c *FakeUDPConn) SetReadDeadline(_ time.Time) error { return nil } -func (c *FakeUDPConn) SetWriteDeadline(t time.Time) error { +func (c *FakeUDPConn) SetWriteDeadline(_ time.Time) error { return nil } @@ -263,4 +263,4 @@ func (l *UDPListener) Addr() net.Addr { type ConnectedUDPConn struct{ *net.UDPConn } // WriteTo redirects all writes to the Write syscall, which is 4 times faster. -func (c *ConnectedUDPConn) WriteTo(b []byte, addr net.Addr) (int, error) { return c.Write(b) } +func (c *ConnectedUDPConn) WriteTo(b []byte, _ net.Addr) (int, error) { return c.Write(b) } diff --git a/pkg/util/tcpmux/httpconnect.go b/pkg/util/tcpmux/httpconnect.go index d6c0ce51..650891f4 100644 --- a/pkg/util/tcpmux/httpconnect.go +++ b/pkg/util/tcpmux/httpconnect.go @@ -66,7 +66,7 @@ func (muxer *HTTPConnectTCPMuxer) readHTTPConnectRequest(rd io.Reader) (host, ht return } -func (muxer *HTTPConnectTCPMuxer) sendConnectResponse(c net.Conn, reqInfo map[string]string) error { +func (muxer *HTTPConnectTCPMuxer) sendConnectResponse(c net.Conn, _ map[string]string) error { if muxer.passthrough { return nil } diff --git a/pkg/util/vhost/https.go b/pkg/util/vhost/https.go index 991c9294..e15c1901 100644 --- a/pkg/util/vhost/https.go +++ b/pkg/util/vhost/https.go @@ -74,10 +74,10 @@ type readOnlyConn struct { } func (conn readOnlyConn) Read(p []byte) (int, error) { return conn.reader.Read(p) } -func (conn readOnlyConn) Write(p []byte) (int, error) { return 0, io.ErrClosedPipe } +func (conn readOnlyConn) Write(_ []byte) (int, error) { return 0, io.ErrClosedPipe } func (conn readOnlyConn) Close() error { return nil } func (conn readOnlyConn) LocalAddr() net.Addr { return nil } func (conn readOnlyConn) RemoteAddr() net.Addr { return nil } -func (conn readOnlyConn) SetDeadline(t time.Time) error { return nil } -func (conn readOnlyConn) SetReadDeadline(t time.Time) error { return nil } -func (conn readOnlyConn) SetWriteDeadline(t time.Time) error { return nil } +func (conn readOnlyConn) SetDeadline(_ time.Time) error { return nil } +func (conn readOnlyConn) SetReadDeadline(_ time.Time) error { return nil } +func (conn readOnlyConn) SetWriteDeadline(_ time.Time) error { return nil } diff --git a/server/control.go b/server/control.go index 637a76b5..9764b7c1 100644 --- a/server/control.go +++ b/server/control.go @@ -434,10 +434,9 @@ func (ctl *Control) manager() { defer ctl.managerShutdown.Done() var heartbeatCh <-chan time.Time - if ctl.serverCfg.TCPMux || ctl.serverCfg.HeartbeatTimeout <= 0 { - // Don't need application heartbeat here. - // yamux will do same thing. - } else { + // Don't need application heartbeat if TCPMux is enabled, + // yamux will do same thing. + if !ctl.serverCfg.TCPMux && ctl.serverCfg.HeartbeatTimeout > 0 { heartbeat := time.NewTicker(time.Second) defer heartbeat.Stop() heartbeatCh = heartbeat.C diff --git a/server/dashboard_api.go b/server/dashboard_api.go index ee758429..198a111a 100644 --- a/server/dashboard_api.go +++ b/server/dashboard_api.go @@ -55,7 +55,7 @@ type serverInfoResp struct { } // /healthz -func (svr *Service) Healthz(w http.ResponseWriter, r *http.Request) { +func (svr *Service) Healthz(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(200) } diff --git a/server/group/http.go b/server/group/http.go index 64091925..26af595e 100644 --- a/server/group/http.go +++ b/server/group/http.go @@ -43,7 +43,7 @@ func (ctl *HTTPGroupController) Register( return g.Register(proxyName, group, groupKey, routeConfig) } -func (ctl *HTTPGroupController) UnRegister(proxyName, group string, routeConfig vhost.RouteConfig) { +func (ctl *HTTPGroupController) UnRegister(proxyName, group string, _ vhost.RouteConfig) { indexKey := group ctl.mu.Lock() defer ctl.mu.Unlock() diff --git a/server/metrics/metrics.go b/server/metrics/metrics.go index faf00d14..5064a238 100644 --- a/server/metrics/metrics.go +++ b/server/metrics/metrics.go @@ -27,11 +27,11 @@ func Register(m ServerMetrics) { type noopServerMetrics struct{} -func (noopServerMetrics) NewClient() {} -func (noopServerMetrics) CloseClient() {} -func (noopServerMetrics) NewProxy(name string, proxyType string) {} -func (noopServerMetrics) CloseProxy(name string, proxyType string) {} -func (noopServerMetrics) OpenConnection(name string, proxyType string) {} -func (noopServerMetrics) CloseConnection(name string, proxyType string) {} -func (noopServerMetrics) AddTrafficIn(name string, proxyType string, trafficBytes int64) {} -func (noopServerMetrics) AddTrafficOut(name string, proxyType string, trafficBytes int64) {} +func (noopServerMetrics) NewClient() {} +func (noopServerMetrics) CloseClient() {} +func (noopServerMetrics) NewProxy(string, string) {} +func (noopServerMetrics) CloseProxy(string, string) {} +func (noopServerMetrics) OpenConnection(string, string) {} +func (noopServerMetrics) CloseConnection(string, string) {} +func (noopServerMetrics) AddTrafficIn(string, string, int64) {} +func (noopServerMetrics) AddTrafficOut(string, string, int64) {} diff --git a/test/e2e/framework/mockservers.go b/test/e2e/framework/mockservers.go index 32f7ac38..2aea36da 100644 --- a/test/e2e/framework/mockservers.go +++ b/test/e2e/framework/mockservers.go @@ -56,10 +56,7 @@ func (m *MockServers) Run() error { if err := m.udsEchoServer.Run(); err != nil { return err } - if err := m.httpSimpleServer.Run(); err != nil { - return err - } - return nil + return m.httpSimpleServer.Run() } func (m *MockServers) Close() {