From e397272fe8550e4f81958d5d00bf3233e1bd0bfc Mon Sep 17 00:00:00 2001 From: Daenney Date: Wed, 8 Mar 2023 13:57:41 +0100 Subject: [feature] Discover webfinger through host-meta (#1588) * [feature] Discover webfinger through host-meta This implements a fallback for discovering the webfinger endpoint in case the /.well-known/webfinger endpoint wasn't properly redirected. Some instances do this because the recommendation used to be to use host-meta for the webfinger redirect in the before times. Closes #1558. * [bug] Ensure we only ever update cache on success * [chore] Move finger tests to their own place This adds a test suite for transport and moves the finger cache tests into there instead of abusing the search test suite. * [chore] cleanup the test a bit more We don't really need a separate function for the oddly located webfinger response as we check the full URL string anyway * Address review comments * [chore] update config example * [chore] access DB only through state in controller --- internal/config/helpers.gen.go | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'internal/config/helpers.gen.go') diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index b021ed617..14fa72b24 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -3003,6 +3003,81 @@ func GetCacheGTSUserSweepFreq() time.Duration { return global.GetCacheGTSUserSwe // SetCacheGTSUserSweepFreq safely sets the value for global configuration 'Cache.GTS.UserSweepFreq' field func SetCacheGTSUserSweepFreq(v time.Duration) { global.SetCacheGTSUserSweepFreq(v) } +// GetCacheGTSWebfingerMaxSize safely fetches the Configuration value for state's 'Cache.GTS.WebfingerMaxSize' field +func (st *ConfigState) GetCacheGTSWebfingerMaxSize() (v int) { + st.mutex.Lock() + v = st.config.Cache.GTS.WebfingerMaxSize + st.mutex.Unlock() + return +} + +// SetCacheGTSWebfingerMaxSize safely sets the Configuration value for state's 'Cache.GTS.WebfingerMaxSize' field +func (st *ConfigState) SetCacheGTSWebfingerMaxSize(v int) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.Cache.GTS.WebfingerMaxSize = v + st.reloadToViper() +} + +// CacheGTSWebfingerMaxSizeFlag returns the flag name for the 'Cache.GTS.WebfingerMaxSize' field +func CacheGTSWebfingerMaxSizeFlag() string { return "cache-gts-webfinger-max-size" } + +// GetCacheGTSWebfingerMaxSize safely fetches the value for global configuration 'Cache.GTS.WebfingerMaxSize' field +func GetCacheGTSWebfingerMaxSize() int { return global.GetCacheGTSWebfingerMaxSize() } + +// SetCacheGTSWebfingerMaxSize safely sets the value for global configuration 'Cache.GTS.WebfingerMaxSize' field +func SetCacheGTSWebfingerMaxSize(v int) { global.SetCacheGTSWebfingerMaxSize(v) } + +// GetCacheGTSWebfingerTTL safely fetches the Configuration value for state's 'Cache.GTS.WebfingerTTL' field +func (st *ConfigState) GetCacheGTSWebfingerTTL() (v time.Duration) { + st.mutex.Lock() + v = st.config.Cache.GTS.WebfingerTTL + st.mutex.Unlock() + return +} + +// SetCacheGTSWebfingerTTL safely sets the Configuration value for state's 'Cache.GTS.WebfingerTTL' field +func (st *ConfigState) SetCacheGTSWebfingerTTL(v time.Duration) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.Cache.GTS.WebfingerTTL = v + st.reloadToViper() +} + +// CacheGTSWebfingerTTLFlag returns the flag name for the 'Cache.GTS.WebfingerTTL' field +func CacheGTSWebfingerTTLFlag() string { return "cache-gts-webfinger-ttl" } + +// GetCacheGTSWebfingerTTL safely fetches the value for global configuration 'Cache.GTS.WebfingerTTL' field +func GetCacheGTSWebfingerTTL() time.Duration { return global.GetCacheGTSWebfingerTTL() } + +// SetCacheGTSWebfingerTTL safely sets the value for global configuration 'Cache.GTS.WebfingerTTL' field +func SetCacheGTSWebfingerTTL(v time.Duration) { global.SetCacheGTSWebfingerTTL(v) } + +// GetCacheGTSWebfingerSweepFreq safely fetches the Configuration value for state's 'Cache.GTS.WebfingerSweepFreq' field +func (st *ConfigState) GetCacheGTSWebfingerSweepFreq() (v time.Duration) { + st.mutex.Lock() + v = st.config.Cache.GTS.WebfingerSweepFreq + st.mutex.Unlock() + return +} + +// SetCacheGTSWebfingerSweepFreq safely sets the Configuration value for state's 'Cache.GTS.WebfingerSweepFreq' field +func (st *ConfigState) SetCacheGTSWebfingerSweepFreq(v time.Duration) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.Cache.GTS.WebfingerSweepFreq = v + st.reloadToViper() +} + +// CacheGTSWebfingerSweepFreqFlag returns the flag name for the 'Cache.GTS.WebfingerSweepFreq' field +func CacheGTSWebfingerSweepFreqFlag() string { return "cache-gts-webfinger-sweep-freq" } + +// GetCacheGTSWebfingerSweepFreq safely fetches the value for global configuration 'Cache.GTS.WebfingerSweepFreq' field +func GetCacheGTSWebfingerSweepFreq() time.Duration { return global.GetCacheGTSWebfingerSweepFreq() } + +// SetCacheGTSWebfingerSweepFreq safely sets the value for global configuration 'Cache.GTS.WebfingerSweepFreq' field +func SetCacheGTSWebfingerSweepFreq(v time.Duration) { global.SetCacheGTSWebfingerSweepFreq(v) } + // GetAdminAccountUsername safely fetches the Configuration value for state's 'AdminAccountUsername' field func (st *ConfigState) GetAdminAccountUsername() (v string) { st.mutex.Lock() -- cgit v1.2.3