summaryrefslogtreecommitdiffhomepage
path: root/control
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-09-16 16:50:31 -0700
committerJosh Bleecher Snyder <josh@tailscale.com>2021-09-17 16:47:00 -0700
commitc7b75465871eb911df4e1ff91a57b9c91c279111 (patch)
tree0b7975a92a5f53ad27ee78525ae4e5660d34c7fe /control
parentb14db5d943b84be3c9f3a909c18c9af4012523dd (diff)
downloadtailscale-josh/immutable-views.tar.xz
tailscale-josh/immutable-views.zip
Next up: view support for maps, etc.
Diffstat (limited to 'control')
-rw-r--r--control/controlclient/auto.go20
-rw-r--r--control/controlclient/direct.go6
-rw-r--r--control/controlclient/map.go2
-rw-r--r--control/controlclient/status.go4
4 files changed, 16 insertions, 16 deletions
diff --git a/control/controlclient/auto.go b/control/controlclient/auto.go
index ad117e08a..449698eda 100644
--- a/control/controlclient/auto.go
+++ b/control/controlclient/auto.go
@@ -285,7 +285,7 @@ func (c *Auto) authRoutine() {
// don't send status updates for context errors,
// since context cancelation is always on purpose.
if ctx.Err() == nil {
- c.sendStatus("authRoutine-report", err, "", nil)
+ c.sendStatus("authRoutine-report", err, "", netmap.NetworkMapView{})
}
}
@@ -313,7 +313,7 @@ func (c *Auto) authRoutine() {
c.synced = false
c.mu.Unlock()
- c.sendStatus("authRoutine-wantout", nil, "", nil)
+ c.sendStatus("authRoutine-wantout", nil, "", netmap.NetworkMapView{})
bo.BackOff(ctx, nil)
} else { // ie. goal.wantLoggedIn
c.mu.Lock()
@@ -355,7 +355,7 @@ func (c *Auto) authRoutine() {
c.synced = false
c.mu.Unlock()
- c.sendStatus("authRoutine-url", err, url, nil)
+ c.sendStatus("authRoutine-url", err, url, netmap.NetworkMapView{})
bo.BackOff(ctx, err)
continue
}
@@ -367,7 +367,7 @@ func (c *Auto) authRoutine() {
c.state = StateAuthenticated
c.mu.Unlock()
- c.sendStatus("authRoutine-success", nil, "", nil)
+ c.sendStatus("authRoutine-success", nil, "", netmap.NetworkMapView{})
c.cancelMapSafely()
bo.BackOff(ctx, nil)
}
@@ -435,7 +435,7 @@ func (c *Auto) mapRoutine() {
// don't send status updates for context errors,
// since context cancelation is always on purpose.
if ctx.Err() == nil {
- c.sendStatus("mapRoutine1", err, "", nil)
+ c.sendStatus("mapRoutine1", err, "", netmap.NetworkMapView{})
}
}
@@ -461,7 +461,7 @@ func (c *Auto) mapRoutine() {
c.mu.Unlock()
health.SetInPollNetMap(false)
- err := c.direct.PollNetMap(ctx, -1, func(nm *netmap.NetworkMap) {
+ err := c.direct.PollNetMap(ctx, -1, func(nm netmap.NetworkMapView) {
health.SetInPollNetMap(true)
c.mu.Lock()
@@ -482,7 +482,7 @@ func (c *Auto) mapRoutine() {
if c.loggedIn {
c.state = StateSynchronized
}
- exp := nm.Expiry
+ exp := nm.Expiry()
c.expiry = &exp
stillAuthed := c.loggedIn
state := c.state
@@ -563,7 +563,7 @@ func (c *Auto) SetNetInfo(ni *tailcfg.NetInfo) {
c.sendNewMapRequest()
}
-func (c *Auto) sendStatus(who string, err error, url string, nm *netmap.NetworkMap) {
+func (c *Auto) sendStatus(who string, err error, url string, nm netmap.NetworkMapView) {
c.mu.Lock()
state := c.state
loggedIn := c.loggedIn
@@ -583,13 +583,13 @@ func (c *Auto) sendStatus(who string, err error, url string, nm *netmap.NetworkM
if state == StateNotAuthenticated {
logoutFin = new(empty.Message)
}
- if nm != nil && loggedIn && synced {
+ if nm.Valid() && loggedIn && synced {
pp := c.direct.GetPersist()
p = &pp
} else {
// don't send netmap status, as it's misleading when we're
// not logged in.
- nm = nil
+ nm = netmap.NetworkMapView{}
}
new := Status{
LoginFinished: loginFin,
diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go
index 0a7105cb3..4cf47a2ad 100644
--- a/control/controlclient/direct.go
+++ b/control/controlclient/direct.go
@@ -535,7 +535,7 @@ func inTest() bool { return flag.Lookup("test.v") != nil }
//
// maxPolls is how many network maps to download; common values are 1
// or -1 (to keep a long-poll query open to the server).
-func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(*netmap.NetworkMap)) error {
+func (c *Direct) PollNetMap(ctx context.Context, maxPolls int, cb func(netmap.NetworkMapView)) error {
return c.sendMapRequest(ctx, maxPolls, cb)
}
@@ -552,7 +552,7 @@ func (c *Direct) SendLiteMapUpdate(ctx context.Context) error {
const pollTimeout = 120 * time.Second
// cb nil means to omit peers.
-func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netmap.NetworkMap)) error {
+func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(netmap.NetworkMapView)) error {
c.mu.Lock()
persist := c.persist
serverURL := c.serverURL
@@ -822,7 +822,7 @@ func (c *Direct) sendMapRequest(ctx context.Context, maxPolls int, cb func(*netm
c.expiry = &nm.Expiry
c.mu.Unlock()
- cb(nm)
+ cb(nm.View())
}
if ctx.Err() != nil {
return ctx.Err()
diff --git a/control/controlclient/map.go b/control/controlclient/map.go
index 40d3109e3..f4df7609b 100644
--- a/control/controlclient/map.go
+++ b/control/controlclient/map.go
@@ -139,7 +139,7 @@ func (ms *mapSession) netmapForResponse(resp *tailcfg.MapResponse) *netmap.Netwo
}
ms.addUserProfile(nm.User)
- magicDNSSuffix := nm.MagicDNSSuffix()
+ magicDNSSuffix := nm.View().MagicDNSSuffix()
if nm.SelfNode != nil {
nm.SelfNode.InitDisplayNames(magicDNSSuffix)
}
diff --git a/control/controlclient/status.go b/control/controlclient/status.go
index 3cbe9261d..a7ffdfc68 100644
--- a/control/controlclient/status.go
+++ b/control/controlclient/status.go
@@ -68,8 +68,8 @@ type Status struct {
LoginFinished *empty.Message // nonempty when login finishes
LogoutFinished *empty.Message // nonempty when logout finishes
Err string
- URL string // interactive URL to visit to finish logging in
- NetMap *netmap.NetworkMap // server-pushed configuration
+ URL string // interactive URL to visit to finish logging in
+ NetMap netmap.NetworkMapView // server-pushed configuration
// The internal state should not be exposed outside this
// package, but we have some automated tests elsewhere that need to