Add "Allow LAN access" checkbox in Exit Node menu

Updates tailscale/tailscale#2155
bradfitz/corp_dns_setting
Brad Fitzpatrick 3 years ago committed by Brad Fitzpatrick
parent 1be9000a6a
commit e3f7123238

@ -189,6 +189,7 @@ type (
GoogleAuthEvent struct{} GoogleAuthEvent struct{}
LogoutEvent struct{} LogoutEvent struct{}
BeExitNodeEvent bool BeExitNodeEvent bool
ExitAllowLANEvent bool
) )
// serverOAuthID is the OAuth ID of the tailscale-android server, used // serverOAuthID is the OAuth ID of the tailscale-android server, used
@ -420,6 +421,9 @@ func (a *App) runBackend() error {
case BeExitNodeEvent: case BeExitNodeEvent:
state.Prefs.SetAdvertiseExitNode(bool(e)) state.Prefs.SetAdvertiseExitNode(bool(e))
go b.backend.SetPrefs(state.Prefs) go b.backend.SetPrefs(state.Prefs)
case ExitAllowLANEvent:
state.Prefs.ExitNodeAllowLANAccess = bool(e)
go b.backend.SetPrefs(state.Prefs)
case WebAuthEvent: case WebAuthEvent:
if !signingIn { if !signingIn {
go b.backend.StartLoginInteractive() go b.backend.StartLoginInteractive()
@ -865,6 +869,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() ui.runningExit = p.AdvertisesExitNode()
ui.exitLAN.Value = p.ExitNodeAllowLANAccess
w.Invalidate() w.Invalidate()
case state.browseURL = <-a.browseURLs: case state.browseURL = <-a.browseURLs:
ui.signinType = noSignin ui.signinType = noSignin
@ -1077,6 +1082,8 @@ func (a *App) processUIEvents(w *app.Window, events []UIEvent, act jni.Object, s
w.WriteClipboard(logMarker) w.WriteClipboard(logMarker)
case BeExitNodeEvent: case BeExitNodeEvent:
requestBackend(e) requestBackend(e)
case ExitAllowLANEvent:
requestBackend(e)
case WebAuthEvent: case WebAuthEvent:
a.store.WriteString(loginMethodPrefKey, loginMethodWeb) a.store.WriteString(loginMethodPrefKey, loginMethodWeb)
requestBackend(e) requestBackend(e)

@ -49,6 +49,8 @@ type UI struct {
enabled widget.Bool enabled widget.Bool
search widget.Editor search widget.Editor
exitLAN widget.Bool
// webSigin is the button for the web-based sign-in flow. // webSigin is the button for the web-based sign-in flow.
webSignin widget.Clickable webSignin widget.Clickable
@ -303,6 +305,9 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
} else { } else {
d.exits.Value = string(exitID) d.exits.Value = string(exitID)
} }
if ui.exitLAN.Changed() {
events = append(events, ExitAllowLANEvent(ui.exitLAN.Value))
}
if ui.googleSignin.Clicked() { if ui.googleSignin.Clicked() {
ui.signinType = googleSignin ui.signinType = googleSignin
@ -892,12 +897,20 @@ func (ui *UI) layoutExitNodeDialog(gtx layout.Context, sysIns system.Insets, exi
}), }),
layout.Flexed(1, func(gtx C) D { layout.Flexed(1, func(gtx C) D {
gtx.Constraints.Min.Y = 0 gtx.Constraints.Min.Y = 0
// Add "none" exit node. // Add "none" exit node, then "Allow LAN" checkbox, then the exit nodes.
n := len(exits) + 1 n := len(exits) + 2
return d.list.Layout(gtx, n, func(gtx C, idx int) D { return d.list.Layout(gtx, n, func(gtx C, idx int) D {
if idx == 0 {
btn := material.CheckBox(ui.theme, &ui.exitLAN, "Allow LAN access")
return layout.Inset{
Right: unit.Dp(16),
Left: unit.Dp(16),
Bottom: unit.Dp(16),
}.Layout(gtx, btn.Layout)
}
node := Peer{Label: "None", Online: true} node := Peer{Label: "None", Online: true}
if idx >= 1 { if idx >= 2 {
node = exits[idx-1] node = exits[idx-2]
} }
lbl := node.Label lbl := node.Label
if !node.Online { if !node.Online {

Loading…
Cancel
Save