Documentation ¶
Index ¶
- Constants
- Variables
- func GetNodeAddresses(cidrs []string, nw NetworkInterfacer) (sets.String, error)
- func IPPart(s string) string
- func IsLocalIP(ip string) (bool, error)
- func IsProxyableHostname(ctx context.Context, resolv Resolver, hostname string) error
- func IsProxyableIP(ip string) error
- func IsZeroCIDR(cidr string) bool
- func LogAndEmitIncorrectIPVersionEvent(recorder record.EventRecorder, ...)
- func PortPart(s string) (int, error)
- func RevertPorts(replacementPortsMap, originalPortsMap map[LocalPort]Closeable)
- func ShouldSkipService(svcName types.NamespacedName, service *v1.Service) bool
- func ToCIDR(ip net.IP) string
- type Closeable
- type LocalPort
- type NetworkInterfacer
- type PortOpener
- type RealNetwork
- type Resolver
Constants ¶
const ( IPv4ZeroCIDR = "0.0.0.0/0" IPv6ZeroCIDR = "::/0" )
Variables ¶
var ( ErrAddressNotAllowed = errors.New("address not allowed") ErrNoAddresses = errors.New("No addresses for hostname") )
Functions ¶
func GetNodeAddresses ¶ added in v1.10.0
func GetNodeAddresses(cidrs []string, nw NetworkInterfacer) (sets.String, error)
GetNodeAddresses return all matched node IP addresses based on given cidr slice. Some callers, e.g. IPVS proxier, need concrete IPs, not ranges, which is why this exists. NetworkInterfacer is injected for test purpose. We expect the cidrs passed in is already validated. Given an empty input `[]`, it will return `0.0.0.0/0` and `::/0` directly. If multiple cidrs is given, it will return the minimal IP sets, e.g. given input `[1.2.0.0/16, 0.0.0.0/0]`, it will only return `0.0.0.0/0`. NOTE: GetNodeAddresses only accepts CIDRs, if you want concrete IPs, e.g. 1.2.3.4, then the input should be 1.2.3.4/32.
func IPPart ¶ added in v1.9.0
IPPart returns just the IP part of an IP or IP:port or endpoint string. If the IP part is an IPv6 address enclosed in brackets (e.g. "[fd00:1::5]:9999"), then the brackets are stripped as well.
func IsProxyableHostname ¶ added in v1.11.6
IsProxyableHostname checks if the IP addresses for a given hostname are permitted to be proxied
func IsProxyableIP ¶ added in v1.11.6
IsProxyableIP checks if a given IP address is permitted to be proxied
func IsZeroCIDR ¶ added in v1.10.0
func LogAndEmitIncorrectIPVersionEvent ¶ added in v1.10.0
func LogAndEmitIncorrectIPVersionEvent(recorder record.EventRecorder, fieldName, fieldValue, svcNamespace, svcName string, svcUID types.UID)
LogAndEmitIncorrectIPVersionEvent logs and emits incorrect IP version event.
func RevertPorts ¶ added in v1.8.0
RevertPorts is closing ports in replacementPortsMap but not in originalPortsMap. In other words, it only closes the ports opened in this sync.
func ShouldSkipService ¶ added in v1.8.0
func ShouldSkipService(svcName types.NamespacedName, service *v1.Service) bool
Types ¶
type Closeable ¶ added in v1.8.0
type Closeable interface {
Close() error
}
Closeable is an interface around closing a port.
type LocalPort ¶ added in v1.8.0
type LocalPort struct { // Description is the identity message of a given local port. Description string // IP is the IP address part of a given local port. // If this string is empty, the port binds to all local IP addresses. IP string // Port is the port part of a given local port. Port int // Protocol is the protocol part of a given local port. // The value is assumed to be lower-case. For example, "udp" not "UDP", "tcp" not "TCP". Protocol string }
LocalPort describes a port on specific IP address and protocol
type NetworkInterfacer ¶ added in v1.10.0
type NetworkInterfacer interface { Addrs(intf *net.Interface) ([]net.Addr, error) Interfaces() ([]net.Interface, error) }
NetworkInterfacer defines an interface for several net library functions. Production code will forward to net library functions, and unit tests will override the methods for testing purposes.
type PortOpener ¶ added in v1.8.0
PortOpener is an interface around port opening/closing. Abstracted out for testing.
type RealNetwork ¶ added in v1.10.0
type RealNetwork struct{}
RealNetwork implements the NetworkInterfacer interface for production code, just wrapping the underlying net library function calls.
func (RealNetwork) Addrs ¶ added in v1.10.0
Addrs wraps net.Interface.Addrs(), it's a part of NetworkInterfacer interface.
func (RealNetwork) Interfaces ¶ added in v1.10.0
func (_ RealNetwork) Interfaces() ([]net.Interface, error)
Interfaces wraps net.Interfaces(), it's a part of NetworkInterfacer interface.