#protocols #client #bitmessage #p2p #networking

koibumi-node-sync

作为Koibumi(同步版本)库的Bitmessage节点实现,一个实验性的Bitmessage客户端。

2个版本

0.0.1 2024年6月26日
0.0.0 2021年1月6日

9 #bitmessage


4 crates中使用

AGPL-3.0-or-later

455KB
11K SLoC

此crate是一个Bitmessage节点实现,作为Koibumi(同步版本)库,一个实验性的Bitmessage客户端。

有关应用的更多信息,请参阅koibumi-sync。有关协议的更多信息,请参阅Bitmessage


lib.rs:

此crate是一个Bitmessage节点实现,作为Koibumi(同步版本)库,一个实验性的Bitmessage客户端。

有关应用的更多信息,请参阅koibumi-sync。有关协议的更多信息,请参阅Bitmessage

示例

use std::{path::PathBuf, str::FromStr};

use koibumi_node_sync::{self as node, Command, Config, Event, Response};

let (command_sender, mut response_receiver, handle) = node::spawn();

let config = Config::builder()
    .server(Some("127.0.0.1:8444".parse().unwrap()))
    .socks(Some("127.0.0.1:9050".parse().unwrap()))
    .connect_to_onion(true)
    .connect_to_ip(true)
    .seeds(vec!["quzwelsuziwqgpt2.onion:8444".parse().unwrap()])
    .build();

let mut sender = command_sender;
let response = {
    let db_path = PathBuf::from_str("sqlite::memory:").unwrap();

    if let Err(err) = sender.send(Command::Start(config.into(), db_path, Vec::new())) {
        eprintln!("{}", err);
        return
    }
    response_receiver.recv()
};
let Response::Started(mut receiver) = response.unwrap();

while let Ok(event) = receiver.recv() {
    match event {
        Event::ConnectionCounts { .. } => (),
        Event::AddrCount(_count) => (),
        Event::Established { addr, user_agent, rating } => {
            println!("established: {} {} rating:{}", addr, user_agent, rating);
        }
        Event::Disconnected { addr } => {
            println!("disconnected: {}", addr);
        }
        Event::Objects { .. } => (),
        Event::Stopped => {
            break;
        }
        Event::Broadcast {
            user_id,
            address,
            object,
        } => {
            println!("broadcast received from {}", address);
        }
        Event::Msg {
            user_id,
            address,
            object,
        } => {
            println!("received msg for {}", address);
        }
    }
}

if let Err(err) = handle.join() {
    eprintln!("{:?}", err);
    return
}

依赖关系

~32MB
~547K SLoC