perf: simplify method signatures and reduce clone across multiple files (#1663)
EasyTier Core / pre_job (push) Has been cancelled
EasyTier Core / build_web (push) Has been cancelled
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-22.04, x86_64-unknown-freebsd) (push) Has been cancelled
EasyTier Core / build (linux-aarch64, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-arm, ubuntu-22.04, arm-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armhf, ubuntu-22.04, arm-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-armv7, ubuntu-22.04, armv7-unknown-linux-musleabi) (push) Has been cancelled
EasyTier Core / build (linux-armv7hf, ubuntu-22.04, armv7-unknown-linux-musleabihf) (push) Has been cancelled
EasyTier Core / build (linux-loongarch64, ubuntu-24.04, loongarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mips, ubuntu-22.04, mips-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-mipsel, ubuntu-22.04, mipsel-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-riscv64, ubuntu-22.04, riscv64gc-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (linux-x86_64, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier Core / build (windows-arm64, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-i686, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier Core / core-result (push) Has been cancelled
EasyTier Core / magisk_build (push) Has been cancelled
EasyTier GUI / pre_job (push) Has been cancelled
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-22.04, aarch64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-22.04, x86_64-unknown-linux-musl) (push) Has been cancelled
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Has been cancelled
EasyTier GUI / build-gui (windows-arm64, aarch64-pc-windows-msvc, windows-latest, aarch64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-i686, i686-pc-windows-msvc, windows-latest, i686-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Has been cancelled
EasyTier GUI / gui-result (push) Has been cancelled
EasyTier Mobile / pre_job (push) Has been cancelled
EasyTier Mobile / build-mobile (android, ubuntu-22.04, android) (push) Has been cancelled
EasyTier Mobile / mobile-result (push) Has been cancelled
EasyTier OHOS / cargo_fmt_check (push) Has been cancelled
EasyTier OHOS / pre_job (push) Has been cancelled
EasyTier OHOS / build-ohos (push) Has been cancelled
EasyTier Test / pre_job (push) Has been cancelled
EasyTier Test / test (push) Has been cancelled

This commit is contained in:
Tunglies
2025-12-09 16:47:57 +08:00
committed by GitHub
parent 2bc51daa98
commit fe4dff5df0
33 changed files with 62 additions and 81 deletions
+1 -1
View File
@@ -509,7 +509,7 @@ impl StatsManager {
let counters = Arc::new(DashMap::new());
// Start cleanup task only if we're in a tokio runtime
let counters_clone = Arc::downgrade(&counters.clone());
let counters_clone = Arc::downgrade(&counters);
let cleanup_task = tokio::spawn(async move {
let mut interval = interval(Duration::from_secs(60)); // Check every minute
loop {
@@ -90,7 +90,7 @@ where
/// Rotates old files to make room for a new one.
/// This may result in the deletion of the oldest file
fn rotate_files(&mut self) -> io::Result<()> {
fn rotate_files(&self) -> io::Result<()> {
// ignore any failure removing the oldest file (may not exist)
let _ = fs::remove_file(self.filename_for(self.max_filecount.max(1)));
let mut r = Ok(());
+1 -1
View File
@@ -249,7 +249,7 @@ impl ManualConnectorManager {
create_connector_by_url(&dead_url, &data.global_ctx.clone(), ip_version).await?;
data.global_ctx
.issue_event(GlobalCtxEvent::Connecting(connector.remote_url().clone()));
.issue_event(GlobalCtxEvent::Connecting(connector.remote_url()));
tracing::info!("reconnect try connect... conn: {:?}", connector);
let Some(pm) = data.peer_manager.upgrade() else {
return Err(Error::AnyhowError(anyhow::anyhow!(
@@ -636,7 +636,6 @@ pub(crate) async fn try_connect_with_socket(
remote_mapped_addr.ip(),
remote_mapped_addr.port()
)
.to_string()
.parse()
.unwrap(),
);
+1 -1
View File
@@ -62,7 +62,7 @@ struct UdpHolePunchServer {
impl UdpHolePunchServer {
pub fn new(peer_mgr: Arc<PeerManager>) -> Arc<Self> {
let common = Arc::new(PunchHoleServerCommon::new(peer_mgr.clone()));
let common = Arc::new(PunchHoleServerCommon::new(peer_mgr));
let cone_server = PunchConeHoleServer::new(common.clone());
let sym_to_cone_server = PunchSymToConeHoleServer::new(common.clone());
let both_easy_sym_server = PunchBothEasySymHoleServer::new(common.clone());
+7 -9
View File
@@ -715,7 +715,7 @@ impl NetworkOptions {
false
}
fn merge_into(&self, cfg: &mut TomlConfigLoader) -> anyhow::Result<()> {
fn merge_into(&self, cfg: &TomlConfigLoader) -> anyhow::Result<()> {
if self.hostname.is_some() {
cfg.set_hostname(self.hostname.clone());
}
@@ -1213,7 +1213,7 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
}
};
for config_file in config_files {
let (mut cfg, mut control) = load_config_from_file(
let (cfg, mut control) = load_config_from_file(
&config_file,
cli.config_dir.as_ref(),
cli.disable_env_parsing,
@@ -1222,7 +1222,7 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
if cli.network_options.can_merge(&cfg, config_file_count) {
cli.network_options
.merge_into(&mut cfg)
.merge_into(&cfg)
.with_context(|| format!("failed to merge config from cli: {:?}", config_file))?;
crate_cli_network = false;
control.set_read_only(true);
@@ -1240,9 +1240,9 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
}
if crate_cli_network {
let mut cfg = TomlConfigLoader::default();
let cfg = TomlConfigLoader::default();
cli.network_options
.merge_into(&mut cfg)
.merge_into(&cfg)
.with_context(|| "failed to create config from cli".to_string())?;
println!("Starting easytier from cli with config:");
println!("############### TOML ###############\n");
@@ -1261,11 +1261,9 @@ async fn run_main(cli: Cli) -> anyhow::Result<()> {
tokio::select! {
_ = manager.wait() => {
let infos = manager.collect_network_infos().await?;
let errs = infos
if infos
.into_values()
.filter_map(|info| info.error_msg)
.collect::<Vec<_>>();
if !errs.is_empty() {
.filter_map(|info| info.error_msg).next().is_some() {
return Err(anyhow::anyhow!("some instances stopped with errors"));
}
}
+3 -7
View File
@@ -610,17 +610,13 @@ impl CommandHandler<'_> {
loss_rate: format!("{:.1}%", p.get_loss_rate().unwrap_or(0.0) * 100.0),
rx_bytes: format_size(p.get_rx_bytes().unwrap_or(0), humansize::DECIMAL),
tx_bytes: format_size(p.get_tx_bytes().unwrap_or(0), humansize::DECIMAL),
tunnel_proto: p
.get_conn_protos()
.unwrap_or_default()
.join(",")
.to_string(),
tunnel_proto: p.get_conn_protos().unwrap_or_default().join(","),
nat_type: p.get_udp_nat_type(),
id: route.peer_id.to_string(),
version: if route.version.is_empty() {
"unknown".to_string()
} else {
route.version.to_string()
route.version
},
}
}
@@ -1521,7 +1517,7 @@ async fn main() -> Result<(), Error> {
node_info.peer_id,
PeerCenterNodeInfo {
hostname: node_info.hostname.clone(),
ipv4: node_info.ipv4_addr.clone(),
ipv4: node_info.ipv4_addr,
},
);
for route_info in route_infos {
+1 -1
View File
@@ -551,7 +551,7 @@ impl KcpProxyDst {
async fn run_accept_task(&mut self) {
let kcp_endpoint = self.kcp_endpoint.clone();
let global_ctx = self.peer_manager.get_global_ctx().clone();
let global_ctx = self.peer_manager.get_global_ctx();
let proxy_entries = self.proxy_entries.clone();
let cidr_set = self.cidr_set.clone();
let route = Arc::new(self.peer_manager.get_route());
-1
View File
@@ -296,7 +296,6 @@ impl Socks5ServerNet {
cap.medium = smoltcp::phy::Medium::Ip;
let (dev, stack_sink, mut stack_stream) = channel_device::ChannelDevice::new(cap);
let packet_recv = packet_recv.clone();
forward_tasks.spawn(async move {
let mut smoltcp_stack_receiver = packet_recv.lock().await;
while let Some(packet) = smoltcp_stack_receiver.recv().await {
@@ -126,7 +126,7 @@ impl Reactor {
(
Reactor {
notify,
iface: iface.clone(),
iface,
socket_allocator,
},
fut,
+6 -9
View File
@@ -46,10 +46,7 @@ impl TcpListener {
local_addr,
})
}
pub fn poll_accept(
&mut self,
cx: &mut Context<'_>,
) -> Poll<io::Result<(TcpStream, SocketAddr)>> {
pub fn poll_accept(&mut self, cx: &Context<'_>) -> Poll<io::Result<(TcpStream, SocketAddr)>> {
let mut socket = self.reactor.get_socket::<tcp::Socket>(*self.handle);
if socket.state() == tcp::State::Established {
@@ -69,7 +66,7 @@ impl TcpListener {
Ok(self.local_addr)
}
pub fn relisten(&mut self) {
pub fn relisten(&self) {
let mut socket = self.reactor.get_socket::<tcp::Socket>(*self.handle);
let local_endpoint = socket.local_endpoint().unwrap();
socket.abort();
@@ -169,7 +166,7 @@ impl TcpStream {
Ok((
TcpStream {
handle: replace(&mut listener.handle, new_handle),
reactor: reactor.clone(),
reactor,
local_addr,
peer_addr,
},
@@ -183,7 +180,7 @@ impl TcpStream {
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
Ok(self.peer_addr)
}
pub fn poll_connected(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
pub fn poll_connected(&self, cx: &Context<'_>) -> Poll<io::Result<()>> {
let mut socket = self.reactor.get_socket::<tcp::Socket>(*self.handle);
if socket.state() == tcp::State::Established {
return Poll::Ready(Ok(()));
@@ -290,7 +287,7 @@ impl UdpSocket {
/// Note that on multiple calls to a poll_* method in the send direction, only the Waker from the Context passed to the most recent call will be scheduled to receive a wakeup.
pub fn poll_send_to(
&self,
cx: &mut Context<'_>,
cx: &Context<'_>,
buf: &[u8],
target: SocketAddr,
) -> Poll<io::Result<usize>> {
@@ -317,7 +314,7 @@ impl UdpSocket {
/// Note that on multiple calls to a poll_* method in the recv direction, only the Waker from the Context passed to the most recent call will be scheduled to receive a wakeup.
pub fn poll_recv_from(
&self,
cx: &mut Context<'_>,
cx: &Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<(usize, SocketAddr)>> {
let mut socket = self.reactor.get_socket::<udp::Socket>(*self.handle);
+3 -3
View File
@@ -85,7 +85,7 @@ impl UdpNatEntry {
async fn compose_ipv4_packet(
self: &Arc<Self>,
packet_sender: &mut Sender<ZCPacket>,
packet_sender: &Sender<ZCPacket>,
buf: &mut [u8],
src_v4: &SocketAddrV4,
payload_len: usize,
@@ -139,7 +139,7 @@ impl UdpNatEntry {
async fn forward_task(
self: Arc<Self>,
mut packet_sender: Sender<ZCPacket>,
packet_sender: Sender<ZCPacket>,
virtual_ipv4: Ipv4Addr,
real_ipv4: Ipv4Addr,
mapped_ipv4: Ipv4Addr,
@@ -207,7 +207,7 @@ impl UdpNatEntry {
let Ok(_) = Self::compose_ipv4_packet(
&self_clone,
&mut packet_sender,
&packet_sender,
&mut packet,
&src_v4,
len,
+1 -1
View File
@@ -67,7 +67,7 @@ impl RequestHandler for CatalogRequestHandler {
pub fn build_authority(domain: &str, records: &[Record]) -> Result<InMemoryAuthority> {
let zone = rr::Name::from_str(domain)?;
let mut authority = InMemoryAuthority::empty(zone.clone(), ZoneType::Primary, false);
let mut authority = InMemoryAuthority::empty(zone, ZoneType::Primary, false);
for record in records.iter() {
let r = record.try_into()?;
authority.upsert_mut(r, 0);
+3 -3
View File
@@ -73,7 +73,7 @@ impl IpProxy {
let tcp_proxy = TcpProxy::new(peer_manager.clone(), NatDstTcpConnector {});
let icmp_proxy = IcmpProxy::new(global_ctx.clone(), peer_manager.clone())
.with_context(|| "create icmp proxy failed")?;
let udp_proxy = UdpProxy::new(global_ctx.clone(), peer_manager.clone())
let udp_proxy = UdpProxy::new(global_ctx.clone(), peer_manager)
.with_context(|| "create udp proxy failed")?;
Ok(IpProxy {
tcp_proxy,
@@ -551,7 +551,7 @@ impl Instance {
let peer_manager = Arc::new(PeerManager::new(
RouteAlgoType::Ospf,
global_ctx.clone(),
peer_packet_sender.clone(),
peer_packet_sender,
));
peer_manager.set_allow_loopback_tunnel(false);
@@ -617,7 +617,7 @@ impl Instance {
self.conn_manager.clone()
}
async fn add_initial_peers(&mut self) -> Result<(), Error> {
async fn add_initial_peers(&self) -> Result<(), Error> {
for peer in self.global_ctx.config.get_peers().iter() {
self.get_conn_manager()
.add_connector_by_url(peer.uri.clone())
+1 -1
View File
@@ -366,7 +366,7 @@ impl VirtualNic {
Ok(())
}
async fn create_tun(&mut self) -> Result<tun::platform::Device, Error> {
async fn create_tun(&self) -> Result<tun::platform::Device, Error> {
let mut config = Configuration::default();
config.layer(Layer::L3);
+2 -2
View File
@@ -224,7 +224,7 @@ impl EasyTierLauncher {
let notifier = data.instance_stop_notifier.clone();
let ret = rt.block_on(Self::easytier_routine(
cfg,
stop_notifier.clone(),
stop_notifier,
api_service,
data,
));
@@ -792,7 +792,7 @@ impl NetworkConfig {
let network_identity = config.get_network_identity();
result.network_name = Some(network_identity.network_name.clone());
result.network_secret = network_identity.network_secret.clone();
result.network_secret = network_identity.network_secret;
if let Some(ipv4) = config.get_ipv4() {
result.virtual_ipv4 = Some(ipv4.address().to_string());
+1 -1
View File
@@ -109,7 +109,7 @@ impl Peer {
Peer {
peer_node_id,
conns: conns.clone(),
conns,
packet_recv_chan,
global_ctx,
+4 -5
View File
@@ -192,7 +192,7 @@ impl PeerConn {
self.is_hole_punched
}
async fn wait_handshake(&mut self, need_retry: &mut bool) -> Result<HandshakeRequest, Error> {
async fn wait_handshake(&self, need_retry: &mut bool) -> Result<HandshakeRequest, Error> {
*need_retry = false;
let mut locked = self.recv.lock().await;
@@ -241,7 +241,7 @@ impl PeerConn {
Ok(rsp)
}
async fn wait_handshake_loop(&mut self) -> Result<HandshakeRequest, Error> {
async fn wait_handshake_loop(&self) -> Result<HandshakeRequest, Error> {
timeout(Duration::from_secs(5), async move {
loop {
let mut need_retry = true;
@@ -260,7 +260,7 @@ impl PeerConn {
.await?
}
async fn send_handshake(&mut self, send_secret_digest: bool) -> Result<(), Error> {
async fn send_handshake(&self, send_secret_digest: bool) -> Result<(), Error> {
let network = self.global_ctx.get_network_identity();
let mut req = HandshakeRequest {
magic: MAGIC,
@@ -384,8 +384,7 @@ impl PeerConn {
traffic_rx_bytes: stats_mgr.get_counter(MetricName::TrafficBytesRx, label_set.clone()),
traffic_tx_packets: stats_mgr
.get_counter(MetricName::TrafficPacketsTx, label_set.clone()),
traffic_rx_packets: stats_mgr
.get_counter(MetricName::TrafficPacketsRx, label_set.clone()),
traffic_rx_packets: stats_mgr.get_counter(MetricName::TrafficPacketsRx, label_set),
};
self.counters.store(Some(Arc::new(counters)));
+3 -3
View File
@@ -161,7 +161,7 @@ impl PeerConnPinger {
async fn do_pingpong_once(
my_node_id: PeerId,
peer_id: PeerId,
sink: &mut MpscTunnelSender,
sink: &MpscTunnelSender,
receiver: &mut broadcast::Receiver<ZCPacket>,
seq: u32,
) -> Result<u128, Error> {
@@ -258,7 +258,7 @@ impl PeerConnPinger {
controller,
);
let mut sink = sink.clone();
let sink = sink.clone();
let receiver = ctrl_resp_sender.subscribe();
let ping_res_sender = ping_res_sender.clone();
pingpong_tasks.spawn(async move {
@@ -266,7 +266,7 @@ impl PeerConnPinger {
let pingpong_once_ret = Self::do_pingpong_once(
my_node_id,
peer_id,
&mut sink,
&sink,
&mut receiver,
req_seq,
)
+2 -2
View File
@@ -242,7 +242,7 @@ impl PeerManager {
));
let foreign_network_client = Arc::new(ForeignNetworkClient::new(
global_ctx.clone(),
packet_send.clone(),
packet_send,
peer_rpc_mgr.clone(),
my_peer_id,
));
@@ -289,7 +289,7 @@ impl PeerManager {
packet_recv: Arc::new(Mutex::new(Some(packet_recv))),
peers: peers.clone(),
peers,
peer_rpc_mgr,
peer_rpc_tspt: rpc_tspt,
+1 -1
View File
@@ -2717,7 +2717,7 @@ impl PeerRoute {
Arc::new(PeerRoute {
my_peer_id,
global_ctx: global_ctx.clone(),
global_ctx,
peer_rpc: Arc::downgrade(&peer_rpc),
service_impl,
+2 -2
View File
@@ -39,11 +39,11 @@ pub async fn create_mock_peer_manager_with_name(network_name: String) -> Arc<Pee
pub async fn connect_peer_manager(client: Arc<PeerManager>, server: Arc<PeerManager>) {
let (a_ring, b_ring) = create_ring_tunnel_pair();
let a_mgr_copy = client.clone();
let a_mgr_copy = client;
tokio::spawn(async move {
a_mgr_copy.add_client_tunnel(a_ring, false).await.unwrap();
});
let b_mgr_copy = server.clone();
let b_mgr_copy = server;
tokio::spawn(async move {
b_mgr_copy.add_tunnel_as_server(b_ring, true).await.unwrap();
});
+1 -1
View File
@@ -243,7 +243,7 @@ mod tests {
let iterations = 100000;
let peer_group_info =
PeerGroupInfo::generate_with_proof(group_name.clone(), group_secret.clone(), peer_id);
PeerGroupInfo::generate_with_proof(group_name, group_secret.clone(), peer_id);
let start = std::time::Instant::now();
for _ in 0..iterations {
+2 -2
View File
@@ -348,7 +348,7 @@ impl Client {
return Err(err.into());
}
let raw_output = Bytes::from(rpc_resp.response.clone());
let raw_output = Bytes::from(rpc_resp.response);
ctrl.set_raw_output(raw_output.clone());
// Record RPC client RX and duration stats
@@ -372,7 +372,7 @@ impl Client {
}
F::new(HandlerImpl::<F> {
domain_name: domain_name.to_string(),
domain_name,
from_peer_id,
to_peer_id,
zc_packet_sender: self.mpsc.lock().unwrap().get_sink(),
+1 -1
View File
@@ -206,7 +206,7 @@ impl WebClientService for InstanceManageRpcService {
.filter_map(|id| {
self.manager
.get_instance_config_control(id)
.and_then(|control| control.path.clone())
.and_then(|control| control.path)
})
.collect::<Vec<_>>();
let remain_inst_ids = self.manager.delete_network_instance(inst_ids)?;
+1 -1
View File
@@ -100,7 +100,7 @@ impl Service {
}
self.service_manager
.install(ctx.clone())
.install(ctx)
.map_err(|e| anyhow::anyhow!("failed to install service: {:?}", e))?;
println!(
+1 -1
View File
@@ -80,7 +80,7 @@ pub fn get_insecure_tls_cert<'a>() -> (Vec<CertificateDer<'a>>, PrivateKeyDer<'a
let cert_der = cert.serialize_der().unwrap();
let priv_key = cert.serialize_private_key_der();
let priv_key = rustls::pki_types::PrivatePkcs8KeyDer::from(priv_key);
let cert_chain = vec![cert_der.clone().into()];
let cert_chain = vec![cert_der.into()];
(cert_chain, priv_key.into())
}
+1 -1
View File
@@ -156,7 +156,7 @@ impl QUICTunnelListener {
}
}
async fn do_accept(&mut self) -> Result<Box<dyn Tunnel>, super::TunnelError> {
async fn do_accept(&self) -> Result<Box<dyn Tunnel>, super::TunnelError> {
// accept a single connection
let conn = self
.endpoint
+3 -3
View File
@@ -29,7 +29,7 @@ impl TcpTunnelListener {
}
}
async fn do_accept(&mut self) -> Result<Box<dyn Tunnel>, std::io::Error> {
async fn do_accept(&self) -> Result<Box<dyn Tunnel>, std::io::Error> {
let listener = self.listener.as_ref().unwrap();
let (stream, _) = listener.accept().await?;
@@ -149,7 +149,7 @@ impl TcpTunnelConnector {
}
async fn connect_with_default_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
tracing::info!(url = ?self.addr, ?addr, "connect tcp start, bind addrs: {:?}", self.bind_addrs);
@@ -159,7 +159,7 @@ impl TcpTunnelConnector {
}
async fn connect_with_custom_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
let futures = FuturesUnordered::new();
+2 -2
View File
@@ -798,7 +798,7 @@ impl UdpTunnelConnector {
}
async fn connect_with_default_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
let socket = if addr.is_ipv4() {
@@ -811,7 +811,7 @@ impl UdpTunnelConnector {
}
async fn connect_with_custom_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
let futures = FuturesUnordered::new();
+3 -3
View File
@@ -73,7 +73,7 @@ impl WSTunnelListener {
}
}
async fn try_accept(&mut self, stream: TcpStream) -> Result<Box<dyn Tunnel>, TunnelError> {
async fn try_accept(&self, stream: TcpStream) -> Result<Box<dyn Tunnel>, TunnelError> {
let info = TunnelInfo {
tunnel_type: self.addr.scheme().to_owned(),
local_addr: Some(self.local_url().into()),
@@ -223,7 +223,7 @@ impl WSTunnelConnector {
}
async fn connect_with_default_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
let socket = if addr.is_ipv4() {
@@ -235,7 +235,7 @@ impl WSTunnelConnector {
}
async fn connect_with_custom_bind(
&mut self,
&self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, super::TunnelError> {
let futures = FuturesUnordered::new();
+1 -4
View File
@@ -690,10 +690,7 @@ impl WgTunnelConnector {
Ok(ret)
}
async fn connect_with_ipv6(
&mut self,
addr: SocketAddr,
) -> Result<Box<dyn Tunnel>, TunnelError> {
async fn connect_with_ipv6(&self, addr: SocketAddr) -> Result<Box<dyn Tunnel>, TunnelError> {
let socket2_socket = socket2::Socket::new(
socket2::Domain::for_address(addr),
socket2::Type::DGRAM,
+1 -5
View File
@@ -330,11 +330,7 @@ impl VpnPortal for WireGuard {
allow_ips.push(client_cidr.to_string());
let allow_ips = allow_ips
.into_iter()
.map(|x| x.to_string())
.collect::<Vec<_>>()
.join(",");
let allow_ips = allow_ips.into_iter().collect::<Vec<_>>().join(",");
let cfg = self.inner.as_ref().unwrap().wg_config.clone();
let cfg_str = format!(