diff --git a/README.md b/README.md index fc8fd22..1d3a8d6 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,6 @@ Think Invidious but for Reddit. Watch your cat videos without being watched. - [ ] Proxied images - [x] Reddit-hosted video - [ ] Proxied video - - [ ] Localized post date - [x] Users - [x] Username - [x] Karma @@ -62,6 +61,17 @@ Think Invidious but for Reddit. Watch your cat videos without being watched. ## Deploy an Instance +Once installed, deploy Libreddit (unless you're using Docker) by running: + +``` +libreddit +``` + +Specify a custom address for the server by passing the `-a` or `--address` argument: +``` +libreddit --address=0.0.0.0:8111 +``` + ### A) Cargo Make sure Rust stable is installed along with `cargo`, Rust's package manager. @@ -91,11 +101,6 @@ Install: yay -S libreddit-git ``` -Deploy: -``` -libreddit -``` - ## Building ``` diff --git a/src/main.rs b/src/main.rs index dd451ff..4d6a4d2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,23 +1,23 @@ // Import Crates use actix_web::{get, App, HttpResponse, HttpServer}; -use std::fs; // Reference local files mod popular; mod post; mod subreddit; mod user; +mod proxy; // Create Services #[get("/style.css")] async fn style() -> HttpResponse { - let file = fs::read_to_string("static/style.css").expect("ERROR: Could not read style.css"); + let file = std::fs::read_to_string("static/style.css").expect("ERROR: Could not read style.css"); HttpResponse::Ok().content_type("text/css").body(file) } #[get("/robots.txt")] async fn robots() -> HttpResponse { - let file = fs::read_to_string("static/robots.txt").expect("ERROR: Could not read robots.txt"); + let file = std::fs::read_to_string("static/robots.txt").expect("ERROR: Could not read robots.txt"); HttpResponse::Ok().body(file) } @@ -28,8 +28,18 @@ async fn favicon() -> HttpResponse { #[actix_web::main] async fn main() -> std::io::Result<()> { + let args: Vec = std::env::args().collect(); + let mut address = "0.0.0.0:8080".to_string(); + + if args.len() > 1 { + if args[1].starts_with("--address=") || args[1].starts_with("-a=") { + let split: Vec<&str> = args[1].split("=").collect(); + address = split[1].to_string(); + } + } + // start http server - println!("Running Libreddit on 0.0.0.0:8080!"); + println!("Running Libreddit on {}!", address); HttpServer::new(|| { App::new() @@ -47,7 +57,7 @@ async fn main() -> std::io::Result<()> { // USER SERVICES .service(user::page) }) - .bind("0.0.0.0:8080")? + .bind(address)? .run() .await } diff --git a/src/proxy.rs b/src/proxy.rs new file mode 100644 index 0000000..e69de29