diff options
-rw-r--r-- | Cargo.lock | 9 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | client-native-lib/Cargo.toml | 27 | ||||
-rw-r--r-- | client-native-lib/src/crypto.rs (renamed from client-native-rift/src/crypto.rs) | 0 | ||||
-rw-r--r-- | client-native-lib/src/main.rs | 85 | ||||
-rw-r--r-- | client-native-lib/src/peer.rs (renamed from client-native-rift/src/peer.rs) | 0 | ||||
-rw-r--r-- | client-native-lib/src/protocol.rs (renamed from client-native-rift/src/protocol.rs) | 0 | ||||
-rw-r--r-- | client-native-lib/src/signaling.rs (renamed from client-native-rift/src/signaling.rs) | 0 | ||||
-rw-r--r-- | client-native-lib/src/state.rs (renamed from client-native-rift/src/state.rs) | 0 | ||||
-rw-r--r-- | client-native-rift/Cargo.toml | 22 | ||||
-rw-r--r-- | client-native-rift/src/main.rs | 84 |
11 files changed, 123 insertions, 106 deletions
@@ -422,7 +422,7 @@ dependencies = [ ] [[package]] -name = "client-native-rift" +name = "client-native-lib" version = "0.1.0" dependencies = [ "aes-gcm 0.10.1", @@ -445,6 +445,13 @@ dependencies = [ ] [[package]] +name = "client-native-rift" +version = "0.1.0" +dependencies = [ + "client-native-lib", +] + +[[package]] name = "const-oid" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1,2 +1,2 @@ [workspace] -members = ["server", "client-native-rift"] +members = ["server", "client-native-rift", "client-native-lib"] diff --git a/client-native-lib/Cargo.toml b/client-native-lib/Cargo.toml new file mode 100644 index 0000000..0fa740b --- /dev/null +++ b/client-native-lib/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "client-native-lib" +version = "0.1.0" +edition = "2021" + +[dependencies] +tokio = { version = "1.21", features = ["full"] } +futures-util = "0.3.24" + +webrtc = "0.5.0" +tokio-tungstenite = { version = "*", features = ["rustls-tls"] } +url = "2.3.1" + +serde = { version = "1.0.144", features = ["derive"] } +serde_json = "*" + +clap = { version = "3.2.21", features = ["derive"] } +env_logger = "0.8" +log = "0.4" + +fastpbkdf2 = "0.1.0" +aes-gcm = "0.10.1" +sha256 = "1.0.3" +rand = "0.8.5" +rand_chacha = "0.3.1" +base64 = "0.13.0" +bytes = "1.2.1" diff --git a/client-native-rift/src/crypto.rs b/client-native-lib/src/crypto.rs index 9bd8908..9bd8908 100644 --- a/client-native-rift/src/crypto.rs +++ b/client-native-lib/src/crypto.rs diff --git a/client-native-lib/src/main.rs b/client-native-lib/src/main.rs new file mode 100644 index 0000000..f2b79e2 --- /dev/null +++ b/client-native-lib/src/main.rs @@ -0,0 +1,85 @@ +#![feature(async_closure)] +#![feature(box_syntax)] + +use clap::{Parser, Subcommand}; +use log::{debug, error}; +use signaling::signaling_connect; +use state::State; +use std::sync::Arc; +use tokio::sync::RwLock; +use webrtc::{ + api::{ + interceptor_registry::register_default_interceptors, media_engine::MediaEngine, APIBuilder, + }, + interceptor::registry::Registry, +}; + +pub mod crypto; +pub mod peer; +pub mod protocol; +pub mod signaling; +pub mod state; + +fn main() { + env_logger::init_from_env("LOG"); + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() + .block_on(run()) +} + +#[derive(Parser)] +pub struct Args { + #[clap(long, default_value = "meet.metamuffin.org")] + signaling_host: String, + #[clap(short, long)] + secret: String, + #[clap(subcommand)] + action: Action, +} +#[derive(Subcommand)] +pub enum Action { + Send {}, + Receive {}, +} + +async fn run() { + let args = Args::parse(); + let (sender, mut recv) = signaling_connect(&args.signaling_host, &args.secret).await; + + let key = crypto::Key::derive(&args.secret); + + let mut media_engine = MediaEngine::default(); + media_engine.register_default_codecs().unwrap(); + let mut registry = Registry::new(); + registry = register_default_interceptors(registry, &mut media_engine).unwrap(); + let api = APIBuilder::new() + .with_media_engine(media_engine) + .with_interceptor_registry(registry) + .build(); + + let state = Arc::new(State { + peers: Default::default(), + key, + api, + my_id: RwLock::new(None), + sender, + args, + }); + + { + let state = state.clone(); + tokio::spawn(async move { + debug!("receiving packets now"); + while let Some(packet) = recv.recv().await { + debug!("{packet:?}"); + let state = state.clone(); + state.on_message(packet).await + } + }); + } + + tokio::signal::ctrl_c().await.unwrap(); + error!("interrupt received, exiting"); +} diff --git a/client-native-rift/src/peer.rs b/client-native-lib/src/peer.rs index 8402fc6..8402fc6 100644 --- a/client-native-rift/src/peer.rs +++ b/client-native-lib/src/peer.rs diff --git a/client-native-rift/src/protocol.rs b/client-native-lib/src/protocol.rs index 431dc42..431dc42 100644 --- a/client-native-rift/src/protocol.rs +++ b/client-native-lib/src/protocol.rs diff --git a/client-native-rift/src/signaling.rs b/client-native-lib/src/signaling.rs index 2ac3edc..2ac3edc 100644 --- a/client-native-rift/src/signaling.rs +++ b/client-native-lib/src/signaling.rs diff --git a/client-native-rift/src/state.rs b/client-native-lib/src/state.rs index baea90a..baea90a 100644 --- a/client-native-rift/src/state.rs +++ b/client-native-lib/src/state.rs diff --git a/client-native-rift/Cargo.toml b/client-native-rift/Cargo.toml index 9030315..f87cf16 100644 --- a/client-native-rift/Cargo.toml +++ b/client-native-rift/Cargo.toml @@ -4,24 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -tokio = { version = "1.21", features = ["full"] } -futures-util = "0.3.24" - -webrtc = "0.5.0" -tokio-tungstenite = { version = "*", features = ["rustls-tls"] } -url = "2.3.1" - -serde = { version = "1.0.144", features = ["derive"] } -serde_json = "*" - -clap = { version = "3.2.21", features = ["derive"] } -env_logger = "0.8" -log = "0.4" - -fastpbkdf2 = "0.1.0" -aes-gcm = "0.10.1" -sha256 = "1.0.3" -rand = "0.8.5" -rand_chacha = "0.3.1" -base64 = "0.13.0" -bytes = "1.2.1" +client-native-lib = { path = "../client-native-lib" } diff --git a/client-native-rift/src/main.rs b/client-native-rift/src/main.rs index f2b79e2..e7a11a9 100644 --- a/client-native-rift/src/main.rs +++ b/client-native-rift/src/main.rs @@ -1,85 +1,3 @@ -#![feature(async_closure)] -#![feature(box_syntax)] - -use clap::{Parser, Subcommand}; -use log::{debug, error}; -use signaling::signaling_connect; -use state::State; -use std::sync::Arc; -use tokio::sync::RwLock; -use webrtc::{ - api::{ - interceptor_registry::register_default_interceptors, media_engine::MediaEngine, APIBuilder, - }, - interceptor::registry::Registry, -}; - -pub mod crypto; -pub mod peer; -pub mod protocol; -pub mod signaling; -pub mod state; - fn main() { - env_logger::init_from_env("LOG"); - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap() - .block_on(run()) -} - -#[derive(Parser)] -pub struct Args { - #[clap(long, default_value = "meet.metamuffin.org")] - signaling_host: String, - #[clap(short, long)] - secret: String, - #[clap(subcommand)] - action: Action, -} -#[derive(Subcommand)] -pub enum Action { - Send {}, - Receive {}, -} - -async fn run() { - let args = Args::parse(); - let (sender, mut recv) = signaling_connect(&args.signaling_host, &args.secret).await; - - let key = crypto::Key::derive(&args.secret); - - let mut media_engine = MediaEngine::default(); - media_engine.register_default_codecs().unwrap(); - let mut registry = Registry::new(); - registry = register_default_interceptors(registry, &mut media_engine).unwrap(); - let api = APIBuilder::new() - .with_media_engine(media_engine) - .with_interceptor_registry(registry) - .build(); - - let state = Arc::new(State { - peers: Default::default(), - key, - api, - my_id: RwLock::new(None), - sender, - args, - }); - - { - let state = state.clone(); - tokio::spawn(async move { - debug!("receiving packets now"); - while let Some(packet) = recv.recv().await { - debug!("{packet:?}"); - let state = state.clone(); - state.on_message(packet).await - } - }); - } - - tokio::signal::ctrl_c().await.unwrap(); - error!("interrupt received, exiting"); + println!("Hello, world!"); } |