add buffer size option for udp connection

This commit is contained in:
ginuerzh
2025-07-30 21:40:53 +08:00
parent b64e5901b6
commit a5309eee97
26 changed files with 218 additions and 219 deletions
+1
View File
@@ -205,6 +205,7 @@ func (h *relayHandler) bindUDP(ctx context.Context, conn net.Conn, network, addr
r := udp.NewRelay(relay_util.UDPTunServerConn(conn), pc).
WithBypass(h.options.Bypass).
WithBufferSize(h.md.udpBufferSize).
WithLogger(log)
t := time.Now()
+7 -5
View File
@@ -14,11 +14,12 @@ import (
)
type metadata struct {
readTimeout time.Duration
enableBind bool
noDelay bool
hash string
muxCfg *mux.Config
readTimeout time.Duration
udpBufferSize int
enableBind bool
noDelay bool
hash string
muxCfg *mux.Config
observerPeriod time.Duration
observerResetTraffic bool
@@ -43,6 +44,7 @@ func (h *relayHandler) parseMetadata(md mdata.Metadata) (err error) {
h.md.readTimeout = 15 * time.Second
}
h.md.udpBufferSize = mdutil.GetInt(md, "udp.bufferSize", "udpBufferSize")
h.md.enableBind = mdutil.GetBool(md, "bind")
h.md.noDelay = mdutil.GetBool(md, "nodelay")
h.md.hash = mdutil.GetString(md, "hash")