-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added wrapper type and todos * modified code to support ipv4 or ipv6 connection * added function for iplookup and made enums in separate file * added the required enum and made the required changes * added functionality to respect ip version preferences * fixed the logic for calcuating the delay * addressed the parameters issue
- Loading branch information
1 parent
bb55530
commit caf3a0d
Showing
3 changed files
with
120 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
/// Enum representing the IP modes that can be used by the DNS resolver. | ||
pub enum DnsResolveIpMode { | ||
#[default] | ||
Dual, | ||
SingleIpV4, | ||
SingleIpV6, | ||
DualPreferIpV4, | ||
} | ||
|
||
impl DnsResolveIpMode { | ||
/// checks if IPv4 is supported in current mode | ||
pub fn ipv4_supported(&self) -> bool { | ||
matches!( | ||
self, | ||
DnsResolveIpMode::Dual | ||
| DnsResolveIpMode::SingleIpV4 | ||
| DnsResolveIpMode::DualPreferIpV4 | ||
) | ||
} | ||
|
||
/// checks if IPv6 is supported in current mode | ||
pub fn ipv6_supported(&self) -> bool { | ||
matches!( | ||
self, | ||
DnsResolveIpMode::Dual | ||
| DnsResolveIpMode::SingleIpV6 | ||
| DnsResolveIpMode::DualPreferIpV4 | ||
) | ||
} | ||
} | ||
///Mode for establishing a connection | ||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
pub enum ConnectIpMode { | ||
#[default] | ||
Dual, | ||
Ipv4, | ||
Ipv6, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters