From 6253e2e24c76e0abdc572b3a0d3b4dd50f9a992c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 22 Aug 2022 16:33:33 +0800 Subject: [PATCH] Fix clash server early close --- experimental/clashapi/server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/experimental/clashapi/server.go b/experimental/clashapi/server.go index f6255a79..b21131ef 100644 --- a/experimental/clashapi/server.go +++ b/experimental/clashapi/server.go @@ -25,6 +25,7 @@ import ( "github.com/go-chi/cors" "github.com/go-chi/render" "github.com/gorilla/websocket" + "github.com/sagernet/sing/common" ) var _ adapter.ClashServer = (*Server)(nil) @@ -103,10 +104,11 @@ func (s *Server) Start() error { } func (s *Server) Close() error { - s.httpServer.Close() - s.tcpListener.Close() - s.trafficManager.Close() - return nil + return common.Close( + common.PtrOrNil(s.httpServer), + s.tcpListener, + s.trafficManager, + ) } func (s *Server) RoutedConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext, matchedRule adapter.Rule) (net.Conn, adapter.Tracker) {