mirror of
https://github.com/slackhq/nebula.git
synced 2025-11-24 01:14:25 +01:00
cursed gso
This commit is contained in:
@@ -3,27 +3,36 @@ package packet
|
||||
import (
|
||||
"net/netip"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const Size = 9001
|
||||
const Size = 0xffff
|
||||
|
||||
type Packet struct {
|
||||
Payload []byte
|
||||
Control []byte
|
||||
SegSize int
|
||||
Addr netip.AddrPort
|
||||
}
|
||||
|
||||
func New() *Packet {
|
||||
return &Packet{Payload: make([]byte, Size)}
|
||||
return &Packet{
|
||||
Payload: make([]byte, Size),
|
||||
Control: make([]byte, unix.CmsgSpace(2)),
|
||||
}
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
func NewPool() *Pool {
|
||||
return &Pool{
|
||||
pool: sync.Pool{New: func() any { return New() }},
|
||||
}
|
||||
var bigPool = &Pool{
|
||||
pool: sync.Pool{New: func() any { return New() }},
|
||||
}
|
||||
|
||||
func GetPool() *Pool {
|
||||
return bigPool
|
||||
}
|
||||
|
||||
func (p *Pool) Get() *Packet {
|
||||
|
||||
Reference in New Issue
Block a user