From 96adf3fbcaaa7bbd21780e41d935b2399bb7e576 Mon Sep 17 00:00:00 2001 From: maskedeken <52683904+maskedeken@users.noreply.github.com> Date: Mon, 11 Jan 2021 17:30:57 +0800 Subject: [PATCH] Trojan: Do not panic when UDP dispatcher failed to write response (#153) --- proxy/trojan/server.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index c11fa230..12bd8758 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -256,7 +256,10 @@ func (s *Server) handleUDPPayload(ctx context.Context, clientReader *PacketReade if udpPayload.UDP == nil { udpPayload.UDP = &packet.Source } - common.Must(clientWriter.WriteMultiBuffer(buf.MultiBuffer{udpPayload})) + + if err := clientWriter.WriteMultiBuffer(buf.MultiBuffer{udpPayload}); err != nil { + newError("failed to write response").Base(err).AtWarning().WriteToLog(session.ExportIDToError(ctx)) + } }) inbound := session.InboundFromContext(ctx)