Skip to content

Commit 5304ba4

Browse files
authored
Merge pull request #214 from dfinity/igor/adapt-new-ic-bn-lib
Adapt to `ic-bn-lib` changes, update crates
2 parents 7e81932 + cef7de1 commit 5304ba4

36 files changed

Lines changed: 439 additions & 644 deletions

Cargo.lock

Lines changed: 281 additions & 357 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ http = "1.3.1"
3535
http-body = "1.0.1"
3636
http-body-util = "0.1.2"
3737
humantime = "2.2.0"
38-
ic-bn-lib = { version = "0.2.4", features = [
39-
"acme",
40-
"vector",
38+
ic-bn-lib = { version = "0.4", features = [
4139
"cert-providers",
40+
"lb",
4241
"clients-hyper",
42+
"custom-domains",
43+
"vector",
4344
] }
44-
ic-bn-lib-common = "0.2.4"
45-
ic-custom-domains-backend = "0.2.6"
46-
ic-custom-domains-base = "0.2.6"
4745
ic-http-certification = { version = "3.1.0", optional = true }
4846
ic-transport-types = "0.47"
4947
ic-http-gateway-protocol = { package = "ic-http-gateway-protocol", git = "https://github.com/dfinity/ic-http-gateway-protocol", tag = "v0.5.1" }

benches/domain_lookup.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ use std::sync::Arc;
22

33
use criterion::{Criterion, criterion_group, criterion_main};
44
use fqdn::fqdn;
5-
use ic_bn_lib_common::{principal, types::CustomDomain};
6-
use prometheus::Registry;
7-
use rand::{Rng, seq::SliceRandom, thread_rng};
8-
5+
use ic_bn_lib::{custom_domains::CustomDomain, principal};
96
use ic_gateway::{
107
routing::domain::{CustomDomainStorage, ResolvesDomain},
118
test::FakeDomainProvider,
129
};
10+
use prometheus::Registry;
11+
use rand::{Rng, seq::SliceRandom, thread_rng};
1312

1413
fn criterion_benchmark(c: &mut Criterion) {
1514
let mut rng = thread_rng();

benches/http_gateway.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ use http::{
1515
};
1616
use http_body_util::BodyExt;
1717
use ic_bn_lib::{
18-
http::body::buffer_body,
18+
http::{body::buffer_body, server::conn::ConnInfo},
1919
hval,
2020
ic_agent::{
2121
Agent, AgentError,
2222
agent::{HttpService, route_provider::RoundRobinRouteProvider},
2323
},
24+
principal,
2425
uuid::Uuid,
2526
};
26-
use ic_bn_lib_common::{principal, types::http::ConnInfo};
2727
use ic_http_certification::HttpRequest;
2828
use ic_http_gateway_protocol::{CanisterRequest, HttpGatewayClientBuilder};
2929

benches/router.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ use std::{sync::Arc, time::Duration};
33
use axum::{body::Body, extract::Request};
44
use criterion::{Criterion, criterion_group, criterion_main};
55
use http::Uri;
6-
use ic_bn_lib::tasks::TaskManager;
7-
use ic_bn_lib_common::types::http::ConnInfo;
8-
use rand::{seq::SliceRandom, thread_rng};
9-
6+
use ic_bn_lib::{http::server::conn::ConnInfo, tasks::TaskManager};
107
use ic_gateway::test::setup_test_router;
8+
use rand::{seq::SliceRandom, thread_rng};
119
use tower::Service;
1210

1311
fn create_request(domain: &str, path: &str) -> Request {

src/api.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ use axum::{
99
};
1010
use derive_new::new;
1111
use http::{Method, StatusCode, header::AUTHORIZATION};
12-
use ic_bn_lib::http::middleware::waf::{self, WafLayer};
13-
use ic_bn_lib_common::traits::Healthy;
12+
use ic_bn_lib::{
13+
health::Healthy,
14+
http::middleware::waf::{self, WafLayer},
15+
};
1416
use tokio_util::sync::CancellationToken;
1517
use tracing::Level;
1618
use tracing_subscriber::{EnvFilter, Registry, reload::Handle};
@@ -123,7 +125,7 @@ mod test {
123125
use axum::body::Body;
124126
use clap::Parser;
125127
use http::{HeaderValue, Request, Uri};
126-
use ic_bn_lib::{hval, utils::health_manager::HealthManager};
128+
use ic_bn_lib::{health::HealthManager, hval};
127129
use tower::ServiceExt;
128130
use tracing_subscriber::reload;
129131

src/cli.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33

44
use std::{net::SocketAddr, path::PathBuf, time::Duration};
55

6-
use ::http::HeaderValue;
76
use clap::{Args, Parser};
87
use fqdn::FQDN;
9-
use http::Uri;
8+
use http::{HeaderValue, Uri};
109
use humantime::parse_duration;
1110
#[cfg(feature = "smtp")]
1211
use ic_bn_lib::smtp::cli::SmtpServerCli;
1312
#[cfg(feature = "acme")]
14-
use ic_bn_lib::tls::acme::dns::cloudflare::DEFAULT_CLOUDFLARE_URL;
15-
#[cfg(feature = "acme")]
16-
use ic_bn_lib_common::types::acme::{AcmeUrl, Challenge, DnsBackend};
17-
use ic_bn_lib_common::{
18-
parse_size, parse_size_decimal, parse_size_usize,
19-
types::{
20-
dns::DnsCli,
21-
http::{HttpClientCli, HttpServerCli, ProxyProtocolMode, WafCli},
13+
use ic_bn_lib::tls::acme::{
14+
AcmeUrl, Challenge, DnsBackend, dns::cloudflare::DEFAULT_CLOUDFLARE_URL,
15+
};
16+
use ic_bn_lib::{
17+
custom_domains::base::cli::CustomDomainsCli,
18+
dns::cli::DnsCli,
19+
http::{
20+
client::cli::HttpClientCli,
21+
middleware::waf::WafCli,
22+
server::{ProxyProtocolMode, cli::HttpServerCli},
2223
shed::{ShedShardedCli, ShedSystemCli},
23-
vector::VectorCli,
2424
},
25+
parse_size, parse_size_decimal, parse_size_usize,
26+
vector::cli::VectorCli,
2527
};
2628
use reqwest::Url;
2729

@@ -66,7 +68,7 @@ pub struct Cli {
6668
pub domain: Domain,
6769

6870
#[command(flatten, next_help_heading = "Custom Domains")]
69-
pub custom_domains: Option<ic_custom_domains_base::cli::CustomDomainsCli>,
71+
pub custom_domains: Option<CustomDomainsCli>,
7072

7173
#[command(flatten, next_help_heading = "Policy")]
7274
pub policy: Policy,
@@ -117,7 +119,7 @@ pub struct Cli {
117119

118120
#[cfg(all(target_os = "linux", feature = "sev-snp"))]
119121
#[command(flatten, next_help_heading = "SEV-SNP")]
120-
pub sev_snp: ic_bn_lib_common::types::utils::SevSnpCli,
122+
pub sev_snp: ic_bn_lib::sev_snp::SevSnpCli,
121123
}
122124

123125
#[derive(Args)]

src/core.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ use std::{
66
use anyhow::{Context, Error, anyhow};
77
use axum::Router;
88
use ic_bn_lib::{
9-
custom_domains::{self},
10-
http::{self as bnhttp, dns::ApiBnResolver, middleware::waf::WafLayer, redirect_to_https},
9+
MAINNET_ROOT_SUBNET_ID,
10+
custom_domains::{self, ProvidesCustomDomains, base::cli::CustomDomainsCli},
11+
dns::{
12+
Options as DnsOptions,
13+
resolvers::{ApiBnResolver, Resolver},
14+
},
15+
health::HealthManager,
16+
http::{
17+
self as bnhttp,
18+
client::ClientOptions,
19+
middleware::waf::WafLayer,
20+
redirect_to_https,
21+
server::{ServerOptions, metrics::Metrics},
22+
},
1123
tasks::TaskManager,
12-
tls::{prepare_client_config, verify::NoopServerCertVerifier},
13-
utils::health_manager::HealthManager,
24+
tls::{ProvidesCertificates, prepare_client_config, verify::NoopServerCertVerifier},
1425
vector::{self, VectorOptions, client::Vector},
1526
};
16-
use ic_bn_lib_common::{
17-
traits::{custom_domains::ProvidesCustomDomains, tls::ProvidesCertificates},
18-
types::{
19-
dns::Options as DnsOptions,
20-
http::{ClientOptions, Metrics, ServerOptions},
21-
},
22-
};
2327
use itertools::Itertools;
2428
use prometheus::Registry;
2529
use tokio_util::sync::CancellationToken;
@@ -33,7 +37,7 @@ use crate::{
3337
self,
3438
domain::CustomDomainStorage,
3539
ic::{
36-
MAINNET_ROOT_SUBNET_ID, create_agent,
40+
create_agent,
3741
http_service::AgentHttpService,
3842
route_provider::{RouteProviderWrapper, setup_route_provider},
3943
routing_table_manager::RoutingTableManager,
@@ -103,7 +107,7 @@ pub async fn main(
103107
// DNS resolver
104108
let dns_options: DnsOptions = (&cli.dns).into();
105109
let dns_resolver =
106-
bnhttp::dns::Resolver::new(dns_options.clone()).context("unable to create DNS Resolver")?;
110+
Resolver::new(dns_options.clone()).context("unable to create DNS Resolver")?;
107111

108112
// HTTP client
109113
let mut http_client_opts: ClientOptions = (&cli.http_client).into();
@@ -446,7 +450,7 @@ pub async fn main(
446450
}
447451

448452
async fn setup_custom_domains(
449-
cli: &ic_custom_domains_base::cli::CustomDomainsCli,
453+
cli: &CustomDomainsCli,
450454
dns_options: DnsOptions,
451455
metrics_registry: &Registry,
452456
tasks: &mut TaskManager,
@@ -455,7 +459,7 @@ async fn setup_custom_domains(
455459
rate_limiter_bypass_token: Option<String>,
456460
) -> Result<Router, Error> {
457461
let token = tasks.token();
458-
let (workers, router, client) = ic_custom_domains_backend::setup(
462+
let (workers, router, client) = custom_domains::backend::setup(
459463
cli,
460464
dns_options,
461465
token,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod test;
1919
mod tls;
2020

2121
pub use crate::cli::Cli;
22-
pub use ic_bn_lib::ic_bn_lib_common::traits::custom_domains::ProvidesCustomDomains;
22+
pub use ic_bn_lib::custom_domains::ProvidesCustomDomains;
2323

2424
pub use core::main;
2525
pub use routing::setup_router;

src/metrics/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ use http::header::{CONTENT_TYPE, ORIGIN, REFERER, USER_AGENT};
1717
use ic_bn_lib::{
1818
http::{
1919
body::CountingBody, cache::CacheStatus, calc_headers_size, extract_host, http_method,
20-
http_version,
20+
http_version, server::conn::ConnInfo,
2121
},
2222
ic_agent::agent::route_provider::RouteProvider,
23+
network::TlsInfo,
2324
tasks::TaskManager,
2425
vector::client::Vector,
2526
};
26-
use ic_bn_lib_common::types::http::{ConnInfo, TlsInfo};
2727
use prometheus::{
2828
HistogramVec, IntCounterVec, Registry, register_histogram_vec_with_registry,
2929
register_int_counter_vec_with_registry,

0 commit comments

Comments
 (0)