From 3370bd53f520a5b86dd04ac16b6553c28269fb79 Mon Sep 17 00:00:00 2001 From: fatedier Date: Fri, 9 Jan 2026 11:33:00 +0800 Subject: [PATCH] udp: fix proxy protocol header sent on every packet instead of first packet only (#5119) --- Release.md | 4 ++++ pkg/proto/udp/udp.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Release.md b/Release.md index a0ce59b5..6cba5645 100644 --- a/Release.md +++ b/Release.md @@ -2,3 +2,7 @@ * frpc now supports a `clientID` option to uniquely identify client instances. The server dashboard displays all connected clients with their online/offline status, connection history, and metadata, making it easier to monitor and manage multiple frpc deployments. * Redesigned the frps web dashboard with a modern UI, dark mode support, and improved navigation. + +## Fixes + +* Fixed UDP proxy protocol sending header on every packet instead of only the first packet of each session. diff --git a/pkg/proto/udp/udp.go b/pkg/proto/udp/udp.go index f97b3b43..0ad8aae1 100644 --- a/pkg/proto/udp/udp.go +++ b/pkg/proto/udp/udp.go @@ -124,8 +124,8 @@ func Forwarder(dstAddr *net.UDPAddr, readCh <-chan *msg.UDPPacket, sendCh chan<- } mu.Unlock() - // Add proxy protocol header if configured - if proxyProtocolVersion != "" && udpMsg.RemoteAddr != nil { + // Add proxy protocol header if configured (only for the first packet of a new connection) + if !ok && proxyProtocolVersion != "" && udpMsg.RemoteAddr != nil { ppBuf, err := netpkg.BuildProxyProtocolHeader(udpMsg.RemoteAddr, dstAddr, proxyProtocolVersion) if err == nil { // Prepend proxy protocol header to the UDP payload