mod ncat;
use std::{
- fs,
- net::{TcpListener, TcpStream},
- thread,
-}
+ env,
+ fs,
+ net::{TcpListener, TcpStream},
+ process::{self, ExitCode},
+ thread
+};
+
+use ncat::ncat::{self as NCAT, NcatOptions};
+
+
+fn main() -> process::ExitCode {
+
+ let args: Vec<String> = env::args().collect();
+
+ let ncat_opts: &mut NCAT::NcatOptions;
+
+ if args.len() < 2 {
+
+ println!("too few arguments");
+
+ return process::ExitCode::from(1u8);
+ }
+
+
+ match ctrlc::set_handler(move || {
+ NCAT::keyboard_interrupt();
+ }) {
+
+ Ok(()) => {
+
+
+ }
+
+ Err(error) => {
+
+ println!("failed to add signal handler: {}", error.to_string());
+
+ }
+
+ }
+
+ let mut args_v = Vec::<String>::new();
+
+ for i in 1..args.len() {
+
+ args_v.push(args[i].clone());
+
+ };
+
+ let mut args_result = NCAT::parse_args(&args_v);
+
+ match args_result {
+
+ Ok(mut boxno) => {
+
+ ncat_opts = boxno.as_mut();
+
+ }
+
+ Err(reason) => {
+
+ println!("failed to parse args: {}", reason);
+ }
+ }
+
+
-fn main() {
- println!("Hello, world!");
+ return process::ExitCode::from(0u8);
}
--- /dev/null
+
+use std::{
+ fmt::Error,
+ process,
+};
+
+
+pub struct NcatOptions {
+
+ mode_client: bool,
+ mode_listen: bool,
+ _client_sock_ready: bool,
+ _client_sockfd: i32,
+ host: String,
+ port: String,
+
+}
+
+impl NcatOptions {
+
+ pub fn new() -> Self {
+ Self {
+ mode_client: false,
+ mode_listen: false,
+ _client_sock_ready: false,
+ _client_sockfd: 0,
+ host: "".to_string(),
+ port: "".to_string()
+ }
+
+ }
+
+}
+
+pub struct NcatComms {
+
+ datalen: u32,
+ data: Vec<u8>
+}
+
+impl NcatComms {
+
+
+ pub fn new() -> Self {
+ Self {
+
+ datalen: 0,
+ data: Vec::<u8>::new()
+ }
+ }
+}
+
+
+pub fn keyboard_interrupt(){
+
+ println!("SIGINT. EXIT.");
+
+ process::exit(0);
+
+}
+
+
+pub fn parse_args(args: &Vec<String>) -> Result<Box<NcatOptions>, String>{
+
+ let no = NcatOptions::new();
+
+ let retno = Box::new(no);
+
+ return Ok(retno);
+
+}
+
+pub fn runner(ncat_opts: &mut NcatOptions) -> Result<(), String> {
+
+
+
+ return Ok(());
+}
+
+
+fn client(ncat_opts: &mut NcatOptions) -> Result<(), String> {
+
+ return Ok(());
+}
+
+
+fn listen_and_serve(ncat_opts: &mut NcatOptions) -> Result<(), String> {
+
+ return Ok(());
+}
\ No newline at end of file