Removed partial password feature

This commit is contained in:
p11 2025-08-09 21:49:52 +02:00
parent 20b1290821
commit 3342de6067

View File

@ -115,8 +115,7 @@ fn main() -> ExitCode {
let address = args.next();
let address = address.as_deref().unwrap_or("127.0.0.1:8080");
let password = args.next();
let partial_password = args.next();
start_server(path, address, password, partial_password);
start_server(path, address, password);
ExitCode::FAILURE
}
@ -126,12 +125,7 @@ fn get_thread_pool_size() -> usize {
.unwrap_or(4)
}
fn start_server(
path: PathBuf,
address: &str,
password: Option<String>,
partial_password: Option<String>,
) {
fn start_server(path: PathBuf, address: &str, password: Option<String>) {
let Ok(listener) = TcpListener::bind(address) else {
eprintln!("Invalid bind address {address:?}!");
return;
@ -160,16 +154,7 @@ fn start_server(
let context = context.clone();
let path = path.clone();
let password = password.clone();
let hidden_password = partial_password.clone();
pool.execute(move || {
handle_connection(
context,
path,
stream,
password.as_deref(),
hidden_password.as_deref(),
)
});
pool.execute(move || handle_connection(context, path, stream, password.as_deref()));
}
}
@ -183,7 +168,6 @@ fn handle_connection(
path: PathBuf,
mut stream: TcpStream,
password: Option<&str>,
partial_password: Option<&str>,
) {
let Some(request) = Request::from(&stream) else {
eprintln!("Invalid request!");
@ -205,7 +189,6 @@ fn handle_connection(
#[derive(PartialEq, Eq)]
enum Access {
None,
Partial,
Full,
}
@ -223,9 +206,6 @@ fn handle_connection(
if input == password {
access = Access::Full;
cookie = Some(password);
} else if Some(input) == partial_password {
access = Access::Partial;
cookie = partial_password;
}
break;
}
@ -254,9 +234,6 @@ fn handle_connection(
if state == password {
access = Access::Full;
break;
} else if Some(state) == partial_password {
access = Access::Partial;
break;
}
}
}