mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 21:52:54 +00:00
* Add DenyLists parsing * Remove unneeded returned error * Plug global denylist into Command * app creation: apply denylist to backchannel logout URI * Inject denylist to backchannel logout worker * webhook config: validate against blocked URLs * Add notificationsWebhook denylist target * command: Add SMTP endpoint validation against blocklist * command: Add SMS endpoint validation against blocklist * Validate webhook endpoint against denylist on channel notification * Remove unused tests * handle deprecated denylists * remove unintended denylist entry in deprecated list * use single http client * fix tests * update comments * fixes * cleanup * address comments * fix merge --------- Co-authored-by: Livio Spring <[email protected]>
31 lines
889 B
Go
31 lines
889 B
Go
package net
|
|
|
|
import (
|
|
builtin_net "net"
|
|
|
|
"github.com/zitadel/zitadel/internal/zerrors"
|
|
)
|
|
|
|
type IPLookupFunc func(string) ([]builtin_net.IP, error)
|
|
|
|
// HostnameToIPList converts the input hostname to a list [net.IP].
|
|
//
|
|
// Returns an internal error if the lookup fails.
|
|
// Returns an invalid argument if the lookup function is nil
|
|
func HostnameToIPList(hostname string, lookupFunc IPLookupFunc) ([]builtin_net.IP, error) {
|
|
ip := builtin_net.ParseIP(hostname)
|
|
ips := []builtin_net.IP{ip}
|
|
if ip != nil {
|
|
return ips, nil
|
|
}
|
|
// if the hostname is a domain, we need to check resolve the ip(s), since it might be denied
|
|
if lookupFunc == nil {
|
|
return nil, zerrors.ThrowInvalidArgument(nil, "NET-naSn77", "lookup function must not be nil")
|
|
}
|
|
ips, err := lookupFunc(hostname)
|
|
if err != nil {
|
|
return nil, zerrors.ThrowInternal(err, "NET-4m9s2", "lookup failed")
|
|
}
|
|
return ips, nil
|
|
}
|