mirror of
https://github.com/zhboner/realm.git
synced 2026-11-17 08:15:55 +00:00
use type converter
This commit is contained in:
@@ -22,14 +22,14 @@ impl Default for DnsMode {
|
||||
}
|
||||
}
|
||||
|
||||
impl DnsMode {
|
||||
pub fn to_strategy(self) -> LookupIpStrategy {
|
||||
match self {
|
||||
Self::Ipv4Only => LookupIpStrategy::Ipv4Only,
|
||||
Self::Ipv6Only => LookupIpStrategy::Ipv6Only,
|
||||
Self::Ipv4AndIpv6 => LookupIpStrategy::Ipv4AndIpv6,
|
||||
Self::Ipv4ThenIpv6 => LookupIpStrategy::Ipv4thenIpv6,
|
||||
Self::Ipv6ThenIpv4 => LookupIpStrategy::Ipv6thenIpv4,
|
||||
impl From<DnsMode> for LookupIpStrategy {
|
||||
fn from(mode: DnsMode) -> Self {
|
||||
match mode {
|
||||
DnsMode::Ipv4Only => LookupIpStrategy::Ipv4Only,
|
||||
DnsMode::Ipv6Only => LookupIpStrategy::Ipv6Only,
|
||||
DnsMode::Ipv4AndIpv6 => LookupIpStrategy::Ipv4AndIpv6,
|
||||
DnsMode::Ipv4ThenIpv6 => LookupIpStrategy::Ipv4thenIpv6,
|
||||
DnsMode::Ipv6ThenIpv4 => LookupIpStrategy::Ipv6thenIpv4,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ fn main() {
|
||||
|
||||
fn start_from_config(c: String) {
|
||||
let config = GlobalConfig::from_config_file(&c);
|
||||
relay::init_resolver(config.dns_mode.to_strategy());
|
||||
relay::init_resolver(config.dns_mode.into());
|
||||
let eps: Vec<Endpoint> = config
|
||||
.endpoints
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user