Config listen address
This commit is contained in:
parent
add69fecfa
commit
be3d2ed478
11
src/main.rs
11
src/main.rs
@ -1,6 +1,7 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rocket;
|
extern crate rocket;
|
||||||
|
|
||||||
|
use std::net::{IpAddr, SocketAddr};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
@ -44,7 +45,15 @@ async fn main() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rocket = rocket::Rocket::build()
|
let mut config = rocket::Config::default();
|
||||||
|
let ip: SocketAddr = match &settings.listen {
|
||||||
|
Some(i) => i.parse().unwrap(),
|
||||||
|
None => SocketAddr::new(IpAddr::from([0, 0, 0, 0]), 8000)
|
||||||
|
};
|
||||||
|
config.address = ip.ip();
|
||||||
|
config.port = ip.port();
|
||||||
|
|
||||||
|
let rocket = rocket::Rocket::custom(config)
|
||||||
.manage(db)
|
.manage(db)
|
||||||
.manage(fetch)
|
.manage(fetch)
|
||||||
.attach(Shield::new()) // disable
|
.attach(Shield::new()) // disable
|
||||||
|
@ -3,6 +3,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
|
/// Listen address for web API
|
||||||
|
pub listen: Option<String>,
|
||||||
|
|
||||||
/// List of relays to connect to for fetching data
|
/// List of relays to connect to for fetching data
|
||||||
pub relays: Vec<Url>
|
pub relays: Vec<Url>
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user