Skip to content

Commit 81c40bd

Browse files
committed
fix: wip
1 parent b64f698 commit 81c40bd

File tree

6 files changed

+67
-14
lines changed

6 files changed

+67
-14
lines changed

.idea/sqldialects.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tracing = "0.1"
2121
tracing-subscriber = "0.2"
2222
tracing-futures = { version = "0.2.4", features = ["futures-03"]}
2323
sqlx = { version = "0.4.1", default-features = false, features = [ "runtime-tokio-rustls", "macros", "migrate"] }
24-
tokio = { version = "0.2", features = ["dns", "tcp", "udp"] }
24+
tokio = { version = "0.2", features = ["dns", "tcp", "udp", "signal"] }
2525
uuid = { version = "0.8", features = ["v4"] }
2626
simplelog = "0.8"
2727
bcrypt = "0.9"

src/acme.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ impl Persist for DatabasePersist {
7373
.await?;
7474

7575
transaction.commit().await
76-
};
76+
}
77+
.in_current_span();
7778

78-
self.handle.block_on(fut.in_current_span()).map_err(error)
79+
self.handle.block_on(fut).map_err(error)
7980
}
8081

8182
#[tracing::instrument(name = "DatabasePersist::get", err, skip(self))]

src/dns/authority.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use trust_dns_server::authority::{
1414
ZoneType,
1515
};
1616
use trust_dns_server::proto::rr::dnssec::SupportedAlgorithms;
17-
use trust_dns_server::proto::rr::rdata::TXT;
17+
use trust_dns_server::proto::rr::rdata::{SOA, TXT};
1818
use trust_dns_server::proto::rr::record_data::RData;
1919
use trust_dns_server::proto::rr::{Record, RecordSet, RecordType};
2020

@@ -197,6 +197,11 @@ impl AuthorityObject for DatabaseAuthority {
197197
span.record("name", &display(&name));
198198
span.record("query_type", &display(&query_type));
199199

200+
// not sure if this handling makes sense
201+
if query_type == RecordType::SOA {
202+
return span.in_scope(|| self.soa());
203+
}
204+
200205
BoxedLookupFuture::from(
201206
async move {
202207
info!("Starting lookup");
@@ -237,6 +242,41 @@ impl AuthorityObject for DatabaseAuthority {
237242
)
238243
}
239244

245+
// fix handling of this as this always take self.origin
246+
// also admin is always same serial numbers need to match
247+
fn soa(&self) -> BoxedLookupFuture {
248+
let origin: Name = self.origin().into();
249+
let supported_algorithms = self.0.supported_algorithms;
250+
BoxedLookupFuture::from(
251+
async move {
252+
let soa = SOA::new(
253+
origin.clone(),
254+
origin.clone(),
255+
1,
256+
28800,
257+
7200,
258+
604800,
259+
86400,
260+
);
261+
let record = Record::from_rdata(origin, 100, RData::SOA(soa));
262+
let record_set = RecordSet::from(record);
263+
let records =
264+
LookupRecords::new(false, supported_algorithms, Arc::from(record_set));
265+
let records = Box::new(records) as Box<dyn LookupObject>;
266+
Ok(records)
267+
}
268+
.in_current_span(),
269+
)
270+
}
271+
272+
fn soa_secure(
273+
&self,
274+
_is_secure: bool,
275+
_supported_algorithms: SupportedAlgorithms,
276+
) -> BoxedLookupFuture {
277+
self.soa()
278+
}
279+
240280
fn get_nsec_records(
241281
&self,
242282
_name: &LowerName,

src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use sqlx::PgPool;
66
use std::env;
77
use std::str::FromStr;
88
use tokio::runtime::Runtime;
9+
use tokio::signal::ctrl_c;
910
use tracing::{debug, error, info, Instrument};
1011

1112
use crate::acme::DatabasePersist;
@@ -64,9 +65,16 @@ fn run() -> Result<()> {
6465
CertManager::new(pool, persist, config.general.acme).and_then(CertManager::spawn);
6566

6667
info!("Starting API Cert Manager and DNS");
67-
tokio::try_join!(api, cert_manager, dns.spawn())?;
68-
69-
Ok(())
68+
tokio::select! {
69+
res = api => res,
70+
res = cert_manager => res,
71+
res = dns.spawn() => res,
72+
res = ctrl_c() => {
73+
res?;
74+
info!("Ctrl C pressed");
75+
Ok(())
76+
}
77+
}
7078
}
7179
.in_current_span(),
7280
);

0 commit comments

Comments
 (0)