mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-08 22:53:10 -06:00
Update config
This commit is contained in:
parent
af3fc7daa8
commit
b5b635f923
|
|
@ -71,11 +71,8 @@ type Global struct {
|
||||||
// ServerNotices configuration used for sending server notices
|
// ServerNotices configuration used for sending server notices
|
||||||
ServerNotices ServerNotices `yaml:"server_notices"`
|
ServerNotices ServerNotices `yaml:"server_notices"`
|
||||||
|
|
||||||
// ReportStats configures anonymous usage stats of the server
|
// ReportStats configures opt-in anonymous stats reporting.
|
||||||
ReportStats bool `yaml:"report_stats"`
|
ReportStats ReportStats `yaml:"report_stats"`
|
||||||
|
|
||||||
// ReportStatsEndpoint configuration
|
|
||||||
ReportStatsEndpoint string `yaml:"report_stats_endpoint"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Global) Defaults(generate bool) {
|
func (c *Global) Defaults(generate bool) {
|
||||||
|
|
@ -86,14 +83,13 @@ func (c *Global) Defaults(generate bool) {
|
||||||
c.KeyID = "ed25519:auto"
|
c.KeyID = "ed25519:auto"
|
||||||
}
|
}
|
||||||
c.KeyValidityPeriod = time.Hour * 24 * 7
|
c.KeyValidityPeriod = time.Hour * 24 * 7
|
||||||
c.ReportStats = false
|
|
||||||
c.ReportStatsEndpoint = "https://matrix.org/report-usage-stats/push"
|
|
||||||
|
|
||||||
c.JetStream.Defaults(generate)
|
c.JetStream.Defaults(generate)
|
||||||
c.Metrics.Defaults(generate)
|
c.Metrics.Defaults(generate)
|
||||||
c.DNSCache.Defaults()
|
c.DNSCache.Defaults()
|
||||||
c.Sentry.Defaults()
|
c.Sentry.Defaults()
|
||||||
c.ServerNotices.Defaults(generate)
|
c.ServerNotices.Defaults(generate)
|
||||||
|
c.ReportStats.Defaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||||
|
|
@ -105,6 +101,7 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||||
c.Sentry.Verify(configErrs, isMonolith)
|
c.Sentry.Verify(configErrs, isMonolith)
|
||||||
c.DNSCache.Verify(configErrs, isMonolith)
|
c.DNSCache.Verify(configErrs, isMonolith)
|
||||||
c.ServerNotices.Verify(configErrs, isMonolith)
|
c.ServerNotices.Verify(configErrs, isMonolith)
|
||||||
|
c.ReportStats.Verify(configErrs, isMonolith)
|
||||||
}
|
}
|
||||||
|
|
||||||
type OldVerifyKeys struct {
|
type OldVerifyKeys struct {
|
||||||
|
|
@ -171,6 +168,26 @@ func (c *ServerNotices) Defaults(generate bool) {
|
||||||
|
|
||||||
func (c *ServerNotices) Verify(errors *ConfigErrors, isMonolith bool) {}
|
func (c *ServerNotices) Verify(errors *ConfigErrors, isMonolith bool) {}
|
||||||
|
|
||||||
|
// ReportStats configures opt-in anonymous stats reporting.
|
||||||
|
type ReportStats struct {
|
||||||
|
// Enabled configures anonymous usage stats of the server
|
||||||
|
Enabled bool `yaml:"enabled"`
|
||||||
|
|
||||||
|
// Endpoint the endpoint to report stats to
|
||||||
|
Endpoint string `yaml:"endpoint"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ReportStats) Defaults() {
|
||||||
|
c.Enabled = false
|
||||||
|
c.Endpoint = "https://matrix.org/report-usage-stats/push"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ReportStats) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||||
|
if c.Enabled {
|
||||||
|
checkNotEmpty(configErrs, "global.report_stats.endpoint", c.Endpoint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The configuration to use for Sentry error reporting
|
// The configuration to use for Sentry error reporting
|
||||||
type Sentry struct {
|
type Sentry struct {
|
||||||
Enabled bool `yaml:"enabled"`
|
Enabled bool `yaml:"enabled"`
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ func NewInternalAPI(
|
||||||
}
|
}
|
||||||
time.AfterFunc(time.Minute, cleanOldNotifs)
|
time.AfterFunc(time.Minute, cleanOldNotifs)
|
||||||
|
|
||||||
if base.Cfg.Global.ReportStats {
|
if base.Cfg.Global.ReportStats.Enabled {
|
||||||
go util.StartPhoneHomeCollector(time.Now(), base.Cfg, db)
|
go util.StartPhoneHomeCollector(time.Now(), base.Cfg, db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,9 @@ func (p *phoneHomeStats) collect() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("Reporting stats to %s: %s", p.cfg.Global.ReportStatsEndpoint, output.String())
|
logrus.Infof("Reporting stats to %s: %s", p.cfg.Global.ReportStats.Endpoint, output.String())
|
||||||
|
|
||||||
request, err := http.NewRequest("POST", p.cfg.Global.ReportStatsEndpoint, &output)
|
request, err := http.NewRequest(http.MethodPost, p.cfg.Global.ReportStats.Endpoint, &output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("unable to create phone home stats request")
|
logrus.WithError(err).Error("unable to create phone home stats request")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue