use fixed buffer size

This commit is contained in:
ginuerzh
2025-02-18 17:38:27 +08:00
parent d610e2dc01
commit e0915affda
14 changed files with 67 additions and 126 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ func (c *ssuConnector) Connect(ctx context.Context, conn net.Conn, network, addr
}
// standard UDP relay
return ss.UDPClientConn(pc, conn.RemoteAddr(), taddr, c.md.bufferSize), nil
return ss.UDPClientConn(pc, conn.RemoteAddr(), taddr), nil
}
if c.cipher != nil {
-9
View File
@@ -1,7 +1,6 @@
package ss
import (
"math"
"time"
mdata "github.com/go-gost/core/metadata"
@@ -11,24 +10,16 @@ import (
type metadata struct {
key string
connectTimeout time.Duration
bufferSize int
}
func (c *ssuConnector) parseMetadata(md mdata.Metadata) (err error) {
const (
key = "key"
connectTimeout = "timeout"
bufferSize = "bufferSize" // udp buffer size
)
c.md.key = mdutil.GetString(md, key)
c.md.connectTimeout = mdutil.GetDuration(md, connectTimeout)
if bs := mdutil.GetInt(md, bufferSize); bs > 0 {
c.md.bufferSize = int(math.Min(math.Max(float64(bs), 512), 64*1024))
} else {
c.md.bufferSize = 4096
}
return
}