mirror of https://github.com/rapiz1/rathole.git
chore: make clippy happy
This commit is contained in:
parent
d842fbb2da
commit
d2c55cc99c
|
@ -33,7 +33,7 @@ pub async fn run_client(
|
|||
shutdown_rx: broadcast::Receiver<bool>,
|
||||
service_rx: mpsc::Receiver<ServiceChange>,
|
||||
) -> Result<()> {
|
||||
let config = config.client.ok_or(anyhow!(
|
||||
let config = config.client.ok_or_else(|| anyhow!(
|
||||
"Try to run as a client, but the configuration is missing. Please add the `[client]` block"
|
||||
))?;
|
||||
|
||||
|
|
|
@ -289,18 +289,18 @@ impl Config {
|
|||
let tls_config = config
|
||||
.tls
|
||||
.as_ref()
|
||||
.ok_or(anyhow!("Missing TLS configuration"))?;
|
||||
.ok_or_else(|| anyhow!("Missing TLS configuration"))?;
|
||||
if is_server {
|
||||
tls_config
|
||||
.pkcs12
|
||||
.as_ref()
|
||||
.and(tls_config.pkcs12_password.as_ref())
|
||||
.ok_or(anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
|
||||
.ok_or_else(|| anyhow!("Missing `pkcs12` or `pkcs12_password`"))?;
|
||||
} else {
|
||||
tls_config
|
||||
.trusted_root
|
||||
.as_ref()
|
||||
.ok_or(anyhow!("Missing `trusted_root`"))?;
|
||||
.ok_or_else(|| anyhow!("Missing `trusted_root`"))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ async fn to_socket_addr<A: ToSocketAddrs>(addr: A) -> Result<SocketAddr> {
|
|||
lookup_host(addr)
|
||||
.await?
|
||||
.next()
|
||||
.ok_or(anyhow!("Failed to lookup the host"))
|
||||
.ok_or_else(|| anyhow!("Failed to lookup the host"))
|
||||
}
|
||||
|
||||
pub fn host_port_pair(s: &str) -> Result<(&str, u16)> {
|
||||
|
|
|
@ -676,7 +676,7 @@ async fn run_udp_connection_pool<T: Transport>(
|
|||
let mut conn = data_ch_rx
|
||||
.recv()
|
||||
.await
|
||||
.ok_or(anyhow!("No available data channels"))?;
|
||||
.ok_or_else(|| anyhow!("No available data channels"))?;
|
||||
conn.write_all(&cmd).await?;
|
||||
|
||||
let mut buf = [0u8; UDP_BUFFER_SIZE];
|
||||
|
|
|
@ -26,7 +26,7 @@ impl Transport for TlsTransport {
|
|||
|
||||
fn new(config: &TransportConfig) -> Result<Self> {
|
||||
let tcp = TcpTransport::new(config)?;
|
||||
let config = config.tls.as_ref().ok_or(anyhow!("Missing tls config"))?;
|
||||
let config = config.tls.as_ref().ok_or_else(|| anyhow!("Missing tls config"))?;
|
||||
|
||||
let connector = match config.trusted_root.as_ref() {
|
||||
Some(path) => {
|
||||
|
|
Loading…
Reference in New Issue