invert reject / allow to make default more sensible

This commit is contained in:
tobi 2025-09-16 15:58:54 +02:00
commit 220b17e2f8
7 changed files with 40 additions and 40 deletions

View file

@ -77,7 +77,7 @@ const (
InstanceSubscriptionsProcessEveryFlag = "instance-subscriptions-process-every"
InstanceStatsModeFlag = "instance-stats-mode"
InstanceAllowBackdatingStatusesFlag = "instance-allow-backdating-statuses"
InstanceRejectEmptyUserAgentsFlag = "instance-reject-empty-user-agents"
InstanceAllowEmptyUserAgentsFlag = "instance-allow-empty-user-agents"
AccountsRegistrationOpenFlag = "accounts-registration-open"
AccountsReasonRequiredFlag = "accounts-reason-required"
AccountsRegistrationDailyLimitFlag = "accounts-registration-daily-limit"
@ -278,7 +278,7 @@ func (cfg *Configuration) RegisterFlags(flags *pflag.FlagSet) {
flags.Duration("instance-subscriptions-process-every", cfg.InstanceSubscriptionsProcessEvery, "Period to elapse between instance subscriptions processing jobs, starting from instance-subscriptions-process-from.")
flags.String("instance-stats-mode", cfg.InstanceStatsMode, "Allows you to customize the way stats are served to crawlers: one of '', 'serve', 'zero', 'baffle'. Home page stats remain unchanged.")
flags.Bool("instance-allow-backdating-statuses", cfg.InstanceAllowBackdatingStatuses, "Allow local accounts to backdate statuses using the scheduled_at param to /api/v1/statuses")
flags.Bool("instance-reject-empty-user-agents", cfg.InstanceRejectEmptyUserAgents, "Reject all incoming HTTP requests that do not have a User-Agent header set")
flags.Bool("instance-allow-empty-user-agents", cfg.InstanceAllowEmptyUserAgents, "Allow incoming HTTP requests that do not have a User-Agent header set")
flags.Bool("accounts-registration-open", cfg.AccountsRegistrationOpen, "Allow anyone to submit an account signup request. If false, server will be invite-only.")
flags.Bool("accounts-reason-required", cfg.AccountsReasonRequired, "Do new account signups require a reason to be submitted on registration?")
flags.Int("accounts-registration-daily-limit", cfg.AccountsRegistrationDailyLimit, "Limit amount of approved account sign-ups allowed per 24hrs before registration is closed. 0 or less = no limit.")
@ -471,7 +471,7 @@ func (cfg *Configuration) MarshalMap() map[string]any {
cfgmap["instance-subscriptions-process-every"] = cfg.InstanceSubscriptionsProcessEvery
cfgmap["instance-stats-mode"] = cfg.InstanceStatsMode
cfgmap["instance-allow-backdating-statuses"] = cfg.InstanceAllowBackdatingStatuses
cfgmap["instance-reject-empty-user-agents"] = cfg.InstanceRejectEmptyUserAgents
cfgmap["instance-allow-empty-user-agents"] = cfg.InstanceAllowEmptyUserAgents
cfgmap["accounts-registration-open"] = cfg.AccountsRegistrationOpen
cfgmap["accounts-reason-required"] = cfg.AccountsReasonRequired
cfgmap["accounts-registration-daily-limit"] = cfg.AccountsRegistrationDailyLimit
@ -1022,11 +1022,11 @@ func (cfg *Configuration) UnmarshalMap(cfgmap map[string]any) error {
}
}
if ival, ok := cfgmap["instance-reject-empty-user-agents"]; ok {
if ival, ok := cfgmap["instance-allow-empty-user-agents"]; ok {
var err error
cfg.InstanceRejectEmptyUserAgents, err = cast.ToBoolE(ival)
cfg.InstanceAllowEmptyUserAgents, err = cast.ToBoolE(ival)
if err != nil {
return fmt.Errorf("error casting %#v -> bool for 'instance-reject-empty-user-agents': %w", ival, err)
return fmt.Errorf("error casting %#v -> bool for 'instance-allow-empty-user-agents': %w", ival, err)
}
}
@ -3313,27 +3313,27 @@ func GetInstanceAllowBackdatingStatuses() bool { return global.GetInstanceAllowB
// SetInstanceAllowBackdatingStatuses safely sets the value for global configuration 'InstanceAllowBackdatingStatuses' field
func SetInstanceAllowBackdatingStatuses(v bool) { global.SetInstanceAllowBackdatingStatuses(v) }
// GetInstanceRejectEmptyUserAgents safely fetches the Configuration value for state's 'InstanceRejectEmptyUserAgents' field
func (st *ConfigState) GetInstanceRejectEmptyUserAgents() (v bool) {
// GetInstanceAllowEmptyUserAgents safely fetches the Configuration value for state's 'InstanceAllowEmptyUserAgents' field
func (st *ConfigState) GetInstanceAllowEmptyUserAgents() (v bool) {
st.mutex.RLock()
v = st.config.InstanceRejectEmptyUserAgents
v = st.config.InstanceAllowEmptyUserAgents
st.mutex.RUnlock()
return
}
// SetInstanceRejectEmptyUserAgents safely sets the Configuration value for state's 'InstanceRejectEmptyUserAgents' field
func (st *ConfigState) SetInstanceRejectEmptyUserAgents(v bool) {
// SetInstanceAllowEmptyUserAgents safely sets the Configuration value for state's 'InstanceAllowEmptyUserAgents' field
func (st *ConfigState) SetInstanceAllowEmptyUserAgents(v bool) {
st.mutex.Lock()
defer st.mutex.Unlock()
st.config.InstanceRejectEmptyUserAgents = v
st.config.InstanceAllowEmptyUserAgents = v
st.reloadToViper()
}
// GetInstanceRejectEmptyUserAgents safely fetches the value for global configuration 'InstanceRejectEmptyUserAgents' field
func GetInstanceRejectEmptyUserAgents() bool { return global.GetInstanceRejectEmptyUserAgents() }
// GetInstanceAllowEmptyUserAgents safely fetches the value for global configuration 'InstanceAllowEmptyUserAgents' field
func GetInstanceAllowEmptyUserAgents() bool { return global.GetInstanceAllowEmptyUserAgents() }
// SetInstanceRejectEmptyUserAgents safely sets the value for global configuration 'InstanceRejectEmptyUserAgents' field
func SetInstanceRejectEmptyUserAgents(v bool) { global.SetInstanceRejectEmptyUserAgents(v) }
// SetInstanceAllowEmptyUserAgents safely sets the value for global configuration 'InstanceAllowEmptyUserAgents' field
func SetInstanceAllowEmptyUserAgents(v bool) { global.SetInstanceAllowEmptyUserAgents(v) }
// GetAccountsRegistrationOpen safely fetches the Configuration value for state's 'AccountsRegistrationOpen' field
func (st *ConfigState) GetAccountsRegistrationOpen() (v bool) {