5 Commits

Author SHA1 Message Date
d1fbc70b40 chore(release): v0.0.4 (#22)
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
chore(release): 0.0.4

Co-authored-by: cuddle-please <bot@cuddle.sh>
Reviewed-on: #22
2025-08-03 14:37:13 +02:00
f060e9d2ca feat: pipe output
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-03 14:32:52 +02:00
05b34fd7ee feat: replace bytes with string to avoid endianness
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-03 13:38:42 +02:00
97f5c3a500 feat: sanitise output
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-03 13:33:31 +02:00
404e393b97 chore: add print to output from paste
All checks were successful
continuous-integration/drone/push Build is passing
2025-08-03 13:29:36 +02:00
8 changed files with 33 additions and 25 deletions

View File

@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.0.4] - 2025-08-03
### Added
- pipe output
- replace bytes with string to avoid endianness
- sanitise output
- replace output spawn with native tokio method
### Other
- add print to output from paste
## [0.0.3] - 2025-08-03
### Added

View File

@@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"
[workspace.package]
version = "0.0.3"
version = "0.0.4"
[workspace.dependencies]
voidpin = { path = "crates/voidpin" }

View File

@@ -3,7 +3,7 @@ syntax = "proto3";
package voidpin.v1;
message CopyRequest {
bytes content = 1;
string content = 1;
}
message CopyResponse {}
@@ -12,7 +12,7 @@ message PasteRequest {
}
message PasteResponse {
bytes content = 1;
string content = 1;
}
service VoidPin {

View File

@@ -54,13 +54,15 @@ impl LocalCopier {
#[cfg(target_os = "macos")]
let paste_process = {
tokio::process::Command::new("pbpaste")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?
};
#[cfg(target_os = "linux")]
let mut paste_process = {
tokio::process::Command::new("wl-paste")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()?
};
#[cfg(target_os = "windows")]

View File

@@ -3,8 +3,8 @@
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CopyRequest {
#[prost(bytes="vec", tag="1")]
pub content: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="1")]
pub content: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
@@ -17,8 +17,8 @@ pub struct PasteRequest {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PasteResponse {
#[prost(bytes="vec", tag="1")]
pub content: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="1")]
pub content: ::prost::alloc::string::String,
}
include!("voidpin.v1.tonic.rs");
// @@protoc_insertion_point(module)

View File

@@ -25,7 +25,7 @@ impl crate::grpc::void_pin_server::VoidPin for GrpcServer {
self.state
.local_copier()
.copy(&req.content)
.copy(&req.content.as_bytes())
.await
.map_err(|e| tonic::Status::internal(e.to_string()))?;
@@ -44,7 +44,7 @@ impl crate::grpc::void_pin_server::VoidPin for GrpcServer {
.map_err(|e| tonic::Status::internal(e.to_string()))?;
Ok(tonic::Response::new(crate::grpc::PasteResponse {
content: output,
content: String::from_utf8_lossy(&output).to_string(),
}))
}
}

View File

@@ -68,7 +68,7 @@ async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
EnvFilter::builder()
.with_default_directive("error".parse().unwrap())
//.with_default_directive("error".parse().unwrap())
.from_env_lossy(),
)
.with_writer(std::io::stderr)
@@ -100,10 +100,7 @@ async fn main() -> anyhow::Result<()> {
}
tracing::debug!(content = &input, "found content");
state
.remote_copier(&remote_host)
.copy(input.as_bytes())
.await?;
state.remote_copier(&remote_host).copy(input).await?;
return Ok(());
}
@@ -123,10 +120,11 @@ async fn main() -> anyhow::Result<()> {
}
Commands::Paste {} => {
let mut stdout = tokio::io::stdout();
if let Ok(remote_host) = std::env::var("VOIDPIN_REMOTE") {
let output = state.remote_copier(&remote_host).paste().await?;
stdout.write_all(&output).await?;
stdout.write_all(output.as_bytes()).await?;
stdout.flush().await?;
return Ok(());
@@ -149,16 +147,13 @@ async fn main() -> anyhow::Result<()> {
}
tracing::debug!(content = &input, "found content");
state
.remote_copier(&remote_host)
.copy(input.as_bytes())
.await?;
state.remote_copier(&remote_host).copy(input).await?;
}
RemoteCommands::Paste { remote_host } => {
let output = state.remote_copier(&remote_host).paste().await?;
let mut stdout = tokio::io::stdout();
stdout.write_all(&output).await?;
stdout.write_all(output.as_bytes()).await?;
stdout.flush().await?;
}
},

View File

@@ -17,7 +17,7 @@ impl RemoteCopier {
}
}
pub async fn copy(&self, input: &[u8]) -> anyhow::Result<()> {
pub async fn copy(&self, input: String) -> anyhow::Result<()> {
let tls = ClientTlsConfig::new();
let channel = Channel::from_shared(self.host.clone())?
.tls_config(if self.host.starts_with("https") {
@@ -41,7 +41,7 @@ impl RemoteCopier {
Ok(())
}
pub async fn paste(&self) -> anyhow::Result<Vec<u8>> {
pub async fn paste(&self) -> anyhow::Result<String> {
let tls = ClientTlsConfig::new();
let channel = Channel::from_shared(self.host.clone())?
.tls_config(if self.host.starts_with("https") {
@@ -58,8 +58,8 @@ impl RemoteCopier {
tracing::info!("sending paste request");
let resp = client.paste(PasteRequest {}).await?;
tracing::info!("received paste response");
let output = resp.into_inner().content;
tracing::info!(content = output, "received paste response");
Ok(output)
}