mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-30 14:49:22 +07:00
optimize: reduce UDP buffer
This commit is contained in:
@ -649,7 +649,7 @@ func (c *ControlPlane) Serve(readyChan chan<- bool, listener *Listener) (err err
|
||||
return
|
||||
default:
|
||||
}
|
||||
var buf [65535]byte
|
||||
var buf [EthernetMtu]byte
|
||||
var oob [120]byte // Size for original dest
|
||||
n, oobn, _, src, err := udpConn.ReadMsgUDPAddrPort(buf[:], oob[:])
|
||||
if err != nil {
|
||||
|
@ -8,14 +8,18 @@ package control
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/daeuniverse/dae/component/outbound/dialer"
|
||||
"github.com/mzz2017/softwind/netproxy"
|
||||
"github.com/mzz2017/softwind/pool"
|
||||
"github.com/daeuniverse/dae/component/outbound/dialer"
|
||||
"net/netip"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
EthernetMtu = 1500
|
||||
)
|
||||
|
||||
type UdpHandler func(data []byte, from netip.AddrPort) error
|
||||
|
||||
type UdpEndpoint struct {
|
||||
@ -30,7 +34,7 @@ type UdpEndpoint struct {
|
||||
}
|
||||
|
||||
func (ue *UdpEndpoint) start() {
|
||||
buf := pool.Get(0xffff)
|
||||
buf := pool.Get(EthernetMtu)
|
||||
defer pool.Put(buf)
|
||||
for {
|
||||
n, from, err := ue.conn.ReadFrom(buf[:])
|
||||
|
Reference in New Issue
Block a user