[−][src]Crate networking
for async examples see crates.io
Sync Server
use networking::{syncronous::SyncHost, test_config, ArtificeConfig, ArtificePeer, SyncDataStream}; let (peer, config) = test_config(); let host = SyncHost::from_host_data(&config).unwrap(); for netstream in host { println!("new connection"); let mut stream = netstream.unwrap().verify(&peer).unwrap(); stream.send(b"hello world").unwrap(); break; }
Sync Client
use networking::{syncronous::SyncHost, test_config, ArtificeConfig, ArtificePeer}; use std::{thread, time::Duration}; let (peer, config) = test_config(); let host = SyncHost::client_only(&config).unwrap(); let mut stream = host.connect(peer).unwrap(); println!("connected"); let mut buffer = Vec::new(); println!("about to read from sream"); println!( "got {} bytes from server", stream.recv(&mut buffer).unwrap() ); println!("read from stream"); let string = String::from_utf8(buffer).unwrap(); println!("got message: {} from server", string);
Re-exports
pub use peers::*; |
pub use utils::*; |
Modules
asyncronous | asyncronous implementation of the tcp networking provided in this crate |
database | provides access to essentially a HashMap that can be written to disk implements peer list so this struct can be used to verify peers |
encryption | contains blowfish encryption wrapper, as well as storage solution (serde) for BigUint principly BigNum |
error | generates random strings of given length |
peers | contains the ArtificePeer struct |
protocol | |
sllp | provides access to Sllp (Secure Low Latency Protocol) Socket and Stream, and is intended for high volume low precision operations such as streaming note that this module has no syncronous implementation |
syncronous | |
utils |
Structs
ArtificeConfig | used to build and configure the local host |
ArtificeHostData | provides a means of saving private keys to files, because the process of generating the keys takes a really long time, but creating them from existing values does not |
Header | contains peer information sent accross the network in an effort to prevent man in the middle attacks |
Traits
ArtificeHost | used to set discoverability on the local network |
ConnectionRequest | implemented on both async and sync connection requests structs to define how to verify a peer |