mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Format code with rustfmt
This commit is contained in:
parent
5c5fc61360
commit
816e221bf5
1 changed files with 15 additions and 4 deletions
|
|
@ -2,7 +2,7 @@ use std::{io, sync::Arc, time::{Duration, SystemTime}};
|
||||||
|
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use russh::keys::{PrivateKeyWithHashAlg, agent::AgentIdentity, known_hosts};
|
use russh::keys::{PrivateKeyWithHashAlg, agent::AgentIdentity, known_hosts};
|
||||||
use yazi_fs::{provider::local::Local, Xdg};
|
use yazi_fs::{Xdg, provider::local::Local};
|
||||||
|
|
||||||
use crate::config::ServiceSftp;
|
use crate::config::ServiceSftp;
|
||||||
|
|
||||||
|
|
@ -27,10 +27,20 @@ impl russh::client::Handler for Conn {
|
||||||
) -> Result<bool, Self::Error> {
|
) -> Result<bool, Self::Error> {
|
||||||
let path = Xdg::config_dir().join("known_hosts");
|
let path = Xdg::config_dir().join("known_hosts");
|
||||||
|
|
||||||
match known_hosts::check_known_hosts_path(&self.config.host, self.config.port, server_public_key, &path) {
|
match known_hosts::check_known_hosts_path(
|
||||||
|
&self.config.host,
|
||||||
|
self.config.port,
|
||||||
|
server_public_key,
|
||||||
|
&path,
|
||||||
|
) {
|
||||||
Ok(true) => Ok(true),
|
Ok(true) => Ok(true),
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
if let Err(e) = known_hosts::learn_known_hosts_path(&self.config.host, self.config.port, server_public_key, &path) {
|
if let Err(e) = known_hosts::learn_known_hosts_path(
|
||||||
|
&self.config.host,
|
||||||
|
self.config.port,
|
||||||
|
server_public_key,
|
||||||
|
&path,
|
||||||
|
) {
|
||||||
tracing::warn!("Failed to record host key in known_hosts: {e}");
|
tracing::warn!("Failed to record host key in known_hosts: {e}");
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|
@ -38,7 +48,8 @@ impl russh::client::Handler for Conn {
|
||||||
Err(russh::keys::Error::KeyChanged { line }) => {
|
Err(russh::keys::Error::KeyChanged { line }) => {
|
||||||
tracing::error!(
|
tracing::error!(
|
||||||
"Host key for `{}` has changed (known_hosts:{}). Possible MITM attack!",
|
"Host key for `{}` has changed (known_hosts:{}). Possible MITM attack!",
|
||||||
self.config.host, line
|
self.config.host,
|
||||||
|
line
|
||||||
);
|
);
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue