diff --git a/Cargo.toml b/Cargo.toml index 157a414..86b17cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,6 @@ keywords = ["tun", "network", "tunnel", "vpn"] categories = ["network-programming", "asynchronous"] readme = "README.md" -[lib] -crate-type = ["cdylib"] - [dependencies] clap = "2.33" aes-gcm = "0.10.3" diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index fe62095..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,58 +0,0 @@ -mod client; -mod config; -mod udp; - -use std::os::raw::{c_char}; -use std::ffi::{CString, CStr}; - -#[no_mangle] -pub extern fn rust_greeting(to: *const c_char) -> *mut c_char { - let c_str = unsafe { CStr::from_ptr(to) }; - let recipient = match c_str.to_str() { - Err(_) => "there", - Ok(string) => string, - }; - - CString::new("Hello ".to_owned() + recipient).unwrap().into_raw() -} - - -/// Expose the JNI interface for android below -#[cfg(target_os="android")] -#[allow(non_snake_case)] -pub mod android { - extern crate jni; - - use config::ClientConfiguration; - use fast32::base32::RFC4648; - - use super::*; - use self::jni::JNIEnv; - use self::jni::objects::{JClass, JString}; - use self::jni::sys::{jstring}; - - #[no_mangle] - pub async unsafe extern fn Java_com_alterdekim_frida_FridaVPN_startClient(env: JNIEnv<'_>, _: JClass<'_>, java_pattern: JString<'_>) { - // Our Java companion code might pass-in "world" as a string, hence the name. - //let world = rust_greeting(env.get_string(java_pattern).expect("invalid pattern string").as_ptr()); - // Retake pointer so that we can use it below and allow memory to be freed when it goes out of scope. - //let world_ptr = CString::from_raw(world); - //let output = env.new_string(world_ptr.to_str().unwrap()).expect("Couldn't create java string!"); - - //output.into_inner() - - let wo = env.get_string(java_pattern).expect("invalid pattern string").as_ptr(); - let c_str = unsafe { CStr::from_ptr(wo) }; - let cfg_raw = match c_str.to_str() { - Err(_) => "", - Ok(string) => string, - }; - - let config: ClientConfiguration = serde_yaml::from_slice(RFC4648.decode(cfg_raw.as_bytes()).unwrap().as_slice()).expect("Bad client config file structure"); - client::client_mode(config).await; - - //let output = env.new_string("gabber").expect("Couldn't create java string!"); - - //output.into_inner() - } -} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5532a3d --- /dev/null +++ b/src/main.rs @@ -0,0 +1,35 @@ +use std::{fs, net::{Ipv4Addr}, str}; +use clap::{App, Arg, ArgMatches}; +use env_logger::Builder; +use log::{error, LevelFilter}; +use crate::config::{ ServerConfiguration, ClientConfiguration, ObfsProtocol, ServerPeer }; +use fast32::base32::RFC4648; + +mod config; +mod client; + +#[tokio::main] +async fn main() { + // Initialize the logger with 'info' as the default level + Builder::new() + .filter(None, LevelFilter::Info) + .init(); + + let matches = App::new("Frida") + .version("0.1.2") + .author("alterwain") + .about("VPN software (android port)") + .arg(Arg::with_name("config") + .long("config") + .required(true) + .value_name("B32_RAW") + .help("Configuration file data (base32 encoded)") + .takes_value(true)) + .get_matches(); + + let cfg_raw = matches.value_of("config").unwrap(); + + let config: ClientConfiguration = serde_yaml::from_slice(RFC4648.decode(cfg_raw.as_bytes()).unwrap().as_slice()).expect("Bad client config file structure"); + + client::client_mode(config).await; +} \ No newline at end of file