Add Address Command-line Argument
This commit is contained in:
parent
1a33582966
commit
16bf825e14
3 changed files with 26 additions and 11 deletions
17
README.md
17
README.md
|
@ -40,7 +40,6 @@ Think Invidious but for Reddit. Watch your cat videos without being watched.
|
||||||
- [ ] Proxied images
|
- [ ] Proxied images
|
||||||
- [x] Reddit-hosted video
|
- [x] Reddit-hosted video
|
||||||
- [ ] Proxied video
|
- [ ] Proxied video
|
||||||
- [ ] Localized post date
|
|
||||||
- [x] Users
|
- [x] Users
|
||||||
- [x] Username
|
- [x] Username
|
||||||
- [x] Karma
|
- [x] Karma
|
||||||
|
@ -62,6 +61,17 @@ Think Invidious but for Reddit. Watch your cat videos without being watched.
|
||||||
|
|
||||||
## Deploy an Instance
|
## 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
|
### A) Cargo
|
||||||
|
|
||||||
Make sure Rust stable is installed along with `cargo`, Rust's package manager.
|
Make sure Rust stable is installed along with `cargo`, Rust's package manager.
|
||||||
|
@ -91,11 +101,6 @@ Install:
|
||||||
yay -S libreddit-git
|
yay -S libreddit-git
|
||||||
```
|
```
|
||||||
|
|
||||||
Deploy:
|
|
||||||
```
|
|
||||||
libreddit
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -1,23 +1,23 @@
|
||||||
// Import Crates
|
// Import Crates
|
||||||
use actix_web::{get, App, HttpResponse, HttpServer};
|
use actix_web::{get, App, HttpResponse, HttpServer};
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
// Reference local files
|
// Reference local files
|
||||||
mod popular;
|
mod popular;
|
||||||
mod post;
|
mod post;
|
||||||
mod subreddit;
|
mod subreddit;
|
||||||
mod user;
|
mod user;
|
||||||
|
mod proxy;
|
||||||
|
|
||||||
// Create Services
|
// Create Services
|
||||||
#[get("/style.css")]
|
#[get("/style.css")]
|
||||||
async fn style() -> HttpResponse {
|
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)
|
HttpResponse::Ok().content_type("text/css").body(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/robots.txt")]
|
#[get("/robots.txt")]
|
||||||
async fn robots() -> HttpResponse {
|
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)
|
HttpResponse::Ok().body(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,18 @@ async fn favicon() -> HttpResponse {
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
let args: Vec<String> = 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
|
// start http server
|
||||||
println!("Running Libreddit on 0.0.0.0:8080!");
|
println!("Running Libreddit on {}!", address);
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
|
@ -47,7 +57,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
// USER SERVICES
|
// USER SERVICES
|
||||||
.service(user::page)
|
.service(user::page)
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:8080")?
|
.bind(address)?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
0
src/proxy.rs
Normal file
0
src/proxy.rs
Normal file
Loading…
Reference in a new issue