From 03653d6a10b74a17ba04b077d7ec5646d79ca34c Mon Sep 17 00:00:00 2001 From: Steven Vergenz <1882376+stevenvergenz@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:16:09 -0700 Subject: [PATCH] Fix domain lookups --- src/api/client_server/media.rs | 4 ++-- src/config/mod.rs | 2 ++ tests/test-config.toml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/api/client_server/media.rs b/src/api/client_server/media.rs index 8c80bbae..75a62d9c 100644 --- a/src/api/client_server/media.rs +++ b/src/api/client_server/media.rs @@ -185,7 +185,7 @@ async fn request_url_preview(url: &Url) -> Result { // resolve host to IP to ensure it's not an internal IP let dns_resolver = services().globals.dns_resolver(); - match dns_resolver.lookup_ip(host).await { + match dns_resolver.lookup_ip(format!("{host}.")).await { Err(_) => { return Err(Error::BadServerResponse("Failed to resolve media preview host")); }, @@ -199,7 +199,7 @@ async fn request_url_preview(url: &Url) -> Result { // https://docs.spamhaus.com/datasets/docs/source/70-access-methods/data-query-service/040-dqs-queries.html if services().globals.url_previews().use_spamhaus_denylist { let resolver = services().globals.dns_resolver(); - match resolver.lookup_ip(format!("{host}.dbl.spamhaus.org")).await { + match resolver.lookup_ip(format!("{host}.dbl.spamhaus.org.")).await { Err(e) => { if let ResolveErrorKind::NoRecordsFound { .. } = e.kind() { } else { diff --git a/src/config/mod.rs b/src/config/mod.rs index 1e9dbccb..8cd2d422 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -109,7 +109,9 @@ pub struct WellKnownConfig { #[derive(Clone, Debug, Deserialize, Default)] pub struct UrlPreviewConfig { pub default: UrlPreviewPermission, + #[serde(default)] pub exceptions: Vec, + #[serde(default)] pub use_spamhaus_denylist: bool, } diff --git a/tests/test-config.toml b/tests/test-config.toml index 10db1408..c6773a16 100644 --- a/tests/test-config.toml +++ b/tests/test-config.toml @@ -8,6 +8,7 @@ database_path = "/tmp" # All the other settings are left at their defaults: address = "127.0.0.1" +database_backend = "rocksdb" allow_registration = true max_request_size = 20_000_000 port = 6167