"bytes"
"encoding/binary"
"io"
+ "log"
"sync"
"sync/atomic"
"time"
CPR int
CPRCycle time.Duration `json:"-"`
EncLess bool
+ MTU int
// Cryptography related
Key *[SSize]byte `json:"-"`
timeout = timeout / TimeoutHeartbeat
}
- bufSize := S20BS + MTU + NonceSize
+ bufSize := S20BS + 2*conf.MTU
if conf.EncLess {
bufSize += EncLessEnlargeSize
noiseEnable = true
CPR: conf.CPR,
CPRCycle: cprCycle,
EncLess: conf.EncLess,
+ MTU: conf.MTU,
Key: key,
NonceCipher: newNonceCipher(key),
// that he is free to receive new packets. Encrypted and authenticated
// packets will be sent to remote Peer side immediately.
func (p *Peer) EthProcess(data []byte) {
+ if len(data) > p.MTU-1 { // 1 is for padding byte
+ log.Println("Padded data packet size", len(data)+1, "is bigger than MTU", p.MTU, p)
+ return
+ }
p.now = time.Now()
p.BusyT.Lock()
}
if p.NoiseEnable && !p.EncLess {
- p.frameT = p.bufT[S20BS : S20BS+MTU-TagSize]
+ p.frameT = p.bufT[S20BS : S20BS+p.MTU-TagSize]
} else if p.EncLess {
- p.frameT = p.bufT[S20BS : S20BS+MTU]
+ p.frameT = p.bufT[S20BS : S20BS+p.MTU]
} else {
p.frameT = p.bufT[S20BS : S20BS+len(data)+1+NonceSize]
}