refactor-for-testability (#3)

Co-authored-by: jdl <jdl@desktop>
Co-authored-by: jdl <jdl@crumpington.com>
Reviewed-on: #3
This commit is contained in:
2025-03-01 20:02:27 +00:00
parent a0b5058544
commit 1d3cc1f959
68 changed files with 3908 additions and 1547 deletions

37
peer/globals.go Normal file
View File

@@ -0,0 +1,37 @@
package peer
import (
"net"
"net/netip"
"time"
)
const (
version = 1
bufferSize = 1536
if_mtu = 1200
if_queue_len = 2048
controlCipherOverhead = 16
dataCipherOverhead = 16
signOverhead = 64
pingInterval = 8 * time.Second
timeoutInterval = 30 * time.Second
broadcastInterval = 16 * time.Second
broadcastErrorTimeoutInterval = 8 * time.Second
)
var multicastAddr = net.UDPAddrFromAddrPort(netip.AddrPortFrom(
netip.AddrFrom4([4]byte{224, 0, 0, 157}),
4560))
func newBuf() []byte {
return make([]byte, bufferSize)
}
type marshaller interface {
Marshal([]byte) []byte
}