g3proxy: fix clippy warning when quic disabled

This commit is contained in:
Zhang Jingqiang 2024-08-23 18:44:24 +08:00
parent d187f2488b
commit b74f53c54c
5 changed files with 18 additions and 30 deletions

4
Cargo.lock generated
View file

@ -502,9 +502,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.13"
version = "1.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48"
checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932"
dependencies = [
"jobserver",
"libc",

View file

@ -261,8 +261,8 @@ where
match_id: u16,
) -> Result<ProxyProtocolV2Encoder, ProxyProtocolEncodeError> {
let mut ppv2 = ProxyProtocolV2Encoder::new_tcp(
self.task_notes.client_addr(),
self.task_notes.server_addr(),
self.task_notes.client_addr,
self.task_notes.server_addr,
)?;
if let Some(name) = self.task_notes.raw_username() {
ppv2.push_username(name)?;
@ -282,8 +282,8 @@ where
match_id: u16,
) -> Result<ProxyProtocolV2Encoder, ProxyProtocolEncodeError> {
let mut ppv2 = ProxyProtocolV2Encoder::new_tcp(
self.task_notes.client_addr(),
self.task_notes.server_addr(),
self.task_notes.client_addr,
self.task_notes.server_addr,
)?;
ppv2.push_match_id(match_id)?;
Ok(ppv2)

View file

@ -18,7 +18,7 @@ use anyhow::anyhow;
use slog::slog_info;
use tokio::io::AsyncWriteExt;
use g3_dpi::{Protocol, ProtocolInspectPolicy};
use g3_dpi::ProtocolInspectPolicy;
use g3_imap_proto::response::ByeResponse;
use g3_imap_proto::CommandPipeline;
use g3_io_ext::{LineRecvVec, OnceBufReader};
@ -175,7 +175,7 @@ where
&self.ctx.server_quit_policy,
&self.ctx.task_notes,
&self.upstream,
Protocol::Imap,
g3_dpi::Protocol::Imap,
);
client.detour_relay(clt_r, clt_w, ups_r, ups_w, ctx).await

View file

@ -69,10 +69,10 @@ impl StreamInspectUserContext {
}
#[derive(Clone)]
pub(super) struct StreamInspectTaskNotes {
pub(crate) struct StreamInspectTaskNotes {
task_id: Uuid,
client_addr: SocketAddr,
server_addr: SocketAddr,
pub(crate) client_addr: SocketAddr,
pub(crate) server_addr: SocketAddr,
worker_id: Option<usize>,
user_ctx: Option<StreamInspectUserContext>,
}
@ -82,26 +82,16 @@ impl StreamInspectTaskNotes {
self.user_ctx.as_ref().map(|ctx| &ctx.user)
}
pub(crate) fn raw_username(&self) -> Option<&String> {
pub(crate) fn raw_username(&self) -> Option<&str> {
self.user_ctx
.as_ref()
.and_then(|ctx| ctx.raw_user_name.as_ref())
.and_then(|ctx| ctx.raw_user_name.as_deref())
}
#[inline]
pub(crate) fn task_id(&self) -> &Uuid {
&self.task_id
}
#[inline]
pub(crate) fn client_addr(&self) -> SocketAddr {
self.client_addr
}
#[inline]
pub(crate) fn server_addr(&self) -> SocketAddr {
self.server_addr
}
}
impl From<&ServerTaskNotes> for StreamInspectTaskNotes {
@ -175,16 +165,14 @@ impl<SC: ServerConfig> StreamInspectContext<SC> {
self.task_notes.user()
}
#[inline]
fn raw_user_name(&self) -> Option<&str> {
self.task_notes
.user_ctx
.as_ref()
.and_then(|cx| cx.raw_user_name.as_deref())
self.task_notes.raw_username()
}
#[inline]
pub(crate) fn server_task_id(&self) -> &Uuid {
&self.task_notes.task_id
self.task_notes.task_id()
}
#[inline]

View file

@ -18,7 +18,7 @@ use anyhow::anyhow;
use slog::slog_info;
use tokio::io::AsyncWriteExt;
use g3_dpi::{Protocol, ProtocolInspectPolicy};
use g3_dpi::ProtocolInspectPolicy;
use g3_io_ext::{LineRecvBuf, OnceBufReader};
use g3_slog_types::{LtHost, LtUpstreamAddr, LtUuid};
use g3_smtp_proto::command::Command;
@ -166,7 +166,7 @@ where
&self.ctx.server_quit_policy,
&self.ctx.task_notes,
&self.upstream,
Protocol::Smtp,
g3_dpi::Protocol::Smtp,
);
client.detour_relay(clt_r, clt_w, ups_r, ups_w, ctx).await