Fix close message

This commit is contained in:
世界 2023-09-22 12:05:27 +08:00
parent 5138a6acc8
commit 541e66a4a1
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 2 additions and 3 deletions

View file

@ -7,7 +7,6 @@ import (
"net/http"
"os"
"runtime"
"strings"
"sync"
"github.com/sagernet/quic-go"
@ -127,7 +126,7 @@ func (s *Service[U]) loopConnections(listener qtls.Listener) {
for {
connection, err := listener.Accept(s.ctx)
if err != nil {
if strings.Contains(err.Error(), "server closed") {
if E.IsClosedOrCanceled(err) {
s.logger.Debug(E.Cause(err, "listener closed"))
} else {
s.logger.Error(E.Cause(err, "listener closed"))

View file

@ -113,7 +113,7 @@ func (s *Service[U]) Start(conn net.PacketConn) error {
for {
connection, hErr := listener.Accept(s.ctx)
if hErr != nil {
if strings.Contains(hErr.Error(), "server closed") {
if E.IsClosedOrCanceled(hErr) {
s.logger.Debug(E.Cause(hErr, "listener closed"))
} else {
s.logger.Error(E.Cause(hErr, "listener closed"))