Skip to content

Commit 74003b4

Browse files
authored
Merge pull request #13 from TheBlueMatt/2025-09-b64url
Correct DoH base64 alphabet to base64url not base64
2 parents 66daf4f + dc044a8 commit 74003b4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/http_resolver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ impl Default for HTTPHrnResolver {
5151
}
5252
}
5353

54+
/// The "URL and Filename safe" Base64 Alphabet from RFC 4648
5455
const B64_CHAR: [u8; 64] = [
5556
b'A', b'B', b'C', b'D', b'E', b'F', b'G', b'H', b'I', b'J', b'K', b'L', b'M', b'N', b'O', b'P',
5657
b'Q', b'R', b'S', b'T', b'U', b'V', b'W', b'X', b'Y', b'Z', b'a', b'b', b'c', b'd', b'e', b'f',
5758
b'g', b'h', b'i', b'j', b'k', b'l', b'm', b'n', b'o', b'p', b'q', b'r', b's', b't', b'u', b'v',
58-
b'w', b'x', b'y', b'z', b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'+', b'/',
59+
b'w', b'x', b'y', b'z', b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'-', b'_',
5960
];
6061

6162
#[rustfmt::skip]

src/onion_message_resolver.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ fn channel() -> (ChannelSend, ChannelRecv) {
8585
/// This implements LDK's [`DNSResolverMessageHandler`], which it uses to send onion messages and
8686
/// process response messages.
8787
///
88+
/// Note that because this implementation does not assume an async runtime, queries which are not
89+
/// responded to *may hang forever*. You must always wrap resolution futures to ensure they time
90+
/// out properly, eg via `tokio::time::timeout`.
91+
///
8892
/// Note that after a query begines, [`PeerManager::process_events`] should be called to ensure the
8993
/// query message goes out in a timely manner. You can call [`Self::register_post_queue_action`] to
9094
/// have this happen automatically.
@@ -343,13 +347,19 @@ mod tests {
343347
let peer_manager =
344348
Arc::new(PeerManager::new(handlers, 0, &rand, &TestLogger, Arc::clone(&signer)));
345349

346-
// Connect to a static LDK node which we know will do DNS resolutions for us.
350+
// Maintain a connection to a static LDK node which we know will do DNS resolutions for us.
347351
let their_id_hex = "03db10aa09ff04d3568b0621750794063df401e6853c79a21a83e1a3f3b5bfb0c8";
348352
let their_id = PublicKey::from_slice(&Vec::<u8>::from_hex(their_id_hex).unwrap()).unwrap();
349353
let addr = "ldk-ln-node.bitcoin.ninja:9735".to_socket_addrs().unwrap().next().unwrap();
350-
let _ = lightning_net_tokio::connect_outbound(Arc::clone(&peer_manager), their_id, addr)
351-
.await
352-
.unwrap();
354+
let connect_pm = Arc::clone(&peer_manager);
355+
tokio::spawn(async move {
356+
loop {
357+
lightning_net_tokio::connect_outbound(Arc::clone(&connect_pm), their_id, addr)
358+
.await
359+
.unwrap()
360+
.await;
361+
}
362+
});
353363

354364
let pm_reference = Arc::clone(&peer_manager);
355365
tokio::spawn(async move {

0 commit comments

Comments
 (0)