adguardhome-sync/pkg/types/features.go

73 lines
1.9 KiB
Go
Raw Normal View History

2021-11-01 15:56:12 +08:00
package types
import (
"go.uber.org/zap"
)
// Features feature flags
type Features struct {
2021-11-02 01:20:14 +08:00
DNS DNS `json:"dns" yaml:"dns"`
DHCP DHCP `json:"dhcp" yaml:"dhcp"`
GeneralSettings bool `json:"generalSettings" yaml:"generalSettings"`
QueryLogConfig bool `json:"queryLogConfig" yaml:"queryLogConfig"`
StatsConfig bool `json:"statsConfig" yaml:"statsConfig"`
ClientSettings bool `json:"clientSettings" yaml:"clientSettings"`
Services bool `json:"services" yaml:"services"`
Filters bool `json:"filters" yaml:"filters"`
2021-11-01 15:56:12 +08:00
}
// DHCP features
type DHCP struct {
ServerConfig bool `json:"serverConfig" yaml:"serverConfig"`
StaticLeases bool `json:"staticLeases" yaml:"staticLeases"`
}
2021-11-02 01:20:14 +08:00
// DNS features
type DNS struct {
AccessLists bool `json:"accessLists" yaml:"accessLists"`
ServerConfig bool `json:"serverConfig" yaml:"serverConfig"`
Rewrites bool `json:"rewrites" yaml:"rewrites"`
}
2021-11-02 01:38:35 +08:00
// LogDisabled log all disabled features
2021-11-01 15:56:12 +08:00
func (f *Features) LogDisabled(l *zap.SugaredLogger) {
var features []string
if !f.DHCP.ServerConfig {
features = append(features, "DHCP.ServerConfig")
}
if !f.DHCP.StaticLeases {
features = append(features, "DHCP.StaticLeases")
}
2021-11-02 01:38:35 +08:00
if !f.DNS.AccessLists {
features = append(features, "DNS.AccessLists")
2021-11-02 01:38:35 +08:00
}
if !f.DNS.ServerConfig {
features = append(features, "DNS.ServerConfig")
2021-11-02 01:38:35 +08:00
}
if !f.DNS.Rewrites {
features = append(features, "DNS.Rewrites")
2021-11-02 01:38:35 +08:00
}
if !f.GeneralSettings {
features = append(features, "GeneralSettings")
}
if !f.QueryLogConfig {
features = append(features, "QueryLogConfig")
}
if !f.StatsConfig {
features = append(features, "StatsConfig")
}
if !f.ClientSettings {
features = append(features, "ClientSettings")
}
if !f.Services {
features = append(features, "Services")
}
if !f.Filters {
features = append(features, "Filters")
}
2021-11-01 15:56:12 +08:00
if len(features) > 0 {
2021-11-02 01:38:35 +08:00
l.With("features", features).Info("Disabled features")
2021-11-01 15:56:12 +08:00
}
}