Merge pull request #13 from GreenPenguino/command-line-argument

Add command-line argument for control api endpoint
This commit is contained in:
Erik van Bennekum 2023-06-06 11:48:32 +02:00 committed by GitHub
commit 7d61fd1686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()),
}
}
}