diff --git a/Cargo.lock b/Cargo.lock index 87594b010c62cf295171a431fe823909cd51300d..86e092dba05a90e32e984dc01b83be54a0db93a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -332,57 +332,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" -[[package]] -name = "door-async" -version = "0.1.0" -dependencies = [ - "anyhow", - "argh", - "async-trait", - "door-sshproto", - "futures 0.4.0-alpha.0", - "heapless", - "libc", - "log", - "moro", - "nix", - "pretty-hex", - "rpassword", - "simplelog", - "snafu", - "tokio", -] - -[[package]] -name = "door-sshproto" -version = "0.1.0" -dependencies = [ - "aes", - "anyhow", - "ascii", - "async-trait", - "chacha20", - "ctr", - "digest 0.10.3", - "heapless", - "hmac", - "log", - "no-panic", - "poly1305", - "pretty-hex", - "proptest", - "rand", - "rand_core 0.6.3", - "salty", - "serde_json", - "sha2 0.10.2", - "signature", - "simplelog", - "snafu", - "ssh-key", - "sshwire_derive", -] - [[package]] name = "ed25519" version = "1.5.2" @@ -1333,6 +1282,57 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +[[package]] +name = "sunset" +version = "0.1.0" +dependencies = [ + "aes", + "anyhow", + "ascii", + "async-trait", + "chacha20", + "ctr", + "digest 0.10.3", + "heapless", + "hmac", + "log", + "no-panic", + "poly1305", + "pretty-hex", + "proptest", + "rand", + "rand_core 0.6.3", + "salty", + "serde_json", + "sha2 0.10.2", + "signature", + "simplelog", + "snafu", + "ssh-key", + "sshwire_derive", +] + +[[package]] +name = "sunset-async" +version = "0.1.0" +dependencies = [ + "anyhow", + "argh", + "async-trait", + "futures 0.4.0-alpha.0", + "heapless", + "libc", + "log", + "moro", + "nix", + "pretty-hex", + "rpassword", + "simplelog", + "snafu", + "sunset", + "tokio", +] + [[package]] name = "syn" version = "1.0.98" diff --git a/Cargo.toml b/Cargo.toml index b8173c9e0af29be8ac4eafaa6898fc4b91923c98..83f80eb3e40a1dacf6d39fdec8ac34948e3aefa2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,12 @@ +[package] +name = "sunset" +version = "0.1.0" +edition = "2021" +categories = ["network-programming", "no-std"] +keywords = ["ssh"] + [workspace] members = [ - "sshproto", "sshwire_derive", "async", ] @@ -9,3 +15,56 @@ members = [ opt-level = 's' lto = "fat" debug = 1 + +[dependencies] +sshwire_derive = { version = "0.1", path = "sshwire_derive" } + +snafu = { version = "0.7", default-features = false, features = ["rust_1_46"] } +# TODO: check that log macro calls disappear in no_std builds +log = { version = "0.4" } +heapless = "0.7.10" +no-panic = "0.1" + +# allows avoiding utf8 for SSH identifier names +ascii = { version = "1.0", default-features = false } + +rand = { version = "0.8", default-features = false } +rand_core = { version = "0.6", default-features = false } + +ctr = "0.9" +aes = "0.8" +sha2 = { version = "0.10", default-features = false } +hmac = "0.12" +digest = "0.10" +signature = { version = "1.4", default-features = false } +chacha20 = "0.9" +poly1305 = "0.7" +# ed25519/x25519 +salty = { version = "0.2", git = "https://github.com/mkj/salty", branch = "parts" } +# could be optional? though isn't linked if openssh keys aren't loaded +ssh-key = { version = "0.4", default-features = false, features = ["ed25519", "ecdsa", "sha2"] } + +# for debug printing +pretty-hex = { version = "0.3", default-features = false } + +async-trait = { version = "0.1", optional = true } + +[features] +default = [ "getrandom" ] +std = ["async-trait", "snafu/std"] +# tokio-queue = ["dep:tokio"] + +getrandom = ["rand/getrandom"] + +[dev-dependencies] +# toml = "0.5" +# examples want std::error +snafu = { version = "0.7", default-features = true } +anyhow = { version = "1.0" } +pretty-hex = "0.3" +simplelog = { version = "0.12", features = ["test"] } +proptest = "1.0" +async-trait = { version = "0.1" } + +serde_json = "1.0" + diff --git a/LICENSE b/LICENSE index f212b3d46a17aa0ef0c10a82f924c33856d77e26..48cde60111dbe29abb9105788881ff15b16a60d8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Door SSH is (c) 2022 Matt Johnston and contributors +Sunset SSH is (c) 2022 Matt Johnston and contributors Provided under terms of the MPL 2.0 as below. diff --git a/async/Cargo.toml b/async/Cargo.toml index 55186727d21109aabec6ba8e3d60896c44bcb9a7..418f58cb0b121259003d9d81ca0e12cda8b7fcb9 100644 --- a/async/Cargo.toml +++ b/async/Cargo.toml @@ -1,11 +1,10 @@ [package] -name = "door-async" +name = "sunset-async" version = "0.1.0" edition = "2021" [dependencies] -door-sshproto = { path = "../sshproto", features = ["std"] } -# door-sshproto = { path = "../sshproto", features = []} +sunset = { path = "..", features = ["std"] } log = { version = "0.4", features = ["release_max_level_info"] } rpassword = "6.0" argh = "0.1" diff --git a/async/examples/con1.rs b/async/examples/con1.rs index e903f9ca3360fc3e78f506768a8df1ddc1516ee1..1763b5d605f9be38ab812d5e4142c46ae90d66f6 100644 --- a/async/examples/con1.rs +++ b/async/examples/con1.rs @@ -10,8 +10,8 @@ use tokio::net::TcpStream; use std::{net::Ipv6Addr, io::Read}; -use door_sshproto::*; -use door_async::{SSHClient, raw_pty}; +use sunset::*; +use sunset_async::{SSHClient, raw_pty}; use simplelog::*; @@ -95,12 +95,12 @@ fn main() -> Result<()> { fn setup_log(args: &Args) -> Result<()> { let mut conf = simplelog::ConfigBuilder::new(); let conf = conf - .add_filter_allow_str("door") + .add_filter_allow_str("sunset") .add_filter_allow_str("con1") // not debugging these bits of the stack at present - // .add_filter_ignore_str("door_sshproto::traffic") - // .add_filter_ignore_str("door_sshproto::runner") - // .add_filter_ignore_str("door_async::async_door") + // .add_filter_ignore_str("sunset::traffic") + // .add_filter_ignore_str("sunset::runner") + // .add_filter_ignore_str("sunset_async::async_sunset") .set_time_offset_to_local().expect("Couldn't get local timezone") .build(); @@ -150,7 +150,7 @@ async fn run(args: &Args) -> Result<()> { let mut cli = SSHClient::new(&mut rxbuf, &mut txbuf)?; // app is a Behaviour - let mut app = door_async::CmdlineClient::new( + let mut app = sunset_async::CmdlineClient::new( args.username.as_ref().unwrap(), cmd, wantpty, @@ -183,12 +183,12 @@ async fn run(args: &Args) -> Result<()> { // } else { // let (io, err) = cli.open_session_nopty(cmd.as_deref()).await // .context("Opening session")?; - // let errpair = (err, door_async::stderr()?); + // let errpair = (err, sunset_async::stderr()?); // (io, Some(errpair)) // }; - // let mut i = door_async::stdin()?; - // let mut o = door_async::stdout()?; + // let mut i = sunset_async::stdin()?; + // let mut o = sunset_async::stdout()?; // let mut io2 = io.clone(); // scope.spawn(async move { // moro::async_scope!(|scope| { diff --git a/async/examples/serv1.rs b/async/examples/serv1.rs index d800910ebccb6dd47c3607517e2e6aab2f3f1aca..233aed18f6445126a314bde8060264a2ec70bdb2 100644 --- a/async/examples/serv1.rs +++ b/async/examples/serv1.rs @@ -12,8 +12,8 @@ use tokio::io::{AsyncReadExt,AsyncWriteExt}; use std::{net::Ipv6Addr, io::Read}; use std::path::Path; -use door_sshproto::*; -use door_async::*; +use sunset::*; +use sunset_async::*; use async_trait::async_trait; @@ -67,12 +67,12 @@ fn main() -> Result<()> { fn setup_log(args: &Args) -> Result<()> { let mut conf = simplelog::ConfigBuilder::new(); let conf = conf - .add_filter_allow_str("door") + .add_filter_allow_str("sunset") .add_filter_allow_str("serv1") // not debugging these bits of the stack at present - .add_filter_ignore_str("door_sshproto::traffic") - .add_filter_ignore_str("door_sshproto::runner") - .add_filter_ignore_str("door_async::async_door") + .add_filter_ignore_str("sunset::traffic") + .add_filter_ignore_str("sunset::runner") + .add_filter_ignore_str("sunset_async::async_sunset") .set_time_offset_to_local().expect("Couldn't get local timezone") .build(); diff --git a/async/src/async_channel.rs b/async/src/async_channel.rs index 93b5f366d730a0cc3f5cb3ca57febaf3983b611b..f2eae13ac520edcd27c0f903f3f860e0a0db38dc 100644 --- a/async/src/async_channel.rs +++ b/async/src/async_channel.rs @@ -16,11 +16,11 @@ use futures::lock::{Mutex, OwnedMutexLockFuture, OwnedMutexGuard}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use crate::*; -use async_door::{Inner, poll_lock}; +use async_sunset::{Inner, poll_lock}; pub struct Channel<'a> { chan: u32, - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, } impl<'a> Channel<'a> { @@ -37,14 +37,14 @@ impl<'a> Channel<'a> { }; // TODO: also need to wait for spare output buffer - self.door.inner.lock().await + self.sunset.inner.lock().await .runner.term_window_change(self.chan, wc); } } pub struct ChanInOut<'a> { chan: u32, - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, rlfut: Option<OwnedMutexLockFuture<Inner<'a>>>, wlfut: Option<OwnedMutexLockFuture<Inner<'a>>>, @@ -53,7 +53,7 @@ pub struct ChanInOut<'a> { pub struct ChanExtIn<'a> { chan: u32, ext: u32, - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, rlfut: Option<OwnedMutexLockFuture<Inner<'a>>>, } @@ -61,15 +61,15 @@ pub struct ChanExtIn<'a> { pub struct ChanExtOut<'a> { chan: u32, ext: u32, - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, wlfut: Option<OwnedMutexLockFuture<Inner<'a>>>, } impl<'a> ChanInOut<'a> { - pub(crate) fn new(chan: u32, door: &AsyncDoor<'a>) -> Self { + pub(crate) fn new(chan: u32, sunset: &AsyncSunset<'a>) -> Self { Self { - chan, door: door.private_clone(), + chan, sunset: sunset.private_clone(), rlfut: None, wlfut: None, } } @@ -78,16 +78,16 @@ impl<'a> ChanInOut<'a> { impl Clone for ChanInOut<'_> { fn clone(&self) -> Self { Self { - chan: self.chan, door: self.door.private_clone(), + chan: self.chan, sunset: self.sunset.private_clone(), rlfut: None, wlfut: None, } } } impl<'a> ChanExtIn<'a> { - pub(crate) fn new(chan: u32, ext: u32, door: &AsyncDoor<'a>) -> Self { + pub(crate) fn new(chan: u32, ext: u32, sunset: &AsyncSunset<'a>) -> Self { Self { - chan, ext, door: door.private_clone(), + chan, ext, sunset: sunset.private_clone(), rlfut: None, } } @@ -101,7 +101,7 @@ impl<'a> AsyncRead for ChanInOut<'a> { ) -> Poll<Result<(), IoError>> { trace!("poll read {}", self.chan); let this = self.deref_mut(); - chan_poll_read(&mut this.door, this.chan, None, cx, buf, &mut this.rlfut) + chan_poll_read(&mut this.sunset, this.chan, None, cx, buf, &mut this.rlfut) } } @@ -112,13 +112,13 @@ impl<'a> AsyncRead for ChanExtIn<'a> { buf: &mut ReadBuf, ) -> Poll<Result<(), IoError>> { let this = self.deref_mut(); - chan_poll_read(&mut this.door, this.chan, Some(this.ext), cx, buf, &mut this.rlfut) + chan_poll_read(&mut this.sunset, this.chan, Some(this.ext), cx, buf, &mut this.rlfut) } } // Common for `ChanInOut` and `ChanExtIn` fn chan_poll_read<'a>( - door: &mut AsyncDoor<'a>, + sunset: &mut AsyncSunset<'a>, chan: u32, ext: Option<u32>, cx: &mut Context, @@ -127,7 +127,7 @@ fn chan_poll_read<'a>( ) -> Poll<Result<(), IoError>> { trace!("chan read"); - let mut p = poll_lock(door.inner.clone(), cx, lock_fut); + let mut p = poll_lock(sunset.inner.clone(), cx, lock_fut); let inner = match p { Poll::Ready(ref mut i) => i, Poll::Pending => { @@ -165,7 +165,7 @@ impl<'a> AsyncWrite for ChanInOut<'a> { ) -> Poll<Result<usize, IoError>> { trace!("poll write {}", self.chan); let this = self.deref_mut(); - chan_poll_write(&mut this.door, this.chan, None, cx, buf, &mut this.wlfut) + chan_poll_write(&mut this.sunset, this.chan, None, cx, buf, &mut this.wlfut) } fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), std::io::Error>> { @@ -179,7 +179,7 @@ impl<'a> AsyncWrite for ChanInOut<'a> { } fn chan_poll_write<'a>( - door: &mut AsyncDoor<'a>, + sunset: &mut AsyncSunset<'a>, chan: u32, ext: Option<u32>, cx: &mut Context<'_>, @@ -188,7 +188,7 @@ fn chan_poll_write<'a>( ) -> Poll<Result<usize, IoError>> { trace!("chan write"); - let mut p = poll_lock(door.inner.clone(), cx, lock_fut); + let mut p = poll_lock(sunset.inner.clone(), cx, lock_fut); let inner = match p { Poll::Ready(ref mut i) => i, Poll::Pending => return Poll::Pending, diff --git a/async/src/async_door.rs b/async/src/async_sunset.rs similarity index 90% rename from async/src/async_door.rs rename to async/src/async_sunset.rs index a76f3d58d4189cbfbc697dad844ff3ec64eee74d..d0f414806c0e568e1e949cd3fa05b6db6e636d0c 100644 --- a/async/src/async_door.rs +++ b/async/src/async_sunset.rs @@ -18,8 +18,7 @@ use core::task::Waker; use core::ops::DerefMut; use std::sync::Arc; -use door_sshproto as door; -use door::{Runner, Result, Behaviour}; +use sunset::{Runner, Result, Behaviour}; use pretty_hex::PrettyHex; @@ -31,13 +30,13 @@ pub(crate) struct Inner<'a> { pub chan_write_wakers: HashMap<(u32, Option<u32>), Waker>, } -pub struct AsyncDoor<'a> { +pub struct AsyncSunset<'a> { pub(crate) inner: Arc<Mutex<Inner<'a>>>, progress_notify: Arc<TokioNotify>, } -impl<'a> AsyncDoor<'a> { +impl<'a> AsyncSunset<'a> { pub fn new(runner: Runner<'a>) -> Self { let chan_read_wakers = HashMap::new(); let chan_write_wakers = HashMap::new(); @@ -53,8 +52,8 @@ impl<'a> AsyncDoor<'a> { } } - pub fn socket(&self) -> AsyncDoorSocket<'a> { - AsyncDoorSocket::new(self) + pub fn socket(&self) -> AsyncSunsetSocket<'a> { + AsyncSunsetSocket::new(self) } /// The `f` closure should return `Some` if the result should be returned @@ -133,21 +132,21 @@ pub(crate) fn poll_lock<'a>(inner: Arc<Mutex<Inner<'a>>>, cx: &mut Context<'_>, p } -pub struct AsyncDoorSocket<'a> { - door: AsyncDoor<'a>, +pub struct AsyncSunsetSocket<'a> { + sunset: AsyncSunset<'a>, read_lock_fut: Option<OwnedMutexLockFuture<Inner<'a>>>, write_lock_fut: Option<OwnedMutexLockFuture<Inner<'a>>>, } -impl<'a> AsyncDoorSocket<'a> { - fn new(door: &AsyncDoor<'a>) -> Self { - AsyncDoorSocket { door: door.private_clone(), +impl<'a> AsyncSunsetSocket<'a> { + fn new(sunset: &AsyncSunset<'a>) -> Self { + AsyncSunsetSocket { sunset: sunset.private_clone(), read_lock_fut: None, write_lock_fut: None } } } -impl<'a> AsyncRead for AsyncDoorSocket<'a> { +impl<'a> AsyncRead for AsyncSunsetSocket<'a> { fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -155,7 +154,7 @@ impl<'a> AsyncRead for AsyncDoorSocket<'a> { ) -> Poll<Result<(), IoError>> { trace!("poll_read"); - let mut p = poll_lock(self.door.inner.clone(), cx, &mut self.read_lock_fut); + let mut p = poll_lock(self.sunset.inner.clone(), cx, &mut self.read_lock_fut); let runner = match p { Poll::Ready(ref mut i) => &mut i.runner, @@ -184,7 +183,7 @@ impl<'a> AsyncRead for AsyncDoorSocket<'a> { } } -impl<'a> AsyncWrite for AsyncDoorSocket<'a> { +impl<'a> AsyncWrite for AsyncSunsetSocket<'a> { fn poll_write( mut self: Pin<&mut Self>, cx: &mut Context<'_>, @@ -192,7 +191,7 @@ impl<'a> AsyncWrite for AsyncDoorSocket<'a> { ) -> Poll<Result<usize, IoError>> { trace!("poll_write {}", buf.len()); - let mut p = poll_lock(self.door.inner.clone(), cx, &mut self.write_lock_fut); + let mut p = poll_lock(self.sunset.inner.clone(), cx, &mut self.write_lock_fut); let runner = match p { Poll::Ready(ref mut i) => &mut i.runner, @@ -222,7 +221,7 @@ impl<'a> AsyncWrite for AsyncDoorSocket<'a> { if let Poll::Ready(_) = r { // TODO: only notify if packet traffic.payload().is_some() ? // Though we also are using progress() for other events. - self.door.progress_notify.notify_one(); + self.sunset.progress_notify.notify_one(); trace!("notify progress"); } r diff --git a/async/src/client.rs b/async/src/client.rs index 29ab8810387c4ae011c068979f563f9ede592905..b0227c354da8bab764dd880fef0430c2854d3a65 100644 --- a/async/src/client.rs +++ b/async/src/client.rs @@ -17,30 +17,29 @@ use core::task::{Context, Poll}; use nix::fcntl::{fcntl, FcntlArg, OFlag}; use crate::*; -use crate::async_door::*; +use crate::async_sunset::*; use crate::async_channel::*; -use door_sshproto as door; -use door::{Behaviour, CliBehaviour, Runner, Result}; -use door::sshnames::SSH_EXTENDED_DATA_STDERR; -use door::config::*; +use sunset::{Behaviour, CliBehaviour, Runner, Result}; +use sunset::sshnames::SSH_EXTENDED_DATA_STDERR; +use sunset::config::*; pub struct SSHClient<'a> { - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, } impl<'a> SSHClient<'a> { pub fn new(inbuf: &'a mut [u8], outbuf: &'a mut [u8]) -> Result<Self> { let runner = Runner::new_client(inbuf, outbuf)?; - let door = AsyncDoor::new(runner); + let sunset = AsyncSunset::new(runner); Ok(Self { - door + sunset }) } - pub fn socket(&self) -> AsyncDoorSocket<'a> { - self.door.socket() + pub fn socket(&self) -> AsyncSunsetSocket<'a> { + self.sunset.socket() } /// Takes a closure to run on the "output" of the progress call. @@ -50,19 +49,19 @@ impl<'a> SSHClient<'a> { b: &mut (dyn CliBehaviour+Send)) -> Result<()> { let mut b = Behaviour::new_client(b); - self.door.progress(&mut b).await + self.sunset.progress(&mut b).await } // TODO: return a Channel object that gives events like WinChange or exit status // TODO: move to SimpleClient or something? pub async fn open_session_nopty(&mut self, exec: Option<&str>) -> Result<(ChanInOut<'a>, ChanExtIn<'a>)> { - let chan = self.door.with_runner(|runner| { + let chan = self.sunset.with_runner(|runner| { runner.open_client_session(exec, None) }).await?; - let cstd = ChanInOut::new(chan, &self.door); - let cerr = ChanExtIn::new(chan, SSH_EXTENDED_DATA_STDERR, &self.door); + let cstd = ChanInOut::new(chan, &self.sunset); + let cerr = ChanExtIn::new(chan, SSH_EXTENDED_DATA_STDERR, &self.sunset); Ok((cstd, cerr)) } @@ -72,11 +71,11 @@ impl<'a> SSHClient<'a> { // XXX error handling let pty = pty::current_pty().expect("pty fetch"); - let chan = self.door.with_runner(|runner| { + let chan = self.sunset.with_runner(|runner| { runner.open_client_session(exec, Some(pty)) }).await?; - let cstd = ChanInOut::new(chan, &self.door); + let cstd = ChanInOut::new(chan, &self.sunset); Ok(cstd) } } diff --git a/async/src/cmdline_client.rs b/async/src/cmdline_client.rs index 4564e72b2bbd9f9a6f5f8e0c3f8edd20fc4ec024..510228521aeefe3da0bb1edd859cf1ea9c1ea947 100644 --- a/async/src/cmdline_client.rs +++ b/async/src/cmdline_client.rs @@ -3,10 +3,9 @@ use log::{debug, error, info, log, trace, warn}; use core::str::FromStr; -use door::SignKey; -use door_sshproto as door; -use door_sshproto::{BhError, BhResult}; -use door_sshproto::{ChanMsg, ChanMsgDetails, Error, Result, Runner}; +use sunset::SignKey; +use sunset::{BhError, BhResult}; +use sunset::{ChanMsg, ChanMsgDetails, Error, Result, Runner}; use std::collections::VecDeque; @@ -90,23 +89,23 @@ impl<'a> CmdlineClient<'a> { // #[async_trait(?Send)] #[async_trait] -impl door::CliBehaviour for CmdlineClient<'_> { - fn username(&mut self) -> BhResult<door::ResponseString> { - door::ResponseString::from_str(&self.username).map_err(|_| BhError::Fail) +impl sunset::CliBehaviour for CmdlineClient<'_> { + fn username(&mut self) -> BhResult<sunset::ResponseString> { + sunset::ResponseString::from_str(&self.username).map_err(|_| BhError::Fail) } - fn valid_hostkey(&mut self, key: &door::PubKey) -> BhResult<bool> { + fn valid_hostkey(&mut self, key: &sunset::PubKey) -> BhResult<bool> { trace!("valid_hostkey for {key:?}"); Ok(true) } - fn next_authkey(&mut self) -> BhResult<Option<door::SignKey>> { + fn next_authkey(&mut self) -> BhResult<Option<sunset::SignKey>> { Ok(self.authkeys.pop_front()) } fn auth_password( &mut self, - pwbuf: &mut door::ResponseString, + pwbuf: &mut sunset::ResponseString, ) -> BhResult<bool> { let pw = rpassword::prompt_password(format!("password for {}: ", self.username)) diff --git a/async/src/lib.rs b/async/src/lib.rs index bda500e0e4d4e6db9a8e53a08f658ea78275f54b..312151c29fe05fd524b955977a1835272319c1b7 100644 --- a/async/src/lib.rs +++ b/async/src/lib.rs @@ -2,12 +2,12 @@ mod client; mod server; -mod async_door; +mod async_sunset; mod async_channel; mod cmdline_client; mod pty; -pub use async_door::AsyncDoor; +pub use async_sunset::AsyncSunset; pub use client::SSHClient; pub use server::SSHServer; pub use cmdline_client::CmdlineClient; diff --git a/async/src/pty.rs b/async/src/pty.rs index b1004fffa5264b31f0d7f860574d735772434092..d5dcbd14b34ba4343436cd58a60f26077bf76da5 100644 --- a/async/src/pty.rs +++ b/async/src/pty.rs @@ -6,10 +6,9 @@ use std::io::Error as IoError; use libc::{ioctl, winsize, termios, tcgetattr, tcsetattr }; -use door_sshproto as door; -use door::{Behaviour, Runner, Result, Pty}; -use door::config::*; -use door::packets::WinChange; +use sunset::{Behaviour, Runner, Result, Pty}; +use sunset::config::*; +use sunset::packets::WinChange; /// Returns the size of the current terminal pub fn win_size() -> Result<WinChange, IoError> { diff --git a/async/src/server.rs b/async/src/server.rs index d9ed0ec75a358fce614910d3a88971b46c673ba0..850b4e6e8ab3f8d261d7f73467491337dc7db494 100644 --- a/async/src/server.rs +++ b/async/src/server.rs @@ -17,16 +17,15 @@ use core::task::{Context, Poll}; use nix::fcntl::{fcntl, FcntlArg, OFlag}; use crate::async_channel::*; -use crate::async_door::*; +use crate::async_sunset::*; use crate::*; -use door::config::*; -use door::sshnames::SSH_EXTENDED_DATA_STDERR; -use door::{ServBehaviour, Behaviour, Result, Runner}; -use door_sshproto as door; +use sunset::config::*; +use sunset::sshnames::SSH_EXTENDED_DATA_STDERR; +use sunset::{ServBehaviour, Behaviour, Result, Runner}; pub struct SSHServer<'a> { - door: AsyncDoor<'a>, + sunset: AsyncSunset<'a>, } impl<'a> SSHServer<'a> { @@ -34,12 +33,12 @@ impl<'a> SSHServer<'a> { b: &mut (dyn ServBehaviour + Send), ) -> Result<Self> { let runner = Runner::new_server(inbuf, outbuf, b)?; - let door = AsyncDoor::new(runner); - Ok(Self { door }) + let sunset = AsyncSunset::new(runner); + Ok(Self { sunset }) } - pub fn socket(&self) -> AsyncDoorSocket<'a> { - self.door.socket() + pub fn socket(&self) -> AsyncSunsetSocket<'a> { + self.sunset.socket() } pub async fn progress( @@ -48,12 +47,12 @@ impl<'a> SSHServer<'a> { ) -> Result<()> { let mut b = Behaviour::new_server(b); - self.door.progress(&mut b).await + self.sunset.progress(&mut b).await } pub async fn channel(&mut self, ch: u32) -> Result<(ChanInOut<'a>, Option<ChanExtOut<'a>>)> { - let ty = self.door.with_runner(|r| r.channel_type(ch)).await?; - let inout = ChanInOut::new(ch, &self.door); + let ty = self.sunset.with_runner(|r| r.channel_type(ch)).await?; + let inout = ChanInOut::new(ch, &self.sunset); // TODO ext let ext = None; Ok((inout, ext)) diff --git a/sshproto/src/auth.rs b/src/auth.rs similarity index 100% rename from sshproto/src/auth.rs rename to src/auth.rs diff --git a/sshproto/src/behaviour.rs b/src/behaviour.rs similarity index 100% rename from sshproto/src/behaviour.rs rename to src/behaviour.rs diff --git a/sshproto/src/channel.rs b/src/channel.rs similarity index 100% rename from sshproto/src/channel.rs rename to src/channel.rs diff --git a/sshproto/src/cliauth.rs b/src/cliauth.rs similarity index 100% rename from sshproto/src/cliauth.rs rename to src/cliauth.rs diff --git a/sshproto/src/client.rs b/src/client.rs similarity index 100% rename from sshproto/src/client.rs rename to src/client.rs diff --git a/sshproto/src/config.rs b/src/config.rs similarity index 100% rename from sshproto/src/config.rs rename to src/config.rs diff --git a/sshproto/src/conn.rs b/src/conn.rs similarity index 99% rename from sshproto/src/conn.rs rename to src/conn.rs index b18de6a5a54833d1f3bdb4fc66fdfdecb5a04416..3041308084dc0f5fa90787c3aa901f9bbd0b4e41 100644 --- a/sshproto/src/conn.rs +++ b/src/conn.rs @@ -400,7 +400,7 @@ impl Conn { #[cfg(test)] mod tests { - use crate::doorlog::*; + use crate::sunsetlog::*; use crate::conn::*; use crate::error::Error; } diff --git a/sshproto/src/encrypt.rs b/src/encrypt.rs similarity index 99% rename from sshproto/src/encrypt.rs rename to src/encrypt.rs index f6ea2afa8d5e2ddf4309b901a394526c8b101506..65a4a4c7159af0c16942d256e2e20bec0750adcf 100644 --- a/sshproto/src/encrypt.rs +++ b/src/encrypt.rs @@ -698,7 +698,7 @@ impl IntegKey { #[cfg(test)] mod tests { - use crate::doorlog::*; + use crate::sunsetlog::*; use crate::encrypt::*; use crate::error::Error; use crate::sshnames::SSH_NAME_CURVE25519; diff --git a/sshproto/src/error.rs b/src/error.rs similarity index 99% rename from sshproto/src/error.rs rename to src/error.rs index fdf3e1eba6f1b2319357a499e9eb1ac7f48738ab..450b14623647de317e81cee2ae4f264ccb1a229f 100644 --- a/sshproto/src/error.rs +++ b/src/error.rs @@ -250,7 +250,7 @@ impl From<BhError> for Error { #[cfg(test)] pub(crate) mod tests { use crate::error::*; - use crate::doorlog::init_test_log; + use crate::sunsetlog::init_test_log; use crate::packets::Unknown; use proptest::prelude::*; diff --git a/sshproto/src/ident.rs b/src/ident.rs similarity index 98% rename from sshproto/src/ident.rs rename to src/ident.rs index ab81ee4386d7f070ef2279ed92ec5cd2d5ccfdb6..73c1e064bac1970c7b121913dac6d7c0d5971827 100644 --- a/sshproto/src/ident.rs +++ b/src/ident.rs @@ -1,6 +1,6 @@ use crate::error::{Error,TrapBug}; -pub(crate) const OUR_VERSION: &[u8] = "SSH-2.0-door".as_bytes(); +pub(crate) const OUR_VERSION: &[u8] = "SSH-2.0-sunset".as_bytes(); const SSH_PREFIX: &[u8] = "SSH-2.0-".as_bytes(); @@ -143,7 +143,7 @@ impl<'a> RemoteVersion { mod tests { use crate::ident; use crate::error::{Error,TrapBug}; - use crate::doorlog::init_test_log; + use crate::sunsetlog::init_test_log; use proptest::prelude::*; fn test_version(v: &str, split: usize, expect: &str) -> Result<usize, Error> { diff --git a/sshproto/src/kex.rs b/src/kex.rs similarity index 99% rename from sshproto/src/kex.rs rename to src/kex.rs index de746a2e28f05e7e5dd5cf3d599e70675fa09c3c..4dd659927367bb11fe33d2b6e41657776200eea5 100644 --- a/sshproto/src/kex.rs +++ b/src/kex.rs @@ -571,7 +571,7 @@ mod tests { use crate::kex; use crate::packets::{Packet,ParseContext}; use crate::*; - use crate::doorlog::init_test_log; + use crate::sunsetlog::init_test_log; use super::SSH_NAME_CURVE25519; @@ -672,9 +672,9 @@ mod tests { let serv_conf = kex::AlgoConfig::new(false); let mut serv_version = RemoteVersion::new(); // needs to be hardcoded because that's what we send. - serv_version.consume("SSH-2.0-door\r\n".as_bytes()).unwrap(); + serv_version.consume("SSH-2.0-sunset\r\n".as_bytes()).unwrap(); let mut cli_version = RemoteVersion::new(); - cli_version.consume("SSH-2.0-door\r\n".as_bytes()).unwrap(); + cli_version.consume("SSH-2.0-sunset\r\n".as_bytes()).unwrap(); let mut sb = TestServBehaviour { // TODO: put keys in diff --git a/sshproto/src/lib.rs b/src/lib.rs similarity index 98% rename from sshproto/src/lib.rs rename to src/lib.rs index a85260dda067a8a6bfa71cacc51d23bf5a806858..34fba4b49c8926375920e2e4f185bc193622c40e 100644 --- a/sshproto/src/lib.rs +++ b/src/lib.rs @@ -31,7 +31,7 @@ mod servauth; // mod bhtokio; // mod bhnostd; -pub mod doorlog; +pub mod sunsetlog; mod auth; mod channel; mod runner; diff --git a/sshproto/src/namelist.rs b/src/namelist.rs similarity index 99% rename from sshproto/src/namelist.rs rename to src/namelist.rs index 58ea3a68fa7ff1acc9211249d66dab8ae8790c4c..74c11b1c995ba01357dc8c81c943b21def3d687d 100644 --- a/sshproto/src/namelist.rs +++ b/src/namelist.rs @@ -195,7 +195,7 @@ mod tests { use crate::namelist::*; use pretty_hex::PrettyHex; use std::vec::Vec; - use crate::doorlog::init_test_log; + use crate::sunsetlog::init_test_log; use proptest::prelude::*; #[test] diff --git a/sshproto/src/packets.rs b/src/packets.rs similarity index 99% rename from sshproto/src/packets.rs rename to src/packets.rs index 42003bbcfe21d8aef99e75bd66682813ab796cd5..3c3e745795f94b51e40a43b83642c4397f7769aa 100644 --- a/sshproto/src/packets.rs +++ b/src/packets.rs @@ -803,7 +803,7 @@ messagetypes![ #[cfg(test)] mod tests { - use crate::doorlog::init_test_log; + use crate::sunsetlog::init_test_log; use crate::packets::*; use crate::sshnames::*; use crate::sshwire::tests::{assert_serialize_equal, test_roundtrip}; diff --git a/sshproto/src/random.rs b/src/random.rs similarity index 85% rename from sshproto/src/random.rs rename to src/random.rs index c35b931ad0b411861ffd10b4089907e8715e3739..892ab4202b2c1ec11623b1270d18ec42302e8131 100644 --- a/sshproto/src/random.rs +++ b/src/random.rs @@ -8,11 +8,11 @@ use rand::{RngCore, Rng, CryptoRng}; use core::num::Wrapping; #[cfg(feature = "getrandom")] -pub type DoorRng = rand::rngs::OsRng; +pub type SunsetRng = rand::rngs::OsRng; pub fn fill_random(buf: &mut [u8]) -> Result<(), Error> { // TODO: can this return an error? - let mut rng = DoorRng::default(); + let mut rng = SunsetRng::default(); rng.try_fill_bytes(buf) .map_err(|e| { debug!("RNG failed: {e:?}"); diff --git a/sshproto/src/runner.rs b/src/runner.rs similarity index 100% rename from sshproto/src/runner.rs rename to src/runner.rs diff --git a/sshproto/src/servauth.rs b/src/servauth.rs similarity index 100% rename from sshproto/src/servauth.rs rename to src/servauth.rs diff --git a/sshproto/src/server.rs b/src/server.rs similarity index 100% rename from sshproto/src/server.rs rename to src/server.rs diff --git a/sshproto/src/sign.rs b/src/sign.rs similarity index 99% rename from sshproto/src/sign.rs rename to src/sign.rs index 902f1fec3be0768b28ec78aadec47dfcf9146309..44b54bb23cb71406e942c048b247615755425a81 100644 --- a/sshproto/src/sign.rs +++ b/src/sign.rs @@ -185,7 +185,7 @@ pub(crate) mod tests { use sshnames::SSH_NAME_ED25519; use packets; use sign::*; - use doorlog::init_test_log; + use sunsetlog::init_test_log; pub(crate) fn make_ed25519_signkey() -> SignKey { let mut s = [0u8; 32]; diff --git a/sshproto/src/ssh_chapoly.rs b/src/ssh_chapoly.rs similarity index 100% rename from sshproto/src/ssh_chapoly.rs rename to src/ssh_chapoly.rs diff --git a/sshproto/src/sshnames.rs b/src/sshnames.rs similarity index 100% rename from sshproto/src/sshnames.rs rename to src/sshnames.rs diff --git a/sshproto/src/sshwire.rs b/src/sshwire.rs similarity index 99% rename from sshproto/src/sshwire.rs rename to src/sshwire.rs index 35c96d6a2b6a5b5bbfec5dc6fd188e668afbc745..3daac030e84b72e4c66d68ee646fd8b1657ec665 100644 --- a/sshproto/src/sshwire.rs +++ b/src/sshwire.rs @@ -549,7 +549,7 @@ impl<'de, const N: usize> SSHDecode<'de> for [u8; N] { #[cfg(test)] pub(crate) mod tests { use crate::*; - use doorlog::init_test_log; + use sunsetlog::init_test_log; use error::Error; use packets::*; use sshwire::*; diff --git a/sshproto/src/doorlog.rs b/src/sunsetlog.rs similarity index 100% rename from sshproto/src/doorlog.rs rename to src/sunsetlog.rs diff --git a/sshproto/src/termmodes.rs b/src/termmodes.rs similarity index 100% rename from sshproto/src/termmodes.rs rename to src/termmodes.rs diff --git a/sshproto/src/test.rs b/src/test.rs similarity index 100% rename from sshproto/src/test.rs rename to src/test.rs diff --git a/sshproto/src/traffic.rs b/src/traffic.rs similarity index 100% rename from sshproto/src/traffic.rs rename to src/traffic.rs diff --git a/sshproto/Cargo.toml b/sshproto/Cargo.toml deleted file mode 100644 index 1cd3609085dc0e9ba88112db2b79093fceae8e4a..0000000000000000000000000000000000000000 --- a/sshproto/Cargo.toml +++ /dev/null @@ -1,59 +0,0 @@ -[package] -name = "door-sshproto" -version = "0.1.0" -edition = "2021" -categories = ["network-programming", "no-std"] -keywords = ["ssh"] - -[dependencies] -sshwire_derive = { path = "../sshwire_derive" } - -snafu = { version = "0.7", default-features = false, features = ["rust_1_46"] } -# TODO: check that log macro calls disappear in no_std builds -log = { version = "0.4" } -heapless = "0.7.10" -no-panic = "0.1" - -# allows avoiding utf8 for SSH identifier names -ascii = { version = "1.0", default-features = false } - -rand = { version = "0.8", default-features = false } -rand_core = { version = "0.6", default-features = false } - -ctr = "0.9" -aes = "0.8" -sha2 = { version = "0.10", default-features = false } -hmac = "0.12" -digest = "0.10" -signature = { version = "1.4", default-features = false } -chacha20 = "0.9" -poly1305 = "0.7" -# ed25519/x25519 -salty = { version = "0.2", git = "https://github.com/mkj/salty", branch = "parts" } -# could be optional? though isn't linked if openssh keys aren't loaded -ssh-key = { version = "0.4", default-features = false, features = ["ed25519", "ecdsa", "sha2"] } - -# for debug printing -pretty-hex = { version = "0.3", default-features = false } - -async-trait = { version = "0.1", optional = true } - -[features] -default = [ "getrandom" ] -std = ["async-trait", "snafu/std"] -# tokio-queue = ["dep:tokio"] - -getrandom = ["rand/getrandom"] - -[dev-dependencies] -# toml = "0.5" -# examples want std::error -snafu = { version = "0.7", default-features = true } -anyhow = { version = "1.0" } -pretty-hex = "0.3" -simplelog = { version = "0.12", features = ["test"] } -proptest = "1.0" -async-trait = { version = "0.1" } - -serde_json = "1.0" -