Add command-line argument for control api endpoint

This commit is contained in:
Erik 2023-05-02 10:45:16 +02:00
parent d8d40e5ba3
commit 1cda80c041
2 changed files with 8 additions and 5 deletions

View File

@ -3,11 +3,17 @@ use axum::{
Router,
};
use proxima_centauri::{process_command, root, GlobalState};
use std::{net::SocketAddr, sync::Arc};
use std::sync::Arc;
use tracing::Level;
#[tokio::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
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_max_level(Level::INFO)
@ -27,7 +33,6 @@ async fn main() {
.with_state(shared_state);
// run our app with hyper
let addr = SocketAddr::from(([127, 0, 0, 1], 14000));
tracing::debug!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())

View File

@ -100,9 +100,7 @@ impl GlobalState {
Self {
proxies: Mutex::new(HashMap::new()),
ports: RwLock::new(HashSet::new()),
verifying_key: verifying_key
.map(|key| VerifyingKey::from_str(key.as_ref()).ok())
.flatten(),
verifying_key: verifying_key.and_then(|key| VerifyingKey::from_str(key.as_ref()).ok()),
}
}
}