mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[PR #5198] [MERGED] pkg/msg: change UDPPacket.Content from string to []byte to avoid redundant base64 encode/decode #5164
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#5164
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fatedier/frp/pull/5198
Author: @fatedier
Created: 3/5/2026
Status: ✅ Merged
Merged: 3/5/2026
Merged by: @fatedier
Base:
dev← Head:new📝 Commits (1)
17b27d8pkg/msg: change UDPPacket.Content from string to []byte to avoid redundant base64 encode/decode📊 Changes
5 files changed (+13 additions, -13 deletions)
View changed files
📝
client/proxy/udp.go(+2 -2)📝
client/visitor/sudp.go(+3 -3)📝
pkg/msg/msg.go(+1 -1)📝
pkg/proto/udp/udp.go(+5 -5)📝
server/proxy/udp.go(+2 -2)📄 Description
Summary
UDPPacket.Contentfield type fromstringto[]byte, removing the manualbase64.StdEncoding.EncodeToString/DecodeStringcalls in the UDP proxy data path.encoding/jsonautomatically handles[]byteas base64, so the wire format is unchanged — fully compatible with older versions.len(Content)to avoid logging binary data.Motivation
Every UDP packet previously went through a redundant encoding cycle: manual base64 encode → JSON marshal (which would handle
[]bytenatively) → JSON unmarshal → manual base64 decode. This change eliminates the intermediate string allocation and explicit base64 encode/decode, reducing GC pressure on the hot path.Test plan
make build— compiles successfullymake test— all unit tests pass (includingpkg/proto/udp.TestUdpPacket)make e2e— 224 passed, 0 failed, 2 skipped🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.