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
8 changes: 8 additions & 0 deletions crates/defguard_core/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::net::IpAddr;

use clap::{Args, Parser, Subcommand};
use humantime::Duration;
use ipnetwork::IpNetwork;
Expand Down Expand Up @@ -160,6 +162,12 @@ pub struct DefGuardConfig {
#[arg(long, env = "DEFGUARD_CHECK_RENEWAL_WINDOW", default_value = "1h")]
#[serde(skip_serializing)]
pub check_period_renewal_window: Duration,

#[arg(long, env = "DEFGUARD_HTTP_BIND_ADDRESS")]
pub http_bind_address: Option<IpAddr>,

#[arg(long, env = "DEFGUARD_GRPC_BIND_ADDRESS")]
pub grpc_bind_address: Option<IpAddr>,
}

#[derive(Clone, Debug, Subcommand)]
Expand Down
3 changes: 1 addition & 2 deletions crates/defguard_core/src/enterprise/ldap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,7 @@ impl LDAPConnection {
.map(|name| name.to_string())
.ok_or_else(|| {
LdapError::ObjectNotFound(format!(
"Couldn't extract a group name from searchentry {:?}.",
entry
"Couldn't extract a group name from searchentry {entry:?}."
))
})
}
Expand Down
4 changes: 2 additions & 2 deletions crates/defguard_core/src/enterprise/ldap/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl super::LDAPConnection {
.get(username_attr)
.and_then(|v| v.first())
.ok_or_else(|| {
LdapError::ObjectNotFound(format!("No {} attribute found", username_attr))
LdapError::ObjectNotFound(format!("No {username_attr} attribute found"))
})?;

match User::from_searchentry(&entry, username, None) {
Expand Down Expand Up @@ -800,7 +800,7 @@ mod tests {
Some("test_password"),
"last name",
"first name",
format!("{}@example.com", username).as_str(),
format!("{username}@example.com").as_str(),
None,
)
}
Expand Down
7 changes: 6 additions & 1 deletion crates/defguard_core/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,12 @@ pub async fn run_grpc_server(
.await;

// Run gRPC server
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), server_config().grpc_port);
let addr = SocketAddr::new(
server_config()
.grpc_bind_address
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
server_config().grpc_port,
);
debug!("Starting gRPC services");
let builder = if let (Some(cert), Some(key)) = (grpc_cert, grpc_key) {
let identity = Identity::from_pem(cert, key);
Expand Down
7 changes: 6 additions & 1 deletion crates/defguard_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,12 @@ pub async fn run_web_server(
event_tx,
);
info!("Started web services");
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), server_config().http_port);
let addr = SocketAddr::new(
server_config()
.http_bind_address
.unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)),
server_config().http_port,
);
let listener = TcpListener::bind(&addr).await?;
serve(
listener,
Expand Down
Loading