pub struct UrlPreview {
pub bound_interface: Option<Either<IpAddr, String>>,
pub domain_contains_allowlist: Vec<String>,
pub domain_explicit_allowlist: Vec<String>,
pub domain_explicit_denylist: Vec<String>,
pub url_contains_allowlist: Vec<String>,
pub max_spider_size: usize,
pub max_media_size: usize,
pub cache_ttl: u64,
pub check_root_domain: bool,
pub user_agent: Option<String>,
pub media_user_agent: Option<String>,
pub accept_language: Option<String>,
}Expand description
URL previews
Link previews the server fetches on behalf of clients, built from the
page’s OpenGraph tags. Previews are off by default: with
domain_explicit_allowlist, domain_contains_allowlist and
url_contains_allowlist all empty, every preview request is refused
and clients are told previews are disabled. To enable previews, list
the hosts to allow.
Minimal example:
[global.media.url_preview]
domain_explicit_allowlist = ["en.wikipedia.org", "github.com"]Tips:
- A host in
domain_explicit_denylistis refused even when an allowlist admits it, except that"*"in any allowlist admits every URL before the denylist is consulted (and draws a startup warning). - An allowed URL is still refused when its host is an address in
network.http.ip_range_denylist, or resolves to one. check_root_domainstrips only the first label of the host:en.wikipedia.orgis also checked aswikipedia.org, buten.m.wikipedia.orgonly asm.wikipedia.org.
Fields§
§bound_interface: Option<Either<IpAddr, String>>Selects an optional source IP address or interface for URL preview requests.
When unset, requests are not bound to a specific address or interface.
Interface names are supported only on Linux, Android, and Fuchsia;
other platforms can specify an IP address. Use ip link show to list
system interfaces.
example: "eth0" or "1.2.3.4"
default:
legacy: url_preview_bound_interface
domain_contains_allowlist: Vec<String>Allows URL preview requests to domains containing a listed string.
Matching is by containment rather than equality: “google.com” matches both “https://google.com” and “http://mymaliciousdomainexamplegoogle.com”. A value of “*” allows all URL previews. This exposes significant server attack surface and requires understanding the risks.
reloadable: yes default: [] legacy: url_preview_domain_contains_allowlist
domain_explicit_allowlist: Vec<String>Allows URL preview requests to explicitly listed domains.
Matching is exact rather than by containment: “google.com” matches “https://google.com” and “http://google.com”, but not “https://mymaliciousdomainexamplegoogle.com”. A value of “*” allows all URL previews. This exposes significant server attack surface and requires understanding the risks.
reloadable: yes default: [] legacy: url_preview_domain_explicit_allowlist
domain_explicit_denylist: Vec<String>Rejects URL preview requests to explicitly listed domains.
Matching is exact rather than by containment: “google.com” matches “https://google.com” and “http://google.com”, but not “https://mymaliciousdomainexamplegoogle.com”. The denylist is checked before the allowlists, unless an allowlist holds “”. A value of “” here has no effect.
reloadable: yes default: [] legacy: url_preview_domain_explicit_denylist
url_contains_allowlist: Vec<String>Allows URL preview requests to URLs containing a listed string.
Matching is by containment rather than equality: “google.com” matches “https://google.com/”, “https://google.com/url?q=https://mymaliciousdomainexample.com”, and “https://mymaliciousdomainexample.com/hi/google.com”. A value of “*” allows all URL previews. This exposes significant server attack surface and requires understanding the risks.
reloadable: yes default: [] legacy: url_preview_url_contains_allowlist
max_spider_size: usizeLimits the body size read when fetching a URL preview page.
Accepts an integer byte count or an SI/IEC string such as “768 KiB”. A page whose OpenGraph tags fall beyond the limit produces an empty preview, so pages beginning with large script blocks need a larger budget.
reloadable: yes default: 786432 legacy: url_preview_max_spider_size
max_media_size: usizeLimits each media item fetched or relayed for a URL preview.
This covers the og:image measurement fetch and lazy-media relay. Media with an advertised length above the limit is not registered, and a relay that would exceed it is refused. Accepts an integer byte count or an SI/IEC string such as “50 MiB”.
reloadable: yes default: “50 MiB” legacy: url_preview_max_media_size
cache_ttl: u64Sets the lifetime in seconds of cached URL previews, including empty previews.
Increasing this reduces requests to origins when room history is read often, at the cost of serving OpenGraph metadata that may have changed. A value of 0 fetches on every request. Raising it beyond seven days takes effect at the next restart because the database applies its retention floor when opened.
reloadable: yes default: 86400 legacy: url_preview_cache_ttl
check_root_domain: boolChecks the host again with its first label removed when no list admitted it.
Only the explicit denylist and allowlist are consulted for the shortened
name, since a contains entry it holds already matched the full host.
One label is removed: with “wikipedia.org” in
domain_explicit_allowlist, “en.wikipedia.org” is admitted, while
“en.m.wikipedia.org” is checked only as “m.wikipedia.org” and refused.
reloadable: yes legacy: url_preview_check_root_domain
user_agent: Option<String>Sets the User-Agent used to fetch preview pages and extract OpenGraph tags.
When unset, the versioned server User-Agent is followed by “preview”,
such as “Tuwunel/1.8.1 preview”. Some origins serve OpenGraph tags only
to recognized preview crawlers and otherwise place them beyond
media.url_preview.max_spider_size.
reloadable: yes default: legacy: url_preview_user_agent
media_user_agent: Option<String>Sets the User-Agent used to fetch and relay URL preview media files.
This covers og:image, og:video, og:audio, and direct links rather than
their containing pages. When unset, it falls back to
media.url_preview.user_agent, then the versioned server User-Agent.
reloadable: yes default: legacy: url_preview_media_user_agent
accept_language: Option<String>Sets Accept-Language for URL preview page and media requests.
For example, “en-US,en;q=0.9” requests English from sites supporting language negotiation, while sites choosing a language solely by IP may ignore it. When unset, no Accept-Language header is sent. Changes affect new requests; cached previews retain their language until expiry.
reloadable: yes default: legacy: url_preview_accept_language
Implementations§
Source§impl UrlPreview
impl UrlPreview
pub(super) fn fmt_config(&self, out: &mut Formatter<'_>) -> Result
Trait Implementations§
Source§impl Clone for UrlPreview
impl Clone for UrlPreview
Source§impl Debug for UrlPreview
impl Debug for UrlPreview
Source§impl Default for UrlPreview
impl Default for UrlPreview
Source§impl<'de> Deserialize<'de> for UrlPreview
impl<'de> Deserialize<'de> for UrlPreview
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for UrlPreview
impl RefUnwindSafe for UrlPreview
impl Send for UrlPreview
impl Sync for UrlPreview
impl Unpin for UrlPreview
impl UnsafeUnpin for UrlPreview
impl UnwindSafe for UrlPreview
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: CheckedAdd + Sized,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: CheckedAdd + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: CheckedSub + Sized,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: CheckedSub + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: CheckedMul + Sized,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: CheckedMul + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: CheckedDiv + Sized,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: CheckedDiv + Sized,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: CheckedRem + Sized,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: CheckedRem + Sized,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self>where
Self: CheckedAdd + Sized,
fn try_add(self, rhs: Self) -> Result<Self>where
Self: CheckedAdd + Sized,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self>where
Self: CheckedSub + Sized,
fn try_sub(self, rhs: Self) -> Result<Self>where
Self: CheckedSub + Sized,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self>where
Self: CheckedMul + Sized,
fn try_mul(self, rhs: Self) -> Result<Self>where
Self: CheckedMul + Sized,
rhs with checked arithmetic. Read more