feat: configurable port - default 1080, editable in UI before connecting

Made-with: Cursor
This commit is contained in:
by-sonic
2026-04-08 15:02:11 +03:00
parent 6795c6177a
commit 1c1ecbc071
2 changed files with 36 additions and 12 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_tungstenite::tungstenite;
use tungstenite::client::IntoClientRequest;
pub const PORT: u16 = 1080;
pub const DEFAULT_PORT: u16 = 1080;
pub struct Stats {
pub running: AtomicBool,
@@ -29,12 +29,12 @@ impl Stats {
}
}
pub async fn run(stats: Arc<Stats>, lan: bool) -> Result<(), String> {
pub async fn run(stats: Arc<Stats>, lan: bool, port: u16) -> Result<(), String> {
let host = if lan { "0.0.0.0" } else { "127.0.0.1" };
let addr = format!("{}:{}", host, PORT);
let addr = format!("{}:{}", host, port);
let listener = TcpListener::bind(&addr)
.await
.map_err(|e| format!("Port {} busy: {}", PORT, e))?;
.map_err(|e| format!("Port {} busy: {}", port, e))?;
stats.running.store(true, Ordering::SeqCst);