mirror of
https://github.com/TeamPiped/piped-proxy.git
synced 2024-08-14 23:50:45 +00:00
Allow configuring listen options.
This commit is contained in:
parent
e5de68aa0c
commit
3ab1529ba7
1 changed files with 11 additions and 7 deletions
18
src/main.rs
18
src/main.rs
|
@ -1,3 +1,4 @@
|
||||||
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web};
|
use actix_web::{App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer, web};
|
||||||
|
@ -12,15 +13,18 @@ use reqwest::{Client, Request, Url};
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
println!("Running server!");
|
println!("Running server!");
|
||||||
|
|
||||||
HttpServer::new(|| {
|
let server =HttpServer::new(|| {
|
||||||
// match all requests
|
// match all requests
|
||||||
App::new()
|
App::new()
|
||||||
.default_service(web::to(index))
|
.default_service(web::to(index))
|
||||||
})
|
});
|
||||||
.bind("0.0.0.0:8080")?
|
// get port from env
|
||||||
.bind_uds("./socket/actix.sock")?
|
if env::var("UDS").is_ok() {
|
||||||
.run()
|
server.bind_uds("./socket/actix.sock")?
|
||||||
.await
|
} else {
|
||||||
|
let bind = env::var("BIND").unwrap_or_else(|_| "0.0.0.0:8080".to_string());
|
||||||
|
server.bind(bind)?
|
||||||
|
}.run().await
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static!(
|
lazy_static!(
|
||||||
|
|
Loading…
Reference in a new issue