Skip to content

Commit

Permalink
make clippy happy and bump 0.1.1
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Lee <[email protected]>
  • Loading branch information
BusyJay committed Feb 17, 2024
1 parent 5c34c52 commit 4fbead7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gpg-bridge"
version = "0.1.0"
version = "0.1.1"
authors = ["Jay Lee <[email protected]>"]
edition = "2018"
description = "A bridge connects openssh-portable and GnuPG on Windows."
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ use log::{debug, error, trace};
use std::path::Path;
use std::pin::Pin;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::sync::Arc;
use std::{error, io, mem, ptr, str};
use tokio::fs::File;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::windows::named_pipe::ServerOptions;
use tokio::net::{TcpListener, TcpStream};
use tokio::process::Command;
use tokio::sync::Mutex;

struct AgentMeta {
path: Option<String>,
Expand Down Expand Up @@ -93,7 +94,7 @@ fn load_cygwin_port_nounce(buffer: &[u8]) -> io::Result<(u16, [u8; 16])> {
Err(e) => Err(report_data_err(e)),
};

let end_pos = find(&buffer, 0, b' ')?;
let end_pos = find(buffer, 0, b' ')?;
let port = parse(&buffer[..end_pos], 10)?;

if (1..=65535).contains(&port)
Expand Down Expand Up @@ -124,7 +125,7 @@ async fn load_port_nounce(path: &str) -> io::Result<(u16, [u8; 16])> {
if !Path::new(&path).exists() {
ping_gpg_agent().await?;
}
let mut f = File::open(&path.replace("\\", "/")).await?;
let mut f = File::open(&path.replace('\\', "/")).await?;
let mut buffer = Vec::with_capacity(50);
f.read_to_end(&mut buffer).await?;
if buffer.starts_with(b"!<socket >") {
Expand Down Expand Up @@ -237,7 +238,7 @@ where

let meta = meta.clone();
let (port, nounce) = {
let mut m = meta.lock().unwrap();
let mut m = meta.lock().await;
if m.args.is_none() {
if m.path.is_none() {
m.path = Some(load_gpg_socket_path(SocketType::Extra).await?);
Expand All @@ -250,7 +251,7 @@ where
tokio::spawn(async move {
if let Err(e) = delegate(conn, port, nounce).await {
error!("failed to delegate stream: {:?}", e);
meta.lock().unwrap().args.take();
meta.lock().await.args.take();
}
});
}
Expand Down

0 comments on commit 4fbead7

Please sign in to comment.