Add command-line argument for control api endpoint
This commit is contained in:
parent
d8d40e5ba3
commit
1cda80c041
@ -3,11 +3,17 @@ use axum::{
|
|||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use proxima_centauri::{process_command, root, GlobalState};
|
use proxima_centauri::{process_command, root, GlobalState};
|
||||||
use std::{net::SocketAddr, sync::Arc};
|
use std::sync::Arc;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
let addr: std::net::SocketAddr = std::env::args()
|
||||||
|
.nth(1)
|
||||||
|
.unwrap_or_else(|| "127.0.0.1:14000".to_string())
|
||||||
|
.parse()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// initialize tracing
|
// initialize tracing
|
||||||
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
||||||
.with_max_level(Level::INFO)
|
.with_max_level(Level::INFO)
|
||||||
@ -27,7 +33,6 @@ async fn main() {
|
|||||||
.with_state(shared_state);
|
.with_state(shared_state);
|
||||||
|
|
||||||
// run our app with hyper
|
// run our app with hyper
|
||||||
let addr = SocketAddr::from(([127, 0, 0, 1], 14000));
|
|
||||||
tracing::debug!("listening on {}", addr);
|
tracing::debug!("listening on {}", addr);
|
||||||
axum::Server::bind(&addr)
|
axum::Server::bind(&addr)
|
||||||
.serve(app.into_make_service())
|
.serve(app.into_make_service())
|
||||||
|
@ -100,9 +100,7 @@ impl GlobalState {
|
|||||||
Self {
|
Self {
|
||||||
proxies: Mutex::new(HashMap::new()),
|
proxies: Mutex::new(HashMap::new()),
|
||||||
ports: RwLock::new(HashSet::new()),
|
ports: RwLock::new(HashSet::new()),
|
||||||
verifying_key: verifying_key
|
verifying_key: verifying_key.and_then(|key| VerifyingKey::from_str(key.as_ref()).ok()),
|
||||||
.map(|key| VerifyingKey::from_str(key.as_ref()).ok())
|
|
||||||
.flatten(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user