mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-21 02:40:24 +08:00
fix(p2p): udplite checksum range
This commit is contained in:
@@ -96,7 +96,7 @@ func (l *Link) write(p *head.Packet, teatype uint8, additional uint16, datasz ui
|
|||||||
}
|
}
|
||||||
if l.doublepacket {
|
if l.doublepacket {
|
||||||
cpp := p.Copy()
|
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()
|
defer cpp.Put()
|
||||||
_, _ = l.writeonce(cpp, teatype, additional, datasz, offset, istransfer, hasmore)
|
_, _ = l.writeonce(cpp, teatype, additional, datasz, offset, istransfer, hasmore)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ func listenUDPLite(network string, laddr *net.UDPAddr) (*net.UDPConn, error) {
|
|||||||
}
|
}
|
||||||
var errsys error
|
var errsys error
|
||||||
err = rc.Control(func(fd uintptr) {
|
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 {
|
if errsys != nil {
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user