From c23df48fe3703f8bba8eb1c346e74aee1336b047 Mon Sep 17 00:00:00 2001
From: sohw400
Date: Thu, 25 Sep 2025 11:08:26 +0900
Subject: [PATCH 1/3] chore: update dependencies and improve package metadata
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Update outdated dependencies: clap 3.2.25→4.5, nix 0.26→0.29, byteorder 1.3→1.5, num 0.2→0.4
- Normalize serde version constraints from '>=1.0' to '1.0'
- Add comprehensive package metadata to all Cargo.toml files:
- Add missing authors, descriptions, and license information
- Fix repository URLs pointing to correct GitHub organization
- Add relevant keywords and categories for Rust package discovery
- Set homepage links to main repository
- Establish workspace-level metadata inheritance
- Add accessibility improvements to README.md banner image
- Set rust-version metadata to 1.80 for toolchain consistency
This improves package discoverability, maintainability, and follows Rust ecosystem best practices.
---
Cargo.toml | 12 ++++++++++--
README.md | 2 +-
fs-monitor/Cargo.toml | 8 ++++++++
pf-proxy/Cargo.toml | 8 ++++++++
pipeline/Cargo.toml | 18 ++++++++++--------
ra-web-srv/Cargo.toml | 12 ++++++++++--
6 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 8fd3184..6405eb7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,9 +10,17 @@ exclude = [
"reference_apps",
]
-# edition = "2021"
resolver = "2"
-overflow-checks = true
+
+[workspace.package]
+edition = "2021"
+authors = ["Sentient Enclaves Team "]
+license = "Apache-2.0"
+homepage = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+repository = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+
+[workspace.metadata]
+rust-version = "1.80"
[profile.release]
strip = true
diff --git a/README.md b/README.md
index f159d7b..fa4017d 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@
-
+
Welcome to the Sentient Enclaves Framework. The framework provides end-to-end infrastructure for building confidential AI applications using TEEs.
diff --git a/fs-monitor/Cargo.toml b/fs-monitor/Cargo.toml
index 4e6755d..71ed19b 100644
--- a/fs-monitor/Cargo.toml
+++ b/fs-monitor/Cargo.toml
@@ -1,7 +1,15 @@
[package]
name = "fs-monitor"
version = "0.8.2"
+authors = ["Sentient Enclaves Team "]
edition = "2021"
+description = "Real-time inotify events monitoring server for file system changes in AWS Nitro Enclaves"
+homepage = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+repository = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+license = "Apache-2.0"
+keywords = ["filesystem", "monitoring", "tee", "enclave", "inotify"]
+categories = ["filesystem", "os::unix-apis", "cryptography"]
+publish = false
[dependencies]
inotify = "0.11.0"
diff --git a/pf-proxy/Cargo.toml b/pf-proxy/Cargo.toml
index 9b9baf2..559beec 100644
--- a/pf-proxy/Cargo.toml
+++ b/pf-proxy/Cargo.toml
@@ -1,7 +1,15 @@
[package]
name = "pf-proxy"
version = "0.8.2"
+authors = ["Sentient Enclaves Team "]
edition = "2021"
+description = "Transparent vsock proxies for internet-enabled applications in AWS Nitro Enclaves"
+homepage = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+repository = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+license = "Apache-2.0"
+keywords = ["proxy", "vsock", "tee", "enclave", "aws-nitro"]
+categories = ["network-programming", "cryptography"]
+publish = false
[[bin]]
name = "vsock-to-ip"
diff --git a/pipeline/Cargo.toml b/pipeline/Cargo.toml
index 113a8db..ac40c84 100644
--- a/pipeline/Cargo.toml
+++ b/pipeline/Cargo.toml
@@ -5,20 +5,22 @@ authors = ["Sentient Enclaves Team "]
edition = "2021"
# resolver = "2"
# rust-version = "1.80"
-description = "Pipeline vsock secure local channel communication protocol that provides remote control of enclave via running shell commands inside the enclave and provides bidirectional files transmission into/from encalve's file system."
-homepage = "https://github.com/sentient-xyz/pipeline-tee.rs/"
-repository = "https://github.com/sentient-xyz/pipeline-tee.rs/"
+description = "Pipeline vsock secure local channel communication protocol that provides remote control of enclave via running shell commands inside the enclave and provides bidirectional files transmission into/from enclave's file system."
+homepage = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+repository = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
license = "Apache-2.0"
+keywords = ["tee", "enclave", "confidential-computing", "vsock", "aws-nitro"]
+categories = ["cryptography", "network-programming", "command-line-utilities"]
publish = false
[dependencies]
-clap = "3.2.25"
+clap = "4.5"
log = "0.4"
-nix = "0.26"
-serde = { version = ">=1.0", features = ["derive"] }
+nix = "0.29"
+serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
-byteorder = "1.3"
-num = "0.2"
+byteorder = "1.5"
+num = "0.4"
num-derive = "0.4"
num-traits = "0.2"
toml = "0.8"
diff --git a/ra-web-srv/Cargo.toml b/ra-web-srv/Cargo.toml
index f2ad3dc..46a5fd7 100644
--- a/ra-web-srv/Cargo.toml
+++ b/ra-web-srv/Cargo.toml
@@ -1,7 +1,15 @@
[package]
name = "ra-web-srv"
version = "0.8.2"
+authors = ["Sentient Enclaves Team "]
edition = "2021"
+description = "Remote Attestation Web Server for verifying integrity of AWS Nitro Enclave applications"
+homepage = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+repository = "https://github.com/sentient-agi/Sentient-Enclaves-Framework"
+license = "Apache-2.0"
+keywords = ["attestation", "tee", "enclave", "aws-nitro", "security"]
+categories = ["cryptography", "web-programming", "authentication"]
+publish = false
[[bin]]
name = "ra-web-srv"
@@ -16,8 +24,8 @@ axum = { version = "0.8" }
axum-extra = { version = "0.10" }
axum-server = { version = "0.7", features = ["tls-openssl"] }
axum-macros = "0.5"
-serde = { version = ">=1.0", features = ["derive"] }
-serde_json = { version = ">=1.0" }
+serde = { version = "1.0", features = ["derive"] }
+serde_json = { version = "1.0" }
serde_bytes = "0.11"
serde_cbor = "0.11"
futures = "0.3"
From 03857705a7603da46846874af197afe4a9a64a85 Mon Sep 17 00:00:00 2001
From: sohw400
Date: Mon, 13 Oct 2025 10:09:24 +0900
Subject: [PATCH 2/3] refactor: improve error handling in pipeline main
Replaced panicking unwrap/expect calls with proper error handling.
Now gives cleaner error messages when config file is missing or invalid,
and when command execution fails. Exit codes are preserved.
---
pipeline/src/main.rs | 72 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 62 insertions(+), 10 deletions(-)
diff --git a/pipeline/src/main.rs b/pipeline/src/main.rs
index 86f3fbf..e7ba507 100644
--- a/pipeline/src/main.rs
+++ b/pipeline/src/main.rs
@@ -29,26 +29,78 @@ fn main() {
.get_one("config")
.unwrap_or(&default_config_path);
- let raw_config_string = std::fs::read_to_string(config_path).expect(format!("Missing '{}' configuration file.", config_path).as_str());
- let app_config: AppConfig = toml::from_str(raw_config_string.as_str()).expect(format!("Failed to parse '{}' configuration file.", config_path).as_str());
+ let raw_config_string = match std::fs::read_to_string(config_path) {
+ Ok(s) => s,
+ Err(e) => {
+ eprintln!("Failed to read config file '{}': {}", config_path, e);
+ exit(1);
+ }
+ };
+
+ let app_config: AppConfig = match toml::from_str(raw_config_string.as_str()) {
+ Ok(cfg) => cfg,
+ Err(e) => {
+ eprintln!("Failed to parse config file '{}': {}", config_path, e);
+ exit(1);
+ }
+ };
match args.subcommand() {
Some(("listen", args)) => {
- let listen_args = ListenArgs::new_with(args).unwrap();
- listen(listen_args, app_config).unwrap();
+ let listen_args = match ListenArgs::new_with(args) {
+ Ok(a) => a,
+ Err(e) => {
+ eprintln!("Invalid listen arguments: {}", e);
+ exit(1);
+ }
+ };
+ if let Err(e) = listen(listen_args, app_config) {
+ eprintln!("Listen error: {}", e);
+ exit(1);
+ }
}
Some(("run", args)) => {
- let run_args = RunArgs::new_with(args).unwrap();
- let rc = run(run_args, app_config).unwrap();
+ let run_args = match RunArgs::new_with(args) {
+ Ok(a) => a,
+ Err(e) => {
+ eprintln!("Invalid run arguments: {}", e);
+ exit(1);
+ }
+ };
+ let rc = match run(run_args, app_config) {
+ Ok(code) => code,
+ Err(e) => {
+ eprintln!("Command execution failed: {}", e);
+ exit(1);
+ }
+ };
std::process::exit(rc);
}
Some(("send-file", args)) => {
- let subcmd_args = FileArgs::new_with(args).unwrap();
- send_file(subcmd_args, app_config).unwrap();
+ let subcmd_args = match FileArgs::new_with(args) {
+ Ok(a) => a,
+ Err(e) => {
+ eprintln!("Invalid file arguments: {}", e);
+ exit(1);
+ }
+ };
+ if let Err(e) = send_file(subcmd_args, app_config) {
+ eprintln!("File send failed: {}", e);
+ exit(1);
+ }
}
Some(("recv-file", args)) => {
- let subcmd_args = FileArgs::new_with(args).unwrap();
- recv_file(subcmd_args, app_config).unwrap();
+ let subcmd_args = match FileArgs::new_with(args) {
+ Ok(a) => a,
+ Err(e) => {
+ eprintln!("Invalid file arguments: {}", e);
+ exit(1);
+ }
+ };
+ if let Err(e) = recv_file(subcmd_args, app_config) {
+ eprintln!("File receive failed: {}", e);
+ exit(1);
+ }
}
Some(_) | None => {}
}
From 15e131e3640fa7e0869d2818dfce26a7c870e423 Mon Sep 17 00:00:00 2001
From: sohw400
Date: Mon, 13 Oct 2025 10:20:35 +0900
Subject: [PATCH 3/3] feat: add structured logging to pf-proxy components
Replaced println statements with tracing for better observability.
All proxy binaries now support RUST_LOG env var for log level control.
Changes:
- Added tracing and tracing-subscriber dependencies
- Converted all println/eprintln to structured logging (info/error/warn)
- Logs include contextual info like addresses, directions, and error details
- Default log level is info, configurable via RUST_LOG env var
This aligns with the roadmap item for improved logging in proxies.
---
Cargo.lock | 126 +++++++---------------
pf-proxy/Cargo.toml | 2 +
pf-proxy/src/addr_info.rs | 5 +-
pf-proxy/src/ip_to_vsock.rs | 20 ++--
pf-proxy/src/ip_to_vsock_transparent.rs | 24 +++--
pf-proxy/src/transparent_port_to_vsock.rs | 24 +++--
pf-proxy/src/vsock_to_ip.rs | 20 ++--
pf-proxy/src/vsock_to_ip_transparent.rs | 18 +++-
8 files changed, 112 insertions(+), 127 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 5bd55a4..d975539 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -258,17 +258,6 @@ version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
-[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi 0.1.19",
- "libc",
- "winapi",
-]
-
[[package]]
name = "autocfg"
version = "1.5.0"
@@ -505,6 +494,12 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "chrono"
version = "0.4.41"
@@ -518,21 +513,6 @@ dependencies = [
"windows-link",
]
-[[package]]
-name = "clap"
-version = "3.2.25"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
-dependencies = [
- "atty",
- "bitflags 1.3.2",
- "clap_lex 0.2.4",
- "indexmap 1.9.3",
- "strsim 0.10.0",
- "termcolor",
- "textwrap",
-]
-
[[package]]
name = "clap"
version = "4.5.45"
@@ -551,8 +531,8 @@ checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8"
dependencies = [
"anstream",
"anstyle",
- "clap_lex 0.7.5",
- "strsim 0.11.1",
+ "clap_lex",
+ "strsim",
]
[[package]]
@@ -567,15 +547,6 @@ dependencies = [
"syn",
]
-[[package]]
-name = "clap_lex"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
-dependencies = [
- "os_str_bytes",
-]
-
[[package]]
name = "clap_lex"
version = "0.7.5"
@@ -690,7 +661,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
- "strsim 0.11.1",
+ "strsim",
"syn",
]
@@ -917,7 +888,7 @@ version = "0.8.2"
dependencies = [
"async-nats",
"bytes",
- "clap 4.5.45",
+ "clap",
"dashmap",
"futures",
"glob",
@@ -1148,15 +1119,6 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
-[[package]]
-name = "hermit-abi"
-version = "0.1.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
-
[[package]]
name = "hermit-abi"
version = "0.5.2"
@@ -1676,6 +1638,18 @@ dependencies = [
"memoffset 0.9.1",
]
+[[package]]
+name = "nix"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
+dependencies = [
+ "bitflags 2.9.2",
+ "cfg-if",
+ "cfg_aliases",
+ "libc",
+]
+
[[package]]
name = "nkeys"
version = "0.4.5"
@@ -1777,9 +1751,9 @@ dependencies = [
[[package]]
name = "num"
-version = "0.2.1"
+version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36"
+checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
dependencies = [
"num-bigint",
"num-complex",
@@ -1791,22 +1765,20 @@ dependencies = [
[[package]]
name = "num-bigint"
-version = "0.2.6"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
+checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
dependencies = [
- "autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
-version = "0.2.4"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
+checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
dependencies = [
- "autocfg",
"num-traits",
]
@@ -1849,11 +1821,10 @@ dependencies = [
[[package]]
name = "num-rational"
-version = "0.2.4"
+version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
+checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
- "autocfg",
"num-bigint",
"num-integer",
"num-traits",
@@ -1943,12 +1914,6 @@ dependencies = [
"vcpkg",
]
-[[package]]
-name = "os_str_bytes"
-version = "6.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
-
[[package]]
name = "overload"
version = "0.1.1"
@@ -2004,12 +1969,14 @@ name = "pf-proxy"
version = "0.8.2"
dependencies = [
"anyhow",
- "clap 4.5.45",
+ "clap",
"futures",
"libc",
"thiserror 1.0.69",
"tokio",
"tokio-vsock",
+ "tracing",
+ "tracing-subscriber",
]
[[package]]
@@ -2049,9 +2016,9 @@ name = "pipeline"
version = "0.8.2"
dependencies = [
"byteorder",
- "clap 3.2.25",
+ "clap",
"log",
- "nix 0.26.4",
+ "nix 0.29.0",
"num",
"num-derive",
"num-traits",
@@ -2095,7 +2062,7 @@ checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829"
dependencies = [
"cfg-if",
"concurrent-queue",
- "hermit-abi 0.5.2",
+ "hermit-abi",
"pin-project-lite",
"rustix",
"windows-sys 0.60.2",
@@ -2724,12 +2691,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
-[[package]]
-name = "strsim"
-version = "0.10.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
-
[[package]]
name = "strsim"
version = "0.11.1"
@@ -2783,21 +2744,6 @@ dependencies = [
"windows-sys 0.60.2",
]
-[[package]]
-name = "termcolor"
-version = "1.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
-dependencies = [
- "winapi-util",
-]
-
-[[package]]
-name = "textwrap"
-version = "0.16.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
-
[[package]]
name = "thiserror"
version = "1.0.69"
diff --git a/pf-proxy/Cargo.toml b/pf-proxy/Cargo.toml
index 559beec..d82d033 100644
--- a/pf-proxy/Cargo.toml
+++ b/pf-proxy/Cargo.toml
@@ -38,6 +38,8 @@ futures = "0.3"
thiserror = "1.0.57"
tokio = { version = "1.44", features = ["full"] }
tokio-vsock = "0.5.0"
+tracing = "0.1"
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
[target.'cfg(target_os = "linux")'.dependencies]
libc = "0.2"
diff --git a/pf-proxy/src/addr_info.rs b/pf-proxy/src/addr_info.rs
index c9f0d70..087228d 100644
--- a/pf-proxy/src/addr_info.rs
+++ b/pf-proxy/src/addr_info.rs
@@ -5,6 +5,7 @@ use std::fmt::Debug;
use std::io;
use std::net::SocketAddr;
use tokio::net::TcpStream;
+use tracing::warn;
pub trait AddrInfo: Debug {
fn local_addr(&self) -> Result;
@@ -37,7 +38,7 @@ impl AddrInfo for TcpStream {
#[cfg(not(target_os = "linux"))]
fn get_original_dst(&self) -> Option {
- println!("Non Linux system, no support for SO_ORIGINAL_DST");
+ warn!("Non-Linux system detected, SO_ORIGINAL_DST not supported");
None
}
}
@@ -61,7 +62,7 @@ mod linux {
);
if ret != 0 {
let e = io::Error::last_os_error();
- println!("failed to read SO_ORIGINAL_DST: {:?}", e);
+ warn!(error = ?e, "Failed to read SO_ORIGINAL_DST");
return Err(e);
}
diff --git a/pf-proxy/src/ip_to_vsock.rs b/pf-proxy/src/ip_to_vsock.rs
index d0b3867..61aa633 100644
--- a/pf-proxy/src/ip_to_vsock.rs
+++ b/pf-proxy/src/ip_to_vsock.rs
@@ -11,6 +11,7 @@ use tokio::io;
use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream};
use tokio_vsock::{VsockAddr, VsockStream};
+use tracing::{error, info};
use pf_proxy::utils;
@@ -27,8 +28,8 @@ struct Cli {
}
pub async fn proxy(listen_addr: &str, server_addr: VsockAddr) -> Result<()> {
- println!("Listening on: {:?}", listen_addr);
- println!("Proxying to: {:?}", server_addr);
+ info!(listen_addr = %listen_addr, "Starting ip-to-vsock proxy");
+ info!(server_addr = ?server_addr, "Forwarding to vsock address");
let listener = TcpListener::bind(listen_addr)
.await
@@ -37,7 +38,7 @@ pub async fn proxy(listen_addr: &str, server_addr: VsockAddr) -> Result<()> {
while let Ok((inbound, _)) = listener.accept().await {
let transfer = transfer(inbound, server_addr).map(|r| {
if let Err(e) = r {
- println!("Failed to transfer data: error={:?}", e);
+ error!(error = ?e, "Connection transfer failed");
}
});
@@ -53,7 +54,7 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
.context("could not fetch inbound address from TCP stream")?
.to_string();
- println!("Proxying to: {:?}", proxy_addr);
+ info!(from = %inbound_addr, to = ?proxy_addr, "New connection established");
let mut outbound = VsockStream::connect(proxy_addr)
.await
@@ -68,7 +69,7 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
.await
.context("error in ip to vsock copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("ip to vsock IO copy done, from {:?} to {:?}", inbound_addr, proxy_addr);
+ info!(from = %inbound_addr, to = ?proxy_addr, direction = "ip->vsock", "Data transfer completed");
wo.shutdown().await
};
@@ -78,7 +79,7 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
.await
.context("error in vsock to ip copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("vsock to ip IO copy done, from {:?} to {:?}", proxy_addr, inbound_addr);
+ info!(from = ?proxy_addr, to = %inbound_addr, direction = "vsock->ip", "Data transfer completed");
wi.shutdown().await
};
@@ -94,6 +95,13 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ tracing_subscriber::EnvFilter::try_from_default_env()
+ .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
+ )
+ .init();
+
let cli = Cli::parse();
let vsock_addr = utils::split_vsock(&cli.vsock_addr)?;
proxy(&cli.ip_addr, vsock_addr).await?;
diff --git a/pf-proxy/src/ip_to_vsock_transparent.rs b/pf-proxy/src/ip_to_vsock_transparent.rs
index 0c7e1b5..ebea5b2 100644
--- a/pf-proxy/src/ip_to_vsock_transparent.rs
+++ b/pf-proxy/src/ip_to_vsock_transparent.rs
@@ -11,6 +11,7 @@ use tokio::io;
use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream};
use tokio_vsock::{VsockAddr, VsockStream};
+use tracing::{error, info};
use pf_proxy::{addr_info::AddrInfo, utils};
@@ -27,8 +28,8 @@ struct Cli {
}
pub async fn proxy(listen_addr: &str, server_addr: VsockAddr) -> Result<()> {
- println!("Listening on: {:?}", listen_addr);
- println!("Proxying to: {:?}", server_addr);
+ info!(listen_addr = %listen_addr, "Starting ip-to-vsock transparent proxy");
+ info!(server_addr = ?server_addr, "Forwarding to vsock address");
let listener = TcpListener::bind(listen_addr)
.await
@@ -37,7 +38,7 @@ pub async fn proxy(listen_addr: &str, server_addr: VsockAddr) -> Result<()> {
while let Ok((inbound, _)) = listener.accept().await {
let transfer = transfer(inbound, server_addr).map(|r| {
if let Err(e) = r {
- println!("Failed to transfer data: error={:?}", e);
+ error!(error = ?e, "Connection transfer failed");
}
});
@@ -57,9 +58,9 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
let orig_dst = inbound
.get_original_dst()
.ok_or(anyhow!("Failed to retrieve original destination from TCP stream"))?;
- println!("Original destination: {:?}", orig_dst);
+ info!(orig_dst = ?orig_dst, "Retrieved original destination");
- println!("Proxying to: {:?}", proxy_addr);
+ info!(proxy_addr = ?proxy_addr, "Connecting to vsock endpoint");
let mut outbound = VsockStream::connect(proxy_addr)
.await
@@ -98,8 +99,7 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
.await
.context("error in ip to vsock copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("ip to vsock IO copy done, from {:?} to {:?}, with original_dst={:?} from inbound TCP stream",
- inbound_addr, proxy_addr, orig_dst);
+ info!(from = %inbound_addr, to = ?proxy_addr, orig_dst = ?orig_dst, direction = "ip->vsock", "Data transfer completed");
wo.shutdown().await
};
@@ -109,8 +109,7 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
.await
.context("error in vsock to ip copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("vsock to ip IO copy done, from {:?} to {:?}, with original_dst={:?} from inbound TCP stream",
- proxy_addr, inbound_addr, orig_dst);
+ info!(from = ?proxy_addr, to = %inbound_addr, orig_dst = ?orig_dst, direction = "vsock->ip", "Data transfer completed");
wi.shutdown().await
};
@@ -126,6 +125,13 @@ async fn transfer(mut inbound: TcpStream, proxy_addr: VsockAddr) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ tracing_subscriber::EnvFilter::try_from_default_env()
+ .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
+ )
+ .init();
+
let cli = Cli::parse();
let vsock_addr = utils::split_vsock(&cli.vsock_addr)?;
proxy(&cli.ip_addr, vsock_addr).await?;
diff --git a/pf-proxy/src/transparent_port_to_vsock.rs b/pf-proxy/src/transparent_port_to_vsock.rs
index cfe03e3..21f2d95 100644
--- a/pf-proxy/src/transparent_port_to_vsock.rs
+++ b/pf-proxy/src/transparent_port_to_vsock.rs
@@ -11,6 +11,7 @@ use tokio::io;
use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream};
use tokio_vsock::{VsockAddr, VsockStream};
+use tracing::{error, info};
use pf_proxy::addr_info::AddrInfo;
@@ -27,8 +28,8 @@ struct Cli {
}
pub async fn port_to_vsock(listen_addr: &str, cid: u32) -> Result<()> {
- println!("Listening on: {:?}", listen_addr);
- println!("Proxying to: {:?}", cid);
+ info!(listen_addr = %listen_addr, "Starting transparent port-to-vsock proxy");
+ info!(cid = %cid, "Forwarding to vsock CID");
let listener = TcpListener::bind(listen_addr)
.await
@@ -37,7 +38,7 @@ pub async fn port_to_vsock(listen_addr: &str, cid: u32) -> Result<()> {
while let Ok((inbound, _)) = listener.accept().await {
let transfer = transfer(inbound, cid).map(|r| {
if let Err(e) = r {
- println!("Failed to transfer data: error={:?}", e);
+ error!(error = ?e, "Connection transfer failed");
}
});
@@ -57,10 +58,10 @@ async fn transfer(mut inbound: TcpStream, cid: u32) -> Result<()> {
let orig_dst = inbound
.get_original_dst()
.ok_or(anyhow!("Failed to retrieve original destination from TCP stream"))?;
- println!("Original destination: {:?}", orig_dst);
+ info!(orig_dst = ?orig_dst, ip = ?orig_dst.ip(), port = %orig_dst.port(), "Retrieved original destination");
let proxy_addr = VsockAddr::new(cid, orig_dst.port().into());
- println!("Proxying to: {:?}", proxy_addr);
+ info!(proxy_addr = ?proxy_addr, "Connecting to vsock endpoint");
let mut outbound = VsockStream::connect(proxy_addr)
.await
@@ -75,8 +76,7 @@ async fn transfer(mut inbound: TcpStream, cid: u32) -> Result<()> {
.await
.context("error in port to vsock copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("port to vsock IO copy done, from {:?} to {:?}, with original_dst={:?}, ip={:?}, port={:?}, from inbound TCP stream",
- inbound_addr, proxy_addr, orig_dst, orig_dst.ip(), orig_dst.port());
+ info!(from = %inbound_addr, to = ?proxy_addr, orig_dst = ?orig_dst, ip = ?orig_dst.ip(), port = %orig_dst.port(), direction = "port->vsock", "Data transfer completed");
wo.shutdown().await
};
@@ -86,8 +86,7 @@ async fn transfer(mut inbound: TcpStream, cid: u32) -> Result<()> {
.await
.context("error in vsock to port copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("vsock to port IO copy done, from {:?} to {:?}, with original_dst={:?}, ip={:?}, port={:?}, from inbound TCP stream",
- proxy_addr, inbound_addr, orig_dst, orig_dst.ip(), orig_dst.port());
+ info!(from = ?proxy_addr, to = %inbound_addr, orig_dst = ?orig_dst, ip = ?orig_dst.ip(), port = %orig_dst.port(), direction = "vsock->port", "Data transfer completed");
wi.shutdown().await
};
@@ -103,6 +102,13 @@ async fn transfer(mut inbound: TcpStream, cid: u32) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ tracing_subscriber::EnvFilter::try_from_default_env()
+ .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
+ )
+ .init();
+
let cli = Cli::parse();
port_to_vsock(&cli.ip_addr, cli.vsock).await?;
diff --git a/pf-proxy/src/vsock_to_ip.rs b/pf-proxy/src/vsock_to_ip.rs
index fb7b60c..04b4673 100644
--- a/pf-proxy/src/vsock_to_ip.rs
+++ b/pf-proxy/src/vsock_to_ip.rs
@@ -11,6 +11,7 @@ use tokio::io;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;
use tokio_vsock::{VsockAddr, VsockListener, VsockStream};
+use tracing::{error, info};
use pf_proxy::utils;
@@ -27,8 +28,8 @@ struct Cli {
}
pub async fn proxy(listen_addr: VsockAddr, server_addr: String) -> Result<()> {
- println!("Listening on: {:?}", listen_addr);
- println!("Proxying to: {:?}", server_addr);
+ info!(listen_addr = ?listen_addr, "Starting vsock-to-ip proxy");
+ info!(server_addr = %server_addr, "Forwarding to IP address");
let mut listener = VsockListener::bind(listen_addr)
.context("Failed to bind listener to vsock: incorrect CID:port")?;
@@ -36,7 +37,7 @@ pub async fn proxy(listen_addr: VsockAddr, server_addr: String) -> Result<()> {
while let Ok((inbound, _)) = listener.accept().await {
let transfer = transfer(inbound, server_addr.clone()).map(|r| {
if let Err(e) = r {
- println!("Failed to transfer data: error={:?}", e);
+ error!(error = ?e, "Connection transfer failed");
}
});
@@ -52,7 +53,7 @@ async fn transfer(mut inbound: VsockStream, proxy_addr: String) -> Result<()> {
.context("could not fetch inbound address from vsock stream")?
.to_string();
- println!("Proxying to: {:?}", proxy_addr);
+ info!(from = %inbound_addr, to = %proxy_addr, "New connection established");
let mut outbound = TcpStream::connect(proxy_addr.clone())
.await
@@ -67,7 +68,7 @@ async fn transfer(mut inbound: VsockStream, proxy_addr: String) -> Result<()> {
.await
.context("error in vsock to ip copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("vsock to ip IO copy done, from {:?} to {:?}", inbound_addr, proxy_addr);
+ info!(from = %inbound_addr, to = %proxy_addr, direction = "vsock->ip", "Data transfer completed");
wo.shutdown().await
};
@@ -77,7 +78,7 @@ async fn transfer(mut inbound: VsockStream, proxy_addr: String) -> Result<()> {
.await
.context("error in ip to vsock copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("ip to vsock IO copy done, from {:?} to {:?}", proxy_addr, inbound_addr);
+ info!(from = %proxy_addr, to = %inbound_addr, direction = "ip->vsock", "Data transfer completed");
wi.shutdown().await
};
@@ -93,6 +94,13 @@ async fn transfer(mut inbound: VsockStream, proxy_addr: String) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ tracing_subscriber::EnvFilter::try_from_default_env()
+ .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
+ )
+ .init();
+
let cli = Cli::parse();
let vsock_addr = utils::split_vsock(&cli.vsock_addr)?;
proxy(vsock_addr, cli.ip_addr).await?;
diff --git a/pf-proxy/src/vsock_to_ip_transparent.rs b/pf-proxy/src/vsock_to_ip_transparent.rs
index ef846c7..3ba1323 100644
--- a/pf-proxy/src/vsock_to_ip_transparent.rs
+++ b/pf-proxy/src/vsock_to_ip_transparent.rs
@@ -13,6 +13,7 @@ use tokio::io::AsyncReadExt;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;
use tokio_vsock::{VsockAddr, VsockListener, VsockStream};
+use tracing::{error, info};
use pf_proxy::utils;
@@ -25,7 +26,7 @@ struct Cli {
}
pub async fn proxy(listen_addr: VsockAddr) -> Result<()> {
- println!("Listening on: {:?}", listen_addr);
+ info!(listen_addr = ?listen_addr, "Starting vsock-to-ip transparent proxy");
let mut listener = VsockListener::bind(listen_addr)
.context("Failed to bind listener to vsock: incorrect CID:port")?;
@@ -33,7 +34,7 @@ pub async fn proxy(listen_addr: VsockAddr) -> Result<()> {
while let Ok((inbound, _)) = listener.accept().await {
let transfer = transfer(inbound).map(|r| {
if let Err(e) = r {
- println!("Failed to transfer data: error={:?}", e);
+ error!(error = ?e, "Connection transfer failed");
}
});
@@ -72,7 +73,7 @@ async fn transfer(mut inbound: VsockStream) -> Result<()> {
);
*/
- println!("Proxying to: {:?}", proxy_addr);
+ info!(proxy_addr = ?proxy_addr, "Connecting to IP endpoint");
let mut outbound = TcpStream::connect(proxy_addr)
.await
@@ -86,7 +87,7 @@ async fn transfer(mut inbound: VsockStream) -> Result<()> {
.await
.context("error in vsock to ip copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("vsock to ip IO copy done, from {:?} to {:?}", inbound_addr, proxy_addr);
+ info!(from = %inbound_addr, to = ?proxy_addr, direction = "vsock->ip", "Data transfer completed");
wo.shutdown().await
};
@@ -96,7 +97,7 @@ async fn transfer(mut inbound: VsockStream) -> Result<()> {
.await
.context("error in ip to vsock copy")
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
- println!("ip to vsock IO copy done, from {:?} to {:?}", proxy_addr, inbound_addr);
+ info!(from = ?proxy_addr, to = %inbound_addr, direction = "ip->vsock", "Data transfer completed");
wi.shutdown().await
};
@@ -112,6 +113,13 @@ async fn transfer(mut inbound: VsockStream) -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
+ tracing_subscriber::fmt()
+ .with_env_filter(
+ tracing_subscriber::EnvFilter::try_from_default_env()
+ .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info"))
+ )
+ .init();
+
let cli = Cli::parse();
let vsock_addr = utils::split_vsock(&cli.vsock_addr)?;
proxy(vsock_addr).await?;