stackable_webhook/constants.rs
1//! Contains various constant definitions, mostly for default ports and IP
2//! addresses.
3use std::net::{IpAddr, Ipv4Addr, SocketAddr};
4
5/// The default HTTPS port `8443`
6pub const DEFAULT_HTTPS_PORT: u16 = 8443;
7
8// The HTTPS port the conversion webhook runs at
9pub const CONVERSION_WEBHOOK_HTTPS_PORT: u16 = DEFAULT_HTTPS_PORT;
10
11/// The default IP address [`Ipv4Addr::UNSPECIFIED`] (`0.0.0.0`) the webhook server binds to,
12/// which represents binding on all network addresses.
13//
14// TODO: We might want to switch to `Ipv6Addr::UNSPECIFIED)` here, as this *normally* binds to IPv4
15// and IPv6. However, it's complicated and depends on the underlying system...
16// If we do so, we should set `set_only_v6(false)` on the socket to not rely on system defaults.
17pub const DEFAULT_LISTEN_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::UNSPECIFIED);
18
19/// The default socket address `0.0.0.0:8443` the webhook server binds to.
20pub const DEFAULT_SOCKET_ADDRESS: SocketAddr =
21 SocketAddr::new(DEFAULT_LISTEN_ADDRESS, DEFAULT_HTTPS_PORT);