Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ jobs:
repository: zentinelproxy/zentinel-agent-rust-sdk
path: zentinel-agent-rust-sdk

- name: Check that the tag matches Cargo.toml
working-directory: agent
run: |
tag="${{ inputs.version }}"
[ -n "$tag" ] || tag="${GITHUB_REF#refs/tags/v}"
crate=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
if [ "$tag" != "$crate" ]; then
echo "::error::Releasing $tag, but Cargo.toml says $crate. Bump Cargo.toml first."
exit 1
fi

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zentinel-agent-transform"
version = "0.2.0"
version = "0.5.0"
edition = "2021"
authors = ["Raskell <hello@raskell.io>"]
description = "Request and response transformation agent for Zentinel proxy"
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,22 @@ rules:
zentinel-transform-agent [OPTIONS]

Options:
-s, --socket <PATH> Unix socket path [default: /tmp/zentinel-transform.sock]
-c, --config <FILE> Configuration file (YAML or JSON)
-t, --template-dir <DIR> Template directory
-l, --log-level <LEVEL> Log level: trace, debug, info, warn, error [default: info]
--json-logs Output logs in JSON format
-h, --help Print help
-V, --version Print version
-c, --config <FILE> Configuration file (YAML or JSON)
--template-dir <DIR> Template directory [default: /etc/zentinel/templates]
-s, --socket <PATH> Listen on this Unix socket (UDS) [env: TRANSFORM_SOCKET]
--grpc-address <ADDR> Listen for gRPC on this address [env: TRANSFORM_GRPC_ADDRESS]
--json-logs Output logs as JSON
--log-level <LEVEL> Log level: trace, debug, info, warn, error [default: info]
--example-config Print an example configuration and exit
--validate Validate the configuration and exit
-h, --help Print help
-V, --version Print version
```

`--socket` and `--grpc-address` are mutually exclusive. With neither, the agent
listens for gRPC on `0.0.0.0:50051`. For gRPC, point Zentinel at it with
`grpc "http://127.0.0.1:50051"` instead of `unix-socket`.

## Debug Mode

Enable debug headers to see transformation info:
Expand Down
28 changes: 26 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use clap::Parser;
use std::path::PathBuf;
use tracing::info;
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use zentinel_agent_protocol::v2::GrpcAgentServerV2;
use zentinel_agent_protocol::v2::{GrpcAgentServerV2, UdsAgentServerV2};
use zentinel_agent_transform::{TransformAgent, TransformConfig};

#[derive(Parser, Debug)]
Expand All @@ -26,8 +26,13 @@ struct Args {
#[arg(long, default_value = "/etc/zentinel/templates")]
template_dir: PathBuf,

/// Unix socket path to listen on. If provided, uses UDS transport
/// instead of gRPC.
#[arg(short, long, env = "TRANSFORM_SOCKET", conflicts_with = "grpc_address")]
socket: Option<PathBuf>,

/// gRPC address to listen on (e.g., "0.0.0.0:50051").
/// Defaults to "0.0.0.0:50051" if not specified.
/// Defaults to "0.0.0.0:50051" if neither this nor --socket is given.
#[arg(long, env = "TRANSFORM_GRPC_ADDRESS")]
grpc_address: Option<String>,

Expand Down Expand Up @@ -157,6 +162,25 @@ async fn main() -> Result<()> {

info!("Transform agent initialized");

if let Some(socket) = args.socket {
info!(
config = ?args.config,
socket = %socket.display(),
"Starting Zentinel Transform Agent (UDS v2)"
);

let server = UdsAgentServerV2::new("transform", socket, Box::new(agent));

info!("Transform agent ready and listening on UDS");

server
.run()
.await
.context("Failed to run Transform Agent UDS server")?;

return Ok(());
}

// Determine gRPC address
let grpc_addr = args
.grpc_address
Expand Down
Loading