Documentation
¶
Index ¶
- Constants
- Variables
- func Normalize(key, value string) string
- func SplitDomains(csv string) []string
- func SplitIPAllowlist(csv string) []string
- func Validate(key, value string) error
- type Store
- func (s *Store) All(ctx context.Context) (map[string]string, error)
- func (s *Store) Effective(ctx context.Context) (map[string]string, error)
- func (s *Store) Get(ctx context.Context, key string) (value string, found bool, err error)
- func (s *Store) Maintenance(ctx context.Context) (bool, error)
- func (s *Store) RateLimits(ctx context.Context) (perUser, perIP int, allowlist []string, err error)
- func (s *Store) RegistrationGate(ctx context.Context) (allow bool, domains []string, err error)
- func (s *Store) Set(ctx context.Context, key, value, actor string) error
Constants ¶
View Source
const ( KeyBannerText = "banner_text" KeyBannerKind = "banner_kind" KeyMaintenanceMode = "maintenance_mode" KeyAllowSignup = "allow_signup" KeyAllowedDomains = "allowed_domains" KeyRateLimitPerUserPerMin = "rate_limit_per_user_per_min" KeyRateLimitPerIPPerMin = "rate_limit_per_ip_per_min" KeyRateLimitAllowlist = "rate_limit_allowlist" KindInfo, KindWarn = "info", "warn" FlagOff, FlagOn = "0", "1" )
Variables ¶
View Source
var Defaults = map[string]string{ KeyBannerText: "", KeyBannerKind: KindInfo, KeyMaintenanceMode: FlagOff, KeyAllowSignup: FlagOn, KeyAllowedDomains: "", KeyRateLimitPerUserPerMin: "0", KeyRateLimitPerIPPerMin: "30", KeyRateLimitAllowlist: "", }
View Source
var Descriptions = map[string]string{ KeyBannerText: "站点公告文本(空 = 无公告);保存后全站顶条即时生效", KeyBannerKind: "公告样式:info = 蓝系 / warn = 橙红系", KeyMaintenanceMode: "维护模式:开启后全站顶栏显示「维护中」条(仅提示,不阻断请求)", KeyAllowSignup: "注册开关:关闭 = 邀请制(仅白名单邮箱可注册);保存后即时生效(SignupGate 热读)", KeyAllowedDomains: "注册邮箱域名白名单,逗号分隔(空 = 不限域名)", KeyRateLimitPerUserPerMin: "API 每用户限流(请求/分钟):0 = 关闭;修改后重启生效(启动期静态注入,不热重载)", KeyRateLimitPerIPPerMin: "认证路径每客户端 IP 限流(请求/分钟):0 = 关闭;修改后重启生效", KeyRateLimitAllowlist: "限流豁免名单:逗号分隔 IP 或 CIDR(如 10.0.0.5, 192.168.0.0/16);修改后重启生效", }
Functions ¶
func SplitDomains ¶
func SplitIPAllowlist ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) RateLimits ¶
func (*Store) RegistrationGate ¶
Click to show internal directories.
Click to hide internal directories.