mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-14 02:17:27 -06: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:
parent
726d2ba483
commit
9048290948
10 changed files with 195 additions and 67 deletions
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue