(self, request: GetInfoRequest)
| 104 | } |
| 105 | |
| 106 | async fn get_info(self, request: GetInfoRequest) -> Result<GetInfoResponse> { |
| 107 | let (base_domain, _port) = self |
| 108 | .state |
| 109 | .kv_store() |
| 110 | .get_best_zt_domain() |
| 111 | .unwrap_or_default(); |
| 112 | let state = self.state.lock(); |
| 113 | let handshakes = state.latest_handshakes(None)?; |
| 114 | |
| 115 | if let Some(instance) = state.state.instances.get(&request.id) { |
| 116 | let host_info = HostInfo { |
| 117 | instance_id: instance.id.clone(), |
| 118 | ip: instance.ip.to_string(), |
| 119 | app_id: instance.app_id.clone(), |
| 120 | base_domain, |
| 121 | latest_handshake: { |
| 122 | let (ts, _) = handshakes |
| 123 | .get(&instance.public_key) |
| 124 | .copied() |
| 125 | .unwrap_or_default(); |
| 126 | ts |
| 127 | }, |
| 128 | num_connections: instance.num_connections(), |
| 129 | }; |
| 130 | Ok(GetInfoResponse { |
| 131 | found: true, |
| 132 | info: Some(host_info), |
| 133 | }) |
| 134 | } else { |
| 135 | Ok(GetInfoResponse { |
| 136 | found: false, |
| 137 | info: None, |
| 138 | }) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | async fn get_meta(self) -> Result<GetMetaResponse> { |
| 143 | let state = self.state.lock(); |
nothing calls this directly
no test coverage detected