pub struct ListenerSpec { /* private fields */ }Expand description
One listener of a server.
use net_io::{ListenerSpec, Limits};
let spec = ListenerSpec::tcp("127.0.0.1:0")
.name("admin")
.limits(Limits::builder().max_per_listener(10).build()?);Implementations§
Source§impl ListenerSpec
impl ListenerSpec
Sourcepub fn tcp<A: ToSocketAddrs>(addr: A) -> ListenerSpec
pub fn tcp<A: ToSocketAddrs>(addr: A) -> ListenerSpec
A TCP listener on addr (resolved now; a failure is reported by build).
Sourcepub fn lockdown_allowed(self, on: bool) -> ListenerSpec
pub fn lockdown_allowed(self, on: bool) -> ListenerSpec
Keeps admitting under ControlState::Lockdown, for the listener an operator
comes in through while everything else is refused.
Sourcepub fn tcp_with<A: ToSocketAddrs>(
addr: A,
options: ListenOptions,
) -> ListenerSpec
pub fn tcp_with<A: ToSocketAddrs>( addr: A, options: ListenOptions, ) -> ListenerSpec
A TCP listener with explicit options (their backlog wins over the limits’).
Sourcepub fn udp<A: ToSocketAddrs>(addr: A, options: UdpOptions) -> ListenerSpec
Available on crate feature udp only.
pub fn udp<A: ToSocketAddrs>(addr: A, options: UdpOptions) -> ListenerSpec
udp only.A UDP socket served by the UdpSession that
ServerBuilder::udp_sessions makes (feature udp). A thread of its own reads
it, with the door and a stop like any listener, and the socket’s budgets and
amplification guard apply.
use net_io::{ListenerSpec, UdpOptions};
let spec = ListenerSpec::udp("0.0.0.0:5353", UdpOptions::new());Sourcepub fn unix(path: impl Into<PathBuf>, options: LocalOptions) -> ListenerSpec
pub fn unix(path: impl Into<PathBuf>, options: LocalOptions) -> ListenerSpec
A Unix domain socket listener at path (feature local; on Windows, AF_UNIX,
where NTFS ACLs replace options’ mode and owner). The socket file gets
options’ mode and owner before it listens, and is removed at shutdown if it
is still the file this server created. Connections carry Transport::Unix, the peer’s
credentials, and no IP address: the per-source cap does not apply, and a
BlockingHandler receives them as a TcpConnection whose peer_addr is
unspecified. With proxy, every peer is trusted: the socket file’s
permissions decide who may connect.
use net_io::{ListenerSpec, LocalOptions};
let spec = ListenerSpec::unix("/run/myapp/api.sock", LocalOptions::new().group_access(33));Sourcepub fn adopt(handle: ListenerHandle) -> ListenerSpec
pub fn adopt(handle: ListenerHandle) -> ListenerSpec
A listener this process was given: inherited from systemd or a FastCGI
manager, received in a hand-off, or released by another server. Its name
is the handle’s unless ListenerSpec::name sets one. The socket is not
bound again; options set at bind time stay as they are, and the backlog is
reported as unknown. An adopted Unix socket’s file is left in place at
shutdown (the next bind removes it as stale).
use net_io::ListenerSpec;
for inherited in net_io::systemd()? {
let spec = ListenerSpec::adopt(inherited.handle);
}Sourcepub fn name(self, name: &str) -> ListenerSpec
pub fn name(self, name: &str) -> ListenerSpec
A name (up to 64 bytes) for events and hand-off.
Sourcepub fn limits(self, limits: Limits) -> ListenerSpec
pub fn limits(self, limits: Limits) -> ListenerSpec
Per-listener caps and deadlines; values set here override the server’s.
Sourcepub fn proxy(self, mode: ProxyMode) -> ListenerSpec
pub fn proxy(self, mode: ProxyMode) -> ListenerSpec
Requires a PROXY protocol header on every connection (feature proxy).
Peers outside the trusted proxies are closed before any byte is read.
use net_io::{ListenerSpec, ProxyMode, ProxyVersions};
let spec = ListenerSpec::tcp("127.0.0.1:0").proxy(ProxyMode::Required { versions: ProxyVersions::Both });Sourcepub fn tls(self, on: bool) -> ListenerSpec
pub fn tls(self, on: bool) -> ListenerSpec
Serves TLS on this listener through the builder’s acceptor
(ServerBuilder::tls, feature tls).
Sourcepub fn trusted_proxies(self, proxies: TrustedProxies) -> ListenerSpec
pub fn trusted_proxies(self, proxies: TrustedProxies) -> ListenerSpec
The proxies trusted on this listener, instead of the server’s list.