[][src]Crate networking

for async examples see crates.io

Sync Server

This example is not tested
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

This example is not tested
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::random_string;
pub use peers::*;

Modules

async_query

asyncrounous implementation of bi-directional communication, that uses tokio::sync::mpsc

asyncronous

asyncronous implementation of the tcp networking provided in this crate

encryption

contains blowfish encryption wrapper, as well as storage solution (serde) for BigUint principly BigNum

error
peers

contains the ArtificePeer struct

sllp

provides access to Sllp (Secure Low Latency Protocol) Socket and Stream note that this module has no syncronous implementation

sync_query

syncrounous implementation of bi-directional communication, that uses std::sync::mpsc

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

used to unlock network streams, to provent unauthorized peers

Header

contains peer information sent accross the network in an effort to prevent man in the middle attacks

StreamHeader

used to ensure man in the middle attack doesn't occure, but used in place of the Header struct because it is much smaller

Traits

ArtificeHost

used to set discoverability on the local network

ArtificeStream

trait used to implement common features between async and syncrounous networking protocols note about this trait, it defines only the shared behavior that doesn't require high levels of IO owing to the fact that async funnctions currently can't be members of traits, I would ask that any implementation of this trait, also provides certain methods, found in the implementations in this crate

Query

Functions

test_config

used in examples, and tests, generates ArtificePeer, and ArtificeConfig because private keys take a while to generate this method generates static data, so it should never be used in production environments