mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add DERPForcedWebsocket to nodeUpdater (#11567)
Add support for DERPForcedWebsocket to nodeUpdater
This commit is contained in:
+20
-6
@@ -86,12 +86,13 @@ func newNodeUpdater(
|
||||
id tailcfg.NodeID, np key.NodePublic, dp key.DiscoPublic,
|
||||
) *nodeUpdater {
|
||||
u := &nodeUpdater{
|
||||
phased: phased{Cond: *(sync.NewCond(&sync.Mutex{}))},
|
||||
logger: logger,
|
||||
id: id,
|
||||
key: np,
|
||||
discoKey: dp,
|
||||
callback: callback,
|
||||
phased: phased{Cond: *(sync.NewCond(&sync.Mutex{}))},
|
||||
logger: logger,
|
||||
id: id,
|
||||
key: np,
|
||||
discoKey: dp,
|
||||
derpForcedWebsockets: make(map[int]string),
|
||||
callback: callback,
|
||||
}
|
||||
go u.updateLoop()
|
||||
return u
|
||||
@@ -132,3 +133,16 @@ func (u *nodeUpdater) setNetInfo(ni *tailcfg.NetInfo) {
|
||||
u.Broadcast()
|
||||
}
|
||||
}
|
||||
|
||||
// setDERPForcedWebsocket handles callbacks from the magicConn about DERP regions that are forced to
|
||||
// use websockets (instead of Upgrade: derp). This information is for debugging only.
|
||||
func (u *nodeUpdater) setDERPForcedWebsocket(region int, reason string) {
|
||||
u.L.Lock()
|
||||
defer u.L.Unlock()
|
||||
dirty := u.derpForcedWebsockets[region] != reason
|
||||
u.derpForcedWebsockets[region] = reason
|
||||
if dirty {
|
||||
u.dirty = true
|
||||
u.Broadcast()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user