Compare commits
1 Commits
v0.0.4
...
aae9189ed8
Author | SHA1 | Date | |
---|---|---|---|
|
aae9189ed8 |
@@ -9,14 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [0.0.4] - 2025-08-03
|
## [0.0.4] - 2025-08-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- pipe output
|
|
||||||
- replace bytes with string to avoid endianness
|
|
||||||
- sanitise output
|
|
||||||
- replace output spawn with native tokio method
|
- replace output spawn with native tokio method
|
||||||
|
|
||||||
### Other
|
|
||||||
- add print to output from paste
|
|
||||||
|
|
||||||
## [0.0.3] - 2025-08-03
|
## [0.0.3] - 2025-08-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -3,7 +3,7 @@ syntax = "proto3";
|
|||||||
package voidpin.v1;
|
package voidpin.v1;
|
||||||
|
|
||||||
message CopyRequest {
|
message CopyRequest {
|
||||||
string content = 1;
|
bytes content = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CopyResponse {}
|
message CopyResponse {}
|
||||||
@@ -12,7 +12,7 @@ message PasteRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message PasteResponse {
|
message PasteResponse {
|
||||||
string content = 1;
|
bytes content = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
service VoidPin {
|
service VoidPin {
|
||||||
|
@@ -54,15 +54,13 @@ impl LocalCopier {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let paste_process = {
|
let paste_process = {
|
||||||
tokio::process::Command::new("pbpaste")
|
tokio::process::Command::new("pbpaste")
|
||||||
.stdout(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
|
||||||
.spawn()?
|
.spawn()?
|
||||||
};
|
};
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let mut paste_process = {
|
let mut paste_process = {
|
||||||
tokio::process::Command::new("wl-paste")
|
tokio::process::Command::new("wl-paste")
|
||||||
.stdout(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
|
||||||
.spawn()?
|
.spawn()?
|
||||||
};
|
};
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct CopyRequest {
|
pub struct CopyRequest {
|
||||||
#[prost(string, tag="1")]
|
#[prost(bytes="vec", tag="1")]
|
||||||
pub content: ::prost::alloc::string::String,
|
pub content: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
|
||||||
@@ -17,8 +17,8 @@ pub struct PasteRequest {
|
|||||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||||
pub struct PasteResponse {
|
pub struct PasteResponse {
|
||||||
#[prost(string, tag="1")]
|
#[prost(bytes="vec", tag="1")]
|
||||||
pub content: ::prost::alloc::string::String,
|
pub content: ::prost::alloc::vec::Vec<u8>,
|
||||||
}
|
}
|
||||||
include!("voidpin.v1.tonic.rs");
|
include!("voidpin.v1.tonic.rs");
|
||||||
// @@protoc_insertion_point(module)
|
// @@protoc_insertion_point(module)
|
@@ -25,7 +25,7 @@ impl crate::grpc::void_pin_server::VoidPin for GrpcServer {
|
|||||||
|
|
||||||
self.state
|
self.state
|
||||||
.local_copier()
|
.local_copier()
|
||||||
.copy(&req.content.as_bytes())
|
.copy(&req.content)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| tonic::Status::internal(e.to_string()))?;
|
.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()))?;
|
.map_err(|e| tonic::Status::internal(e.to_string()))?;
|
||||||
|
|
||||||
Ok(tonic::Response::new(crate::grpc::PasteResponse {
|
Ok(tonic::Response::new(crate::grpc::PasteResponse {
|
||||||
content: String::from_utf8_lossy(&output).to_string(),
|
content: output,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
.with_env_filter(
|
.with_env_filter(
|
||||||
EnvFilter::builder()
|
EnvFilter::builder()
|
||||||
//.with_default_directive("error".parse().unwrap())
|
.with_default_directive("error".parse().unwrap())
|
||||||
.from_env_lossy(),
|
.from_env_lossy(),
|
||||||
)
|
)
|
||||||
.with_writer(std::io::stderr)
|
.with_writer(std::io::stderr)
|
||||||
@@ -100,7 +100,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!(content = &input, "found content");
|
tracing::debug!(content = &input, "found content");
|
||||||
state.remote_copier(&remote_host).copy(input).await?;
|
state
|
||||||
|
.remote_copier(&remote_host)
|
||||||
|
.copy(input.as_bytes())
|
||||||
|
.await?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -120,11 +123,10 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
Commands::Paste {} => {
|
Commands::Paste {} => {
|
||||||
let mut stdout = tokio::io::stdout();
|
let mut stdout = tokio::io::stdout();
|
||||||
|
|
||||||
if let Ok(remote_host) = std::env::var("VOIDPIN_REMOTE") {
|
if let Ok(remote_host) = std::env::var("VOIDPIN_REMOTE") {
|
||||||
let output = state.remote_copier(&remote_host).paste().await?;
|
let output = state.remote_copier(&remote_host).paste().await?;
|
||||||
|
|
||||||
stdout.write_all(output.as_bytes()).await?;
|
stdout.write_all(&output).await?;
|
||||||
stdout.flush().await?;
|
stdout.flush().await?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -147,13 +149,16 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tracing::debug!(content = &input, "found content");
|
tracing::debug!(content = &input, "found content");
|
||||||
state.remote_copier(&remote_host).copy(input).await?;
|
state
|
||||||
|
.remote_copier(&remote_host)
|
||||||
|
.copy(input.as_bytes())
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
RemoteCommands::Paste { remote_host } => {
|
RemoteCommands::Paste { remote_host } => {
|
||||||
let output = state.remote_copier(&remote_host).paste().await?;
|
let output = state.remote_copier(&remote_host).paste().await?;
|
||||||
|
|
||||||
let mut stdout = tokio::io::stdout();
|
let mut stdout = tokio::io::stdout();
|
||||||
stdout.write_all(output.as_bytes()).await?;
|
stdout.write_all(&output).await?;
|
||||||
stdout.flush().await?;
|
stdout.flush().await?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -17,7 +17,7 @@ impl RemoteCopier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn copy(&self, input: String) -> anyhow::Result<()> {
|
pub async fn copy(&self, input: &[u8]) -> anyhow::Result<()> {
|
||||||
let tls = ClientTlsConfig::new();
|
let tls = ClientTlsConfig::new();
|
||||||
let channel = Channel::from_shared(self.host.clone())?
|
let channel = Channel::from_shared(self.host.clone())?
|
||||||
.tls_config(if self.host.starts_with("https") {
|
.tls_config(if self.host.starts_with("https") {
|
||||||
@@ -41,7 +41,7 @@ impl RemoteCopier {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn paste(&self) -> anyhow::Result<String> {
|
pub async fn paste(&self) -> anyhow::Result<Vec<u8>> {
|
||||||
let tls = ClientTlsConfig::new();
|
let tls = ClientTlsConfig::new();
|
||||||
let channel = Channel::from_shared(self.host.clone())?
|
let channel = Channel::from_shared(self.host.clone())?
|
||||||
.tls_config(if self.host.starts_with("https") {
|
.tls_config(if self.host.starts_with("https") {
|
||||||
@@ -58,8 +58,8 @@ impl RemoteCopier {
|
|||||||
tracing::info!("sending paste request");
|
tracing::info!("sending paste request");
|
||||||
let resp = client.paste(PasteRequest {}).await?;
|
let resp = client.paste(PasteRequest {}).await?;
|
||||||
|
|
||||||
|
tracing::info!("received paste response");
|
||||||
let output = resp.into_inner().content;
|
let output = resp.into_inner().content;
|
||||||
tracing::info!(content = output, "received paste response");
|
|
||||||
|
|
||||||
Ok(output)
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user