Update to support the latest KeePassXC
This commit is contained in:
Generated
+25
-25
@@ -1,91 +1,91 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "keepassxc-proxy"
|
name = "keepassxc-proxy"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder",
|
||||||
"named_pipe 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"named_pipe",
|
||||||
"nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"nix",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi-build",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.43"
|
version = "0.2.43"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "named_pipe"
|
name = "named_pipe"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "516fe2b5b1131f912a3d4e0cbfec369ca9a65f89d477c15d86ef0fc376faaa55"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys",
|
||||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags",
|
||||||
"cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc",
|
||||||
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cfg-if",
|
||||||
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc",
|
||||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"void",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "void"
|
name = "void"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi-build"
|
name = "winapi-build"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||||
[metadata]
|
|
||||||
"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789"
|
|
||||||
"checksum byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff81738b726f5d099632ceaffe7fb65b90212e8dce59d518729e7e8634032d3d"
|
|
||||||
"checksum cc 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "2119ea4867bd2b8ed3aecab467709720b2d55b1bcfe09f772fd68066eaf15275"
|
|
||||||
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
|
|
||||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
|
||||||
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
|
|
||||||
"checksum named_pipe 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "516fe2b5b1131f912a3d4e0cbfec369ca9a65f89d477c15d86ef0fc376faaa55"
|
|
||||||
"checksum nix 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d37e713a259ff641624b6cb20e3b12b2952313ba36b6823c0f16e6cfd9e5de17"
|
|
||||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
|
||||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
|
||||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ Application that works as a proxy between Native Messaging browser extension and
|
|||||||
This is still under development. Installing the proxy needs manual changes to JSON scripts installed for Native Messaging.
|
This is still under development. Installing the proxy needs manual changes to JSON scripts installed for Native Messaging.
|
||||||
See [this page](https://developer.chrome.com/extensions/nativeMessaging) for further information.
|
See [this page](https://developer.chrome.com/extensions/nativeMessaging) for further information.
|
||||||
|
|
||||||
keepassxc-proxy listens stdin from keepassxc-browser extension and transfers the data to Unix domain socket `XDG_RUNTIME_DIR` or `/tmp/kpxc_server` which KeePassXC listens.
|
keepassxc-proxy listens stdin from keepassxc-browser extension and transfers the data to Unix domain socket `XDG_RUNTIME_DIR` or `/tmp/org.keepassxc.KeePassXC.BrowserServer` which KeePassXC listens.
|
||||||
With Windows this is a named pipe under `keepassxc\<username>\kpxc_server`.
|
With Windows this is a named pipe under `org.keepassxc.KeePassXC.BrowserServer\<username>`.
|
||||||
|
|
||||||
```
|
```
|
||||||
Copyright (C) 2017-2018 Sami Vänttinen <sami.vanttinen@protonmail.com>
|
Copyright (C) 2017-2021 Sami Vänttinen <sami.vanttinen@protonmail.com>
|
||||||
Copyright (C) 2017-2018 Andy Brandt <andy@brandt.tech>
|
Copyright (C) 2017-2018 Andy Brandt <andy@brandt.tech>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
+34
-34
@@ -14,58 +14,58 @@ use proxy_socket::ProxySocket;
|
|||||||
const BUFFER_SIZE: u32 = 1024 ^ 2; // 1024 ^ 2 is the maximum
|
const BUFFER_SIZE: u32 = 1024 ^ 2; // 1024 ^ 2 is the maximum
|
||||||
|
|
||||||
fn valid_length(length: u32) -> bool {
|
fn valid_length(length: u32) -> bool {
|
||||||
return length > 0 && length <= BUFFER_SIZE;
|
return length > 0 && length <= BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_header() -> u32 {
|
fn read_header() -> u32 {
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
let mut buf = vec![0; 4];
|
let mut buf = vec![0; 4];
|
||||||
let mut handle = stdin.lock();
|
let mut handle = stdin.lock();
|
||||||
|
|
||||||
handle.read_exact(&mut buf).unwrap();
|
handle.read_exact(&mut buf).unwrap();
|
||||||
NativeEndian::read_u32(&buf)
|
NativeEndian::read_u32(&buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_body<T: Read + Write>(length: u32, socket: &mut ProxySocket<T>) {
|
fn read_body<T: Read + Write>(length: u32, socket: &mut ProxySocket<T>) {
|
||||||
let mut buffer = vec![0; length as usize];
|
let mut buffer = vec![0; length as usize];
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
let mut handle = stdin.lock();
|
let mut handle = stdin.lock();
|
||||||
|
|
||||||
if let Ok(_) = handle.read_exact(&mut buffer) {
|
if let Ok(_) = handle.read_exact(&mut buffer) {
|
||||||
if valid_length(length) {
|
if valid_length(length) {
|
||||||
socket.write(&buffer).unwrap();
|
socket.write(&buffer).unwrap();
|
||||||
socket.flush().unwrap();
|
socket.flush().unwrap();
|
||||||
read_response(socket);
|
read_response(socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_response<T: Read>(socket: &mut ProxySocket<T>) {
|
fn read_response<T: Read>(socket: &mut ProxySocket<T>) {
|
||||||
let mut buf = vec![0; BUFFER_SIZE as usize];
|
let mut buf = vec![0; BUFFER_SIZE as usize];
|
||||||
if let Ok(len) = socket.read(&mut buf) {
|
if let Ok(len) = socket.read(&mut buf) {
|
||||||
write_response(&buf[0..len]);
|
write_response(&buf[0..len]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_response(buf: &[u8]) {
|
fn write_response(buf: &[u8]) {
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut out = stdout.lock();
|
let mut out = stdout.lock();
|
||||||
|
|
||||||
out.write_u32::<NativeEndian>(buf.len() as u32).unwrap();
|
out.write_u32::<NativeEndian>(buf.len() as u32).unwrap();
|
||||||
out.write(buf).unwrap();
|
out.write(buf).unwrap();
|
||||||
out.flush().unwrap();
|
out.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut socket = proxy_socket::connect(BUFFER_SIZE).unwrap();
|
let mut socket = proxy_socket::connect(BUFFER_SIZE).unwrap();
|
||||||
|
|
||||||
// Start thread for user input reading
|
// Start thread for user input reading
|
||||||
let ui = thread::spawn(move || {
|
let ui = thread::spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
let length = read_header();
|
let length = read_header();
|
||||||
read_body(length, &mut socket);
|
read_body(length, &mut socket);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ui_res = ui.join().unwrap();
|
let _ui_res = ui.join().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-28
@@ -12,48 +12,48 @@ use nix::sys::socket::sockopt::RcvBuf;
|
|||||||
use named_pipe::PipeClient;
|
use named_pipe::PipeClient;
|
||||||
|
|
||||||
pub struct ProxySocket<T> {
|
pub struct ProxySocket<T> {
|
||||||
inner: T,
|
inner: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Read> Read for ProxySocket<R> {
|
impl<R: Read> Read for ProxySocket<R> {
|
||||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
self.inner.read(buf)
|
self.inner.read(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: Write> Write for ProxySocket<W> {
|
impl<W: Write> Write for ProxySocket<W> {
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||||
self.inner.write(buf)
|
self.inner.write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> io::Result<()> {
|
fn flush(&mut self) -> io::Result<()> {
|
||||||
self.inner.flush()
|
self.inner.flush()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn connect(buffer_size: u32) -> io::Result<ProxySocket<PipeClient>> {
|
pub fn connect(buffer_size: u32) -> io::Result<ProxySocket<PipeClient>> {
|
||||||
let username = env::var("USERNAME").unwrap();
|
let username = env::var("USERNAME").unwrap();
|
||||||
let pipe_name = format!("\\\\.\\pipe\\keepassxc\\{}\\kpxc_server", username);
|
let pipe_name = format!("\\\\.\\pipe\\keepassxc\\{}\\org.keepassxc.KeePassXC.BrowserServer", username);
|
||||||
let client = PipeClient::connect(pipe_name)?;
|
let client = PipeClient::connect(pipe_name)?;
|
||||||
Ok(ProxySocket { inner: client })
|
Ok(ProxySocket { inner: client })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn connect(buffer_size: u32) -> io::Result<ProxySocket<UnixStream>> {
|
pub fn connect(buffer_size: u32) -> io::Result<ProxySocket<UnixStream>> {
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
let socket_name = "kpxc_server";
|
let socket_name = "org.keepassxc.KeePassXC.BrowserServer";
|
||||||
let socket: String;
|
let socket: String;
|
||||||
if let Ok(dir) = if cfg!(target_os = "macos") {env::var("TMPDIR") } else { env::var("XDG_RUNTIME_DIR") } {
|
if let Ok(dir) = if cfg!(target_os = "macos") {env::var("TMPDIR") } else { env::var("XDG_RUNTIME_DIR") } {
|
||||||
socket = format!("{}/{}", dir, socket_name);
|
socket = format!("{}/{}", dir, socket_name);
|
||||||
} else {
|
} else {
|
||||||
socket = format!("/tmp/{}", socket_name);
|
socket = format!("/tmp/{}", socket_name);
|
||||||
}
|
}
|
||||||
let s = UnixStream::connect(socket)?;
|
let s = UnixStream::connect(socket)?;
|
||||||
socket::setsockopt(s.as_raw_fd(), SndBuf, &(buffer_size as usize)).expect("setsockopt for SndBuf failed");
|
socket::setsockopt(s.as_raw_fd(), SndBuf, &(buffer_size as usize)).expect("setsockopt for SndBuf failed");
|
||||||
socket::setsockopt(s.as_raw_fd(), RcvBuf, &(buffer_size as usize)).expect("setsockopt for RcvBuf failed");
|
socket::setsockopt(s.as_raw_fd(), RcvBuf, &(buffer_size as usize)).expect("setsockopt for RcvBuf failed");
|
||||||
let timeout: Option<Duration> = Some(Duration::from_secs(1));
|
let timeout: Option<Duration> = Some(Duration::from_secs(1));
|
||||||
s.set_read_timeout(timeout)?;
|
s.set_read_timeout(timeout)?;
|
||||||
Ok(ProxySocket { inner: s })
|
Ok(ProxySocket { inner: s })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user