Files
zitadel/internal/net/net.go
T
8e82ec1cb9 Merge commit from fork
* 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]>
2026-06-15 15:36:14 +02:00

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
}