From af9281dc76dfb99ab0b228968450fa93a40d22da Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 30 Sep 2022 14:00:22 +0800 Subject: [PATCH] Fix udpmux not work on AWS/ECS ECS network might not set destination address of udp packet to local address, so we can't only rely on it to dispatch packet. --- udp_mux.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/udp_mux.go b/udp_mux.go index a477ead..6e05773 100644 --- a/udp_mux.go +++ b/udp_mux.go @@ -365,13 +365,12 @@ func (m *UDPMuxDefault) connWorker() { //nolint:gocognit var destinationConn *udpMuxedConn m.addressMapMu.Lock() if conns, ok := m.addressMap[addr.String()]; ok { - if localHost.IsUnspecified() { + destinationConn, ok = conns[ipAddr(localHost.String())] + if !ok { for _, c := range conns { destinationConn = c break } - } else { - destinationConn = conns[ipAddr(localHost.String())] } } m.addressMapMu.Unlock()