From 22024a38c3ef6a1aa656e664ec0dfa7b790fd9fe Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 19 Oct 2020 08:30:36 -0700 Subject: [PATCH] control/controlclient: log Hostinfo on change Fixes #830 Signed-off-by: Brad Fitzpatrick --- control/controlclient/direct.go | 2 ++ tailcfg/tailcfg.go | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index d30dad74a..611a13999 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -228,6 +228,8 @@ func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) bool { return false } c.hostinfo = hi.Clone() + j, _ := json.Marshal(c.hostinfo) + c.logf("HostInfo: %s", j) return true } diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 3e87c69b7..eda215a58 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -259,7 +259,7 @@ type Service struct { _ structs.Incomparable Proto ServiceProto // TCP or UDP Port uint16 // port number service is listening on - Description string // text description of service + Description string `json:",omitempty"` // text description of service // TODO(apenwarr): allow advertising services on subnet IPs? // TODO(apenwarr): add "tags" here for each service? @@ -275,13 +275,13 @@ type Hostinfo struct { // TODO(crawshaw): mark all these fields ",omitempty" when all the // iOS apps are updated with the latest swift version of this struct. IPNVersion string // version of this code - FrontendLogID string // logtail ID of frontend instance - BackendLogID string // logtail ID of backend instance + FrontendLogID string `json:",omitempty"` // logtail ID of frontend instance + BackendLogID string `json:",omitempty"` // logtail ID of backend instance OS string // operating system the client runs on (a version.OS value) - OSVersion string // operating system version, with optional distro prefix ("Debian 10.4", "Windows 10 Pro 10.0.19041") - DeviceModel string // mobile phone model ("Pixel 3a", "iPhone 11 Pro") + OSVersion string `json:",omitempty"` // operating system version, with optional distro prefix ("Debian 10.4", "Windows 10 Pro 10.0.19041") + DeviceModel string `json:",omitempty"` // mobile phone model ("Pixel 3a", "iPhone 11 Pro") Hostname string // name of the host the client runs on - GoArch string // the host's GOARCH value (of the running binary) + GoArch string `json:",omitempty"` // the host's GOARCH value (of the running binary) RoutableIPs []wgcfg.CIDR `json:",omitempty"` // set of IP ranges this client can route RequestTags []string `json:",omitempty"` // set of ACL tags this node wants to claim Services []Service `json:",omitempty"` // services advertised by this machine @@ -328,7 +328,7 @@ type NetInfo struct { PreferredDERP int // LinkType is the current link type, if known. - LinkType string // "wired", "wifi", "mobile" (LTE, 4G, 3G, etc) + LinkType string `json:",omitempty"` // "wired", "wifi", "mobile" (LTE, 4G, 3G, etc) // DERPLatency is the fastest recent time to reach various // DERP STUN servers, in seconds. The map key is the