mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
perf: simplify method signatures and reduce clone across multiple files (#1663)
This commit is contained in:
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user