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, 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())

View File

@ -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(),
} }
} }
} }