minor logic optimization

This commit is contained in:
postscriptum 2026-03-23 04:28:36 +02:00
parent 239a85ca47
commit 82b09d74ae
3 changed files with 13 additions and 13 deletions

View file

@ -120,7 +120,6 @@ async fn serve_socks5(
totals: Arc<Total>,
) -> Result<(), SocksError> {
totals.increase_request();
let request = match &opt.auth {
AuthMode::NoAuth if opt.skip_auth => {
Socks5ServerProtocol::skip_auth_this_is_not_rfc_compliant(socket)
@ -137,16 +136,20 @@ async fn serve_socks5(
.read_command()
.await?;
let (host, _) = request.2.clone().into_string_and_port(); // @TODO ref
let (proto, cmd, addr) = request.resolve_dns().await?;
let (host, _) = request.2.clone().into_string_and_port();
if !list.any(&[&host, &addr.to_string()]).await {
if !list.any(&host).await {
totals.increase_blocked();
info!("Blocked connection attempt to: {host}");
proto.reply_error(&ReplyError::ConnectionNotAllowed).await?;
request
.0
.reply_error(&ReplyError::ConnectionNotAllowed)
.await?;
return Err(ReplyError::ConnectionNotAllowed.into());
}
let (proto, cmd, addr) = request.resolve_dns().await?;
match cmd {
Socks5Command::TCPConnect => {
run_tcp_proxy(proto, &addr, opt.request_timeout, false).await?;