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>,
|
shutdown_rx: broadcast::Receiver<bool>,
|
||||||
service_rx: mpsc::Receiver<ServiceChange>,
|
service_rx: mpsc::Receiver<ServiceChange>,
|
||||||
) -> Result<()> {
|
) -> 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"
|
"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
|
let tls_config = config
|
||||||
.tls
|
.tls
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or(anyhow!("Missing TLS configuration"))?;
|
.ok_or_else(|| anyhow!("Missing TLS configuration"))?;
|
||||||
if is_server {
|
if is_server {
|
||||||
tls_config
|
tls_config
|
||||||
.pkcs12
|
.pkcs12
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and(tls_config.pkcs12_password.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 {
|
} else {
|
||||||
tls_config
|
tls_config
|
||||||
.trusted_root
|
.trusted_root
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or(anyhow!("Missing `trusted_root`"))?;
|
.ok_or_else(|| anyhow!("Missing `trusted_root`"))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ async fn to_socket_addr<A: ToSocketAddrs>(addr: A) -> Result<SocketAddr> {
|
||||||
lookup_host(addr)
|
lookup_host(addr)
|
||||||
.await?
|
.await?
|
||||||
.next()
|
.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)> {
|
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
|
let mut conn = data_ch_rx
|
||||||
.recv()
|
.recv()
|
||||||
.await
|
.await
|
||||||
.ok_or(anyhow!("No available data channels"))?;
|
.ok_or_else(|| anyhow!("No available data channels"))?;
|
||||||
conn.write_all(&cmd).await?;
|
conn.write_all(&cmd).await?;
|
||||||
|
|
||||||
let mut buf = [0u8; UDP_BUFFER_SIZE];
|
let mut buf = [0u8; UDP_BUFFER_SIZE];
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl Transport for TlsTransport {
|
||||||
|
|
||||||
fn new(config: &TransportConfig) -> Result<Self> {
|
fn new(config: &TransportConfig) -> Result<Self> {
|
||||||
let tcp = TcpTransport::new(config)?;
|
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() {
|
let connector = match config.trusted_root.as_ref() {
|
||||||
Some(path) => {
|
Some(path) => {
|
||||||
|
|
Loading…
Reference in New Issue