MCPcopy
hub / github.com/tailscale/tailscale / newMapSession

Function newMapSession

control/controlclient/map.go:120–142  ·  view source on GitHub ↗

newMapSession returns a mostly unconfigured new mapSession. Modify its optional fields on the returned value before use. It must have its Close method called to release resources.

(privateNodeKey key.NodePrivate, nu NetmapUpdater, controlKnobs *controlknobs.Knobs)

Source from the content-addressed store, hash-verified

118//
119// It must have its Close method called to release resources.
120func newMapSession(privateNodeKey key.NodePrivate, nu NetmapUpdater, controlKnobs *controlknobs.Knobs) *mapSession {
121 ms := &mapSession{
122 netmapUpdater: nu,
123 controlKnobs: controlKnobs,
124 privateNodeKey: privateNodeKey,
125 publicNodeKey: privateNodeKey.Public(),
126 lastDNSConfig: new(tailcfg.DNSConfig),
127 lastUserProfile: map[tailcfg.UserID]tailcfg.UserProfileView{},
128
129 // Non-nil no-op defaults, to be optionally overridden by the caller.
130 logf: logger.Discard,
131 vlogf: logger.Discard,
132 cancel: func() {},
133 onDebug: func(context.Context, *tailcfg.Debug) error { return nil },
134 onSelfNodeChanged: func(*netmap.NetworkMap) {},
135 changeQueue: make(chan responseWithSource),
136 changeQueueClosed: false,
137 }
138 ms.sessionAliveCtx, ms.sessionAliveCtxClose = context.WithCancel(context.Background())
139 ms.processQueue.Add(1)
140 go ms.run()
141 return ms
142}
143
144// run starts the mapSession processing a queue of tailcfg.MapResponse one by
145// one until close() is called on the mapSession.

Callers 3

newTestMapSessionFunction · 0.85
sendMapRequestMethod · 0.85

Calls 3

runMethod · 0.95
AddMethod · 0.65
PublicMethod · 0.45

Tested by 1

newTestMapSessionFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…