pub async fn interface_discovery(
    port: NonZeroU16,
    e: events::Queue<DaemonEvent>,
    discovery_interval: Duration,
) {
    log::debug!("Starting Zedboot discovery");
    // See fxbug.dev/62617#c10 for details. A macOS system can end up in
    // a situation where the default routes for protocols are on
    // non-functional interfaces, and under such conditions the wildcard
    // listen socket binds will fail. We will repeat attempting to bind
    // them, as newly added interfaces later may unstick the issue, if
    // they introduce new routes. These boolean flags are used to
    // suppress the production of a log output in every interface
    // iteration.
    // In order to manually reproduce these conditions on a macOS
    // system, open Network.prefpane, and for each connection in the
    // list select Advanced... > TCP/IP > Configure IPv6 > Link-local
    // only. Click apply, then restart the ffx daemon.
    let mut should_log_v6_listen_error = true;
    let mut v6_listen_socket: Weak<UdpSocket> = Weak::new();
    loop {
        // fxb/90219 - disabled by default
        let is_enabled: bool = ffx_config::get("discovery.zedboot.enabled").await.unwrap_or(false);
        if is_enabled {
            if v6_listen_socket.upgrade().is_none() {
                match make_listen_socket((ZEDBOOT_MCAST_V6, port.get()).into())
                    .context("make_listen_socket for IPv6")
                {
                    Ok(sock) => {
                        let sock = Arc::new(sock);
                        v6_listen_socket = Arc::downgrade(&sock);
                        Task::local(recv_loop(sock.clone(), e.clone())).detach();
                        should_log_v6_listen_error = true;
                    }
                    Err(err) => {
                        if should_log_v6_listen_error {
                            log::error!(
                                "unable to bind IPv6 listen socket: {}. Discovery may fail.",
                                err
                            );
                            should_log_v6_listen_error = false;
                        }
                    }
                }
            }

            for iface in get_mcast_interfaces().unwrap_or(Vec::new()) {
                match iface.id() {
                    Ok(id) => {
                        if let Some(sock) = v6_listen_socket.upgrade() {
                            let _ = sock.join_multicast_v6(&ZEDBOOT_MCAST_V6, id);
                        }
                    }
                    Err(err) => {
                        log::warn!("{}", err);
                    }
                }
            }
        }
        Timer::new(discovery_interval).await;
    }
}
// interface_discovery iterates over all multicast interfaces
interface_discovery iterates over all multicast interfaces
interface_discovery iterates over all multicast interfaces
pub async fn interface_discovery(
    port: NonZeroU16,
    e: events::Queue<DaemonEvent>,
    discovery_interval: Duration,
) {
    log::debug!("Starting Zedboot discovery");
    // See fxbug.dev/62617#c10 for details. A macOS system can end up in
    // a situation where the default routes for protocols are on
    // non-functional interfaces, and under such conditions the wildcard
    // listen socket binds will fail. We will repeat attempting to bind
    // them, as newly added interfaces later may unstick the issue, if
    // they introduce new routes. These boolean flags are used to
    // suppress the production of a log output in every interface
    // iteration.
    // In order to manually reproduce these conditions on a macOS
    // system, open Network.prefpane, and for each connection in the
    // list select Advanced... > TCP/IP > Configure IPv6 > Link-local
    // only. Click apply, then restart the ffx daemon.
    let mut should_log_v6_listen_error = true;
    let mut v6_listen_socket: Weak<UdpSocket> = Weak::new();
    loop {
        // fxb/90219 - disabled by default
        let is_enabled: bool = ffx_config::get("discovery.zedboot.enabled").await.unwrap_or(false);
        if is_enabled {
            if v6_listen_socket.upgrade().is_none() {
                match make_listen_socket((ZEDBOOT_MCAST_V6, port.get()).into())
                    .context("make_listen_socket for IPv6")
                {
                    Ok(sock) => {
                        let sock = Arc::new(sock);
                        v6_listen_socket = Arc::downgrade(&sock);
                        Task::local(recv_loop(sock.clone(), e.clone())).detach();
                        should_log_v6_listen_error = true;
                    }
                    Err(err) => {
                        if should_log_v6_listen_error {
                            log::error!(
                                "unable to bind IPv6 listen socket: {}. Discovery may fail.",
                                err
                            );
                            should_log_v6_listen_error = false;
                        }
                    }
                }
            }
            for iface in get_mcast_interfaces().unwrap_or(Vec::new()) {
                match iface.id() {
                    Ok(id) => {
                        if let Some(sock) = v6_listen_socket.upgrade() {
                            let _ = sock.join_multicast_v6(&ZEDBOOT_MCAST_V6, id);
                        }
                    }
                    Err(err) => {
                        log::warn!("{}", err);
                    }
                }
            }
        }
        Timer::new(discovery_interval).await;
    }
}
pub async fn interface_discovery ( port : NonZeroU16 , e : events :: Queue < DaemonEvent > , discovery_interval : Duration , ) { log :: debug ! ( " " ) ; // See fxbug.dev/62617#c10 for details. A macOS system can end up in // a situation where the default routes for protocols are on // non-functional interfaces, and under such conditions the wildcard // listen socket binds will fail. We will repeat attempting to bind // them, as newly added interfaces later may unstick the issue, if // they introduce new routes. These boolean flags are used to // suppress the production of a log output in every interface // iteration. // In order to manually reproduce these conditions on a macOS // system, open Network.prefpane, and for each connection in the // list select Advanced... > TCP/IP > Configure IPv6 > Link-local // only. Click apply, then restart the ffx daemon. let mut should_log_v6_listen_error = true ; let mut v6_listen_socket : Weak < UdpSocket > = Weak :: new ( ) ; loop { // fxb/90219 - disabled by default let is_enabled : bool = ffx_config :: get ( " " ) . await . unwrap_or ( false ) ; if is_enabled { if v6_listen_socket . upgrade ( ) . is_none ( ) { match make_listen_socket ( ( ZEDBOOT_MCAST_V6 , port . get ( ) ) . into ( ) ) . context ( " " ) { Ok ( sock ) => { let sock = Arc :: new ( sock ) ; v6_listen_socket = Arc :: downgrade ( & sock ) ; Task :: local ( recv_loop ( sock . clone ( ) , e . clone ( ) ) ) . detach ( ) ; should_log_v6_listen_error = true ; } Err ( err ) => { if should_log_v6_listen_error { log :: error ! ( " " err ) ; should_log_v6_listen_error = false ; } } } } for iface in get_mcast_interfaces ( ) . unwrap_or ( Vec :: new ( ) ) { match iface . id ( ) { Ok ( id ) => { if let Some ( sock ) = v6_listen_socket . upgrade ( ) { let _ = sock . join_multicast_v6 ( & ZEDBOOT_MCAST_V6 , id ) ; } } Err ( err ) => { log :: warn ! ( " " err ) ; } } } } Timer :: new ( discovery_interval ) . await ; } }
interface_discovery iterates over all multicast interfaces
interface_discovery iterates over all multicast interfaces
port
NonZeroU16
e
events::Queue<DaemonEvent>
discovery_interval
Duration
port
NonZeroU16
e
events::Queue<DaemonEvent>
discovery_interval
Duration