cmd/tailscale: fix code breakages from OSS changes

Changes in OSS broke building android. This change updates the various
bits of code for it to work again.

Updates #14529
catzkorn/fixit
Charlotte Brandhorst-Satzkorn 2 years ago
parent c73f8533f0
commit 9af0b83f85

@ -454,7 +454,7 @@ func (a *App) runBackend() error {
} }
}() }()
case LogoutEvent: case LogoutEvent:
go b.backend.Logout() go b.backend.Logout(context.Background())
case ConnectEvent: case ConnectEvent:
state.Prefs.WantRunning = e.Enable state.Prefs.WantRunning = e.Enable
go b.backend.SetPrefs(state.Prefs) go b.backend.SetPrefs(state.Prefs)
@ -655,24 +655,24 @@ func (s *BackendState) updateExitNodes() {
} }
hasMyExit := exitID == "" hasMyExit := exitID == ""
s.Exits = nil s.Exits = nil
var peers []*tailcfg.Node var peers []tailcfg.NodeView
if s.NetworkMap != nil { if s.NetworkMap != nil {
peers = s.NetworkMap.Peers peers = s.NetworkMap.Peers
} }
for _, p := range peers { for _, p := range peers {
canRoute := false canRoute := false
for _, r := range p.AllowedIPs { for _, r := range p.AllowedIPs().AsSlice() {
if r == netip.MustParsePrefix("0.0.0.0/0") || r == netip.MustParsePrefix("::/0") { if r == netip.MustParsePrefix("0.0.0.0/0") || r == netip.MustParsePrefix("::/0") {
canRoute = true canRoute = true
break break
} }
} }
myExit := p.StableID == exitID myExit := p.StableID() == exitID
hasMyExit = hasMyExit || myExit hasMyExit = hasMyExit || myExit
exit := Peer{ exit := Peer{
Label: p.DisplayName(true), Label: p.DisplayName(true),
Online: canRoute, Online: canRoute,
ID: p.StableID, ID: p.StableID(),
} }
if myExit { if myExit {
s.Exit = exit s.Exit = exit
@ -1050,18 +1050,18 @@ func (a *App) updateState(act jni.Object, state *clientState) {
netmap := state.backend.NetworkMap netmap := state.backend.NetworkMap
var ( var (
peers []*tailcfg.Node peers []tailcfg.NodeView
myID tailcfg.UserID myID tailcfg.UserID
) )
if netmap != nil { if netmap != nil {
peers = netmap.Peers peers = netmap.Peers
myID = netmap.User myID = netmap.User()
} }
// Split into sections. // Split into sections.
users := make(map[tailcfg.UserID]struct{}) users := make(map[tailcfg.UserID]struct{})
var uiPeers []UIPeer var uiPeers []UIPeer
for _, p := range peers { for _, p := range peers {
if p.Hostinfo.Valid() && p.Hostinfo.ShareeNode() { if p.Hostinfo().Valid() && p.Hostinfo().ShareeNode() {
// Don't show nodes that only exist in the netmap because they're // Don't show nodes that only exist in the netmap because they're
// owned by somebody the user shared a node with. We can't see their // owned by somebody the user shared a node with. We can't see their
// details (including their name) anyway, so there's nothing // details (including their name) anyway, so there's nothing
@ -1070,20 +1070,20 @@ func (a *App) updateState(act jni.Object, state *clientState) {
} }
if q := state.query; q != "" { if q := state.query; q != "" {
// Filter peers according to search query. // Filter peers according to search query.
host := strings.ToLower(p.Hostinfo.Hostname()) host := strings.ToLower(p.Hostinfo().Hostname())
name := strings.ToLower(p.Name) name := strings.ToLower(p.Name())
var addr string var addr string
if len(p.Addresses) > 0 { if p.Addresses().Len() > 0 {
addr = p.Addresses[0].Addr().String() addr = p.Addresses().At(0).Addr().String()
} }
if !strings.Contains(host, q) && !strings.Contains(name, q) && !strings.Contains(addr, q) { if !strings.Contains(host, q) && !strings.Contains(name, q) && !strings.Contains(addr, q) {
continue continue
} }
} }
users[p.User] = struct{}{} users[p.User()] = struct{}{}
uiPeers = append(uiPeers, UIPeer{ uiPeers = append(uiPeers, UIPeer{
Owner: p.User, Owner: p.User(),
Peer: p, Peer: p.AsStruct(),
}) })
} }
// Add section (user) headers. // Add section (user) headers.

@ -363,7 +363,7 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
exitID tailcfg.StableNodeID exitID tailcfg.StableNodeID
) )
if netmap != nil { if netmap != nil {
userID = netmap.User userID = netmap.User()
expiry = netmap.Expiry expiry = netmap.Expiry
localName = netmap.SelfNode.DisplayName(false) localName = netmap.SelfNode.DisplayName(false)
if addrs := netmap.Addresses; len(addrs) > 0 { if addrs := netmap.Addresses; len(addrs) > 0 {

Loading…
Cancel
Save