This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

knot2/ssh: force no compression bc makes no sense

Lewis: May this revision serve well! <did:plc:3fwecdnvtcscjnrx2p4n7alz>

author did:plc:3fwecdnvtcscjnrx2p4n7a… date (Jul 28, 2026, 8:04 PM +0300) commit e18dd272 parent 8a19bbd8 change-id lxwtvqqw
+48 -1
+6 -1
knot2/crates/knot-ssh/src/lib.rs
··· 2 2 mod roster; 3 3 mod server; 4 4 5 + use std::borrow::Cow; 5 6 use std::collections::BTreeSet; 6 7 use std::net::SocketAddr; 7 8 use std::path::Path; ··· 20 21 use russh::keys::ssh_key::rand_core; 21 22 use russh::keys::{Algorithm, PrivateKey, ssh_key}; 22 23 use russh::server::{Config, Server as _}; 23 - use russh::{MethodKind, MethodSet}; 24 + use russh::{MethodKind, MethodSet, Preferred, compression}; 24 25 use tokio::sync::Semaphore; 25 26 use tokio_util::sync::CancellationToken; 26 27 use tokio_util::task::TaskTracker; ··· 153 154 inactivity_timeout: Some(INACTIVITY_TIMEOUT), 154 155 keepalive_interval: Some(KEEPALIVE_INTERVAL), 155 156 auth_rejection_time: AUTH_REJECTION_TIME, 157 + preferred: Preferred { 158 + compression: Cow::Borrowed(&[compression::NONE]), 159 + ..Preferred::DEFAULT 160 + }, 156 161 ..Config::default() 157 162 }) 158 163 }
+42
knot2/crates/knot-ssh/tests/ssh_push.rs
··· 653 653 } 654 654 655 655 #[tokio::test(flavor = "multi_thread", worker_threads = 4)] 656 + async fn a_client_requesting_ssh_compression_clones_an_incompressible_pack() { 657 + let fx = fixture().await; 658 + std::fs::create_dir_all(&fx.work).unwrap(); 659 + git(&fx.work, &[], &["init", "-q", "-b", "main"]); 660 + let mut state = 0x9e3779b97f4a7c15u64; 661 + let payload: Vec<u8> = std::iter::repeat_with(|| { 662 + state ^= state << 13; 663 + state ^= state >> 7; 664 + state ^= state << 17; 665 + state.to_le_bytes() 666 + }) 667 + .take(32 * 1024) 668 + .flatten() 669 + .collect(); 670 + std::fs::write(fx.work.join("noise.bin"), &payload).unwrap(); 671 + git(&fx.work, &[], &["add", "-A"]); 672 + git(&fx.work, &[], &["commit", "-q", "-m", "noise"]); 673 + 674 + let (ok, out) = push(&fx.work, &fx.url, &fx.key_path, &["main"]).await; 675 + assert!(ok, "push must succeed:\n{out}"); 676 + 677 + let dest = fx.scratch.path().join("compressed-clone"); 678 + let ssh = format!("{} -o Compression=yes", ssh_command(&fx.key_path)); 679 + let url = fx.url.clone(); 680 + let dest_arg = dest.to_str().unwrap().to_string(); 681 + let (ok, out) = tokio::task::spawn_blocking(move || { 682 + git( 683 + Path::new("/tmp"), 684 + &[("GIT_SSH_COMMAND", &ssh)], 685 + &["clone", "-q", &url, &dest_arg], 686 + ) 687 + }) 688 + .await 689 + .unwrap(); 690 + assert!( 691 + ok, 692 + "clone with ssh compression requested must succeed:\n{out}" 693 + ); 694 + assert_eq!(std::fs::read(dest.join("noise.bin")).unwrap(), payload); 695 + } 696 + 697 + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] 656 698 async fn an_oversized_push_is_refused_at_the_ssh_boundary() { 657 699 let scratch = tempfile::tempdir().unwrap(); 658 700 let (key_path, public_line) = keygen(scratch.path(), "client");