fix dtls connection

This commit is contained in:
ginuerzh
2022-12-23 18:56:58 +08:00
parent fb29d5c80e
commit bb106e2d89
11 changed files with 249 additions and 58 deletions

View File

@ -12,11 +12,16 @@ const (
)
type tunDevice struct {
dev tun.Device
dev tun.Device
readBufferSize int
}
func (d *tunDevice) Read(p []byte) (n int, err error) {
b := bufpool.Get(tunOffsetBytes + 65535)
rbuf := d.readBufferSize
if rbuf <= tunOffsetBytes {
rbuf = defaultReadBufferSize
}
b := bufpool.Get(rbuf)
defer bufpool.Put(b)
n, err = d.dev.Read(*b, tunOffsetBytes)
@ -51,7 +56,8 @@ func (l *tunListener) createTunDevice() (dev io.ReadWriteCloser, name string, er
}
dev = &tunDevice{
dev: ifce,
dev: ifce,
readBufferSize: l.md.readBufferSize,
}
name, err = ifce.Name()