Browse Source

Merge pull request #2242 from calmh/ur

Add interesting fields to usage report (fixes #559)
Audrius Butkevicius 10 years ago
parent
commit
0a42b85c06

+ 90 - 1
cmd/syncthing/usage_report.go

@@ -15,17 +15,20 @@ import (
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"runtime"
 	"runtime"
+	"sort"
 	"time"
 	"time"
 
 
+	"github.com/syncthing/protocol"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/model"
 	"github.com/syncthing/syncthing/lib/model"
+	"github.com/syncthing/syncthing/lib/upgrade"
 	"github.com/thejerf/suture"
 	"github.com/thejerf/suture"
 )
 )
 
 
 // Current version number of the usage report, for acceptance purposes. If
 // Current version number of the usage report, for acceptance purposes. If
 // fields are added or changed this integer must be incremented so that users
 // fields are added or changed this integer must be incremented so that users
 // are prompted for acceptance of the new report.
 // are prompted for acceptance of the new report.
-const usageReportVersion = 1
+const usageReportVersion = 2
 
 
 type usageReportingManager struct {
 type usageReportingManager struct {
 	model *model.Model
 	model *model.Model
@@ -120,6 +123,92 @@ func reportData(m *model.Model) map[string]interface{} {
 	if err == nil {
 	if err == nil {
 		res["memorySize"] = bytes / 1024 / 1024
 		res["memorySize"] = bytes / 1024 / 1024
 	}
 	}
+	res["numCPU"] = runtime.NumCPU()
+
+	var rescanIntvs []int
+	folderUses := map[string]int{
+		"readonly":      0,
+		"ignorePerms":   0,
+		"ignoreDelete":  0,
+		"autoNormalize": 0,
+	}
+	for _, cfg := range cfg.Folders() {
+		rescanIntvs = append(rescanIntvs, cfg.RescanIntervalS)
+
+		if cfg.ReadOnly {
+			folderUses["readonly"]++
+		}
+		if cfg.IgnorePerms {
+			folderUses["ignorePerms"]++
+		}
+		if cfg.IgnoreDelete {
+			folderUses["ignoreDelete"]++
+		}
+		if cfg.AutoNormalize {
+			folderUses["autoNormalize"]++
+		}
+	}
+	sort.Ints(rescanIntvs)
+	res["rescanIntvs"] = rescanIntvs
+	res["folderUses"] = folderUses
+
+	deviceUses := map[string]int{
+		"introducer":       0,
+		"customCertName":   0,
+		"compressAlways":   0,
+		"compressMetadata": 0,
+		"compressNever":    0,
+		"dynamicAddr":      0,
+		"staticAddr":       0,
+	}
+	for _, cfg := range cfg.Devices() {
+		if cfg.Introducer {
+			deviceUses["introducer"]++
+		}
+		if cfg.CertName != "" && cfg.CertName != "syncthing" {
+			deviceUses["customCertName"]++
+		}
+		if cfg.Compression == protocol.CompressAlways {
+			deviceUses["compressAlways"]++
+		} else if cfg.Compression == protocol.CompressMetadata {
+			deviceUses["compressMetadata"]++
+		} else if cfg.Compression == protocol.CompressNever {
+			deviceUses["compressNever"]++
+		}
+		for _, addr := range cfg.Addresses {
+			if addr == "dynamic" {
+				deviceUses["dynamicAddr"]++
+			} else {
+				deviceUses["staticAddr"]++
+			}
+		}
+	}
+	res["deviceUses"] = deviceUses
+
+	defaultAnnounceServersDNS, defaultAnnounceServersIP, otherAnnounceServers := 0, 0, 0
+	for _, addr := range cfg.Options().GlobalAnnServers {
+		switch addr {
+		case "udp4://announce.syncthing.net:22027", "udp6://announce-v6.syncthing.net:22027":
+			defaultAnnounceServersDNS++
+		case "udp4://194.126.249.5:22027", "udp6://[2001:470:28:4d6::5]:22027":
+			defaultAnnounceServersIP++
+		default:
+			otherAnnounceServers++
+		}
+	}
+	res["announce"] = map[string]interface{}{
+		"globalEnabled":     cfg.Options().GlobalAnnEnabled,
+		"localEnabled":      cfg.Options().LocalAnnEnabled,
+		"defaultServersDNS": defaultAnnounceServersDNS,
+		"defaultServersIP":  defaultAnnounceServersIP,
+		"otherServers":      otherAnnounceServers,
+	}
+
+	res["usesRelays"] = cfg.Options().RelaysEnabled
+	res["usesRateLimit"] = cfg.Options().MaxRecvKbps > 0 || cfg.Options().MaxSendKbps > 0
+
+	res["upgradeAllowedManual"] = !(upgrade.DisabledByCompilation || noUpgrade)
+	res["upgradeAllowedAuto"] = !(upgrade.DisabledByCompilation || noUpgrade) && cfg.Options().AutoUpgradeIntervalH > 0
 
 
 	return res
 	return res
 }
 }

+ 3 - 1
gui/syncthing/usagereport/usageReportPreviewModalView.html

@@ -1,5 +1,7 @@
 <modal id="urPreview" status="success" icon="bar-chart" title="{{'Anonymous Usage Reporting' | translate}}" large="yes" close="yes" tabindex="-1">
 <modal id="urPreview" status="success" icon="bar-chart" title="{{'Anonymous Usage Reporting' | translate}}" large="yes" close="yes" tabindex="-1">
   <p translate>The encrypted usage report is sent daily. It is used to track common platforms, folder sizes and app versions. If the reported data set is changed you will be prompted with this dialog again.</p>
   <p translate>The encrypted usage report is sent daily. It is used to track common platforms, folder sizes and app versions. If the reported data set is changed you will be prompted with this dialog again.</p>
   <p translate translate-value-url="<a href=&quot;https://data.syncthing.net&quot; target=&quot;_blank&quot;>https://data.syncthing.net</a>">The aggregated statistics are publicly available at {%url%}.</p>
   <p translate translate-value-url="<a href=&quot;https://data.syncthing.net&quot; target=&quot;_blank&quot;>https://data.syncthing.net</a>">The aggregated statistics are publicly available at {%url%}.</p>
-  <pre><small>{{reportData | json}}</small></pre>
+  <form>
+  <textarea class="form-control" rows="20">{{reportData | json}}</textarea>
+  </form>
 </modal>
 </modal>

File diff suppressed because it is too large
+ 2 - 2
lib/auto/gui.files.go


+ 2 - 0
lib/upgrade/upgrade_supported.go

@@ -29,6 +29,8 @@ import (
 	"github.com/syncthing/syncthing/lib/signature"
 	"github.com/syncthing/syncthing/lib/signature"
 )
 )
 
 
+const DisabledByCompilation = false
+
 // This is an HTTP/HTTPS client that does *not* perform certificate
 // This is an HTTP/HTTPS client that does *not* perform certificate
 // validation. We do this because some systems where Syncthing runs have
 // validation. We do this because some systems where Syncthing runs have
 // issues with old or missing CA roots. It doesn't actually matter that we
 // issues with old or missing CA roots. It doesn't actually matter that we

+ 2 - 0
lib/upgrade/upgrade_unsupp.go

@@ -8,6 +8,8 @@
 
 
 package upgrade
 package upgrade
 
 
+const DisabledByCompilation = true
+
 func upgradeTo(binary string, rel Release) error {
 func upgradeTo(binary string, rel Release) error {
 	return ErrUpgradeUnsupported
 	return ErrUpgradeUnsupported
 }
 }

Some files were not shown because too many files changed in this diff