diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index dea2f017..6aa923e3 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -526,6 +526,28 @@ impl RendezvousServer { msg_out.set_test_nat_response(res); Self::send_to_sink(sink, msg_out).await; } + Some(rendezvous_message::Union::OnlineRequest(or)) => { + log::debug!("OnlineRequest payload={:?}", or); + // copy from function handle_online_request() + let mut states = BytesMut::zeroed((or.peers.len() + 7) / 8); + for (i, peer_id) in or.peers.iter().enumerate() { + if let Some(peer) = self.pm.get_in_memory(peer_id).await { + let elapsed = peer.read().await.last_reg_time.elapsed().as_millis() as i32; + // bytes index from left to right + let states_idx = i / 8; + let bit_idx = 7 - i % 8; + if elapsed < REG_TIMEOUT { + states[states_idx] |= 0x01 << bit_idx; + } + } + } + let mut msg_out = RendezvousMessage::new(); + msg_out.set_online_response(OnlineResponse { + states: states.into(), + ..Default::default() + }); + Self::send_to_sink(sink, msg_out).await; + } Some(rendezvous_message::Union::RegisterPk(rk)) => { let response = self.handle_register_pk(rk, addr).await; match response {