mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Merge f94b474364 into dbb0cc0d55
This commit is contained in:
commit
b5f5bc45fc
2 changed files with 38 additions and 6 deletions
|
|
@ -167,8 +167,8 @@ impl UrlBuf {
|
||||||
Self::Archive { loc: loc.rebase(base), domain: domain.clone() }
|
Self::Archive { loc: loc.rebase(base), domain: domain.clone() }
|
||||||
}
|
}
|
||||||
Self::Sftp { loc, domain } => {
|
Self::Sftp { loc, domain } => {
|
||||||
todo!();
|
let base = typed_path::UnixPath::new(base.as_os_str().as_encoded_bytes());
|
||||||
// Self::Sftp { loc: loc.rebase(base), domain: domain.clone() }
|
Self::Sftp { loc: loc.rebase(base), domain: domain.clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::{io, sync::Arc, time::{Duration, SystemTime}};
|
use std::{io, sync::Arc, time::{Duration, SystemTime}};
|
||||||
|
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use russh::keys::{PrivateKeyWithHashAlg, agent::AgentIdentity};
|
use russh::keys::{PrivateKeyWithHashAlg, agent::AgentIdentity, known_hosts};
|
||||||
use yazi_fs::provider::local::Local;
|
use yazi_fs::{Xdg, provider::local::Local};
|
||||||
|
|
||||||
use crate::config::ServiceSftp;
|
use crate::config::ServiceSftp;
|
||||||
|
|
||||||
|
|
@ -23,9 +23,41 @@ impl russh::client::Handler for Conn {
|
||||||
|
|
||||||
async fn check_server_key(
|
async fn check_server_key(
|
||||||
&mut self,
|
&mut self,
|
||||||
_server_public_key: &russh::keys::PublicKey,
|
server_public_key: &russh::keys::PublicKey,
|
||||||
) -> Result<bool, Self::Error> {
|
) -> Result<bool, Self::Error> {
|
||||||
Ok(true)
|
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,
|
||||||
|
) {
|
||||||
|
Ok(true) => Ok(true),
|
||||||
|
Ok(false) => {
|
||||||
|
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}");
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
Err(russh::keys::Error::KeyChanged { line }) => {
|
||||||
|
tracing::error!(
|
||||||
|
"Host key for `{}` has changed (known_hosts:{}). Possible MITM attack!",
|
||||||
|
self.config.host,
|
||||||
|
line
|
||||||
|
);
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
tracing::error!("Could not verify host key for `{}`: {e}", self.config.host);
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue