diff --git a/common/tls/client.go b/common/tls/client.go index 5e05c990..868e039d 100644 --- a/common/tls/client.go +++ b/common/tls/client.go @@ -2,6 +2,8 @@ package tls import ( "context" + "crypto/tls" + "errors" "net" "os" @@ -41,6 +43,12 @@ func ClientHandshake(ctx context.Context, conn net.Conn, config Config) (Conn, e ctx, cancel := context.WithTimeout(ctx, C.TCPTimeout) defer cancel() tlsConn, err := aTLS.ClientHandshake(ctx, conn, config) + var echErr *tls.ECHRejectionError + if errors.As(err, &echErr) && len(echErr.RetryConfigList) > 0 { + if echConfig, isECH := config.(ECHCapableConfig); isECH { + echConfig.SetECHConfigList(echErr.RetryConfigList) + } + } if err != nil { return nil, err } diff --git a/service/ssmapi/api.go b/service/ssmapi/api.go index b9b753a4..14c3ac32 100644 --- a/service/ssmapi/api.go +++ b/service/ssmapi/api.go @@ -2,6 +2,7 @@ package ssmapi import ( "net/http" + "strconv" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing/common/logger" @@ -156,7 +157,7 @@ func (s *APIServer) deleteUser(writer http.ResponseWriter, request *http.Request } func (s *APIServer) getStats(writer http.ResponseWriter, request *http.Request) { - requireClear := chi.URLParam(request, "clear") == "true" + requireClear, _ := strconv.ParseBool(chi.URLParam(request, "clear")) users := s.user.List() s.traffic.ReadUsers(users)