tungo: additional metadata options

This commit is contained in:
ginuerzh
2025-07-30 10:07:18 +08:00
parent 3bbc10796c
commit 87e454a6f1
9 changed files with 115 additions and 12 deletions
+14
View File
@@ -20,6 +20,7 @@ import (
"github.com/go-gost/x/registry"
"github.com/xjasonlyu/tun2socks/v2/core"
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
"github.com/xjasonlyu/tun2socks/v2/core/option"
"gvisor.dev/gvisor/pkg/tcpip/stack"
)
@@ -129,9 +130,22 @@ func (h *tungoHandler) Handle(ctx context.Context, conn net.Conn, opts ...handle
th.ProcessAsync()
defer th.Close()
var cOpts []option.Option
if h.md.tcpModerateReceiveBuffer {
cOpts = append(cOpts, option.WithTCPModerateReceiveBuffer(h.md.tcpModerateReceiveBuffer))
}
if h.md.tcpSendBufferSize > 0 {
cOpts = append(cOpts, option.WithTCPSendBufferSize(h.md.tcpSendBufferSize))
}
if h.md.tcpReceiveBufferSize > 0 {
cOpts = append(cOpts, option.WithTCPReceiveBufferSize(h.md.tcpReceiveBufferSize))
}
stack, err := core.CreateStack(&core.Config{
LinkEndpoint: newEndpoint(conn, config.MTU, log),
TransportHandler: th,
MulticastGroups: h.md.multicastGroups,
Options: cOpts,
})
if err != nil {
return err