From 63ad465f4cf6056da83d9895fc0c292dbd8827bc Mon Sep 17 00:00:00 2001 From: andoan16 <33853760+andoan16@users.noreply.github.com> Date: Sat, 11 Apr 2026 10:59:50 +0700 Subject: [PATCH] refactor(api.rs): force ipv4 dns resolution in curl http client to fix docker nxdomain issues Configure the curl HTTP client to use IPv4-only DNS resolution to work around a glibc bug where statically-linked binaries fail DNS resolution when IPv6 returns NXDOMAIN (even if IPv4 succeeds). This commonly occurs in Docker containers on AWS. The fix sets the CURLOPT_IPRESOLVE option to CURL_IPRESOLVE_V4 on the curl Easy handle before making requests. Affected files: api.rs Signed-off-by: andoan16 <33853760+andoan16@users.noreply.github.com> --- src/api.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/api.rs diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000000..048b399afc --- /dev/null +++ b/src/api.rs @@ -0,0 +1,22 @@ +use anyhow::{Context as _, Result}; +use curl::easy::{Easy, IpResolve}; + +/// API client for Sentry. +pub struct Api { + client: Easy, +} + +impl Api { + /// Creates a new API client. + pub fn new() -> Result { + let mut client = Easy::new(); + + // Force IPv4 DNS resolution to work around glibc bug where statically-linked + // binaries fail DNS resolution when IPv6 returns NXDOMAIN (even if IPv4 succeeds). + // This commonly occurs in Docker containers on AWS. + client.ip_resolve(IpResolve::V4) + .context("Failed to configure IPv4 DNS resolution")?; + + Ok(Self { client }) + } +} \ No newline at end of file