Add secret Run Exit Node option when "debug" is searched for.

And bump tailscale dep, to bring in new ipn.Prefs API and wire up
ExitDNS for Android.

This change has no visible behavior change to anybody unless they
search for "debug" and then hit the "..." menu.

Updates tailscale/tailscale#1738

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz/bump_target
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent ed29f4b3d2
commit 9d801a42d7

@ -29,6 +29,7 @@ import (
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/util/dnsname" "tailscale.com/util/dnsname"
"tailscale.com/wgengine" "tailscale.com/wgengine"
"tailscale.com/wgengine/netstack"
"tailscale.com/wgengine/router" "tailscale.com/wgengine/router"
) )
@ -120,6 +121,9 @@ func newBackend(dataDir string, jvm *jni.JVM, appCtx jni.Object, store *stateSto
return nil, fmt.Errorf("runBackend: NewUserspaceEngine: %v", err) return nil, fmt.Errorf("runBackend: NewUserspaceEngine: %v", err)
} }
b.logIDPublic = logID.Public().String() b.logIDPublic = logID.Public().String()
if err := startNetstack(log.Printf, dialer, engine); err != nil {
return nil, fmt.Errorf("startNetstack: %w", err)
}
local, err := ipnlocal.NewLocalBackend(logf, b.logIDPublic, store, dialer, engine) local, err := ipnlocal.NewLocalBackend(logf, b.logIDPublic, store, dialer, engine)
if err != nil { if err != nil {
engine.Close() engine.Close()
@ -428,3 +432,17 @@ func (b *backend) getDNSBaseConfig() (dns.OSConfig, error) {
return config, nil return config, nil
} }
func startNetstack(logf logger.Logf, dialer *tsdial.Dialer, e wgengine.Engine) error {
tunDev, magicConn, ok := e.(wgengine.InternalsGetter).GetInternals()
if !ok {
return fmt.Errorf("%T is not a wgengine.InternalsGetter", e)
}
ns, err := netstack.Create(logf, tunDev, e, magicConn, dialer)
if err != nil {
return fmt.Errorf("netstack.Create: %w", err)
}
ns.ProcessLocalIPs = false
ns.ProcessSubnets = true
return ns.Start()
}

@ -188,6 +188,7 @@ type (
WebAuthEvent struct{} WebAuthEvent struct{}
GoogleAuthEvent struct{} GoogleAuthEvent struct{}
LogoutEvent struct{} LogoutEvent struct{}
BeExitNodeEvent bool
) )
// serverOAuthID is the OAuth ID of the tailscale-android server, used // serverOAuthID is the OAuth ID of the tailscale-android server, used
@ -416,6 +417,9 @@ func (a *App) runBackend() error {
case ToggleEvent: case ToggleEvent:
state.Prefs.WantRunning = !state.Prefs.WantRunning state.Prefs.WantRunning = !state.Prefs.WantRunning
go b.backend.SetPrefs(state.Prefs) go b.backend.SetPrefs(state.Prefs)
case BeExitNodeEvent:
state.Prefs.SetAdvertiseExitNode(bool(e))
go b.backend.SetPrefs(state.Prefs)
case WebAuthEvent: case WebAuthEvent:
if !signingIn { if !signingIn {
go b.backend.StartLoginInteractive() go b.backend.StartLoginInteractive()
@ -860,6 +864,7 @@ func (a *App) runUI() error {
} }
case p := <-a.prefs: case p := <-a.prefs:
ui.enabled.Value = p.WantRunning ui.enabled.Value = p.WantRunning
ui.runningExit = p.AdvertisesExitNode()
w.Invalidate() w.Invalidate()
case state.browseURL = <-a.browseURLs: case state.browseURL = <-a.browseURLs:
ui.signinType = noSignin ui.signinType = noSignin
@ -1070,6 +1075,8 @@ func (a *App) processUIEvents(w *app.Window, events []UIEvent, act jni.Object, s
logMarker := fmt.Sprintf("BUG-%v-%v-%v", backendLogID, time.Now().UTC().Format("20060102150405Z"), randHex(8)) logMarker := fmt.Sprintf("BUG-%v-%v-%v", backendLogID, time.Now().UTC().Format("20060102150405Z"), randHex(8))
log.Printf("user bugreport: %s", logMarker) log.Printf("user bugreport: %s", logMarker)
w.WriteClipboard(logMarker) w.WriteClipboard(logMarker)
case BeExitNodeEvent:
requestBackend(e)
case WebAuthEvent: case WebAuthEvent:
a.store.WriteString(loginMethodPrefKey, loginMethodWeb) a.store.WriteString(loginMethodPrefKey, loginMethodWeb)
requestBackend(e) requestBackend(e)

@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"image" "image"
"image/color" "image/color"
"strings"
"time" "time"
"gioui.org/f32" "gioui.org/f32"
@ -70,6 +71,9 @@ type UI struct {
list layout.List list layout.List
} }
showDebugMenu bool
runningExit bool // are we an exit node now?
intro struct { intro struct {
list layout.List list layout.List
start widget.Clickable start widget.Clickable
@ -84,6 +88,7 @@ type UI struct {
copy widget.Clickable copy widget.Clickable
reauth widget.Clickable reauth widget.Clickable
bug widget.Clickable bug widget.Clickable
beExit widget.Clickable
exits widget.Clickable exits widget.Clickable
logout widget.Clickable logout widget.Clickable
} }
@ -260,7 +265,11 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
for _, e := range ui.search.Events() { for _, e := range ui.search.Events() {
if _, ok := e.(widget.ChangeEvent); ok { if _, ok := e.(widget.ChangeEvent); ok {
events = append(events, SearchEvent{Query: ui.search.Text()}) text := ui.search.Text()
if strings.EqualFold(text, "debug") {
ui.showDebugMenu = true
}
events = append(events, SearchEvent{Query: text})
break break
} }
} }
@ -319,6 +328,16 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
ui.showCopied(gtx, "bug report marker to clipboard") ui.showCopied(gtx, "bug report marker to clipboard")
} }
if ui.menuClicked(&ui.menu.beExit) {
ui.runningExit = !ui.runningExit
events = append(events, BeExitNodeEvent(ui.runningExit))
if ui.runningExit {
ui.showMessage(gtx, "Running exit node")
} else {
ui.showMessage(gtx, "Stopped running exit node")
}
}
if ui.menuClicked(&ui.menu.exits) || ui.openExitDialog.Clicked() { if ui.menuClicked(&ui.menu.exits) || ui.openExitDialog.Clicked() {
ui.exitDialog.show = true ui.exitDialog.show = true
} }
@ -981,6 +1000,15 @@ func (ui *UI) layoutMenu(gtx layout.Context, sysIns system.Insets, expiry time.T
menuItem{title: "Reauthenticate", btn: &menu.reauth}, menuItem{title: "Reauthenticate", btn: &menu.reauth},
menuItem{title: "Log out", btn: &menu.logout}, menuItem{title: "Log out", btn: &menu.logout},
) )
if ui.runningExit || ui.showDebugMenu {
var title string
if ui.runningExit {
title = "Stop running exit node [BETA]"
} else {
title = "Run exit node [BETA]"
}
items = append(items, menuItem{title: title, btn: &menu.beExit})
}
return layoutMenu(ui.theme, gtx, items, func(gtx C) D { return layoutMenu(ui.theme, gtx, items, func(gtx C) D {
var expiryStr string var expiryStr string
const fmtStr = time.Stamp const fmtStr = time.Stamp

@ -10,7 +10,7 @@ require (
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d golang.org/x/sys v0.0.0-20211205182925-97ca703d548d
golang.zx2c4.com/wireguard v0.0.0-20211116201604-de7c702ace45 golang.zx2c4.com/wireguard v0.0.0-20211116201604-de7c702ace45
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6
tailscale.com v1.1.1-0.20220106164417-64c2657448c9 tailscale.com v1.1.1-0.20220107180532-1a4e8da0849f
) )
require ( require (

@ -705,3 +705,7 @@ tailscale.com v1.1.1-0.20220103195654-dd45bba76b3a h1:f1Ixr2b9pnSeVLRt1caMxd4rJV
tailscale.com v1.1.1-0.20220103195654-dd45bba76b3a/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4= tailscale.com v1.1.1-0.20220103195654-dd45bba76b3a/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4=
tailscale.com v1.1.1-0.20220106164417-64c2657448c9 h1:LFkTqkAfdB+FzWS0KmOwv2Y5ba0Kbbc3IQfHi6G09fA= tailscale.com v1.1.1-0.20220106164417-64c2657448c9 h1:LFkTqkAfdB+FzWS0KmOwv2Y5ba0Kbbc3IQfHi6G09fA=
tailscale.com v1.1.1-0.20220106164417-64c2657448c9/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4= tailscale.com v1.1.1-0.20220106164417-64c2657448c9/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4=
tailscale.com v1.1.1-0.20220107005935-1b426cc232c0 h1:Z2+Z5HEPrInsP7BlE/2kMohRRWRvjxzJiLryhsrT+/c=
tailscale.com v1.1.1-0.20220107005935-1b426cc232c0/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4=
tailscale.com v1.1.1-0.20220107180532-1a4e8da0849f h1:PIv9L0qXK6HZuAer6hg6mmSByzJ5jv1MR5J7Wlbnfek=
tailscale.com v1.1.1-0.20220107180532-1a4e8da0849f/go.mod h1:kjVy3ji2OH5lZhPLIIRacoY3CN4Bo3Yyb2mtoM8nfJ4=

Loading…
Cancel
Save