[−][src]Crate networking
for async examples see crates.io
Sync Server
use networking::{syncronous::SyncHost, test_config, ArtificeConfig, ArtificePeer, ArtificeStream}; 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(); //thread::sleep(Duration::from_millis(200)); 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 encryption::*; |
pub use peers::*; |
Modules
asyncronous | |
encryption | contains blowfish encryption wrapper, as well as storage solution (serde) for BigUint principly BigNum |
error | |
peers | contains the ArtificePeer struct |
query | used for permission requests in the manager crate |
syncronous |
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 |
ConnectionRequest | |
Header | contains peer information sent accross the network in an effort to prevent man in the middle attacks |
StreamHeader |
Traits
ArtificeHost | |
ArtificeStream | trait used to implement common features between async and sync implementations of networking |
Functions
test_config |