main.rs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2024 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. use std::{
  19. collections::{HashMap, HashSet},
  20. sync::Arc,
  21. };
  22. use async_trait::async_trait;
  23. use log::{debug, error, info, warn};
  24. use smol::{
  25. channel,
  26. fs::File,
  27. lock::{Mutex, MutexGuard, RwLock},
  28. stream::StreamExt,
  29. Executor,
  30. };
  31. use structopt_toml::{structopt::StructOpt, StructOptToml};
  32. use tinyjson::JsonValue;
  33. use url::Url;
  34. use darkfi::{
  35. async_daemonize, cli_desc,
  36. geode::Geode,
  37. net::{
  38. self, connector::Connector, protocol::ProtocolVersion, session::Session,
  39. settings::SettingsOpt, P2p, P2pPtr,
  40. },
  41. rpc::{
  42. jsonrpc::{ErrorCode, JsonError, JsonRequest, JsonResponse, JsonResult},
  43. server::{listen_and_serve, RequestHandler},
  44. },
  45. system::{StoppableTask, StoppableTaskPtr},
  46. util::path::expand_path,
  47. Error, Result,
  48. };
  49. /// P2P protocols
  50. mod proto;
  51. use proto::{
  52. FudChunkPut, FudChunkReply, FudChunkRequest, FudFilePut, FudFileReply, FudFileRequest,
  53. ProtocolFud,
  54. };
  55. const CONFIG_FILE: &str = "fud_config.toml";
  56. const CONFIG_FILE_CONTENTS: &str = include_str!("../fud_config.toml");
  57. #[derive(Clone, Debug, serde::Deserialize, StructOpt, StructOptToml)]
  58. #[serde(default)]
  59. #[structopt(name = "fud", about = cli_desc!())]
  60. struct Args {
  61. #[structopt(short, parse(from_occurrences))]
  62. /// Increase verbosity (-vvv supported)
  63. verbose: u8,
  64. #[structopt(long, default_value = "tcp://127.0.0.1:13336")]
  65. /// JSON-RPC listen URL
  66. rpc_listen: Url,
  67. #[structopt(short, long)]
  68. /// Configuration file to use
  69. config: Option<String>,
  70. #[structopt(long)]
  71. /// Set log file path to output daemon logs into
  72. log: Option<String>,
  73. #[structopt(long, default_value = "~/.local/share/fud")]
  74. /// Base directory for filesystem storage
  75. base_dir: String,
  76. #[structopt(flatten)]
  77. /// Network settings
  78. net: SettingsOpt,
  79. }
  80. pub struct Fud {
  81. /// Routing table for file metadata
  82. metadata_router: Arc<RwLock<HashMap<blake3::Hash, HashSet<Url>>>>,
  83. /// Routing table for file chunks
  84. chunks_router: Arc<RwLock<HashMap<blake3::Hash, HashSet<Url>>>>,
  85. /// Pointer to the P2P network instance
  86. p2p: P2pPtr,
  87. /// The Geode instance
  88. geode: Geode,
  89. file_fetch_tx: channel::Sender<(blake3::Hash, Result<()>)>,
  90. file_fetch_rx: channel::Receiver<(blake3::Hash, Result<()>)>,
  91. chunk_fetch_tx: channel::Sender<(blake3::Hash, Result<()>)>,
  92. chunk_fetch_rx: channel::Receiver<(blake3::Hash, Result<()>)>,
  93. rpc_connections: Mutex<HashSet<StoppableTaskPtr>>,
  94. }
  95. #[async_trait]
  96. impl RequestHandler<()> for Fud {
  97. async fn handle_request(&self, req: JsonRequest) -> JsonResult {
  98. return match req.method.as_str() {
  99. "ping" => self.pong(req.id, req.params).await,
  100. "put" => self.put(req.id, req.params).await,
  101. "get" => self.get(req.id, req.params).await,
  102. "dnet_switch" => self.dnet_switch(req.id, req.params).await,
  103. _ => JsonError::new(ErrorCode::MethodNotFound, None, req.id).into(),
  104. }
  105. }
  106. async fn connections_mut(&self) -> MutexGuard<'_, HashSet<StoppableTaskPtr>> {
  107. self.rpc_connections.lock().await
  108. }
  109. }
  110. impl Fud {
  111. // RPCAPI:
  112. // Put a file onto the network. Takes a local filesystem path as a parameter.
  113. // Returns the file hash that serves as a pointer to the uploaded file.
  114. //
  115. // --> {"jsonrpc": "2.0", "method": "put", "params": ["/foo.txt"], "id": 42}
  116. // <-- {"jsonrpc": "2.0", "result: "df4...3db7", "id": 42}
  117. async fn put(&self, id: u16, params: JsonValue) -> JsonResult {
  118. let params = params.get::<Vec<JsonValue>>().unwrap();
  119. if params.len() != 1 || !params[0].is_string() {
  120. return JsonError::new(ErrorCode::InvalidParams, None, id).into()
  121. }
  122. let path = params[0].get::<String>().unwrap();
  123. let path = match expand_path(path.as_str()) {
  124. Ok(v) => v,
  125. Err(_) => return JsonError::new(ErrorCode::InvalidParams, None, id).into(),
  126. };
  127. // A valid path was passed. Let's see if we can read it, and if so,
  128. // add it to Geode.
  129. let fd = match File::open(&path).await {
  130. Ok(v) => v,
  131. Err(e) => {
  132. error!("Failed to open {:?}: {}", path, e);
  133. return JsonError::new(ErrorCode::InvalidParams, None, id).into()
  134. }
  135. };
  136. let (file_hash, chunk_hashes) = match self.geode.insert(fd).await {
  137. Ok(v) => v,
  138. Err(e) => {
  139. error!("Failed inserting file {:?} to geode: {}", path, e);
  140. return JsonError::new(ErrorCode::InternalError, None, id).into()
  141. }
  142. };
  143. let fud_file = FudFilePut { file_hash, chunk_hashes };
  144. self.p2p.broadcast(&fud_file).await;
  145. JsonResponse::new(JsonValue::String(file_hash.to_hex().to_string()), id).into()
  146. }
  147. // RPCAPI:
  148. // Fetch a file from the network. Takes a file hash as parameter.
  149. // Returns the paths to the local chunks of the file, if found/fetched.
  150. //
  151. // --> {"jsonrpc": "2.0", "method": "get", "params": ["1211...abfd"], "id": 42}
  152. // <-- {"jsonrpc": "2.0", "result: ["~/.local/share/fud/chunks/fab1...2314", ...], "id": 42}
  153. async fn get(&self, id: u16, params: JsonValue) -> JsonResult {
  154. let params = params.get::<Vec<JsonValue>>().unwrap();
  155. if params.len() != 1 || !params[0].is_string() {
  156. return JsonError::new(ErrorCode::InvalidParams, None, id).into()
  157. }
  158. let file_hash = match blake3::Hash::from_hex(params[0].get::<String>().unwrap()) {
  159. Ok(v) => v,
  160. Err(_) => return JsonError::new(ErrorCode::InvalidParams, None, id).into(),
  161. };
  162. let chunked_file = match self.geode.get(&file_hash).await {
  163. Ok(v) => v,
  164. Err(Error::GeodeNeedsGc) => todo!(),
  165. Err(Error::GeodeFileNotFound) => {
  166. info!("Requested file {} not found in Geode, triggering fetch", file_hash);
  167. self.file_fetch_tx.send((file_hash, Ok(()))).await.unwrap();
  168. info!("Waiting for background file fetch task...");
  169. let (i_file_hash, status) = self.file_fetch_rx.recv().await.unwrap();
  170. match status {
  171. Ok(()) => {
  172. let ch_file = self.geode.get(&file_hash).await.unwrap();
  173. let m = FudFilePut {
  174. file_hash: i_file_hash,
  175. chunk_hashes: ch_file.iter().map(|(h, _)| *h).collect(),
  176. };
  177. self.p2p.broadcast(&m).await;
  178. ch_file
  179. }
  180. Err(Error::GeodeFileRouteNotFound) => {
  181. // TODO: Return FileNotFound error
  182. return JsonError::new(ErrorCode::InternalError, None, id).into()
  183. }
  184. Err(e) => panic!("{}", e),
  185. }
  186. }
  187. Err(e) => panic!("{}", e),
  188. };
  189. if chunked_file.is_complete() {
  190. let chunks: Vec<JsonValue> = chunked_file
  191. .iter()
  192. .map(|(_, path)| {
  193. JsonValue::String(
  194. path.as_ref().unwrap().clone().into_os_string().into_string().unwrap(),
  195. )
  196. })
  197. .collect();
  198. return JsonResponse::new(JsonValue::Array(chunks), id).into()
  199. }
  200. // Fetch any missing chunks
  201. let mut missing_chunks = vec![];
  202. for (chunk, path) in chunked_file.iter() {
  203. if path.is_none() {
  204. missing_chunks.push(*chunk);
  205. }
  206. }
  207. for chunk in missing_chunks {
  208. self.chunk_fetch_tx.send((chunk, Ok(()))).await.unwrap();
  209. let (i_chunk_hash, status) = self.chunk_fetch_rx.recv().await.unwrap();
  210. match status {
  211. Ok(()) => {
  212. let m = FudChunkPut { chunk_hash: i_chunk_hash };
  213. self.p2p.broadcast(&m).await;
  214. break
  215. }
  216. Err(Error::GeodeChunkRouteNotFound) => continue,
  217. Err(e) => panic!("{}", e),
  218. }
  219. }
  220. let chunked_file = match self.geode.get(&file_hash).await {
  221. Ok(v) => v,
  222. Err(e) => panic!("{}", e),
  223. };
  224. if !chunked_file.is_complete() {
  225. todo!();
  226. // Return JsonError missing chunks
  227. }
  228. let chunks: Vec<JsonValue> = chunked_file
  229. .iter()
  230. .map(|(_, path)| {
  231. JsonValue::String(
  232. path.as_ref().unwrap().clone().into_os_string().into_string().unwrap(),
  233. )
  234. })
  235. .collect();
  236. JsonResponse::new(JsonValue::Array(chunks), id).into()
  237. }
  238. // RPCAPI:
  239. // Activate or deactivate dnet in the P2P stack.
  240. // By sending `true`, dnet will be activated, and by sending `false` dnet
  241. // will be deactivated. Returns `true` on success.
  242. //
  243. // --> {"jsonrpc": "2.0", "method": "dnet_switch", "params": [true], "id": 42}
  244. // <-- {"jsonrpc": "2.0", "result": true, "id": 42}
  245. async fn dnet_switch(&self, id: u16, params: JsonValue) -> JsonResult {
  246. let params = params.get::<Vec<JsonValue>>().unwrap();
  247. if params.len() != 1 || !params[0].is_bool() {
  248. return JsonError::new(ErrorCode::InvalidParams, None, id).into()
  249. }
  250. let switch = params[0].get::<bool>().unwrap();
  251. if *switch {
  252. self.p2p.dnet_enable().await;
  253. } else {
  254. self.p2p.dnet_disable().await;
  255. }
  256. JsonResponse::new(JsonValue::Boolean(true), id).into()
  257. }
  258. }
  259. /// Background task that receives file fetch requests and tries to
  260. /// fetch objects from the network using the routing table.
  261. /// TODO: This can be optimised a lot for connection reuse, etc.
  262. async fn fetch_file_task(fud: Arc<Fud>, executor: Arc<Executor<'_>>) -> Result<()> {
  263. info!("Started background file fetch task");
  264. loop {
  265. let (file_hash, _) = fud.file_fetch_rx.recv().await.unwrap();
  266. info!("fetch_file_task: Received {}", file_hash);
  267. let mut metadata_router = fud.metadata_router.write().await;
  268. let peers = metadata_router.get_mut(&file_hash);
  269. if peers.is_none() {
  270. warn!("File {} not in routing table, cannot fetch", file_hash);
  271. fud.file_fetch_tx.send((file_hash, Err(Error::GeodeFileRouteNotFound))).await.unwrap();
  272. continue
  273. }
  274. let mut found = false;
  275. let peers = peers.unwrap();
  276. let mut invalid_file_routes = vec![];
  277. for peer in peers.iter() {
  278. let session_out = fud.p2p.session_outbound();
  279. let session_weak = Arc::downgrade(&fud.p2p.session_outbound());
  280. info!("Connecting to {} to fetch {}", peer, file_hash);
  281. let connector = Connector::new(fud.p2p.settings(), session_weak);
  282. match connector.connect(peer).await {
  283. Ok((url, channel)) => {
  284. let proto_ver = ProtocolVersion::new(
  285. channel.clone(),
  286. fud.p2p.settings().clone(),
  287. fud.p2p.hosts().clone(),
  288. )
  289. .await;
  290. let handshake_task = session_out.perform_handshake_protocols(
  291. proto_ver,
  292. channel.clone(),
  293. executor.clone(),
  294. );
  295. channel.clone().start(executor.clone());
  296. if let Err(e) = handshake_task.await {
  297. error!("Handshake with {} failed: {}", url, e);
  298. // Delete peer from router
  299. invalid_file_routes.push(peer.clone());
  300. continue
  301. }
  302. let msg_subscriber = channel.subscribe_msg::<FudFileReply>().await.unwrap();
  303. let request = FudFileRequest { file_hash };
  304. if let Err(e) = channel.send(&request).await {
  305. error!("Failed sending FudFileRequest({}) to {}: {}", file_hash, url, e);
  306. continue
  307. }
  308. // TODO: With timeout!
  309. let reply = match msg_subscriber.receive().await {
  310. Ok(v) => v,
  311. Err(e) => {
  312. error!("Error receiving FudFileReply from subscriber: {}", e);
  313. continue
  314. }
  315. };
  316. msg_subscriber.unsubscribe().await;
  317. channel.stop().await;
  318. if let Err(e) = fud.geode.insert_file(&file_hash, &reply.chunk_hashes).await {
  319. error!("Failed inserting file {} to Geode: {}", file_hash, e);
  320. continue
  321. }
  322. found = true;
  323. break
  324. }
  325. Err(e) => {
  326. error!("Failed to connect to {}: {}", peer, e);
  327. continue
  328. }
  329. }
  330. }
  331. for peer in invalid_file_routes {
  332. debug!("Removing peer {} from {} file router", peer, file_hash);
  333. peers.remove(&peer);
  334. }
  335. if !found {
  336. warn!("Did not manage to fetch {} file metadata", file_hash);
  337. fud.file_fetch_tx.send((file_hash, Err(Error::GeodeFileRouteNotFound))).await.unwrap();
  338. continue
  339. }
  340. info!("Successfully fetched {} file metadata", file_hash);
  341. fud.file_fetch_tx.send((file_hash, Ok(()))).await.unwrap();
  342. }
  343. }
  344. /// Background task that receives chunk fetch requests and tries to
  345. /// fetch objects from the network using the routing table.
  346. /// TODO: This can be optimised a lot for connection reuse, etc.
  347. async fn fetch_chunk_task(fud: Arc<Fud>, executor: Arc<Executor<'_>>) -> Result<()> {
  348. info!("Started background chunk fetch task");
  349. loop {
  350. let (chunk_hash, _) = fud.chunk_fetch_rx.recv().await.unwrap();
  351. info!("fetch_chunk_task: Received {}", chunk_hash);
  352. let mut chunk_router = fud.chunks_router.write().await;
  353. let peers = chunk_router.get_mut(&chunk_hash);
  354. if peers.is_none() {
  355. warn!("Chunk {} not in routing table, cannot fetch", chunk_hash);
  356. fud.chunk_fetch_tx
  357. .send((chunk_hash, Err(Error::GeodeChunkRouteNotFound)))
  358. .await
  359. .unwrap();
  360. continue
  361. }
  362. let mut found = false;
  363. let peers = peers.unwrap();
  364. let mut invalid_chunk_routes = vec![];
  365. for peer in peers.iter() {
  366. let session_out = fud.p2p.session_outbound();
  367. let session_weak = Arc::downgrade(&fud.p2p.session_outbound());
  368. info!("Connecting to {} to fetch {}", peer, chunk_hash);
  369. let connector = Connector::new(fud.p2p.settings(), session_weak);
  370. match connector.connect(peer).await {
  371. Ok((url, channel)) => {
  372. let proto_ver = ProtocolVersion::new(
  373. channel.clone(),
  374. fud.p2p.settings().clone(),
  375. fud.p2p.hosts().clone(),
  376. )
  377. .await;
  378. let handshake_task = session_out.perform_handshake_protocols(
  379. proto_ver,
  380. channel.clone(),
  381. executor.clone(),
  382. );
  383. channel.clone().start(executor.clone());
  384. if let Err(e) = handshake_task.await {
  385. error!("Handshake with {} failed: {}", url, e);
  386. // Delete peer from router
  387. invalid_chunk_routes.push(peer.clone());
  388. continue
  389. }
  390. let msg_subscriber = channel.subscribe_msg::<FudChunkReply>().await.unwrap();
  391. let request = FudChunkRequest { chunk_hash };
  392. if let Err(e) = channel.send(&request).await {
  393. error!("Failed sending FudChunkRequest({}) to {}: {}", chunk_hash, url, e);
  394. continue
  395. }
  396. // TODO: With timeout!
  397. let reply = match msg_subscriber.receive().await {
  398. Ok(v) => v,
  399. Err(e) => {
  400. error!("Error receiving FudChunkReply from subscriber: {}", e);
  401. continue
  402. }
  403. };
  404. msg_subscriber.unsubscribe().await;
  405. channel.stop().await;
  406. match fud.geode.insert_chunk(&reply.chunk).await {
  407. Ok(inserted_hash) => {
  408. if inserted_hash != chunk_hash {
  409. warn!("Received chunk does not match requested chunk");
  410. invalid_chunk_routes.push(peer.clone());
  411. continue
  412. }
  413. }
  414. Err(e) => {
  415. error!("Failed inserting chunk {} to Geode: {}", chunk_hash, e);
  416. continue
  417. }
  418. }
  419. found = true;
  420. break
  421. }
  422. Err(e) => {
  423. error!("Failed to connect to {}: {}", peer, e);
  424. continue
  425. }
  426. }
  427. }
  428. for peer in invalid_chunk_routes {
  429. debug!("Removing peer {} from {} chunk router", peer, chunk_hash);
  430. peers.remove(&peer);
  431. }
  432. if !found {
  433. warn!("Did not manage to fetch {} chunk", chunk_hash);
  434. fud.chunk_fetch_tx
  435. .send((chunk_hash, Err(Error::GeodeChunkRouteNotFound)))
  436. .await
  437. .unwrap();
  438. continue
  439. }
  440. info!("Successfully fetched {} chunk", chunk_hash);
  441. fud.chunk_fetch_tx.send((chunk_hash, Ok(()))).await.unwrap();
  442. }
  443. }
  444. async_daemonize!(realmain);
  445. async fn realmain(args: Args, ex: Arc<Executor<'static>>) -> Result<()> {
  446. // The working directory for this daemon and geode.
  447. let basedir = expand_path(&args.base_dir)?;
  448. // Hashmaps used for routing
  449. let metadata_router = Arc::new(RwLock::new(HashMap::new()));
  450. let chunks_router = Arc::new(RwLock::new(HashMap::new()));
  451. info!("Instantiating Geode instance");
  452. let geode = Geode::new(&basedir).await?;
  453. info!("Instantiating P2P network");
  454. let p2p = P2p::new(args.net.into(), ex.clone()).await;
  455. // Daemon instantiation
  456. let (file_fetch_tx, file_fetch_rx) = smol::channel::unbounded();
  457. let (chunk_fetch_tx, chunk_fetch_rx) = smol::channel::unbounded();
  458. let fud = Arc::new(Fud {
  459. metadata_router,
  460. chunks_router,
  461. p2p: p2p.clone(),
  462. geode,
  463. file_fetch_tx,
  464. file_fetch_rx,
  465. chunk_fetch_tx,
  466. chunk_fetch_rx,
  467. rpc_connections: Mutex::new(HashSet::new()),
  468. });
  469. info!(target: "fud", "Starting fetch file task");
  470. let file_task = StoppableTask::new();
  471. file_task.clone().start(
  472. fetch_file_task(fud.clone(), ex.clone()),
  473. |res| async {
  474. match res {
  475. Ok(()) | Err(Error::DetachedTaskStopped) => { /* Do nothing */ }
  476. Err(e) => error!(target: "fud", "Failed starting fetch file task: {}", e),
  477. }
  478. },
  479. Error::DetachedTaskStopped,
  480. ex.clone(),
  481. );
  482. info!(target: "fud", "Starting fetch chunk task");
  483. let chunk_task = StoppableTask::new();
  484. chunk_task.clone().start(
  485. fetch_chunk_task(fud.clone(), ex.clone()),
  486. |res| async {
  487. match res {
  488. Ok(()) | Err(Error::DetachedTaskStopped) => { /* Do nothing */ }
  489. Err(e) => error!(target: "fud", "Failed starting fetch chunk task: {}", e),
  490. }
  491. },
  492. Error::DetachedTaskStopped,
  493. ex.clone(),
  494. );
  495. info!(target: "fud", "Starting JSON-RPC server on {}", args.rpc_listen);
  496. let rpc_task = StoppableTask::new();
  497. let fud_ = fud.clone();
  498. rpc_task.clone().start(
  499. listen_and_serve(args.rpc_listen, fud.clone(), None, ex.clone()),
  500. |res| async move {
  501. match res {
  502. Ok(()) | Err(Error::RpcServerStopped) => fud_.stop_connections().await,
  503. Err(e) => error!(target: "fud", "Failed starting sync JSON-RPC server: {}", e),
  504. }
  505. },
  506. Error::RpcServerStopped,
  507. ex.clone(),
  508. );
  509. info!("Starting P2P protocols");
  510. let registry = p2p.protocol_registry();
  511. let fud_ = fud.clone();
  512. registry
  513. .register(net::SESSION_NET, move |channel, p2p| {
  514. let fud_ = fud_.clone();
  515. async move { ProtocolFud::init(fud_, channel, p2p).await.unwrap() }
  516. })
  517. .await;
  518. p2p.clone().start().await?;
  519. // Signal handling for graceful termination.
  520. let (signals_handler, signals_task) = SignalHandler::new(ex)?;
  521. signals_handler.wait_termination(signals_task).await?;
  522. info!("Caught termination signal, cleaning up and exiting...");
  523. info!(target: "fud", "Stopping fetch file task...");
  524. file_task.stop().await;
  525. info!(target: "fud", "Stopping fetch chunk task...");
  526. chunk_task.stop().await;
  527. info!(target: "fud", "Stopping JSON-RPC server...");
  528. rpc_task.stop().await;
  529. info!("Stopping P2P network");
  530. p2p.stop().await;
  531. info!("Bye!");
  532. Ok(())
  533. }