From 90d5ed3be03228691dc0f41aa38e6eb521e8bfe2 Mon Sep 17 00:00:00 2001 From: Zhang Jingqiang Date: Wed, 16 Aug 2023 18:09:29 +0800 Subject: [PATCH] g3proxy: reuse socks5 udp wrapper stats --- .../peer/socks5/udp_connect/mod.rs | 14 +-- .../peer/socks5/udp_connect/stats.rs | 91 ------------------- .../proxy_float/peer/socks5/udp_relay/mod.rs | 15 +-- .../peer/socks5/udp_relay/stats.rs | 91 ------------------- .../src/escape/proxy_float/stats/escaper.rs | 38 ++++++++ g3proxy/src/escape/proxy_socks5/stats.rs | 38 ++++++++ .../escape/proxy_socks5/udp_connect/mod.rs | 10 +- .../escape/proxy_socks5/udp_connect/stats.rs | 23 +++-- .../src/escape/proxy_socks5/udp_relay/mod.rs | 10 +- .../escape/proxy_socks5/udp_relay/stats.rs | 23 +++-- 10 files changed, 128 insertions(+), 225 deletions(-) delete mode 100644 g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/stats.rs delete mode 100644 g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/stats.rs diff --git a/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/mod.rs b/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/mod.rs index d52a81522..aef97d9ac 100644 --- a/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/mod.rs +++ b/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/mod.rs @@ -14,11 +14,14 @@ * limitations under the License. */ +use std::sync::Arc; + use g3_io_ext::{LimitedUdpRecv, LimitedUdpSend}; -use super::{NextProxyPeerInternal, ProxyFloatEscaperStats, ProxyFloatSocks5Peer}; +use super::{NextProxyPeerInternal, ProxyFloatSocks5Peer}; use crate::escape::proxy_socks5::udp_connect::{ ProxySocks5UdpConnectRemoteRecv, ProxySocks5UdpConnectRemoteSend, + ProxySocks5UdpConnectRemoteStats, }; use crate::module::tcp_connect::TcpConnectTaskNotes; use crate::module::udp_connect::{ @@ -26,9 +29,6 @@ use crate::module::udp_connect::{ }; use crate::serve::ServerTaskNotes; -mod stats; -use stats::ProxySocks5UdpConnectRemoteStats; - impl ProxyFloatSocks5Peer { pub(super) async fn udp_connect_to<'a>( &'a self, @@ -50,8 +50,10 @@ impl ProxyFloatSocks5Peer { udp_notes.local = Some(udp_local_addr); udp_notes.next = Some(udp_peer_addr); - let mut wrapper_stats = - ProxySocks5UdpConnectRemoteStats::new(&self.escaper_stats, task_stats); + let mut wrapper_stats = ProxySocks5UdpConnectRemoteStats::new( + Arc::clone(&self.escaper_stats) as ArcUdpConnectTaskRemoteStats, + task_stats, + ); wrapper_stats.push_user_io_stats(self.fetch_user_upstream_io_stats(task_notes)); let (ups_r_stats, ups_w_stats) = wrapper_stats.into_pair(); diff --git a/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/stats.rs b/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/stats.rs deleted file mode 100644 index a754a25f7..000000000 --- a/g3proxy/src/escape/proxy_float/peer/socks5/udp_connect/stats.rs +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2023 ByteDance and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -use std::sync::Arc; - -use g3_io_ext::{ArcLimitedRecvStats, ArcLimitedSendStats, LimitedRecvStats, LimitedSendStats}; - -use super::ProxyFloatEscaperStats; -use crate::auth::UserUpstreamTrafficStats; -use crate::module::udp_connect::ArcUdpConnectTaskRemoteStats; - -#[derive(Clone)] -pub(super) struct ProxySocks5UdpConnectRemoteStats { - escaper: Arc, - task: ArcUdpConnectTaskRemoteStats, - others: Vec, -} - -impl ProxySocks5UdpConnectRemoteStats { - pub(super) fn new( - escaper: &Arc, - task: ArcUdpConnectTaskRemoteStats, - ) -> Self { - ProxySocks5UdpConnectRemoteStats { - escaper: Arc::clone(escaper), - task, - others: Vec::with_capacity(2), - } - } - - pub(super) fn push_user_io_stats(&mut self, all: Vec>) { - for s in all { - self.others.push(s as ArcUdpConnectTaskRemoteStats); - } - } - - pub(super) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { - let s = Arc::new(self); - ( - Arc::clone(&s) as ArcLimitedRecvStats, - s as ArcLimitedSendStats, - ) - } -} - -impl LimitedRecvStats for ProxySocks5UdpConnectRemoteStats { - fn add_recv_bytes(&self, size: usize) { - let size = size as u64; - self.escaper.udp.io.add_in_bytes(size); - self.task.add_recv_bytes(size); - self.others - .iter() - .for_each(|stats| stats.add_recv_bytes(size)); - } - - fn add_recv_packet(&self) { - self.escaper.udp.io.add_in_packet(); - self.task.add_recv_packet(); - self.others.iter().for_each(|stats| stats.add_recv_packet()); - } -} - -impl LimitedSendStats for ProxySocks5UdpConnectRemoteStats { - fn add_send_bytes(&self, size: usize) { - let size = size as u64; - self.escaper.udp.io.add_out_bytes(size); - self.task.add_send_bytes(size); - self.others - .iter() - .for_each(|stats| stats.add_send_bytes(size)); - } - - fn add_send_packet(&self) { - self.escaper.udp.io.add_out_packet(); - self.task.add_send_packet(); - self.others.iter().for_each(|stats| stats.add_send_packet()); - } -} diff --git a/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/mod.rs b/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/mod.rs index 3211cfd5b..0e02fdc47 100644 --- a/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/mod.rs +++ b/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/mod.rs @@ -14,11 +14,13 @@ * limitations under the License. */ +use std::sync::Arc; + use g3_io_ext::{LimitedUdpRecv, LimitedUdpSend}; -use super::{NextProxyPeerInternal, ProxyFloatEscaperStats, ProxyFloatSocks5Peer}; +use super::{NextProxyPeerInternal, ProxyFloatSocks5Peer}; use crate::escape::proxy_socks5::udp_relay::{ - ProxySocks5UdpRelayRemoteRecv, ProxySocks5UdpRelayRemoteSend, + ProxySocks5UdpRelayRemoteRecv, ProxySocks5UdpRelayRemoteSend, ProxySocks5UdpRelayRemoteStats, }; use crate::module::tcp_connect::TcpConnectTaskNotes; use crate::module::udp_relay::{ @@ -26,9 +28,6 @@ use crate::module::udp_relay::{ }; use crate::serve::ServerTaskNotes; -mod stats; -use stats::ProxySocks5UdpRelayRemoteStats; - impl ProxyFloatSocks5Peer { pub(super) async fn udp_setup_relay<'a>( &'a self, @@ -42,8 +41,10 @@ impl ProxyFloatSocks5Peer { .await .map_err(UdpRelaySetupError::SetupSocketFailed)?; - let mut wrapper_stats = - ProxySocks5UdpRelayRemoteStats::new(&self.escaper_stats, task_stats); + let mut wrapper_stats = ProxySocks5UdpRelayRemoteStats::new( + Arc::clone(&self.escaper_stats) as ArcUdpRelayTaskRemoteStats, + task_stats, + ); wrapper_stats.push_user_io_stats(self.fetch_user_upstream_io_stats(task_notes)); let (ups_r_stats, ups_w_stats) = wrapper_stats.into_pair(); diff --git a/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/stats.rs b/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/stats.rs deleted file mode 100644 index 0645bfec6..000000000 --- a/g3proxy/src/escape/proxy_float/peer/socks5/udp_relay/stats.rs +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2023 ByteDance and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -use std::sync::Arc; - -use g3_io_ext::{ArcLimitedRecvStats, ArcLimitedSendStats, LimitedRecvStats, LimitedSendStats}; - -use super::ProxyFloatEscaperStats; -use crate::auth::UserUpstreamTrafficStats; -use crate::module::udp_relay::ArcUdpRelayTaskRemoteStats; - -#[derive(Clone)] -pub(super) struct ProxySocks5UdpRelayRemoteStats { - escaper: Arc, - task: ArcUdpRelayTaskRemoteStats, - others: Vec, -} - -impl ProxySocks5UdpRelayRemoteStats { - pub(super) fn new( - escaper: &Arc, - task: ArcUdpRelayTaskRemoteStats, - ) -> Self { - ProxySocks5UdpRelayRemoteStats { - escaper: Arc::clone(escaper), - task, - others: Vec::with_capacity(2), - } - } - - pub(super) fn push_user_io_stats(&mut self, all: Vec>) { - for s in all { - self.others.push(s as ArcUdpRelayTaskRemoteStats); - } - } - - pub(super) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { - let s = Arc::new(self); - ( - Arc::clone(&s) as ArcLimitedRecvStats, - s as ArcLimitedSendStats, - ) - } -} - -impl LimitedRecvStats for ProxySocks5UdpRelayRemoteStats { - fn add_recv_bytes(&self, size: usize) { - let size = size as u64; - self.escaper.udp.io.add_in_bytes(size); - self.task.add_recv_bytes(size); - self.others - .iter() - .for_each(|stats| stats.add_recv_bytes(size)); - } - - fn add_recv_packet(&self) { - self.escaper.udp.io.add_in_packet(); - self.task.add_recv_packet(); - self.others.iter().for_each(|stats| stats.add_recv_packet()); - } -} - -impl LimitedSendStats for ProxySocks5UdpRelayRemoteStats { - fn add_send_bytes(&self, size: usize) { - let size = size as u64; - self.escaper.udp.io.add_out_bytes(size); - self.task.add_send_bytes(size); - self.others - .iter() - .for_each(|stats| stats.add_send_bytes(size)); - } - - fn add_send_packet(&self) { - self.escaper.udp.io.add_out_packet(); - self.task.add_send_packet(); - self.others.iter().for_each(|stats| stats.add_send_packet()); - } -} diff --git a/g3proxy/src/escape/proxy_float/stats/escaper.rs b/g3proxy/src/escape/proxy_float/stats/escaper.rs index 351178f43..8213e2e0b 100644 --- a/g3proxy/src/escape/proxy_float/stats/escaper.rs +++ b/g3proxy/src/escape/proxy_float/stats/escaper.rs @@ -27,6 +27,8 @@ use g3_types::stats::{StatId, TcpIoSnapshot, UdpIoSnapshot}; use crate::escape::{ EscaperInterfaceStats, EscaperInternalStats, EscaperStats, EscaperTcpStats, EscaperUdpStats, }; +use crate::module::udp_connect::UdpConnectTaskRemoteStats; +use crate::module::udp_relay::UdpRelayTaskRemoteStats; pub(crate) struct ProxyFloatEscaperStats { name: MetricsName, @@ -123,3 +125,39 @@ impl LimitedWriterStats for ProxyFloatEscaperStats { self.tcp.io.add_out_bytes(size); } } + +impl UdpRelayTaskRemoteStats for ProxyFloatEscaperStats { + fn add_recv_bytes(&self, size: u64) { + self.udp.io.add_in_bytes(size); + } + + fn add_recv_packet(&self) { + self.udp.io.add_in_packet(); + } + + fn add_send_bytes(&self, size: u64) { + self.udp.io.add_out_bytes(size); + } + + fn add_send_packet(&self) { + self.udp.io.add_out_packet(); + } +} + +impl UdpConnectTaskRemoteStats for ProxyFloatEscaperStats { + fn add_recv_bytes(&self, size: u64) { + self.udp.io.add_in_bytes(size); + } + + fn add_recv_packet(&self) { + self.udp.io.add_in_packet(); + } + + fn add_send_bytes(&self, size: u64) { + self.udp.io.add_out_bytes(size); + } + + fn add_send_packet(&self) { + self.udp.io.add_out_packet(); + } +} diff --git a/g3proxy/src/escape/proxy_socks5/stats.rs b/g3proxy/src/escape/proxy_socks5/stats.rs index 0bc394c52..37570732e 100644 --- a/g3proxy/src/escape/proxy_socks5/stats.rs +++ b/g3proxy/src/escape/proxy_socks5/stats.rs @@ -27,6 +27,8 @@ use g3_types::stats::{StatId, TcpIoSnapshot, UdpIoSnapshot}; use crate::escape::{ EscaperInterfaceStats, EscaperInternalStats, EscaperStats, EscaperTcpStats, EscaperUdpStats, }; +use crate::module::udp_connect::UdpConnectTaskRemoteStats; +use crate::module::udp_relay::UdpRelayTaskRemoteStats; pub(super) struct ProxySocks5EscaperStats { name: MetricsName, @@ -123,3 +125,39 @@ impl LimitedWriterStats for ProxySocks5EscaperStats { self.tcp.io.add_out_bytes(size); } } + +impl UdpRelayTaskRemoteStats for ProxySocks5EscaperStats { + fn add_recv_bytes(&self, size: u64) { + self.udp.io.add_in_bytes(size); + } + + fn add_recv_packet(&self) { + self.udp.io.add_in_packet(); + } + + fn add_send_bytes(&self, size: u64) { + self.udp.io.add_out_bytes(size); + } + + fn add_send_packet(&self) { + self.udp.io.add_out_packet(); + } +} + +impl UdpConnectTaskRemoteStats for ProxySocks5EscaperStats { + fn add_recv_bytes(&self, size: u64) { + self.udp.io.add_in_bytes(size); + } + + fn add_recv_packet(&self) { + self.udp.io.add_in_packet(); + } + + fn add_send_bytes(&self, size: u64) { + self.udp.io.add_out_bytes(size); + } + + fn add_send_packet(&self) { + self.udp.io.add_out_packet(); + } +} diff --git a/g3proxy/src/escape/proxy_socks5/udp_connect/mod.rs b/g3proxy/src/escape/proxy_socks5/udp_connect/mod.rs index 103ed7dfb..cdfd5bc00 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_connect/mod.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_connect/mod.rs @@ -15,8 +15,9 @@ */ use g3_io_ext::{LimitedUdpRecv, LimitedUdpSend}; +use std::sync::Arc; -use super::{ProxySocks5Escaper, ProxySocks5EscaperStats}; +use super::ProxySocks5Escaper; use crate::module::tcp_connect::TcpConnectTaskNotes; use crate::module::udp_connect::{ ArcUdpConnectTaskRemoteStats, UdpConnectError, UdpConnectResult, UdpConnectTaskNotes, @@ -24,7 +25,7 @@ use crate::module::udp_connect::{ use crate::serve::ServerTaskNotes; mod stats; -use stats::ProxySocks5UdpConnectRemoteStats; +pub(crate) use stats::ProxySocks5UdpConnectRemoteStats; mod recv; mod send; @@ -53,7 +54,10 @@ impl ProxySocks5Escaper { udp_notes.local = Some(udp_local_addr); udp_notes.next = Some(udp_peer_addr); - let mut wrapper_stats = ProxySocks5UdpConnectRemoteStats::new(&self.stats, task_stats); + let mut wrapper_stats = ProxySocks5UdpConnectRemoteStats::new( + Arc::clone(&self.stats) as ArcUdpConnectTaskRemoteStats, + task_stats, + ); wrapper_stats.push_user_io_stats(self.fetch_user_upstream_io_stats(task_notes)); let (ups_r_stats, ups_w_stats) = wrapper_stats.into_pair(); diff --git a/g3proxy/src/escape/proxy_socks5/udp_connect/stats.rs b/g3proxy/src/escape/proxy_socks5/udp_connect/stats.rs index 0e6c50765..d32c22575 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_connect/stats.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_connect/stats.rs @@ -18,36 +18,35 @@ use std::sync::Arc; use g3_io_ext::{ArcLimitedRecvStats, ArcLimitedSendStats, LimitedRecvStats, LimitedSendStats}; -use super::ProxySocks5EscaperStats; use crate::auth::UserUpstreamTrafficStats; use crate::module::udp_connect::ArcUdpConnectTaskRemoteStats; #[derive(Clone)] -pub(super) struct ProxySocks5UdpConnectRemoteStats { - escaper: Arc, +pub(crate) struct ProxySocks5UdpConnectRemoteStats { + escaper: ArcUdpConnectTaskRemoteStats, task: ArcUdpConnectTaskRemoteStats, others: Vec, } impl ProxySocks5UdpConnectRemoteStats { - pub(super) fn new( - escaper: &Arc, + pub(crate) fn new( + escaper: ArcUdpConnectTaskRemoteStats, task: ArcUdpConnectTaskRemoteStats, ) -> Self { ProxySocks5UdpConnectRemoteStats { - escaper: Arc::clone(escaper), + escaper, task, others: Vec::with_capacity(2), } } - pub(super) fn push_user_io_stats(&mut self, all: Vec>) { + pub(crate) fn push_user_io_stats(&mut self, all: Vec>) { for s in all { self.others.push(s as ArcUdpConnectTaskRemoteStats); } } - pub(super) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { + pub(crate) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { let s = Arc::new(self); ( Arc::clone(&s) as ArcLimitedRecvStats, @@ -59,7 +58,7 @@ impl ProxySocks5UdpConnectRemoteStats { impl LimitedRecvStats for ProxySocks5UdpConnectRemoteStats { fn add_recv_bytes(&self, size: usize) { let size = size as u64; - self.escaper.udp.io.add_in_bytes(size); + self.escaper.add_recv_bytes(size); self.task.add_recv_bytes(size); self.others .iter() @@ -67,7 +66,7 @@ impl LimitedRecvStats for ProxySocks5UdpConnectRemoteStats { } fn add_recv_packet(&self) { - self.escaper.udp.io.add_in_packet(); + self.escaper.add_recv_packet(); self.task.add_recv_packet(); self.others.iter().for_each(|stats| stats.add_recv_packet()); } @@ -76,7 +75,7 @@ impl LimitedRecvStats for ProxySocks5UdpConnectRemoteStats { impl LimitedSendStats for ProxySocks5UdpConnectRemoteStats { fn add_send_bytes(&self, size: usize) { let size = size as u64; - self.escaper.udp.io.add_out_bytes(size); + self.escaper.add_send_bytes(size); self.task.add_send_bytes(size); self.others .iter() @@ -84,7 +83,7 @@ impl LimitedSendStats for ProxySocks5UdpConnectRemoteStats { } fn add_send_packet(&self) { - self.escaper.udp.io.add_out_packet(); + self.escaper.add_send_packet(); self.task.add_send_packet(); self.others.iter().for_each(|stats| stats.add_send_packet()); } diff --git a/g3proxy/src/escape/proxy_socks5/udp_relay/mod.rs b/g3proxy/src/escape/proxy_socks5/udp_relay/mod.rs index 6cc9a3340..bede6b07c 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_relay/mod.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_relay/mod.rs @@ -15,8 +15,9 @@ */ use g3_io_ext::{LimitedUdpRecv, LimitedUdpSend}; +use std::sync::Arc; -use super::{ProxySocks5Escaper, ProxySocks5EscaperStats}; +use super::ProxySocks5Escaper; use crate::module::tcp_connect::TcpConnectTaskNotes; use crate::module::udp_relay::{ ArcUdpRelayTaskRemoteStats, UdpRelaySetupError, UdpRelaySetupResult, UdpRelayTaskNotes, @@ -24,7 +25,7 @@ use crate::module::udp_relay::{ use crate::serve::ServerTaskNotes; mod stats; -use stats::ProxySocks5UdpRelayRemoteStats; +pub(crate) use stats::ProxySocks5UdpRelayRemoteStats; mod recv; mod send; @@ -45,7 +46,10 @@ impl ProxySocks5Escaper { .await .map_err(UdpRelaySetupError::SetupSocketFailed)?; - let mut wrapper_stats = ProxySocks5UdpRelayRemoteStats::new(&self.stats, task_stats); + let mut wrapper_stats = ProxySocks5UdpRelayRemoteStats::new( + Arc::clone(&self.stats) as ArcUdpRelayTaskRemoteStats, + task_stats, + ); wrapper_stats.push_user_io_stats(self.fetch_user_upstream_io_stats(task_notes)); let (ups_r_stats, ups_w_stats) = wrapper_stats.into_pair(); diff --git a/g3proxy/src/escape/proxy_socks5/udp_relay/stats.rs b/g3proxy/src/escape/proxy_socks5/udp_relay/stats.rs index ad07ae35f..bcf089795 100644 --- a/g3proxy/src/escape/proxy_socks5/udp_relay/stats.rs +++ b/g3proxy/src/escape/proxy_socks5/udp_relay/stats.rs @@ -18,36 +18,35 @@ use std::sync::Arc; use g3_io_ext::{ArcLimitedRecvStats, ArcLimitedSendStats, LimitedRecvStats, LimitedSendStats}; -use super::ProxySocks5EscaperStats; use crate::auth::UserUpstreamTrafficStats; use crate::module::udp_relay::ArcUdpRelayTaskRemoteStats; #[derive(Clone)] -pub(super) struct ProxySocks5UdpRelayRemoteStats { - escaper: Arc, +pub(crate) struct ProxySocks5UdpRelayRemoteStats { + escaper: ArcUdpRelayTaskRemoteStats, task: ArcUdpRelayTaskRemoteStats, others: Vec, } impl ProxySocks5UdpRelayRemoteStats { - pub(super) fn new( - escaper: &Arc, + pub(crate) fn new( + escaper: ArcUdpRelayTaskRemoteStats, task: ArcUdpRelayTaskRemoteStats, ) -> Self { ProxySocks5UdpRelayRemoteStats { - escaper: Arc::clone(escaper), + escaper, task, others: Vec::with_capacity(2), } } - pub(super) fn push_user_io_stats(&mut self, all: Vec>) { + pub(crate) fn push_user_io_stats(&mut self, all: Vec>) { for s in all { self.others.push(s as ArcUdpRelayTaskRemoteStats); } } - pub(super) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { + pub(crate) fn into_pair(self) -> (ArcLimitedRecvStats, ArcLimitedSendStats) { let s = Arc::new(self); ( Arc::clone(&s) as ArcLimitedRecvStats, @@ -59,7 +58,7 @@ impl ProxySocks5UdpRelayRemoteStats { impl LimitedRecvStats for ProxySocks5UdpRelayRemoteStats { fn add_recv_bytes(&self, size: usize) { let size = size as u64; - self.escaper.udp.io.add_in_bytes(size); + self.escaper.add_recv_bytes(size); self.task.add_recv_bytes(size); self.others .iter() @@ -67,7 +66,7 @@ impl LimitedRecvStats for ProxySocks5UdpRelayRemoteStats { } fn add_recv_packet(&self) { - self.escaper.udp.io.add_in_packet(); + self.escaper.add_recv_packet(); self.task.add_recv_packet(); self.others.iter().for_each(|stats| stats.add_recv_packet()); } @@ -76,7 +75,7 @@ impl LimitedRecvStats for ProxySocks5UdpRelayRemoteStats { impl LimitedSendStats for ProxySocks5UdpRelayRemoteStats { fn add_send_bytes(&self, size: usize) { let size = size as u64; - self.escaper.udp.io.add_out_bytes(size); + self.escaper.add_send_bytes(size); self.task.add_send_bytes(size); self.others .iter() @@ -84,7 +83,7 @@ impl LimitedSendStats for ProxySocks5UdpRelayRemoteStats { } fn add_send_packet(&self) { - self.escaper.udp.io.add_out_packet(); + self.escaper.add_send_packet(); self.task.add_send_packet(); self.others.iter().for_each(|stats| stats.add_send_packet()); }