From 6f93ef77369ae179abdb4dbbbef6a8c88c8629aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 1 Jun 2022 11:11:53 +0800 Subject: [PATCH] Remove useless error log --- app/proxyman/inbound/worker.go | 4 +--- app/proxyman/outbound/handler.go | 11 ++++++++++- transport/internet/udp/dispatcher.go | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 9c033534..5b227c06 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -108,9 +108,7 @@ func (w *tcpWorker) callback(conn stat.Connection) { newError("connection ends").Base(err).WriteToLog(session.ExportIDToError(ctx)) } cancel() - if err := conn.Close(); err != nil { - newError("failed to close connection").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } + conn.Close() } func (w *tcpWorker) Proxy() proxy.Inbound { diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 3f9bc848..49751909 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -2,6 +2,9 @@ package outbound import ( "context" + "errors" + "io" + "os" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" @@ -141,7 +144,13 @@ func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { common.Interrupt(link.Writer) } } else { - if err := h.proxy.Process(ctx, link, h); err != nil { + err := h.proxy.Process(ctx, link, h) + if err != nil { + if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) || errors.Is(err, context.Canceled) { + err = nil + } + } + if err != nil { // Ensure outbound ray is properly closed. err := newError("failed to process outbound traffic").Base(err) session.SubmitOutboundErrorToOriginator(ctx, err) diff --git a/transport/internet/udp/dispatcher.go b/transport/internet/udp/dispatcher.go index 6243cb57..dda26e6e 100644 --- a/transport/internet/udp/dispatcher.go +++ b/transport/internet/udp/dispatcher.go @@ -2,6 +2,7 @@ package udp import ( "context" + "errors" "io" "sync" "time" @@ -107,7 +108,9 @@ func handleInput(ctx context.Context, conn *connEntry, dest net.Destination, cal mb, err := input.ReadMultiBuffer() if err != nil { - newError("failed to handle UDP input").Base(err).WriteToLog(session.ExportIDToError(ctx)) + if !errors.Is(err, io.EOF) { + newError("failed to handle UDP input").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } return } timer.Update()