Update const.go

refactor: replace var with const for timeouts, fix RaknetMagic allocation
This commit is contained in:
cubexteam
2026-03-04 18:05:56 +03:00
committed by GitHub
parent 65c83e685d
commit d2ccb5fde2

View File

@@ -2,17 +2,20 @@ package raknet
import "time" import "time"
var raknetMagic = [16]byte{0x00, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfd, 0x12, 0x34, 0x56, 0x78}
func RaknetMagic() []byte { func RaknetMagic() []byte {
return []byte{0x00, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, 0xfd, 0xfd, 0xfd, 0x12, 0x34, 0x56, 0x78} b := raknetMagic
return b[:]
} }
const ( const (
MaxMTU = 1400 MaxMTU = 1400
MinMTU = 400 MinMTU = 400
MaxChannels = 32 MaxChannels = 32
) )
var ( const (
SessionTimeout = 10 * time.Second SessionTimeout = 10 * time.Second
PingSendInterval = 2500 * time.Millisecond PingSendInterval = 2500 * time.Millisecond
DetectionSendInterval = 5 * time.Second DetectionSendInterval = 5 * time.Second