Skip to content

Commit 2e07f54

Browse files
jxsrainliu
authored andcommitted
ice: Remove unused MulticastDnsMode:Unspecified variant.
1 parent ad21cf7 commit 2e07f54

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

ice/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Breaking changes
6+
7+
* remove non used `MulticastDnsMode::Unspecified` variant [#XXX](https://github.com/webrtc-rs/webrtc/pull/XXX):
8+
59
## v0.9.0
610

711
* Increased minimum support rust version to `1.60.0`.

ice/src/agent/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ impl Agent {
125125
return Err(Error::ErrInvalidMulticastDnshostName);
126126
}
127127

128-
let mut mdns_mode = config.multicast_dns_mode;
129-
if mdns_mode == MulticastDnsMode::Unspecified {
130-
mdns_mode = MulticastDnsMode::QueryOnly;
131-
}
128+
let mdns_mode = config.multicast_dns_mode;
132129

133130
let mdns_conn =
134131
match create_multicast_dns(mdns_mode, &mdns_name, &config.multicast_dns_dest_addr) {

ice/src/mdns/mod.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ use uuid::Uuid;
1414
/// Represents the different Multicast modes that ICE can run.
1515
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
1616
pub enum MulticastDnsMode {
17-
Unspecified,
18-
1917
/// Means remote mDNS candidates will be discarded, and local host candidates will use IPs.
2018
Disabled,
2119

@@ -28,7 +26,7 @@ pub enum MulticastDnsMode {
2826

2927
impl Default for MulticastDnsMode {
3028
fn default() -> Self {
31-
Self::Unspecified
29+
Self::QueryOnly
3230
}
3331
}
3432

@@ -44,9 +42,11 @@ pub(crate) fn create_multicast_dns(
4442
mdns_name: &str,
4543
dest_addr: &str,
4644
) -> Result<Option<Arc<DnsConn>>> {
47-
if mdns_mode == MulticastDnsMode::Disabled {
48-
return Ok(None);
49-
}
45+
let local_names = match mdns_mode {
46+
MulticastDnsMode::QueryOnly => vec![],
47+
MulticastDnsMode::QueryAndGather => vec![mdns_name.to_owned()],
48+
MulticastDnsMode::Disabled => return Ok(None),
49+
};
5050

5151
let addr = if dest_addr.is_empty() {
5252
//TODO: why DEFAULT_DEST_ADDR doesn't work on Mac/Win?
@@ -60,21 +60,12 @@ pub(crate) fn create_multicast_dns(
6060
};
6161
log::info!("mDNS is using {} as dest_addr", addr);
6262

63-
match mdns_mode {
64-
MulticastDnsMode::QueryOnly => {
65-
let conn = DnsConn::server(addr, Config::default())?;
66-
Ok(Some(Arc::new(conn)))
67-
}
68-
MulticastDnsMode::QueryAndGather => {
69-
let conn = DnsConn::server(
70-
addr,
71-
Config {
72-
local_names: vec![mdns_name.to_owned()],
73-
..Config::default()
74-
},
75-
)?;
76-
Ok(Some(Arc::new(conn)))
77-
}
78-
_ => Ok(None),
79-
}
63+
let conn = DnsConn::server(
64+
addr,
65+
Config {
66+
local_names,
67+
..Config::default()
68+
},
69+
)?;
70+
Ok(Some(Arc::new(conn)))
8071
}

webrtc/src/ice_transport/ice_gatherer.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,7 @@ impl RTCIceGatherer {
103103
_ => CandidateType::Unspecified,
104104
};
105105

106-
let mut mdns_mode = self.setting_engine.candidates.multicast_dns_mode;
107-
if mdns_mode != ice::mdns::MulticastDnsMode::Disabled
108-
&& mdns_mode != ice::mdns::MulticastDnsMode::QueryAndGather
109-
{
110-
// If enum is in state we don't recognized default to MulticastDNSModeQueryOnly
111-
mdns_mode = ice::mdns::MulticastDnsMode::QueryOnly;
112-
}
106+
let mdns_mode = self.setting_engine.candidates.multicast_dns_mode;
113107

114108
let mut config = ice::agent::agent_config::AgentConfig {
115109
udp_network: self.setting_engine.udp_network.clone(),

0 commit comments

Comments
 (0)