2 releases
0.2.1 | May 16, 2022 |
---|---|
0.2.0 | May 15, 2022 |
0.1.1 |
|
0.1.0 |
|
#205 in WebSocket
31MB
1.5K
SLoC
Contains (WOFF font, 16KB) assets/stats/fonts/nucleo.woff, (WOFF font, 13KB) assets/stats/fonts/nucleo.woff2
Gun-rs
Pure Rust implementation of Gun.js. For a wasm version, check out gun-rs-wasm.
Iris-messenger uses the gun-rs node at wss://gun-rs.iris.to/gun
Why?
- Rust can be compiled into high-performing native binaries on many platforms, including embedded systems.
- Maintaining and contributing to the codebase is easier than in Gun.js. Gun.js doesn't have compilation or minification steps, and the code is kind of manually minified 😄
Use
Install Rust first.
Gun relay
cargo install gundb
gundb start
Gun library
use gundb::{Node, NodeConfig};
use gundb::types::GunValue;
let mut db = Node::new_with_config(NodeConfig {
outgoing_websocket_peers: vec!["wss://some-server-to-sync.with/gun".to_string()],
..NodeConfig::default()
});
let mut sub = db.get("greeting").on();
db.get("greeting").put("Hello World!".into());
if let GunValue::Text(str) = sub.recv().await.unwrap() {
assert_eq!(&str, "Hello World!");
}
Status
15/5/2022:
- Gun basic API
- CLI for running the server
- Incoming websockets
- Outgoing websockets (env PEERS=wss://some-server-url.herokuapp.com/gun)
- Multicast (currently size limited to 65KB — large photos in messages will not sync over it)
- In-memory storage
- TLS support (env CERT_PATH and KEY_PATH)
- Advanced deduplication of network messages
- Publish & subscribe (network messages only relayed to relevant peers)
- Disk storage (sled.rs)
- Hash verification for content-addressed data (
db.get('#').get(data_hash).put(data)
) - Signature verification of user data (
db.get('~' + pubkey).get('profile') ...
) - Encryption & decryption (usually done on the client side in js, like iris private messaging)
Issues
- Multicast doesn't relay large messages like Iris posts with photos
Develop
cargo install cargo-watch
RUST_LOG=debug cargo watch -x 'run -- start'
Run on Heroku
heroku create --buildpack emk/rust
git push heroku master
or:
Dependencies
~21–36MB
~672K SLoC