diff --git a/adapter/outbound/snell.go b/adapter/outbound/snell.go index 92343055..7b272d5d 100644 --- a/adapter/outbound/snell.go +++ b/adapter/outbound/snell.go @@ -99,7 +99,13 @@ func (s *Snell) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o tcpKeepAlive(c) c = streamConn(c, streamOption{s.psk, s.version, s.addr, s.obfsOption}) - return s.ListenPacketOnStreamConn(c, metadata) + err = snell.WriteUDPHeader(c, s.version) + if err != nil { + return nil, err + } + + pc := snell.PacketConn(c) + return newPacketConn(pc, s), nil } // ListenPacketOnStreamConn implements C.ProxyAdapter diff --git a/adapter/outbound/trojan.go b/adapter/outbound/trojan.go index 46586673..31811c51 100644 --- a/adapter/outbound/trojan.go +++ b/adapter/outbound/trojan.go @@ -161,7 +161,13 @@ func (t *Trojan) ListenPacketContext(ctx context.Context, metadata *C.Metadata, } } - return t.ListenPacketOnStreamConn(c, metadata) + err = t.instance.WriteHeader(c, trojan.CommandUDP, serializesSocksAddr(metadata)) + if err != nil { + return nil, err + } + + pc := t.instance.PacketConn(c) + return newPacketConn(pc, t), err } // ListenPacketOnStreamConn implements C.ProxyAdapter