Minor fixes

This commit is contained in:
世界
2022-07-20 09:41:44 +08:00
parent 45643fbed1
commit 6327c4b40c
16 changed files with 79 additions and 84 deletions

View File

@@ -324,7 +324,7 @@ func (a *myInboundAdapter) NewError(ctx context.Context, err error) {
func NewError(logger log.ContextLogger, ctx context.Context, err error) {
common.Close(err)
if E.IsClosed(err) || E.IsCanceled(err) {
if E.IsClosedOrCanceled(err) {
logger.DebugContext(ctx, "connection closed")
return
}

View File

@@ -116,7 +116,11 @@ func (t *Tun) NewConnection(ctx context.Context, conn net.Conn, upstreamMetadata
}
t.logger.InfoContext(ctx, "inbound connection from ", metadata.Source)
t.logger.InfoContext(ctx, "inbound connection to ", metadata.Destination)
return t.router.RouteConnection(ctx, conn, metadata)
err := t.router.RouteConnection(ctx, conn, metadata)
if err != nil {
t.NewError(ctx, err)
}
return err
}
func (t *Tun) NewPacketConnection(ctx context.Context, conn N.PacketConn, upstreamMetadata M.Metadata) error {
@@ -137,7 +141,11 @@ func (t *Tun) NewPacketConnection(ctx context.Context, conn N.PacketConn, upstre
}
t.logger.InfoContext(ctx, "inbound packet connection from ", metadata.Source)
t.logger.InfoContext(ctx, "inbound packet connection to ", metadata.Destination)
return t.router.RoutePacketConnection(ctx, conn, metadata)
err := t.router.RoutePacketConnection(ctx, conn, metadata)
if err != nil {
t.NewError(ctx, err)
}
return err
}
func (t *Tun) NewError(ctx context.Context, err error) {