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
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
test:
runs-on:
- codebuild-defguard-proxy-runner-${{ github.run_id }}-${{ github.run_attempt }}
container: rust:1
container: public.ecr.aws/docker/library/rust:1

steps:
- name: Debug
Expand All @@ -47,6 +47,8 @@ jobs:
rustup component add clippy
cargo clippy --all-targets --all-features -- -D warnings
- name: Run cargo deny
uses: EmbarkStudios/cargo-deny-action@v2
run: |
cargo install cargo-deny
cargo deny check
- name: Run tests
run: cargo test --locked --no-fail-fast
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = "https://github.com/DefGuard/proxy"
repository = "https://github.com/DefGuard/proxy"

[dependencies]
defguard_version = { git = "https://github.com/DefGuard/defguard.git", rev = "f61ce40927a4d21095ea53a691219d5ae46e3e4e" }
defguard_version = { git = "https://github.com/DefGuard/defguard.git", rev = "a5709e7117103458ad8417d4437a8a369ca5bbce" }
# base `axum` deps
axum = { version = "0.7", features = ["macros", "tracing", "ws"] }
axum-client-ip = "0.6"
Expand Down
6 changes: 4 additions & 2 deletions src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tokio_stream::wrappers::UnboundedReceiverStream;
use tonic::{Request, Response, Status, Streaming};
use tracing::Instrument;

use defguard_version::{version_info_from_metadata, DefguardComponent};
use defguard_version::{get_tracing_variables, parse_metadata, DefguardComponent};

use crate::{
error::ApiError,
Expand Down Expand Up @@ -100,9 +100,11 @@ impl proxy_server::Proxy for ProxyServer {
error!("Failed to determine client address for request: {request:?}");
return Err(Status::internal("Failed to determine client address"));
};
let (version, info) = version_info_from_metadata(request.metadata());
let maybe_info = parse_metadata(request.metadata());
let (version, info) = get_tracing_variables(&maybe_info);
let span = tracing::info_span!("core_bidi_stream", component = %DefguardComponent::Core, version, info);
let _guard = span.enter();

info!("Defguard Core gRPC client connected from: {address}");

let (tx, rx) = mpsc::unbounded_channel();
Expand Down
18 changes: 15 additions & 3 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ use axum::{
};
use axum_extra::extract::cookie::Key;
use clap::crate_version;
use defguard_version::{server::DefguardVersionLayer, Version};
use defguard_version::{
server::{DefguardVersionInterceptor, DefguardVersionLayer},
DefguardComponent, Version,
};
use serde::Serialize;
use tokio::{net::TcpListener, sync::oneshot, task::JoinSet};
use tonic::transport::{Identity, Server, ServerTlsConfig};
Expand All @@ -36,7 +39,7 @@ use crate::{
grpc::ProxyServer,
handlers::{desktop_client_mfa, enrollment, password_reset, polling},
proto::proxy_server,
VERSION,
MIN_CORE_VERSION, VERSION,
};

pub(crate) static ENROLLMENT_COOKIE_NAME: &str = "defguard_proxy";
Expand Down Expand Up @@ -169,8 +172,17 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
} else {
Server::builder()
};
let own_version = Version::parse(VERSION)?;
let versioned_service = ServiceBuilder::new()
.layer(DefguardVersionLayer::new(Version::parse(VERSION)?))
.layer(tonic::service::InterceptorLayer::new(
DefguardVersionInterceptor::new(
own_version.clone(),
DefguardComponent::Core,
MIN_CORE_VERSION,
false,
),
))
.layer(DefguardVersionLayer::new(own_version))
.service(proxy_server::ProxyServer::new(grpc_server));
builder
.add_service(versioned_service)
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use defguard_version::Version;

pub mod assets;
pub mod config;
mod enterprise;
Expand All @@ -14,4 +16,5 @@ pub(crate) mod proto {
#[macro_use]
extern crate tracing;

pub static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "-", env!("VERGEN_GIT_SHA"));
pub static VERSION: &str = concat!(env!("CARGO_PKG_VERSION"), "+", env!("VERGEN_GIT_SHA"));
pub const MIN_CORE_VERSION: Version = Version::new(1, 5, 0);