Skip to content

Commit

Permalink
Merge pull request #85 from dimbleby/c-ares-123
Browse files Browse the repository at this point in the history
c-ares 1.23.0
  • Loading branch information
dimbleby authored Nov 30, 2023
2 parents 7174b1a + 9c0255d commit 2caa507
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 8.2.0 (30 November 2023)

- c-ares 1.23.0

## 8.1.0 (14 November 2023)

- c-ares 1.22.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "c-ares"
license = "MIT"
version = "8.1.0"
version = "8.2.0"
authors = ["David Hotham"]
description = """
A Rust wrapper for the c-ares library, for asynchronous DNS requests.
Expand All @@ -22,7 +22,7 @@ include = [

[dependencies]
bitflags = "2.0"
c-ares-sys = { version = "8.1.0", path = "c-ares-sys", default-features = false }
c-ares-sys = { version = "8.2.0", path = "c-ares-sys", default-features = false }
c-types = "3.0.0"
itertools = "0.11"

Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ fn main() {
if version >= 0x1_16_00 {
println!("cargo:rustc-cfg=cares1_22");
}

if version >= 0x1_17_00 {
println!("cargo:rustc-cfg=cares1_23");
}
}
}
4 changes: 4 additions & 0 deletions c-ares-sys/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 8.2.0 (30 November 2023)

- c-ares 1.23.0

## 8.1.1 (19 November 2023)

- c-ares 1.22.1
Expand Down
2 changes: 1 addition & 1 deletion c-ares-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "c-ares-sys"
license = "MIT"
version = "8.1.1"
version = "8.2.0"
authors = ["David Hotham"]
build = "build/main.rs"
links = "cares"
Expand Down
4 changes: 4 additions & 0 deletions c-ares-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ fn check_version(include_dirs: &[PathBuf]) {
if version >= 0x1_16_00 {
println!("cargo:rustc-cfg=cares1_22");
}

if version >= 0x1_17_00 {
println!("cargo:rustc-cfg=cares1_23");
}
}

fn parse_version(version: &str) -> u64 {
Expand Down
2 changes: 2 additions & 0 deletions c-ares-sys/build/vendored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn compile() {
.define("CARES_STATIC", "ON")
.define("CARES_SHARED", "OFF")
.define("CARES_BUILD_TOOLS", "OFF")
.define("CARES_THREADS", "OFF")
.define("CMAKE_INSTALL_LIBDIR", "lib")
.build();

Expand Down Expand Up @@ -118,6 +119,7 @@ fn compile() {
.arg("--enable-optimize")
.arg("--disable-debug")
.arg("--disable-tests")
.arg("--disable-cares-threads")
.arg(format!("--prefix={}", outdir.display()));

// This code fragment copied from curl-rust... c-ares and curl come from
Expand Down
2 changes: 1 addition & 1 deletion c-ares-sys/c-ares
Submodule c-ares updated 107 files
14 changes: 8 additions & 6 deletions c-ares-sys/ffi.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- src/ffi.rs.orig 2023-11-13 23:08:19.324968030 +0000
+++ src/ffi.rs 2023-11-13 23:09:51.754972525 +0000
--- src/ffi.rs.orig 2023-11-30 17:52:26.745674652 +0000
+++ src/ffi.rs 2023-11-30 17:53:17.697548304 +0000
@@ -1,14 +1,24 @@
/* automatically generated by rust-bindgen 0.69.1 */
+#![allow(non_camel_case_types, non_snake_case)]
Expand All @@ -18,7 +18,7 @@
+pub type ares_socket_t = ::std::os::windows::io::RawSocket;
+#[cfg(unix)]
+pub type ares_socket_t = ::std::os::unix::io::RawFd;

pub type ares_socklen_t = socklen_t;
pub type ares_ssize_t = isize;
-pub type in_addr_t = u32;
Expand All @@ -40,7 +40,7 @@
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum ares_bool_t {
ARES_FALSE = 0,
@@ -78,9 +88,13 @@
@@ -78,10 +88,15 @@
pub sortlist: *mut apattern,
pub nsort: ::std::os::raw::c_int,
pub ednspsz: ::std::os::raw::c_int,
Expand All @@ -52,17 +52,19 @@
pub udp_max_queries: ::std::os::raw::c_int,
+ #[cfg(cares1_22)]
pub maxtimeout: ::std::os::raw::c_int,
+ #[cfg(cares1_23)]
pub qcache_max_ttl: ::std::os::raw::c_uint,
}
#[repr(C)]
@@ -572,6 +586,7 @@
@@ -573,6 +588,7 @@
pub struct ares_addrinfo {
pub cnames: *mut ares_addrinfo_cname,
pub nodes: *mut ares_addrinfo_node,
+ #[cfg(cares1_18)]
pub name: *mut ::std::os::raw::c_char,
}
#[repr(C)]
@@ -1517,3 +1532,17 @@
@@ -1522,3 +1538,17 @@
buf_len: *mut usize,
) -> ares_status_t;
}
Expand Down
1 change: 1 addition & 0 deletions c-ares-sys/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub const ARES_OPT_RESOLVCONF: c_int = 1 << 17;
pub const ARES_OPT_HOSTS_FILE: c_int = 1 << 18;
pub const ARES_OPT_UDP_MAX_QUERIES: c_int = 1 << 19;
pub const ARES_OPT_MAXTIMEOUTMS: c_int = 1 << 20;
pub const ARES_OPT_QUERY_CACHE: c_int = 1 << 21;

// Flags for nameinfo queries
pub const ARES_NI_NOFQDN: c_int = 1;
Expand Down
8 changes: 7 additions & 1 deletion c-ares-sys/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub struct ares_options {
pub udp_max_queries: ::std::os::raw::c_int,
#[cfg(cares1_22)]
pub maxtimeout: ::std::os::raw::c_int,
#[cfg(cares1_23)]
pub qcache_max_ttl: ::std::os::raw::c_uint,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -779,6 +781,10 @@ extern "C" {
dst: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Whether or not the c-ares library was built with threadsafety\n\n \\return ARES_TRUE if built with threadsafety, ARES_FALSE if not"]
pub fn ares_threadsafety() -> ares_bool_t;
}
#[repr(u32)]
#[doc = " DNS Record types handled by c-ares. Some record types may only be valid\n on requests (e.g. ARES_REC_TYPE_ANY), and some may only be valid on\n responses"]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
Expand Down Expand Up @@ -896,7 +902,7 @@ pub enum ares_dns_rcode_t {
ARES_RCODE_NXDOMAIN = 3,
#[doc = "< Not implemented. The name server does\n not support the requested kind of\n query"]
ARES_RCODE_NOTIMP = 4,
#[doc = "< Refused. The name server refuses to\n perform the speciied operation for\n policy reasons."]
#[doc = "< Refused. The name server refuses to\n perform the specified operation for\n policy reasons."]
ARES_RCODE_REFUSED = 5,
#[doc = "< RFC 2136. Some name that ought not to\n exist, does exist."]
ARES_RCODE_YXDOMAIN = 6,
Expand Down
6 changes: 6 additions & 0 deletions examples/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ extern crate c_ares;
fn main() {
let (vstr, vint) = c_ares::version();
println!("Version {:x} ({})", vint, vstr);

#[cfg(cares1_23)]
{
let safety = c_ares::thread_safety();
println!("Built with thread-safety? {}", safety);
}
}
13 changes: 13 additions & 0 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ impl Options {
self.optmask |= c_ares_sys::ARES_OPT_MAXTIMEOUTMS;
self
}

/// Enable the built-in query cache. Will cache queries based on the returned TTL in the DNS
/// message. Only fully successful and NXDOMAIN query results will be cached.
///
/// The provided value is the maximum number of seconds a query result may be cached; this will
/// override a larger TTL in the response message. This must be a non-zero value otherwise the
/// cache will be disabled.
#[cfg(cares1_23)]
pub fn set_query_cache_max_ttl(&mut self, qcache_max_ttl: u32) -> &mut Self {
self.ares_options.qcache_max_ttl = qcache_max_ttl;
self.optmask |= c_ares_sys::ARES_OPT_QUERY_CACHE;
self
}
}

/// A channel for name service lookups.
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ pub use crate::srv::{SRVResult, SRVResults, SRVResultsIter};
pub use crate::txt::{TXTResult, TXTResults, TXTResultsIter};
pub use crate::types::{AddressFamily, Socket, SOCKET_BAD};
pub use crate::uri::{URIResult, URIResults, URIResultsIter};
#[cfg(cares1_23)]
pub use crate::utils::thread_safety;
pub use crate::utils::version;
10 changes: 10 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,13 @@ pub fn version() -> (&'static str, u32) {
};
(str_version, int_version as u32)
}

/// Whether the underlying `c-ares` library was built with thread safety enabled or not.
///
/// This is unlikely to be of interest to users of this crate. Our API assumes that c-ares was not
/// built with thread safety, and uses Rust's safety features to prevent errors.
#[cfg(cares1_23)]
pub fn thread_safety() -> bool {
let safety = unsafe { c_ares_sys::ares_threadsafety() };
safety != c_ares_sys::ares_bool_t::ARES_FALSE
}

0 comments on commit 2caa507

Please sign in to comment.