v0.12.0 migrate sqlite3 to psql18, updated auth, deploy docs, account and replay updates
test / test (push) Canceled after 0s
test / test (push) Canceled after 0s
This commit is contained in:
1 parent
5d2be4abb2
commit
d0326b059e
66 files changed
+4016
-2433
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// parseTrustedProxies validates a comma-separated list of IPs and CIDRs.
|
||||
// Fiber skips entries it cannot parse, which would silently disable trust.
|
||||
func parseTrustedProxies(value string) ([]string, error) {
|
||||
var proxies []string
|
||||
for _, entry := range strings.Split(value, ",") {
|
||||
entry = strings.TrimSpace(entry)
|
||||
if entry == "" {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(entry, "/") {
|
||||
if _, err := netip.ParsePrefix(entry); err != nil {
|
||||
return nil, fmt.Errorf("%q is not a valid CIDR", entry)
|
||||
}
|
||||
} else if _, err := netip.ParseAddr(entry); err != nil {
|
||||
return nil, fmt.Errorf("%q is not a valid IP address", entry)
|
||||
}
|
||||
proxies = append(proxies, entry)
|
||||
}
|
||||
return proxies, nil
|
||||
}
|
||||
Reference in new issue
Block a user