This commit is contained in:
jdl
2025-08-26 19:12:07 +02:00
parent 1ca55158c2
commit 6382c13d1a
5 changed files with 44 additions and 30 deletions

View File

@@ -36,6 +36,9 @@ var multicastAddr = net.UDPAddrFromAddrPort(netip.AddrPortFrom(
type Globals struct {
LocalConfig // Embed, immutable.
// The number of startups
StartupCount uint16
// Local public address (if available). Immutable.
LocalAddr netip.AddrPort
@@ -63,11 +66,13 @@ type Globals struct {
func NewGlobals(
localConfig LocalConfig,
startupCount startupCount,
localAddr netip.AddrPort,
conn *net.UDPConn,
iface io.ReadWriteCloser,
) (g Globals) {
g.LocalConfig = localConfig
g.StartupCount = startupCount.Count
g.LocalAddr = localAddr
g.LocalAddrValid = localAddr.IsValid()
@@ -87,8 +92,7 @@ func NewGlobals(
g.IFace = iface
// TODO: Initialize w/ startup count.
traceID := uint64(time.Now().Unix()<<30) + 1
traceID := (uint64(g.StartupCount) << 48) + 1
g.NewTraceID = func() uint64 {
return atomic.AddUint64(&traceID, 1)
}