diff options
author | 2023-08-01 19:50:17 +0200 | |
---|---|---|
committer | 2023-08-01 18:50:17 +0100 | |
commit | 2be83fdca5c440d45b8cd92bda9315757463d6c7 (patch) | |
tree | 041eb0ef390f2995cd243206c5f0cc8fb3d66488 /internal/config | |
parent | [feature] Set timezone in Docker using TZ env variable (#2050) (diff) | |
download | gotosocial-2be83fdca5c440d45b8cd92bda9315757463d6c7.tar.xz |
[feature] Allow users to skip http client tls verification for testing purposes (with appropriately loud warnings) (#2052)
Diffstat (limited to 'internal/config')
-rw-r--r-- | internal/config/config.go | 7 | ||||
-rw-r--r-- | internal/config/defaults.go | 7 | ||||
-rw-r--r-- | internal/config/flags.go | 1 | ||||
-rw-r--r-- | internal/config/helpers.gen.go | 25 |
4 files changed, 34 insertions, 6 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 9397379b8..7f09b5fc1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -168,9 +168,10 @@ type Configuration struct { } type HTTPClientConfiguration struct { - AllowIPs []string `name:"allow-ips"` - BlockIPs []string `name:"block-ips"` - Timeout time.Duration `name:"timeout"` + AllowIPs []string `name:"allow-ips"` + BlockIPs []string `name:"block-ips"` + Timeout time.Duration `name:"timeout"` + TLSInsecureSkipVerify bool `name:"tls-insecure-skip-verify"` } type CacheConfiguration struct { diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 7729840f0..e8cb39325 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -234,9 +234,10 @@ var Defaults = Configuration{ }, HTTPClient: HTTPClientConfiguration{ - AllowIPs: make([]string, 0), - BlockIPs: make([]string, 0), - Timeout: 10 * time.Second, + AllowIPs: make([]string, 0), + BlockIPs: make([]string, 0), + Timeout: 10 * time.Second, + TLSInsecureSkipVerify: false, }, AdminMediaPruneDryRun: true, diff --git a/internal/config/flags.go b/internal/config/flags.go index c42b5c7b2..321400252 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -60,6 +60,7 @@ func (s *ConfigState) AddGlobalFlags(cmd *cobra.Command) { cmd.PersistentFlags().StringSlice(HTTPClientAllowIPsFlag(), cfg.HTTPClient.AllowIPs, "no usage string") cmd.PersistentFlags().StringSlice(HTTPClientBlockIPsFlag(), cfg.HTTPClient.BlockIPs, "no usage string") cmd.PersistentFlags().Duration(HTTPClientTimeoutFlag(), cfg.HTTPClient.Timeout, "no usage string") + cmd.PersistentFlags().Bool(HTTPClientTLSInsecureSkipVerifyFlag(), cfg.HTTPClient.TLSInsecureSkipVerify, "no usage string") }) } diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index e4b82edd5..4c2f1d059 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -2399,6 +2399,31 @@ func GetHTTPClientTimeout() time.Duration { return global.GetHTTPClientTimeout() // SetHTTPClientTimeout safely sets the value for global configuration 'HTTPClient.Timeout' field func SetHTTPClientTimeout(v time.Duration) { global.SetHTTPClientTimeout(v) } +// GetHTTPClientTLSInsecureSkipVerify safely fetches the Configuration value for state's 'HTTPClient.TLSInsecureSkipVerify' field +func (st *ConfigState) GetHTTPClientTLSInsecureSkipVerify() (v bool) { + st.mutex.RLock() + v = st.config.HTTPClient.TLSInsecureSkipVerify + st.mutex.RUnlock() + return +} + +// SetHTTPClientTLSInsecureSkipVerify safely sets the Configuration value for state's 'HTTPClient.TLSInsecureSkipVerify' field +func (st *ConfigState) SetHTTPClientTLSInsecureSkipVerify(v bool) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.HTTPClient.TLSInsecureSkipVerify = v + st.reloadToViper() +} + +// HTTPClientTLSInsecureSkipVerifyFlag returns the flag name for the 'HTTPClient.TLSInsecureSkipVerify' field +func HTTPClientTLSInsecureSkipVerifyFlag() string { return "httpclient-tls-insecure-skip-verify" } + +// GetHTTPClientTLSInsecureSkipVerify safely fetches the value for global configuration 'HTTPClient.TLSInsecureSkipVerify' field +func GetHTTPClientTLSInsecureSkipVerify() bool { return global.GetHTTPClientTLSInsecureSkipVerify() } + +// SetHTTPClientTLSInsecureSkipVerify safely sets the value for global configuration 'HTTPClient.TLSInsecureSkipVerify' field +func SetHTTPClientTLSInsecureSkipVerify(v bool) { global.SetHTTPClientTLSInsecureSkipVerify(v) } + // GetCacheGTSAccountMaxSize safely fetches the Configuration value for state's 'Cache.GTS.AccountMaxSize' field func (st *ConfigState) GetCacheGTSAccountMaxSize() (v int) { st.mutex.RLock() |