[PR #5198] [MERGED] pkg/msg: change UDPPacket.Content from string to []byte to avoid redundant base64 encode/decode #5164

Closed
opened 2026-05-05 14:55:57 -06:00 by gitea-mirror · 0 comments
Owner

📋 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: devHead: new


📝 Commits (1)

  • 17b27d8 pkg/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

  • Change UDPPacket.Content field type from string to []byte, removing the manual base64.StdEncoding.EncodeToString/DecodeString calls in the UDP proxy data path.
  • Go's encoding/json automatically handles []byte as base64, so the wire format is unchanged — fully compatible with older versions.
  • Update trace logs from printing raw content to printing 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 []byte natively) → 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 successfully
  • make test — all unit tests pass (including pkg/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.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/5198 **Author:** [@fatedier](https://github.com/fatedier) **Created:** 3/5/2026 **Status:** ✅ Merged **Merged:** 3/5/2026 **Merged by:** [@fatedier](https://github.com/fatedier) **Base:** `dev` ← **Head:** `new` --- ### 📝 Commits (1) - [`17b27d8`](https://github.com/fatedier/frp/commit/17b27d8d96c0e1e655b1f6b86c84c872557d380d) pkg/msg: change UDPPacket.Content from string to []byte to avoid redundant base64 encode/decode ### 📊 Changes **5 files changed** (+13 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 Description ## Summary - Change `UDPPacket.Content` field type from `string` to `[]byte`, removing the manual `base64.StdEncoding.EncodeToString/DecodeString` calls in the UDP proxy data path. - Go's `encoding/json` automatically handles `[]byte` as base64, so the wire format is unchanged — fully compatible with older versions. - Update trace logs from printing raw content to printing `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 `[]byte` natively) → 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 - [x] `make build` — compiles successfully - [x] `make test` — all unit tests pass (including `pkg/proto/udp.TestUdpPacket`) - [x] `make e2e` — 224 passed, 0 failed, 2 skipped --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 14:55:57 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5164
No description provided.