From a3113a793a8477d8a30a26a31266003c4dde5896 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 12 Apr 2021 10:45:33 -0700 Subject: [PATCH] ipn: add hostname to Prefs.Pretty output Signed-off-by: Brad Fitzpatrick --- ipn/prefs.go | 3 +++ ipn/prefs_test.go | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/ipn/prefs.go b/ipn/prefs.go index 8edbc14ab..6fc4ce69a 100644 --- a/ipn/prefs.go +++ b/ipn/prefs.go @@ -256,6 +256,9 @@ func (p *Prefs) pretty(goos string) string { if p.ControlURL != "" && p.ControlURL != "https://login.tailscale.com" { fmt.Fprintf(&sb, "url=%q ", p.ControlURL) } + if p.Hostname != "" { + fmt.Fprintf(&sb, "host=%q ", p.Hostname) + } if p.Persist != nil { sb.WriteString(p.Persist.Pretty()) } else { diff --git a/ipn/prefs_test.go b/ipn/prefs_test.go index 211a8a7e7..251bf9c13 100644 --- a/ipn/prefs_test.go +++ b/ipn/prefs_test.go @@ -393,6 +393,13 @@ func TestPrefsPretty(t *testing.T) { "linux", `Prefs{ra=false mesh=false dns=false want=false exit=myNodeABC routes=[] nf=off Persist=nil}`, }, + { + Prefs{ + Hostname: "foo", + }, + "linux", + `Prefs{ra=false mesh=false dns=false want=false routes=[] nf=off host="foo" Persist=nil}`, + }, } for i, tt := range tests { got := tt.p.pretty(tt.os)