Added config parsing in config.rs

This commit is contained in:
Random936
2024-12-22 18:47:37 -08:00
parent 23102ce070
commit adda5dd958
5 changed files with 355 additions and 17 deletions

View File

@@ -1,17 +1,35 @@
use axum::Router;
use tokio::net::TcpListener;
use axum::routing::get;
use tower_http::services::ServeDir;
use axum::routing::{get, post};
use axum::Router;
use std::env;
use std::net::SocketAddr;
mod argparse;
mod print_dir;
mod config;
mod shells;
#[tokio::main]
async fn main() {
let args = argparse::parse_args();
print_dir::print_interface(&args.interface, &args.port, &args.directory);
let conf = config::load_config();
let cwd = env::current_dir().unwrap();
let app = Router::new().route("/", get(|| async { "Hello world!" }));
let listener = TcpListener::bind(format!("0.0.0.0:{}", args.port))
let port = match args.port {
Some(port) => port,
None => conf.web_port
};
print_dir::print_interface(&args.interface, &port, &args.directory);
let app = Router::new()
//.route("/download/:path", get(download_handler))
//.route("/upload", post(upload_handler))
.route("/shells/:shell", get(shells::shells_handler))
.nest_service("/", ServeDir::new(cwd));
let listener = TcpListener::bind(format!("0.0.0.0:{}", port))
.await
.unwrap();