Rust

destinations

Module

Where a client may connect.

A transport checks its Destinations against the address each connection actually reached (every connection, every redirect hop), not a DNS answer taken earlier, so a host name that resolves differently at connect time cannot get past the check.

Contents

use utopia_client::Anywhere;
Rust
pub struct Anywhere

Any address, through any proxy: for services whose address the operator configured, never for a URL a user supplied. The default.

use utopia_client::IpRange;
Rust
pub struct IpRange

An IPv4 or IPv6 address or CIDR range. A single address is its /32 or /128, so every spelling of an address (::1, 0:0:0:0:0:0:0:1) is the same range.

Rust
use utopia_client::IpRange;

let range = IpRange::new("10.0.0.0/8")?;
assert!(range.contains("10.1.2.3"));
assert!(!range.contains("11.0.0.1"));
assert!(IpRange::new("10.0.0.0/").is_err());
use utopia_client::PublicInternet;
Rust
pub struct PublicInternet

Globally routable addresses only: never a private, loopback, link-local, multicast or otherwise reserved one (cloud metadata, the host, the internal network), unless one of the given ranges admits it. Never through a proxy. For fetching a URL a user supplied.

Rust
use utopia_client::{Destinations, IpRange, PublicInternet};

let public = PublicInternet::new([]);
assert!(public.allows("8.8.8.8"));
assert!(!public.allows("169.254.169.254"));

let internal = PublicInternet::new([IpRange::new("10.0.0.0/8")?]);
assert!(internal.allows("10.0.0.7"));
Also implements Default.
use utopia_client::Destinations;
Rust
pub trait Destinations: Send + Sync + std::fmt::Debug

Where requests may connect. Implement it for a policy of your own.