Skip to content

Commit

Permalink
preparing for c-ares 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Oct 14, 2023
1 parent 0e9bc53 commit a528fbe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion c-ares-sys/c-ares
Submodule c-ares updated 274 files
8 changes: 4 additions & 4 deletions c-ares-sys/ffi.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- src/ffi.rs.orig 2023-05-04 16:08:51.671439524 +0100
+++ src/ffi.rs 2023-05-04 16:11:25.431331417 +0100
--- src/ffi.rs.orig 2023-10-06 21:01:06.294030877 +0100
+++ src/ffi.rs 2023-10-06 21:01:20.774032176 +0100
@@ -1,13 +1,23 @@
/* automatically generated by rust-bindgen 0.65.1 */
/* automatically generated by rust-bindgen 0.68.1 */
+#![allow(non_camel_case_types, non_snake_case)]
+use c_types::fd_set;
+use c_types::hostent;
Expand Down Expand Up @@ -30,7 +30,7 @@
pub type ares_sock_state_cb = ::std::option::Option<
unsafe extern "C" fn(
data: *mut ::std::os::raw::c_void,
@@ -694,3 +704,17 @@
@@ -695,3 +705,17 @@
dst: *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int;
}
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 @@ -65,6 +65,7 @@ pub const ARES_OPT_EDNSPSZ: c_int = 1 << 15;
pub const ARES_OPT_NOROTATE: c_int = 1 << 16;
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;

// Flags for nameinfo queries
pub const ARES_NI_NOFQDN: c_int = 1;
Expand Down
3 changes: 2 additions & 1 deletion c-ares-sys/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* automatically generated by rust-bindgen 0.65.1 */
/* automatically generated by rust-bindgen 0.68.1 */
#![allow(non_camel_case_types, non_snake_case)]
use c_types::fd_set;
use c_types::hostent;
Expand Down Expand Up @@ -54,6 +54,7 @@ pub struct ares_options {
pub ednspsz: ::std::os::raw::c_int,
pub resolvconf_path: *mut ::std::os::raw::c_char,
pub hosts_path: *mut ::std::os::raw::c_char,
pub udp_max_queries: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
13 changes: 11 additions & 2 deletions src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ impl Options {

/// Set the number of milliseconds each name server is given to respond to a query on the first
/// try. (After the first try, the timeout algorithm becomes more complicated, but scales
/// linearly with the value of timeout). The default is 5000ms.
/// linearly with the value of timeout). The default is 2000ms.
pub fn set_timeout(&mut self, ms: u32) -> &mut Self {
self.ares_options.timeout = ms as c_int;
self.optmask |= c_ares_sys::ARES_OPT_TIMEOUTMS;
self
}

/// Set the number of tries the resolver will try contacting each name server before giving up.
/// The default is four tries.
/// The default is three tries.
pub fn set_tries(&mut self, tries: u32) -> &mut Self {
self.ares_options.tries = tries as c_int;
self.optmask |= c_ares_sys::ARES_OPT_TRIES;
Expand Down Expand Up @@ -153,6 +153,15 @@ impl Options {
self
}

/// The maximum number of udp queries that can be sent on a single ephermeral port to a given
/// DNS server before a new ephemeral port is assigned. Any value of 0 or less will be
/// considered unlimited, and is the default.
pub fn set_udp_max_queries(&mut self, udp_max_queries: i32) -> &mut Self {
self.ares_options.udp_max_queries = udp_max_queries;
self.optmask |= c_ares_sys::ARES_OPT_UDP_MAX_QUERIES;
self
}

/// Set the callback function to be invoked when a socket changes state.
///
/// `callback(socket, read, write)` will be called when a socket changes state:
Expand Down

0 comments on commit a528fbe

Please sign in to comment.