Skip to content

Commit b972c60

Browse files
committed
fix smoke test
1 parent 32283df commit b972c60

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

transports/webrtc/src/tokio/upgrade.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1919
// DEALINGS IN THE SOFTWARE.
2020

21-
use std::{net::SocketAddr, sync::Arc, time::Duration};
21+
use std::{
22+
net::SocketAddr,
23+
sync::{
24+
atomic::{AtomicBool, Ordering},
25+
Arc,
26+
},
27+
time::Duration,
28+
};
2229

2330
use futures::{channel::oneshot, future::Either};
2431
use futures_timer::Delay;
@@ -172,6 +179,20 @@ fn setting_engine(
172179
};
173180
se.set_network_types(vec![network_type]);
174181

182+
// Select only the first address of the local candidates.
183+
// See https://github.com/libp2p/rust-libp2p/pull/5448#discussion_r2017418520.
184+
// TODO: remove when https://github.com/webrtc-rs/webrtc/issues/662 get's addressed.
185+
se.set_ip_filter(Box::new({
186+
let once = AtomicBool::new(true);
187+
move |_ip| {
188+
if once.load(Ordering::Relaxed) {
189+
once.store(false, Ordering::Relaxed);
190+
return true;
191+
}
192+
false
193+
}
194+
}));
195+
175196
se
176197
}
177198

0 commit comments

Comments
 (0)