[PR #5199] [CLOSED] pkg/msg: switch UDPPacket.Content to []byte in UDP path #5166

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

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5199
Author: @Copilot
Created: 3/5/2026
Status: Closed

Base: newHead: copilot/review-pull-request-5198


📝 Commits (1)

📄 Description

WHY

UDP forwarding was doing a redundant conversion cycle ([]byte -> base64 string -> JSON -> base64 decode -> []byte) on a hot path.
This update keeps payloads as bytes in memory while preserving the existing JSON wire format compatibility.

  • Data model change

    • msg.UDPPacket.Content is now []byte (was string).
  • Protocol path simplification

    • Removed explicit base64.StdEncoding.EncodeToString/DecodeString from pkg/proto/udp.
    • NewUDPPacket now copies input bytes into packet content directly.
  • Behavioral compatibility

    • JSON encoding remains compatible because Go marshals []byte as base64 automatically.
  • Logging hygiene

    • Replaced payload content logs with len(Content) in UDP client/server paths to avoid logging binary data.
type UDPPacket struct {
    Content    []byte       `json:"c,omitempty"`
    LocalAddr  *net.UDPAddr `json:"l,omitempty"`
    RemoteAddr *net.UDPAddr `json:"r,omitempty"`
}

func GetContent(m *msg.UDPPacket) ([]byte, error) {
    return m.Content, nil
}
Original prompt

Pull request: https://github.com/fatedier/frp/pull/5198/files

Review一下这个pr


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


🔄 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/5199 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 3/5/2026 **Status:** ❌ Closed **Base:** `new` ← **Head:** `copilot/review-pull-request-5198` --- ### 📝 Commits (1) - [`7993225`](https://github.com/fatedier/frp/commit/7993225be1d629ff7a719ba1035beb7a47f28d1c) Initial plan ### 📄 Description ### WHY UDP forwarding was doing a redundant conversion cycle (`[]byte -> base64 string -> JSON -> base64 decode -> []byte`) on a hot path. This update keeps payloads as bytes in memory while preserving the existing JSON wire format compatibility. - **Data model change** - `msg.UDPPacket.Content` is now `[]byte` (was `string`). - **Protocol path simplification** - Removed explicit `base64.StdEncoding.EncodeToString/DecodeString` from `pkg/proto/udp`. - `NewUDPPacket` now copies input bytes into packet content directly. - **Behavioral compatibility** - JSON encoding remains compatible because Go marshals `[]byte` as base64 automatically. - **Logging hygiene** - Replaced payload content logs with `len(Content)` in UDP client/server paths to avoid logging binary data. ```go type UDPPacket struct { Content []byte `json:"c,omitempty"` LocalAddr *net.UDPAddr `json:"l,omitempty"` RemoteAddr *net.UDPAddr `json:"r,omitempty"` } func GetContent(m *msg.UDPPacket) ([]byte, error) { return m.Content, nil } ``` <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Pull request: https://github.com/fatedier/frp/pull/5198/files > > Review一下这个pr </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/fatedier/frp/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --- <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:58 -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#5166
No description provided.