mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-09 16:17:49 +00:00
initial commit
This commit is contained in:
parent
ddeefb5917
commit
80034c9a1a
5 changed files with 3186 additions and 73 deletions
3233
Cargo.lock
generated
3233
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,10 @@ authors = [
|
|||
edition = "2021"
|
||||
default-run = "redlib"
|
||||
|
||||
[features]
|
||||
default = ["p2p"]
|
||||
p2p = ["iroh"]
|
||||
|
||||
[dependencies]
|
||||
rinja = { version = "0.3.4", default-features = false }
|
||||
cached = { version = "0.54.0", features = ["async"] }
|
||||
|
@ -56,7 +60,8 @@ htmlescape = "0.3.1"
|
|||
bincode = "1.3.3"
|
||||
base2048 = "2.0.2"
|
||||
revision = "0.10.0"
|
||||
|
||||
iroh = { version = "0.34.1", optional = true, default-features = false }
|
||||
iroh-gossip = { version = "0.34.1", features = ["rpc"] }
|
||||
|
||||
[dev-dependencies]
|
||||
lipsum = "0.9.0"
|
||||
|
|
|
@ -11,3 +11,4 @@ pub mod settings;
|
|||
pub mod subreddit;
|
||||
pub mod user;
|
||||
pub mod utils;
|
||||
pub mod p2p;
|
|
@ -173,6 +173,13 @@ async fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "p2p")]
|
||||
{
|
||||
tokio::spawn(async move {
|
||||
let _ = redlib::p2p::main().await;
|
||||
});
|
||||
}
|
||||
|
||||
let address = matches.get_one::<String>("address").unwrap();
|
||||
let port = matches.get_one::<String>("port").unwrap();
|
||||
let hsts = matches.get_one("hsts").map(|m: &String| m.as_str());
|
||||
|
|
11
src/p2p.rs
Normal file
11
src/p2p.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use iroh::{protocol::Router, Endpoint};
|
||||
use iroh_gossip::{net::Gossip, ALPN as GOSSIP_ALPN};
|
||||
|
||||
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
|
||||
println!("[P2P] Endpoint node ID: {}", endpoint.node_id());
|
||||
let builder = Router::builder(endpoint);
|
||||
let gossip = Gossip::builder().spawn(builder.endpoint().clone()).await?;
|
||||
let _router: Router = builder.accept(GOSSIP_ALPN, gossip).spawn().await?;
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue