Rename send -> action and bump to 0.3.0

pull/38/head v0.3.0
Chip Senkbeil 3 years ago
parent 3cbdfb19d9
commit f24bb6067d
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

2
Cargo.lock generated

@ -199,7 +199,7 @@ dependencies = [
[[package]]
name = "distant"
version = "0.2.3"
version = "0.3.0"
dependencies = [
"bytes",
"derive_more",

@ -2,7 +2,7 @@
name = "distant"
description = "Operate on a remote computer through file and process manipulation"
categories = ["command-line-utilities"]
version = "0.2.3"
version = "0.3.0"
authors = ["Chip Senkbeil <chip@senkbeil.org>"]
edition = "2018"
homepage = "https://github.com/chipsenkbeil/distant"

@ -1,5 +1,12 @@
# distant
[![Crates.io][distant_crates_img]][distant_crates_lnk] [![Docs.rs][distant_doc_img]][distant_doc_lnk]
[distant_crates_img]: https://img.shields.io/crates/v/distant.svg
[distant_crates_lnk]: https://crates.io/crates/distant
[distant_doc_img]: https://docs.rs/distant/badge.svg
[distant_doc_lnk]: https://docs.rs/distant
Binary to connect with a remote machine to edit files and run programs.
## Details
@ -25,9 +32,9 @@ starting the `distant` executable:
distant launch my.example.com
# After the session is established, you can perform different operations
# on the remote machine via `distant send {command} [args]`
distant send copy path/to/file new/path/to/file
distant send proc-run echo 'Hello, this is from the other side'
# on the remote machine via `distant action {command} [args]`
distant action copy path/to/file new/path/to/file
distant action proc-run -- echo 'Hello, this is from the other side'
```
## License

@ -50,27 +50,27 @@ pub struct CommonOpt {
#[derive(Debug, StructOpt)]
pub enum Subcommand {
/// Performs some task related to the current session
Session(SessionSubcommand),
/// Sends some operation to be performed on a remote machine
Send(SendSubcommand),
/// Performs some action on a remote machine
Action(ActionSubcommand),
/// Launches the server-portion of the binary on a remote machine
Launch(LaunchSubcommand),
/// Begins listening for incoming requests
Listen(ListenSubcommand),
/// Performs some task related to the current session
Session(SessionSubcommand),
}
impl Subcommand {
/// Runs the subcommand, returning the result
pub fn run(self, opt: CommonOpt) -> Result<(), Box<dyn std::error::Error>> {
match self {
Self::Session(cmd) => subcommand::session::run(cmd, opt)?,
Self::Send(cmd) => subcommand::send::run(cmd, opt)?,
Self::Action(cmd) => subcommand::action::run(cmd, opt)?,
Self::Launch(cmd) => subcommand::launch::run(cmd, opt)?,
Self::Listen(cmd) => subcommand::listen::run(cmd, opt)?,
Self::Session(cmd) => subcommand::session::run(cmd, opt)?,
}
Ok(())
@ -119,7 +119,7 @@ pub enum Mode {
/// Represents subcommand to execute some operation remotely
#[derive(Debug, StructOpt)]
#[structopt(verbatim_doc_comment)]
pub struct SendSubcommand {
pub struct ActionSubcommand {
/// Represents the format that results should be returned
///
/// Currently, there are two possible formats:

@ -1,7 +1,7 @@
use crate::{
data::{Request, RequestPayload, Response, ResponsePayload},
net::{Client, TransportError},
opt::{CommonOpt, Mode, SendSubcommand},
opt::{ActionSubcommand, CommonOpt, Mode},
utils::{Session, SessionError},
};
use derive_more::{Display, Error, From};
@ -26,13 +26,13 @@ pub enum Error {
MissingOperation,
}
pub fn run(cmd: SendSubcommand, opt: CommonOpt) -> Result<(), Error> {
pub fn run(cmd: ActionSubcommand, opt: CommonOpt) -> Result<(), Error> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async { run_async(cmd, opt).await })
}
async fn run_async(cmd: SendSubcommand, _opt: CommonOpt) -> Result<(), Error> {
async fn run_async(cmd: ActionSubcommand, _opt: CommonOpt) -> Result<(), Error> {
let session = Session::load().await?;
let mut client = Client::connect(session).await?;

@ -255,7 +255,6 @@ async fn proc_run(
});
// Spawn a task that sends stdin to the process
// TODO: Should this be configurable?
let mut stdin = child.stdin.take().unwrap();
let (stdin_tx, mut stdin_rx) = mpsc::channel::<Vec<u8>>(1);
tokio::spawn(async move {

@ -198,6 +198,7 @@ async fn request_loop(
}
}
/// Repeatedly sends responses out over the wire
async fn response_loop(
addr: SocketAddr,
mut transport: TransportWriteHalf,
@ -211,10 +212,10 @@ async fn response_loop(
}
}
/// Prints out the port and **secret auth key** to share with a client when
/// establishing communication. This is **highly unsafe** and should only be
/// done when the server is launched over a secure channel such as SSH.
fn publish_data(port: u16, key: &SecretKey) {
// TODO: We have to share the key in some manner (maybe use k256 to arrive at the same key?)
// For now, we do what mosh does and print out the key knowing that this is shared over
// ssh, which should provide security
println!(
"DISTANT DATA {} {}",
port,

@ -1,4 +1,4 @@
pub mod action;
pub mod launch;
pub mod listen;
pub mod send;
pub mod session;

Loading…
Cancel
Save