File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
transports/webrtc/src/tokio Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 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
2330use futures:: { channel:: oneshot, future:: Either } ;
2431use 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
You can’t perform that action at this time.
0 commit comments