1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-18 08:50:25 +08:00

fix(p2p): udplite checksum range

This commit is contained in:
源文雨
2024-07-31 16:06:22 +08:00
parent aaafcdfa6c
commit a4275beced
2 changed files with 3 additions and 3 deletions

View File

@@ -96,7 +96,7 @@ func (l *Link) write(p *head.Packet, teatype uint8, additional uint16, datasz ui
}
if l.doublepacket {
cpp := p.Copy()
_ = time.AfterFunc(time.Millisecond*(100+time.Duration(rand.Intn(50))), func() {
_ = time.AfterFunc(time.Millisecond*(10+time.Duration(rand.Intn(40))), func() {
defer cpp.Put()
_, _ = l.writeonce(cpp, teatype, additional, datasz, offset, istransfer, hasmore)
})

View File

@@ -75,11 +75,11 @@ func listenUDPLite(network string, laddr *net.UDPAddr) (*net.UDPConn, error) {
}
var errsys error
err = rc.Control(func(fd uintptr) {
errsys = syscall.SetsockoptInt(int(fd), SOL_UDPLITE, UDPLITE_SEND_CSCOV, head.PacketHeadLen)
errsys = syscall.SetsockoptInt(int(fd), SOL_UDPLITE, UDPLITE_SEND_CSCOV, head.PacketHeadLen+8) // for xor rand
if errsys != nil {
return
}
errsys = syscall.SetsockoptInt(int(fd), SOL_UDPLITE, UDPLITE_RECV_CSCOV, head.PacketHeadLen)
errsys = syscall.SetsockoptInt(int(fd), SOL_UDPLITE, UDPLITE_RECV_CSCOV, head.PacketHeadLen+8) // for xor rand
})
if err != nil {
_ = conn.Close()