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)
| 118 | // |
| 119 | // It must have its Close method called to release resources. |
| 120 | func 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. |
searching dependent graphs…