mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore] skip trusted-proxies
warning if ip excepted from rate limiting (#3699)
* [chore] skip `trusted-proxies` warning if ip excepted from rate limiting * weep * typo * fix env parsing test
This commit is contained in:
@@ -19,6 +19,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
@@ -168,5 +169,22 @@ func Validate() error {
|
||||
)
|
||||
}
|
||||
|
||||
// Parse `advanced-rate-limit-exceptions` and set
|
||||
// parsed versions on config to avoid reparsing calls.
|
||||
rles := GetAdvancedRateLimitExceptions()
|
||||
rlesParsed := make([]netip.Prefix, 0, len(rles))
|
||||
for _, rle := range rles {
|
||||
parsed, err := netip.ParsePrefix(rle)
|
||||
if err != nil {
|
||||
errf(
|
||||
"invalid entry %s in %s: %w",
|
||||
rle, AdvancedRateLimitExceptionsFlag(), err,
|
||||
)
|
||||
continue
|
||||
}
|
||||
rlesParsed = append(rlesParsed, parsed)
|
||||
}
|
||||
SetAdvancedRateLimitExceptionsParsed(rlesParsed)
|
||||
|
||||
return errs.Combine()
|
||||
}
|
||||
|
Reference in New Issue
Block a user