Skip to content

Commit fa3ff17

Browse files
committed
Logic reflow suggestion
1 parent 0263f11 commit fa3ff17

File tree

1 file changed

+26
-31
lines changed

1 file changed

+26
-31
lines changed

nts-pool-monitor/src/probe.rs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,44 +102,39 @@ impl Probe {
102102
Err(e)
103103
if e.kind() == std::io::ErrorKind::NotFound || e.raw_os_error().is_none() =>
104104
{
105+
let (status, description);
105106
if resolve_as_version((domain.as_ref(), port), ipprot.other_ip_protocol())
106107
.await
107108
.is_ok()
108109
{
109-
return Ok((
110-
KeyExchangeProbeResult {
111-
status: match ipprot {
112-
IpVersion::Ipv4 => KeyExchangeStatus::Failed,
113-
IpVersion::Ipv6 => KeyExchangeStatus::Failed,
114-
IpVersion::Srvv4 => KeyExchangeStatus::SrvIpv6Only,
115-
IpVersion::Srvv6 => KeyExchangeStatus::SrvIpv4Only,
116-
},
117-
description: "Only resolvable over other IP version".into(),
118-
exchange_start: SystemTime::now()
119-
.duration_since(SystemTime::UNIX_EPOCH)
120-
.unwrap_or_default()
121-
.as_secs(),
122-
exchange_duration: 0.0,
123-
num_cookies: 0,
124-
},
125-
None,
126-
));
110+
status = match ipprot {
111+
IpVersion::Ipv4 => KeyExchangeStatus::Failed,
112+
IpVersion::Ipv6 => KeyExchangeStatus::Failed,
113+
IpVersion::Srvv4 => KeyExchangeStatus::SrvIpv6Only,
114+
IpVersion::Srvv6 => KeyExchangeStatus::SrvIpv4Only,
115+
};
116+
description = "Only resolvable over other IP version".into();
127117
} else {
128-
return Ok((
129-
KeyExchangeProbeResult {
130-
status: KeyExchangeStatus::Failed,
131-
description: "Domain name not resolvable".into(),
132-
exchange_start: SystemTime::now()
133-
.duration_since(SystemTime::UNIX_EPOCH)
134-
.unwrap_or_default()
135-
.as_secs(),
136-
exchange_duration: 0.0,
137-
num_cookies: 0,
138-
},
139-
None,
140-
));
118+
status = KeyExchangeStatus::Failed;
119+
description = "Domain name not resolvable".into();
141120
}
121+
122+
return Ok((
123+
KeyExchangeProbeResult {
124+
status,
125+
description,
126+
exchange_start: SystemTime::now()
127+
.duration_since(SystemTime::UNIX_EPOCH)
128+
.unwrap_or_default()
129+
.as_secs(),
130+
131+
exchange_duration: 0.0,
132+
num_cookies: 0,
133+
},
134+
None,
135+
));
142136
}
137+
143138
Err(e) => return Err(e.into()),
144139
}
145140
} else {

0 commit comments

Comments
 (0)