mirror of
https://github.com/n0-computer/iroh.git
synced 2026-11-30 16:03:05 +00:00
deploy: 45479d38299615a68a863b48acd5db19d797b7cd
This commit is contained in:
@@ -21,9 +21,9 @@ and testing.</p>
|
||||
</div><span id="structfield.mainline" class="structfield section-header"><a href="#structfield.mainline" class="anchor field">§</a><code>mainline: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.MainlineConfig.html" title="struct iroh_dns_server::config::MainlineConfig">MainlineConfig</a>></code></span><div class="docblock"><p>Config for the mainline lookup.</p>
|
||||
</div><span id="structfield.zone_store" class="structfield section-header"><a href="#structfield.zone_store" class="anchor field">§</a><code>zone_store: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="struct.StoreConfig.html" title="struct iroh_dns_server::config::StoreConfig">StoreConfig</a>></code></span><div class="docblock"><p>Config for the zone store.</p>
|
||||
</div><span id="structfield.pkarr_put_rate_limit" class="structfield section-header"><a href="#structfield.pkarr_put_rate_limit" class="anchor field">§</a><code>pkarr_put_rate_limit: <a class="enum" href="../http/enum.RateLimitConfig.html" title="enum iroh_dns_server::http::RateLimitConfig">RateLimitConfig</a></code></span><div class="docblock"><p>Config for pkarr rate limit</p>
|
||||
</div><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#156-212">Source</a><a href="#impl-Config" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.load" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#158-168">Source</a><h4 class="code-header">pub async fn <a href="#method.load" class="fn">load</a>(path: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>) -> <a class="type" href="https://docs.rs/anyhow/1.0.98/anyhow/type.Result.html" title="type anyhow::Result">Result</a><<a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a>></h4></section></summary><div class="docblock"><p>Load the config from a file.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.data_dir" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#171-181">Source</a><h4 class="code-header">pub fn <a href="#method.data_dir" class="fn">data_dir</a>() -> <a class="type" href="https://docs.rs/anyhow/1.0.98/anyhow/type.Result.html" title="type anyhow::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>></h4></section></summary><div class="docblock"><p>Get the data directory.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.signed_packet_store_path" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#184-186">Source</a><h4 class="code-header">pub fn <a href="#method.signed_packet_store_path" class="fn">signed_packet_store_path</a>() -> <a class="type" href="https://docs.rs/anyhow/1.0.98/anyhow/type.Result.html" title="type anyhow::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>></h4></section></summary><div class="docblock"><p>Get the path to the store database file.</p>
|
||||
</div><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#156-212">Source</a><a href="#impl-Config" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.load" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#158-168">Source</a><h4 class="code-header">pub async fn <a href="#method.load" class="fn">load</a>(path: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>) -> Result<<a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a>></h4></section></summary><div class="docblock"><p>Load the config from a file.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.data_dir" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#171-181">Source</a><h4 class="code-header">pub fn <a href="#method.data_dir" class="fn">data_dir</a>() -> Result<<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>></h4></section></summary><div class="docblock"><p>Get the data directory.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.signed_packet_store_path" class="method"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#184-186">Source</a><h4 class="code-header">pub fn <a href="#method.signed_packet_store_path" class="fn">signed_packet_store_path</a>() -> Result<<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>></h4></section></summary><div class="docblock"><p>Get the path to the store database file.</p>
|
||||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#impl-Debug-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Default-for-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#214-248">Source</a><a href="#impl-Default-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#215-247">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deserialize%3C'de%3E-for-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#impl-Deserialize%3C'de%3E-for-Config" class="anchor">§</a><h3 class="code-header">impl<'de> <a class="trait" href="https://docs.rs/serde/1.0.219/serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'de> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.deserialize" class="method trait-impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#method.deserialize" class="anchor">§</a><h4 class="code-header">fn <a href="https://docs.rs/serde/1.0.219/serde/de/trait.Deserialize.html#tymethod.deserialize" class="fn">deserialize</a><__D>(__deserializer: __D) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, __D::<a class="associatedtype" href="https://docs.rs/serde/1.0.219/serde/de/trait.Deserializer.html#associatedtype.Error" title="type serde::de::Deserializer::Error">Error</a>><div class="where">where
|
||||
__D: <a class="trait" href="https://docs.rs/serde/1.0.219/serde/de/trait.Deserializer.html" title="trait serde::de::Deserializer">Deserializer</a><'de>,</div></h4></section></summary><div class='docblock'>Deserialize this value from the given Serde deserializer. <a href="https://docs.rs/serde/1.0.219/serde/de/trait.Deserialize.html#tymethod.deserialize">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Serialize-for-Config" class="impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#impl-Serialize-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.serialize" class="method trait-impl"><a class="src rightside" href="../../src/iroh_dns_server/config.rs.html#28">Source</a><a href="#method.serialize" class="anchor">§</a><h4 class="code-header">fn <a href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serialize.html#tymethod.serialize" class="fn">serialize</a><__S>(&self, __serializer: __S) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><__S::<a class="associatedtype" href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serializer.html#associatedtype.Ok" title="type serde::ser::Serializer::Ok">Ok</a>, __S::<a class="associatedtype" href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serializer.html#associatedtype.Error" title="type serde::ser::Serializer::Error">Error</a>><div class="where">where
|
||||
__S: <a class="trait" href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serializer.html" title="trait serde::ser::Serializer">Serializer</a>,</div></h4></section></summary><div class='docblock'>Serialize this value into the given Serde serializer. <a href="https://docs.rs/serde/1.0.219/serde/ser/trait.Serialize.html#tymethod.serialize">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Config" class="impl"><a href="#impl-Freeze-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section><section id="impl-RefUnwindSafe-for-Config" class="impl"><a href="#impl-RefUnwindSafe-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section><section id="impl-Send-for-Config" class="impl"><a href="#impl-Send-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section><section id="impl-Sync-for-Config" class="impl"><a href="#impl-Sync-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section><section id="impl-Unpin-for-Config" class="impl"><a href="#impl-Unpin-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section><section id="impl-UnwindSafe-for-Config" class="impl"><a href="#impl-UnwindSafe-for-Config" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Implementation of a DNS name server for iroh node announces"><title>iroh_dns_server::dns - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module dns</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>dns</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/dns.rs.html#1-276">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementation of a DNS name server for iroh node announces</p>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Implementation of a DNS name server for iroh node announces"><title>iroh_dns_server::dns - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module dns</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>dns</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/dns.rs.html#1-287">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementation of a DNS name server for iroh node announces</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.DnsConfig.html" title="struct iroh_dns_server::dns::DnsConfig">DnsConfig</a></div><div class="desc docblock-short">DNS server settings</div></li><li><div class="item-name"><a class="struct" href="struct.DnsHandler.html" title="struct iroh_dns_server::dns::DnsHandler">DnsHandler</a></div><div class="desc docblock-short">State for serving DNS</div></li><li><div class="item-name"><a class="struct" href="struct.DnsServer.html" title="struct iroh_dns_server::dns::DnsServer">DnsServer</a></div><div class="desc docblock-short">A DNS server that serves pkarr signed packets.</div></li><li><div class="item-name"><a class="struct" href="struct.Handle.html" title="struct iroh_dns_server::dns::Handle">Handle</a></div><div class="desc docblock-short">A handle to the channel over which the response to a DNS request will be sent</div></li></ul></section></div></main></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="HTTP server part of iroh-dns-server"><title>iroh_dns_server::http - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module http</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>http</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/http.rs.html#1-260">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>HTTP server part of iroh-dns-server</p>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="HTTP server part of iroh-dns-server"><title>iroh_dns_server::http - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module http</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>http</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/http.rs.html#1-269">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>HTTP server part of iroh-dns-server</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.HttpConfig.html" title="struct iroh_dns_server::http::HttpConfig">Http<wbr>Config</a></div><div class="desc docblock-short">Config for the HTTP server</div></li><li><div class="item-name"><a class="struct" href="struct.HttpServer.html" title="struct iroh_dns_server::http::HttpServer">Http<wbr>Server</a></div><div class="desc docblock-short">The HTTP(S) server part of iroh-dns-server</div></li><li><div class="item-name"><a class="struct" href="struct.HttpsConfig.html" title="struct iroh_dns_server::http::HttpsConfig">Https<wbr>Config</a></div><div class="desc docblock-short">Config for the HTTPS server</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.CertMode.html" title="enum iroh_dns_server::http::CertMode">Cert<wbr>Mode</a></div><div class="desc docblock-short">The mode how SSL certificates should be created.</div></li><li><div class="item-name"><a class="enum" href="enum.RateLimitConfig.html" title="enum iroh_dns_server::http::RateLimitConfig">Rate<wbr>Limit<wbr>Config</a></div><div class="desc docblock-short">Config for http server rate limit.</div></li></ul></section></div></main></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,2 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A DNS server and pkarr relay"><title>iroh_dns_server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_dns_server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_dns_server/lib.rs.html#1-269">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A DNS server and pkarr relay</p>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A DNS server and pkarr relay"><title>iroh_dns_server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>iroh_dns_server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/iroh_dns_server/lib.rs.html#1-280">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A DNS server and pkarr relay</p>
|
||||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="config/index.html" title="mod iroh_dns_server::config">config</a></div><div class="desc docblock-short">Configuration for the server</div></li><li><div class="item-name"><a class="mod" href="dns/index.html" title="mod iroh_dns_server::dns">dns</a></div><div class="desc docblock-short">Implementation of a DNS name server for iroh node announces</div></li><li><div class="item-name"><a class="mod" href="http/index.html" title="mod iroh_dns_server::http">http</a></div><div class="desc docblock-short">HTTP server part of iroh-dns-server</div></li><li><div class="item-name"><a class="mod" href="metrics/index.html" title="mod iroh_dns_server::metrics">metrics</a></div><div class="desc docblock-short">Metrics support for the server</div></li><li><div class="item-name"><a class="mod" href="server/index.html" title="mod iroh_dns_server::server">server</a></div><div class="desc docblock-short">The main server which combines the DNS and HTTP(S) servers.</div></li><li><div class="item-name"><a class="mod" href="state/index.html" title="mod iroh_dns_server::state">state</a></div><div class="desc docblock-short">Shared state and store for the iroh-dns-server</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.ZoneStore.html" title="struct iroh_dns_server::ZoneStore">Zone<wbr>Store</a></div><div class="desc docblock-short">A store for pkarr signed packets.</div></li></ul></section></div></main></body></html>
|
||||
@@ -1,2 +1,2 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Spawn the server and run until the `Ctrl-C` signal is received, then shutdown."><title>run_with_config_until_ctrl_c in iroh_dns_server::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>dns_<wbr>server::<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a>::<wbr><a href="index.html">server</a></span><h1>Function <span class="fn">run_with_config_until_ctrl_c</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/server.rs.html#16-31">Source</a> </span></div><pre class="rust item-decl"><code>pub async fn run_with_config_until_ctrl_c(config: <a class="struct" href="../config/struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a>) -> <a class="type" href="https://docs.rs/anyhow/1.0.98/anyhow/type.Result.html" title="type anyhow::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawn the server and run until the <code>Ctrl-C</code> signal is received, then shutdown.</p>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Spawn the server and run until the `Ctrl-C` signal is received, then shutdown."><title>run_with_config_until_ctrl_c in iroh_dns_server::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In iroh_<wbr>dns_<wbr>server::<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a>::<wbr><a href="index.html">server</a></span><h1>Function <span class="fn">run_with_config_until_ctrl_c</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/server.rs.html#16-31">Source</a> </span></div><pre class="rust item-decl"><code>pub async fn run_with_config_until_ctrl_c(config: <a class="struct" href="../config/struct.Config.html" title="struct iroh_dns_server::config::Config">Config</a>) -> TestResult<<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Spawn the server and run until the <code>Ctrl-C</code> signal is received, then shutdown.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
@@ -1,2 +1,2 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The main server which combines the DNS and HTTP(S) servers."><title>iroh_dns_server::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module server</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/server.rs.html#1-136">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The main server which combines the DNS and HTTP(S) servers.</p>
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The main server which combines the DNS and HTTP(S) servers."><title>iroh_dns_server::server - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-dbdb5eec.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="iroh_dns_server" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (d10a6823f 2024-11-29)" data-channel="nightly" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../iroh_dns_server/index.html">iroh_<wbr>dns_<wbr>server</a><span class="version">0.34.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module server</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate iroh_<wbr>dns_<wbr>server</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">iroh_dns_server</a></span><h1>Module <span>server</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/iroh_dns_server/server.rs.html#1-138">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The main server which combines the DNS and HTTP(S) servers.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Server.html" title="struct iroh_dns_server::server::Server">Server</a></div><div class="desc docblock-short">The iroh-dns server.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.run_with_config_until_ctrl_c.html" title="fn iroh_dns_server::server::run_with_config_until_ctrl_c">run_<wbr>with_<wbr>config_<wbr>until_<wbr>ctrl_<wbr>c</a></div><div class="desc docblock-short">Spawn the server and run until the <code>Ctrl-C</code> signal is received, then shutdown.</div></li></ul></section></div></main></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -255,7 +255,7 @@
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::{anyhow, Context, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>tracing::info;
|
||||
|
||||
@@ -411,7 +411,7 @@
|
||||
<span class="kw">let </span>s = tokio::fs::read_to_string(path.as_ref())
|
||||
.<span class="kw">await
|
||||
</span>.with_context(|| <span class="macro">format!</span>(<span class="string">"failed to read {}"</span>, path.as_ref().to_string_lossy()))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config: Config = toml::from_str(<span class="kw-2">&</span>s)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config: Config = toml::from_str(<span class="kw-2">&</span>s).context(<span class="string">"toml decode"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(config)
|
||||
}
|
||||
|
||||
@@ -420,9 +420,9 @@
|
||||
<span class="kw">let </span>dir = <span class="kw">if let </span><span class="prelude-val">Some</span>(val) = env::var_os(<span class="string">"IROH_DNS_DATA_DIR"</span>) {
|
||||
PathBuf::from(val)
|
||||
} <span class="kw">else </span>{
|
||||
<span class="kw">let </span>path = dirs_next::data_dir().ok_or_else(|| {
|
||||
<span class="macro">anyhow!</span>(<span class="string">"operating environment provides no directory for application data"</span>)
|
||||
})<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>path = dirs_next::data_dir()
|
||||
.context(<span class="string">"operating environment provides no directory for application data"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
path.join(<span class="string">"iroh-dns"</span>)
|
||||
};
|
||||
<span class="prelude-val">Ok</span>(dir)
|
||||
|
||||
@@ -274,7 +274,18 @@
|
||||
<a href="#273" id="273">273</a>
|
||||
<a href="#274" id="274">274</a>
|
||||
<a href="#275" id="275">275</a>
|
||||
<a href="#276" id="276">276</a></pre></div><pre class="rust"><code><span class="doccomment">//! Implementation of a DNS name server for iroh node announces
|
||||
<a href="#276" id="276">276</a>
|
||||
<a href="#277" id="277">277</a>
|
||||
<a href="#278" id="278">278</a>
|
||||
<a href="#279" id="279">279</a>
|
||||
<a href="#280" id="280">280</a>
|
||||
<a href="#281" id="281">281</a>
|
||||
<a href="#282" id="282">282</a>
|
||||
<a href="#283" id="283">283</a>
|
||||
<a href="#284" id="284">284</a>
|
||||
<a href="#285" id="285">285</a>
|
||||
<a href="#286" id="286">286</a>
|
||||
<a href="#287" id="287">287</a></pre></div><pre class="rust"><code><span class="doccomment">//! Implementation of a DNS name server for iroh node announces
|
||||
|
||||
</span><span class="kw">use </span>std::{
|
||||
collections::BTreeMap,
|
||||
@@ -284,7 +295,6 @@
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::{anyhow, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>async_trait::async_trait;
|
||||
<span class="kw">use </span>bytes::Bytes;
|
||||
<span class="kw">use </span>hickory_server::{
|
||||
@@ -303,6 +313,7 @@
|
||||
store::in_memory::InMemoryAuthority,
|
||||
};
|
||||
<span class="kw">use </span>iroh_metrics::inc;
|
||||
<span class="kw">use </span>n0_snafu::{format_err, TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>tokio::{
|
||||
net::{TcpListener, UdpSocket},
|
||||
@@ -359,12 +370,15 @@
|
||||
config.port,
|
||||
);
|
||||
|
||||
<span class="kw">let </span>socket = UdpSocket::bind(bind_addr).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>socket = UdpSocket::bind(bind_addr).<span class="kw">await</span>.context(<span class="string">"UDP bind"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>socket_addr = socket.local_addr()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>socket_addr = socket.local_addr().context(<span class="string">"local address"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
server.register_socket(socket);
|
||||
server.register_listener(TcpListener::bind(bind_addr).<span class="kw">await</span><span class="question-mark">?</span>, TCP_TIMEOUT);
|
||||
server.register_listener(
|
||||
TcpListener::bind(bind_addr).<span class="kw">await</span>.context(<span class="string">"TCP bind"</span>)<span class="question-mark">?</span>,
|
||||
TCP_TIMEOUT,
|
||||
);
|
||||
<span class="macro">info!</span>(<span class="string">"DNS server listening on {}"</span>, bind_addr);
|
||||
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
|
||||
@@ -380,7 +394,10 @@
|
||||
|
||||
<span class="doccomment">/// Shutdown the server an wait for all tasks to complete.
|
||||
</span><span class="kw">pub async fn </span>shutdown(<span class="kw-2">mut </span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="self">self</span>.server.shutdown_gracefully().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="self">self</span>.server
|
||||
.shutdown_gracefully()
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"graceful shutdown"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
|
||||
@@ -388,7 +405,10 @@
|
||||
///
|
||||
/// Runs forever unless tasks fail.
|
||||
</span><span class="kw">pub async fn </span>run_until_done(<span class="kw-2">mut </span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="self">self</span>.server.block_until_done().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="self">self</span>.server
|
||||
.block_until_done()
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"block until done"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
}
|
||||
@@ -408,7 +428,8 @@
|
||||
.origins
|
||||
.iter()
|
||||
.map(Name::from_utf8)
|
||||
.collect::<<span class="prelude-ty">Result</span><Vec<<span class="kw">_</span>>, <span class="kw">_</span>>>()<span class="question-mark">?</span>;
|
||||
.collect::<<span class="prelude-ty">Result</span><Vec<<span class="kw">_</span>>, <span class="kw">_</span>>>()
|
||||
.context(<span class="string">"origin names"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>(static_authority, serial) = create_static_authority(<span class="kw-2">&</span>origins, config)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>authority = Arc::new(NodeAuthority::new(
|
||||
@@ -433,7 +454,7 @@
|
||||
<span class="kw">let </span>(tx, <span class="kw-2">mut </span>rx) = broadcast::channel(<span class="number">1</span>);
|
||||
<span class="kw">let </span>response_handle = Handle(tx);
|
||||
<span class="self">self</span>.handle_request(<span class="kw-2">&</span>request, response_handle).<span class="kw">await</span>;
|
||||
<span class="prelude-val">Ok</span>(rx.recv().<span class="kw">await</span><span class="question-mark">?</span>)
|
||||
rx.recv().<span class="kw">await</span>.context(<span class="string">"recv"</span>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,9 +524,10 @@
|
||||
RecordType::SOA,
|
||||
config.default_soa.split_ascii_whitespace(),
|
||||
<span class="prelude-val">None</span>,
|
||||
)<span class="question-mark">?
|
||||
)
|
||||
.context(<span class="string">"rdata"</span>)<span class="question-mark">?
|
||||
</span>.into_soa()
|
||||
.map_err(|<span class="kw">_</span>| <span class="macro">anyhow!</span>(<span class="string">"Couldn't parse SOA: {}"</span>, config.default_soa))<span class="question-mark">?</span>;
|
||||
.map_err(|<span class="kw">_</span>| <span class="macro">format_err!</span>(<span class="string">"Couldn't parse SOA: {}"</span>, config.default_soa))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>serial = soa.serial();
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>records = BTreeMap::new();
|
||||
<span class="kw">for </span>name <span class="kw">in </span>origins {
|
||||
@@ -529,7 +551,7 @@
|
||||
);
|
||||
}
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(ns) = <span class="kw-2">&</span>config.rr_ns {
|
||||
<span class="kw">let </span>ns = Name::parse(ns, <span class="prelude-val">Some</span>(<span class="kw-2">&</span>Name::root()))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>ns = Name::parse(ns, <span class="prelude-val">Some</span>(<span class="kw-2">&</span>Name::root())).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
push_record(
|
||||
<span class="kw-2">&mut </span>records,
|
||||
serial,
|
||||
@@ -539,7 +561,7 @@
|
||||
}
|
||||
|
||||
<span class="kw">let </span>static_authority = InMemoryAuthority::new(Name::root(), records, ZoneType::Primary, <span class="bool-val">false</span>)
|
||||
.map_err(|e| <span class="macro">anyhow!</span>(e))<span class="question-mark">?</span>;
|
||||
.map_err(|e| <span class="macro">format_err!</span>(<span class="string">"new authority: {}"</span>, e))<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>((static_authority, serial))
|
||||
}
|
||||
|
||||
@@ -204,9 +204,11 @@
|
||||
<a href="#203" id="203">203</a>
|
||||
<a href="#204" id="204">204</a>
|
||||
<a href="#205" id="205">205</a>
|
||||
<a href="#206" id="206">206</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{fmt, sync::Arc};
|
||||
<a href="#206" id="206">206</a>
|
||||
<a href="#207" id="207">207</a>
|
||||
<a href="#208" id="208">208</a>
|
||||
<a href="#209" id="209">209</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{fmt, sync::Arc};
|
||||
|
||||
<span class="kw">use </span>anyhow::{bail, ensure, Context, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>async_trait::async_trait;
|
||||
<span class="kw">use </span>hickory_server::{
|
||||
authority::{
|
||||
@@ -220,6 +222,8 @@
|
||||
server::RequestInfo,
|
||||
store::in_memory::InMemoryAuthority,
|
||||
};
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>snafu::whatever;
|
||||
<span class="kw">use </span>tracing::{debug, trace};
|
||||
|
||||
<span class="kw">use crate</span>::{
|
||||
@@ -246,7 +250,9 @@
|
||||
origins: Vec<Name>,
|
||||
serial: u32,
|
||||
) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="macro">ensure!</span>(!origins.is_empty(), <span class="string">"at least one origin is required"</span>);
|
||||
<span class="kw">if </span>origins.is_empty() {
|
||||
<span class="macro">whatever!</span>(<span class="string">"at least one origin is required"</span>);
|
||||
}
|
||||
<span class="kw">let </span>first_origin = LowerName::from(<span class="kw-2">&</span>origins[<span class="number">0</span>]);
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
|
||||
static_authority,
|
||||
@@ -387,19 +393,19 @@
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="kw">if </span>name.num_labels() < origin.num_labels() + <span class="number">1 </span>{
|
||||
<span class="macro">bail!</span>(<span class="string">"not a valid pkarr name: missing pubkey"</span>);
|
||||
<span class="macro">whatever!</span>(<span class="string">"not a valid pkarr name: missing pubkey"</span>);
|
||||
}
|
||||
<span class="macro">trace!</span>(<span class="string">"parse {origin}"</span>);
|
||||
<span class="kw">let </span>labels = name.iter().rev();
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>labels_without_origin = labels.skip(origin.num_labels() <span class="kw">as </span>usize);
|
||||
<span class="kw">let </span>pkey_label = labels_without_origin.next().expect(<span class="string">"length checked above"</span>);
|
||||
<span class="kw">let </span>pkey_str = std::str::from_utf8(pkey_label)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>pkey_str = std::str::from_utf8(pkey_label).context(<span class="string">"utf8"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>pkey =
|
||||
PublicKeyBytes::from_z32(pkey_str).context(<span class="string">"not a valid pkarr name: invalid pubkey"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>remaining_name = Name::from_labels(labels_without_origin.rev())<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>remaining_name = Name::from_labels(labels_without_origin.rev()).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>((remaining_name, pkey, origin.clone()));
|
||||
}
|
||||
<span class="macro">bail!</span>(<span class="string">"name does not match any allowed origin"</span>);
|
||||
<span class="macro">whatever!</span>(<span class="string">"name does not match any allowed origin"</span>);
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>err_refused(e: <span class="kw">impl </span>fmt::Debug) -> LookupError {
|
||||
|
||||
@@ -258,14 +258,22 @@
|
||||
<a href="#257" id="257">257</a>
|
||||
<a href="#258" id="258">258</a>
|
||||
<a href="#259" id="259">259</a>
|
||||
<a href="#260" id="260">260</a></pre></div><pre class="rust"><code><span class="doccomment">//! HTTP server part of iroh-dns-server
|
||||
<a href="#260" id="260">260</a>
|
||||
<a href="#261" id="261">261</a>
|
||||
<a href="#262" id="262">262</a>
|
||||
<a href="#263" id="263">263</a>
|
||||
<a href="#264" id="264">264</a>
|
||||
<a href="#265" id="265">265</a>
|
||||
<a href="#266" id="266">266</a>
|
||||
<a href="#267" id="267">267</a>
|
||||
<a href="#268" id="268">268</a>
|
||||
<a href="#269" id="269">269</a></pre></div><pre class="rust"><code><span class="doccomment">//! HTTP server part of iroh-dns-server
|
||||
|
||||
</span><span class="kw">use </span>std::{
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::{bail, Context, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>axum::{
|
||||
extract::{ConnectInfo, Request},
|
||||
handler::Handler,
|
||||
@@ -276,7 +284,9 @@
|
||||
Router,
|
||||
};
|
||||
<span class="kw">use </span>iroh_metrics::{inc, inc_by};
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>snafu::whatever;
|
||||
<span class="kw">use </span>tokio::{net::TcpListener, task::JoinSet};
|
||||
<span class="kw">use </span>tower_http::{
|
||||
cors::{<span class="self">self</span>, CorsLayer},
|
||||
@@ -335,7 +345,7 @@
|
||||
state: AppState,
|
||||
) -> <span class="prelude-ty">Result</span><HttpServer> {
|
||||
<span class="kw">if </span>http_config.is_none() && https_config.is_none() {
|
||||
<span class="macro">bail!</span>(<span class="string">"Either http or https config is required"</span>);
|
||||
<span class="macro">whatever!</span>(<span class="string">"Either http or https config is required"</span>);
|
||||
}
|
||||
|
||||
<span class="kw">let </span>app = create_app(state, <span class="kw-2">&</span>rate_limit_config);
|
||||
@@ -349,8 +359,12 @@
|
||||
config.port,
|
||||
);
|
||||
<span class="kw">let </span>app = app.clone();
|
||||
<span class="kw">let </span>listener = TcpListener::bind(bind_addr).<span class="kw">await</span><span class="question-mark">?</span>.into_std()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bound_addr = listener.local_addr()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>listener = TcpListener::bind(bind_addr)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"TCP bind"</span>)<span class="question-mark">?
|
||||
</span>.into_std()
|
||||
.context(<span class="string">"into std"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bound_addr = listener.local_addr().context(<span class="string">"local addr"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>fut = axum_server::from_tcp(listener)
|
||||
.serve(app.into_make_service_with_connect_info::<SocketAddr>());
|
||||
<span class="macro">info!</span>(<span class="string">"HTTP server listening on {bind_addr}"</span>);
|
||||
@@ -385,8 +399,12 @@
|
||||
)
|
||||
.<span class="kw">await</span><span class="question-mark">?
|
||||
</span>};
|
||||
<span class="kw">let </span>listener = TcpListener::bind(bind_addr).<span class="kw">await</span><span class="question-mark">?</span>.into_std()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bound_addr = listener.local_addr()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>listener = TcpListener::bind(bind_addr)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"TCP bind"</span>)<span class="question-mark">?
|
||||
</span>.into_std()
|
||||
.context(<span class="string">"into std"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bound_addr = listener.local_addr().context(<span class="string">"local addr"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>fut = axum_server::from_tcp(listener)
|
||||
.acceptor(acceptor)
|
||||
.serve(app.into_make_service_with_connect_info::<SocketAddr>());
|
||||
@@ -426,18 +444,18 @@
|
||||
///
|
||||
/// Runs forever unless tasks fail.
|
||||
</span><span class="kw">pub async fn </span>run_until_done(<span class="kw-2">mut </span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>final_res: anyhow::Result<()> = <span class="prelude-val">Ok</span>(());
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>final_res: <span class="prelude-ty">Result</span><()> = <span class="prelude-val">Ok</span>(());
|
||||
<span class="kw">while let </span><span class="prelude-val">Some</span>(res) = <span class="self">self</span>.tasks.join_next().<span class="kw">await </span>{
|
||||
<span class="kw">match </span>res {
|
||||
<span class="prelude-val">Ok</span>(<span class="prelude-val">Ok</span>(())) => {}
|
||||
<span class="prelude-val">Err</span>(err) <span class="kw">if </span>err.is_cancelled() => {}
|
||||
<span class="prelude-val">Ok</span>(<span class="prelude-val">Err</span>(err)) => {
|
||||
<span class="macro">warn!</span>(<span class="question-mark">?</span>err, <span class="string">"task failed"</span>);
|
||||
final_res = <span class="prelude-val">Err</span>(anyhow::Error::from(err));
|
||||
final_res = <span class="prelude-val">Err</span>(err).context(<span class="string">"task"</span>);
|
||||
}
|
||||
<span class="prelude-val">Err</span>(err) => {
|
||||
<span class="macro">warn!</span>(<span class="question-mark">?</span>err, <span class="string">"task panicked"</span>);
|
||||
final_res = <span class="prelude-val">Err</span>(err.into());
|
||||
final_res = <span class="prelude-val">Err</span>(err).context(<span class="string">"join"</span>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,12 @@
|
||||
<a href="#75" id="75">75</a>
|
||||
<a href="#76" id="76">76</a>
|
||||
<a href="#77" id="77">77</a>
|
||||
<a href="#78" id="78">78</a>
|
||||
<a href="#79" id="79">79</a></pre></div><pre class="rust"><code><span class="doccomment">//! DNS over HTTPS
|
||||
<a href="#78" id="78">78</a></pre></div><pre class="rust"><code><span class="doccomment">//! DNS over HTTPS
|
||||
|
||||
</span><span class="comment">// This module is mostly copied from
|
||||
// https://github.com/fission-codes/fission-server/blob/main/fission-server/src/routes/doh.rs
|
||||
|
||||
</span><span class="kw">use </span>anyhow::anyhow;
|
||||
<span class="kw">use </span>axum::{
|
||||
</span><span class="kw">use </span>axum::{
|
||||
extract::State,
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
@@ -96,6 +94,7 @@
|
||||
header::{CACHE_CONTROL, CONTENT_TYPE},
|
||||
HeaderValue, StatusCode,
|
||||
};
|
||||
<span class="kw">use </span>n0_snafu::TestResultExt;
|
||||
|
||||
<span class="kw">use </span><span class="kw">super</span>::error::AppResult;
|
||||
<span class="kw">use </span><span class="kw">crate</span>::state::AppState;
|
||||
@@ -111,7 +110,7 @@
|
||||
DnsRequestQuery(request, accept_type): DnsRequestQuery,
|
||||
) -> AppResult<Response> {
|
||||
<span class="kw">let </span>message_bytes = state.dns_handler.answer_request(request).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>message = proto::op::Message::from_bytes(<span class="kw-2">&</span>message_bytes).map_err(|e| <span class="macro">anyhow!</span>(e))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>message = proto::op::Message::from_bytes(<span class="kw-2">&</span>message_bytes).context(<span class="string">"decode"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>min_ttl = message.answers().iter().map(|rec| rec.ttl()).min();
|
||||
|
||||
@@ -128,8 +127,7 @@
|
||||
.insert(CONTENT_TYPE, accept_type.to_header_value());
|
||||
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(min_ttl) = min_ttl {
|
||||
<span class="kw">let </span>maxage =
|
||||
HeaderValue::from_str(<span class="kw-2">&</span><span class="macro">format!</span>(<span class="string">"s-maxage={min_ttl}"</span>)).map_err(|e| <span class="macro">anyhow!</span>(e))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>maxage = HeaderValue::from_str(<span class="kw-2">&</span><span class="macro">format!</span>(<span class="string">"s-maxage={min_ttl}"</span>)).context(<span class="string">"header"</span>)<span class="question-mark">?</span>;
|
||||
response.headers_mut().insert(CACHE_CONTROL, maxage);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,14 +138,16 @@
|
||||
<a href="#137" id="137">137</a>
|
||||
<a href="#138" id="138">138</a>
|
||||
<a href="#139" id="139">139</a>
|
||||
<a href="#140" id="140">140</a></pre></div><pre class="rust"><code><span class="doccomment">//! DNS Response
|
||||
<a href="#140" id="140">140</a>
|
||||
<a href="#141" id="141">141</a></pre></div><pre class="rust"><code><span class="doccomment">//! DNS Response
|
||||
|
||||
</span><span class="comment">// This module is mostly copied from
|
||||
// https://github.com/fission-codes/fission-server/blob/394de877fad021260c69fdb1edd7bb4b2f98108c/fission-core/src/dns.rs
|
||||
|
||||
</span><span class="kw">use </span>anyhow::{ensure, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>hickory_server::proto;
|
||||
</span><span class="kw">use </span>hickory_server::proto;
|
||||
<span class="kw">use </span>n0_snafu::TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>;
|
||||
<span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>snafu::ensure_whatever;
|
||||
|
||||
<span class="attr">#[derive(Debug, Serialize, Deserialize)]
|
||||
</span><span class="doccomment">/// JSON representation of a DNS response
|
||||
@@ -187,17 +189,17 @@
|
||||
<span class="kw">impl </span>DnsResponse {
|
||||
<span class="doccomment">/// Create a new JSON response from a DNS message
|
||||
</span><span class="kw">pub fn </span>from_message(message: proto::op::Message) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="macro">ensure!</span>(
|
||||
<span class="macro">ensure_whatever!</span>(
|
||||
message.message_type() == proto::op::MessageType::Response,
|
||||
<span class="string">"Expected message type to be response"
|
||||
</span>);
|
||||
|
||||
<span class="macro">ensure!</span>(
|
||||
<span class="macro">ensure_whatever!</span>(
|
||||
message.query_count() == message.queries().len() <span class="kw">as </span>u16,
|
||||
<span class="string">"Query count mismatch"
|
||||
</span>);
|
||||
|
||||
<span class="macro">ensure!</span>(
|
||||
<span class="macro">ensure_whatever!</span>(
|
||||
message.answer_count() == message.answers().len() <span class="kw">as </span>u16,
|
||||
<span class="string">"Answer count mismatch"
|
||||
</span>);
|
||||
|
||||
@@ -150,8 +150,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>From<anyhow::Error> <span class="kw">for </span>AppError {
|
||||
<span class="kw">fn </span>from(value: anyhow::Error) -> <span class="self">Self </span>{
|
||||
<span class="kw">impl </span>From<n0_snafu::TestError> <span class="kw">for </span>AppError {
|
||||
<span class="kw">fn </span>from(value: n0_snafu::TestError) -> <span class="self">Self </span>{
|
||||
<span class="self">Self </span>{
|
||||
status: StatusCode::INTERNAL_SERVER_ERROR,
|
||||
detail: <span class="prelude-val">Some</span>(value.to_string()),
|
||||
|
||||
@@ -47,9 +47,7 @@
|
||||
<a href="#46" id="46">46</a>
|
||||
<a href="#47" id="47">47</a>
|
||||
<a href="#48" id="48">48</a>
|
||||
<a href="#49" id="49">49</a>
|
||||
<a href="#50" id="50">50</a></pre></div><pre class="rust"><code><span class="kw">use </span>anyhow::Result;
|
||||
<span class="kw">use </span>axum::{
|
||||
<a href="#49" id="49">49</a></pre></div><pre class="rust"><code><span class="kw">use </span>axum::{
|
||||
extract::{Path, State},
|
||||
response::IntoResponse,
|
||||
};
|
||||
|
||||
@@ -182,20 +182,25 @@
|
||||
<a href="#181" id="181">181</a>
|
||||
<a href="#182" id="182">182</a>
|
||||
<a href="#183" id="183">183</a>
|
||||
<a href="#184" id="184">184</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
|
||||
<a href="#184" id="184">184</a>
|
||||
<a href="#185" id="185">185</a>
|
||||
<a href="#186" id="186">186</a>
|
||||
<a href="#187" id="187">187</a>
|
||||
<a href="#188" id="188">188</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{
|
||||
borrow::Cow,
|
||||
io,
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, OnceLock},
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::{bail, Context, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>axum_server::{
|
||||
accept::Accept,
|
||||
tls_rustls::{RustlsAcceptor, RustlsConfig},
|
||||
};
|
||||
<span class="kw">use </span>n0_future::{future::Boxed <span class="kw">as </span>BoxFuture, FutureExt};
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>snafu::whatever;
|
||||
<span class="kw">use </span>tokio::io::{AsyncRead, AsyncWrite};
|
||||
<span class="kw">use </span>tokio_rustls_acme::{axum::AxumAcceptor, caches::DirCache, AcmeConfig};
|
||||
<span class="kw">use </span>tokio_stream::StreamExt;
|
||||
@@ -258,9 +263,11 @@
|
||||
|
||||
<span class="kw">impl </span>TlsAcceptor {
|
||||
<span class="kw">async fn </span>self_signed(domains: Vec<String>) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="kw">let </span>rcgen::CertifiedKey { cert, key_pair } = rcgen::generate_simple_self_signed(domains)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config =
|
||||
RustlsConfig::from_der(<span class="macro">vec!</span>[cert.der().to_vec()], key_pair.serialize_der()).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>rcgen::CertifiedKey { cert, key_pair } =
|
||||
rcgen::generate_simple_self_signed(domains).context(<span class="string">"generate self signed cert"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config = RustlsConfig::from_der(<span class="macro">vec!</span>[cert.der().to_vec()], key_pair.serialize_der())
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"rustls config"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>acceptor = RustlsAcceptor::new(config);
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self</span>::Manual(acceptor))
|
||||
}
|
||||
@@ -268,8 +275,9 @@
|
||||
<span class="kw">async fn </span>manual(domains: Vec<String>, dir: PathBuf) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="kw">let </span>config = rustls::ServerConfig::builder().with_no_client_auth();
|
||||
<span class="kw">if </span>domains.len() != <span class="number">1 </span>{
|
||||
<span class="macro">bail!</span>(<span class="string">"Multiple domains in manual mode are not supported"</span>);
|
||||
<span class="macro">whatever!</span>(<span class="string">"Multiple domains in manual mode are not supported"</span>);
|
||||
}
|
||||
|
||||
<span class="kw">let </span>keyname = escape_hostname(<span class="kw-2">&</span>domains[<span class="number">0</span>]);
|
||||
<span class="kw">let </span>cert_path = dir.join(<span class="macro">format!</span>(<span class="string">"{keyname}.crt"</span>));
|
||||
<span class="kw">let </span>key_path = dir.join(<span class="macro">format!</span>(<span class="string">"{keyname}.key"</span>));
|
||||
@@ -277,7 +285,7 @@
|
||||
<span class="kw">let </span>certs = load_certs(cert_path).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>secret_key = load_secret_key(key_path).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>config = config.with_single_cert(certs, secret_key)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config = config.with_single_cert(certs, secret_key).context(<span class="string">"cert"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>config = RustlsConfig::from_config(Arc::new(config));
|
||||
<span class="kw">let </span>acceptor = RustlsAcceptor::new(config);
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self</span>::Manual(acceptor))
|
||||
@@ -324,7 +332,7 @@
|
||||
</span>.context(<span class="string">"cannot open certificate file"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>reader = std::io::Cursor::new(certfile);
|
||||
<span class="kw">let </span>certs: <span class="prelude-ty">Result</span><Vec<<span class="kw">_</span>>, std::io::Error> = rustls_pemfile::certs(<span class="kw-2">&mut </span>reader).collect();
|
||||
<span class="kw">let </span>certs = certs<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>certs = certs.context(<span class="string">"read certs"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(certs)
|
||||
}
|
||||
@@ -353,7 +361,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="macro">bail!</span>(
|
||||
<span class="macro">whatever!</span>(
|
||||
<span class="string">"no keys found in {} (encrypted keys not supported)"</span>,
|
||||
filename.as_ref().display()
|
||||
);
|
||||
|
||||
@@ -267,7 +267,18 @@
|
||||
<a href="#266" id="266">266</a>
|
||||
<a href="#267" id="267">267</a>
|
||||
<a href="#268" id="268">268</a>
|
||||
<a href="#269" id="269">269</a></pre></div><pre class="rust"><code><span class="doccomment">//! A DNS server and pkarr relay
|
||||
<a href="#269" id="269">269</a>
|
||||
<a href="#270" id="270">270</a>
|
||||
<a href="#271" id="271">271</a>
|
||||
<a href="#272" id="272">272</a>
|
||||
<a href="#273" id="273">273</a>
|
||||
<a href="#274" id="274">274</a>
|
||||
<a href="#275" id="275">275</a>
|
||||
<a href="#276" id="276">276</a>
|
||||
<a href="#277" id="277">277</a>
|
||||
<a href="#278" id="278">278</a>
|
||||
<a href="#279" id="279">279</a>
|
||||
<a href="#280" id="280">280</a></pre></div><pre class="rust"><code><span class="doccomment">//! A DNS server and pkarr relay
|
||||
|
||||
</span><span class="attr">#![deny(missing_docs, rustdoc::broken_intra_doc_links)]
|
||||
|
||||
@@ -290,13 +301,12 @@
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::Result;
|
||||
<span class="kw">use </span>iroh::{
|
||||
discovery::pkarr::PkarrRelayClient, dns::DnsResolver, node_info::NodeInfo, RelayUrl,
|
||||
SecretKey,
|
||||
};
|
||||
<span class="kw">use </span>n0_snafu::{TestResult, TestResultExt};
|
||||
<span class="kw">use </span>pkarr::{SignedPacket, Timestamp};
|
||||
<span class="kw">use </span>testresult::TestResult;
|
||||
<span class="kw">use </span>tracing_test::traced_test;
|
||||
|
||||
<span class="kw">use crate</span>::{
|
||||
@@ -311,7 +321,7 @@
|
||||
|
||||
<span class="attr">#[tokio::test]
|
||||
#[traced_test]
|
||||
</span><span class="kw">async fn </span>pkarr_publish_dns_resolve() -> <span class="prelude-ty">Result</span><()> {
|
||||
</span><span class="kw">async fn </span>pkarr_publish_dns_resolve() -> TestResult {
|
||||
<span class="kw">let </span>(server, nameserver, http_url) = Server::spawn_for_tests().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>pkarr_relay_url = {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>url = http_url.clone();
|
||||
@@ -327,34 +337,34 @@
|
||||
dns::Name::new(<span class="string">""</span>).unwrap(),
|
||||
dns::CLASS::IN,
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::TXT(<span class="string">"hi0"</span>.try_into()<span class="question-mark">?</span>),
|
||||
dns::rdata::RData::TXT(<span class="string">"hi0"</span>.try_into().unwrap()),
|
||||
));
|
||||
<span class="comment">// record at level one
|
||||
</span>packet.answers.push(dns::ResourceRecord::new(
|
||||
dns::Name::new(<span class="string">"_hello"</span>).unwrap(),
|
||||
dns::CLASS::IN,
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::TXT(<span class="string">"hi1"</span>.try_into()<span class="question-mark">?</span>),
|
||||
dns::rdata::RData::TXT(<span class="string">"hi1"</span>.try_into().unwrap()),
|
||||
));
|
||||
<span class="comment">// record at level two
|
||||
</span>packet.answers.push(dns::ResourceRecord::new(
|
||||
dns::Name::new(<span class="string">"_hello.world"</span>).unwrap(),
|
||||
dns::CLASS::IN,
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::TXT(<span class="string">"hi2"</span>.try_into()<span class="question-mark">?</span>),
|
||||
dns::rdata::RData::TXT(<span class="string">"hi2"</span>.try_into().unwrap()),
|
||||
));
|
||||
<span class="comment">// multiple records for same name
|
||||
</span>packet.answers.push(dns::ResourceRecord::new(
|
||||
dns::Name::new(<span class="string">"multiple"</span>).unwrap(),
|
||||
dns::CLASS::IN,
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::TXT(<span class="string">"hi3"</span>.try_into()<span class="question-mark">?</span>),
|
||||
dns::rdata::RData::TXT(<span class="string">"hi3"</span>.try_into().unwrap()),
|
||||
));
|
||||
packet.answers.push(dns::ResourceRecord::new(
|
||||
dns::Name::new(<span class="string">"multiple"</span>).unwrap(),
|
||||
dns::CLASS::IN,
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::TXT(<span class="string">"hi4"</span>.try_into()<span class="question-mark">?</span>),
|
||||
dns::rdata::RData::TXT(<span class="string">"hi4"</span>.try_into().unwrap()),
|
||||
));
|
||||
<span class="comment">// record of type A
|
||||
</span>packet.answers.push(dns::ResourceRecord::new(
|
||||
@@ -370,50 +380,56 @@
|
||||
<span class="number">30</span>,
|
||||
dns::rdata::RData::AAAA(Ipv6Addr::LOCALHOST.into()),
|
||||
));
|
||||
SignedPacket::new(<span class="kw-2">&</span>keypair, <span class="kw-2">&</span>packet.answers, Timestamp::now())<span class="question-mark">?
|
||||
SignedPacket::new(<span class="kw-2">&</span>keypair, <span class="kw-2">&</span>packet.answers, Timestamp::now())
|
||||
.context(<span class="string">"signed packet"</span>)<span class="question-mark">?
|
||||
</span>};
|
||||
<span class="kw">let </span>pkarr_client = pkarr::Client::builder()
|
||||
.no_default_network()
|
||||
.relays(<span class="kw-2">&</span>[pkarr_relay_url])<span class="question-mark">?
|
||||
</span>.build()<span class="question-mark">?</span>;
|
||||
pkarr_client.publish(<span class="kw-2">&</span>signed_packet, <span class="prelude-val">None</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
.relays(<span class="kw-2">&</span>[pkarr_relay_url])
|
||||
.context(<span class="string">"relays"</span>)<span class="question-mark">?
|
||||
</span>.build()
|
||||
.context(<span class="string">"build pkarr client"</span>)<span class="question-mark">?</span>;
|
||||
pkarr_client
|
||||
.publish(<span class="kw-2">&</span>signed_packet, <span class="prelude-val">None</span>)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"publish pkarr"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">use </span>hickory_server::proto::rr::Name;
|
||||
<span class="kw">let </span>pubkey = signed_packet.public_key().to_z32();
|
||||
<span class="kw">let </span>resolver = test_resolver(nameserver);
|
||||
|
||||
<span class="comment">// resolve root record
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_txt(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.into_iter().map(|t| t.to_string()).collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[<span class="string">"hi0"</span>.to_string()]);
|
||||
|
||||
<span class="comment">// resolve level one record
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"_hello.{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"_hello.{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_txt(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.into_iter().map(|t| t.to_string()).collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[<span class="string">"hi1"</span>.to_string()]);
|
||||
|
||||
<span class="comment">// resolve level two record
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"_hello.world.{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"_hello.world.{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_txt(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.into_iter().map(|t| t.to_string()).collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[<span class="string">"hi2"</span>.to_string()]);
|
||||
|
||||
<span class="comment">// resolve multiple records for same name
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"multiple.{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"multiple.{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_txt(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.into_iter().map(|t| t.to_string()).collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[<span class="string">"hi3"</span>.to_string(), <span class="string">"hi4"</span>.to_string()]);
|
||||
|
||||
<span class="comment">// resolve A record
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_ipv4(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[Ipv4Addr::LOCALHOST]);
|
||||
|
||||
<span class="comment">// resolve AAAA record
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"foo.bar.baz.{pubkey}."</span>))<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>name = Name::from_utf8(<span class="macro">format!</span>(<span class="string">"foo.bar.baz.{pubkey}."</span>)).context(<span class="string">"name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>res = resolver.lookup_ipv6(name, DNS_TIMEOUT).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>records = res.collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="macro">assert_eq!</span>(records, <span class="macro">vec!</span>[Ipv6Addr::LOCALHOST]);
|
||||
@@ -424,7 +440,7 @@
|
||||
|
||||
<span class="attr">#[tokio::test]
|
||||
#[traced_test]
|
||||
</span><span class="kw">async fn </span>integration_smoke() -> <span class="prelude-ty">Result</span><()> {
|
||||
</span><span class="kw">async fn </span>integration_smoke() -> TestResult {
|
||||
<span class="kw">let </span>(server, nameserver, http_url) = Server::spawn_for_tests().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>pkarr_relay = {
|
||||
@@ -456,7 +472,7 @@
|
||||
|
||||
<span class="attr">#[tokio::test]
|
||||
#[traced_test]
|
||||
</span><span class="kw">async fn </span>store_eviction() -> TestResult<()> {
|
||||
</span><span class="kw">async fn </span>store_eviction() -> TestResult {
|
||||
<span class="kw">let </span>options = ZoneStoreOptions {
|
||||
eviction: Duration::from_millis(<span class="number">100</span>),
|
||||
eviction_interval: Duration::from_millis(<span class="number">100</span>),
|
||||
@@ -486,9 +502,11 @@
|
||||
|
||||
<span class="attr">#[tokio::test]
|
||||
#[traced_test]
|
||||
</span><span class="kw">async fn </span>integration_mainline() -> <span class="prelude-ty">Result</span><()> {
|
||||
</span><span class="kw">async fn </span>integration_mainline() -> TestResult {
|
||||
<span class="comment">// run a mainline testnet
|
||||
</span><span class="kw">let </span>testnet = pkarr::mainline::Testnet::new_async(<span class="number">5</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>testnet = pkarr::mainline::Testnet::new_async(<span class="number">5</span>)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"new testnet"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bootstrap = testnet.bootstrap.clone();
|
||||
|
||||
<span class="comment">// spawn our server with mainline support
|
||||
@@ -509,8 +527,12 @@
|
||||
</span><span class="kw">let </span>pkarr = pkarr::Client::builder()
|
||||
.no_default_network()
|
||||
.dht(|builder| builder.bootstrap(<span class="kw-2">&</span>testnet.bootstrap))
|
||||
.build()<span class="question-mark">?</span>;
|
||||
pkarr.publish(<span class="kw-2">&</span>signed_packet, <span class="prelude-val">None</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
.build()
|
||||
.context(<span class="string">"build pkarr client"</span>)<span class="question-mark">?</span>;
|
||||
pkarr
|
||||
.publish(<span class="kw-2">&</span>signed_packet, <span class="prelude-val">None</span>)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"publish"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// resolve via DNS from our server, which will lookup from our DHT
|
||||
</span><span class="kw">let </span>resolver = test_resolver(nameserver);
|
||||
@@ -527,7 +549,7 @@
|
||||
DnsResolver::with_nameserver(nameserver)
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>random_signed_packet() -> <span class="prelude-ty">Result</span><SignedPacket> {
|
||||
<span class="kw">fn </span>random_signed_packet() -> TestResult<SignedPacket> {
|
||||
<span class="kw">let </span>secret_key = SecretKey::generate(rand::thread_rng());
|
||||
<span class="kw">let </span>node_id = secret_key.public();
|
||||
<span class="kw">let </span>relay_url: RelayUrl = <span class="string">"https://relay.example."</span>.parse()<span class="question-mark">?</span>;
|
||||
|
||||
@@ -134,10 +134,12 @@
|
||||
<a href="#133" id="133">133</a>
|
||||
<a href="#134" id="134">134</a>
|
||||
<a href="#135" id="135">135</a>
|
||||
<a href="#136" id="136">136</a></pre></div><pre class="rust"><code><span class="doccomment">//! The main server which combines the DNS and HTTP(S) servers.
|
||||
<a href="#136" id="136">136</a>
|
||||
<a href="#137" id="137">137</a>
|
||||
<a href="#138" id="138">138</a></pre></div><pre class="rust"><code><span class="doccomment">//! The main server which combines the DNS and HTTP(S) servers.
|
||||
|
||||
</span><span class="kw">use </span>anyhow::Result;
|
||||
<span class="kw">use </span>iroh_metrics::metrics::start_metrics_server;
|
||||
</span><span class="kw">use </span>iroh_metrics::metrics::start_metrics_server;
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>tracing::info;
|
||||
|
||||
<span class="kw">use crate</span>::{
|
||||
@@ -160,7 +162,7 @@
|
||||
store = store.with_mainline_fallback(bootstrap);
|
||||
};
|
||||
<span class="kw">let </span>server = Server::spawn(config, store).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
tokio::signal::ctrl_c().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
tokio::signal::ctrl_c().<span class="kw">await</span>.context(<span class="string">"ctrl+c"</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">info!</span>(<span class="string">"shutdown"</span>);
|
||||
server.shutdown().<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
@@ -170,7 +172,7 @@
|
||||
</span><span class="kw">pub struct </span>Server {
|
||||
http_server: HttpServer,
|
||||
dns_server: DnsServer,
|
||||
metrics_task: tokio::task::JoinHandle<anyhow::Result<()>>,
|
||||
metrics_task: tokio::task::JoinHandle<<span class="prelude-ty">Result</span><()>>,
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>Server {
|
||||
@@ -188,7 +190,7 @@
|
||||
<span class="kw">let </span>metrics_addr = config.metrics_addr();
|
||||
<span class="kw">let </span>metrics_task = tokio::task::spawn(<span class="kw">async move </span>{
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(addr) = metrics_addr {
|
||||
start_metrics_server(addr).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
start_metrics_server(addr).<span class="kw">await</span>.context(<span class="string">"metrics server"</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
});
|
||||
@@ -266,7 +268,9 @@
|
||||
<span class="kw">let </span>server = <span class="self">Self</span>::spawn(config, store).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>dns_addr = server.dns_server.local_addr();
|
||||
<span class="kw">let </span>http_addr = server.http_server.http_addr().expect(<span class="string">"http is set"</span>);
|
||||
<span class="kw">let </span>http_url = <span class="macro">format!</span>(<span class="string">"http://{http_addr}"</span>).parse()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>http_url = <span class="macro">format!</span>(<span class="string">"http://{http_addr}"</span>)
|
||||
.parse::<url::Url>()
|
||||
.context(<span class="string">"url parse"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>((server, dns_addr, http_url))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,10 +266,10 @@
|
||||
|
||||
</span><span class="kw">use </span>std::{collections::BTreeMap, num::NonZeroUsize, path::Path, sync::Arc, time::Duration};
|
||||
|
||||
<span class="kw">use </span>anyhow::Result;
|
||||
<span class="kw">use </span>hickory_server::proto::rr::{Name, RecordSet, RecordType, RrKey};
|
||||
<span class="kw">use </span>iroh_metrics::inc;
|
||||
<span class="kw">use </span>lru::LruCache;
|
||||
<span class="kw">use </span>n0_snafu::TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>;
|
||||
<span class="kw">use </span>pkarr::{Client <span class="kw">as </span>PkarrClient, SignedPacket};
|
||||
<span class="kw">use </span>tokio::sync::Mutex;
|
||||
<span class="kw">use </span>tracing::{debug, trace};
|
||||
|
||||
@@ -457,10 +457,30 @@
|
||||
<a href="#456" id="456">456</a>
|
||||
<a href="#457" id="457">457</a>
|
||||
<a href="#458" id="458">458</a>
|
||||
<a href="#459" id="459">459</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{future::Future, path::Path, result, time::Duration};
|
||||
<a href="#459" id="459">459</a>
|
||||
<a href="#460" id="460">460</a>
|
||||
<a href="#461" id="461">461</a>
|
||||
<a href="#462" id="462">462</a>
|
||||
<a href="#463" id="463">463</a>
|
||||
<a href="#464" id="464">464</a>
|
||||
<a href="#465" id="465">465</a>
|
||||
<a href="#466" id="466">466</a>
|
||||
<a href="#467" id="467">467</a>
|
||||
<a href="#468" id="468">468</a>
|
||||
<a href="#469" id="469">469</a>
|
||||
<a href="#470" id="470">470</a>
|
||||
<a href="#471" id="471">471</a>
|
||||
<a href="#472" id="472">472</a>
|
||||
<a href="#473" id="473">473</a>
|
||||
<a href="#474" id="474">474</a>
|
||||
<a href="#475" id="475">475</a>
|
||||
<a href="#476" id="476">476</a>
|
||||
<a href="#477" id="477">477</a>
|
||||
<a href="#478" id="478">478</a>
|
||||
<a href="#479" id="479">479</a></pre></div><pre class="rust"><code><span class="kw">use </span>std::{future::Future, path::Path, result, time::Duration};
|
||||
|
||||
<span class="kw">use </span>anyhow::{Context, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>iroh_metrics::inc;
|
||||
<span class="kw">use </span>n0_snafu::{TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>pkarr::{SignedPacket, Timestamp};
|
||||
<span class="kw">use </span>redb::{
|
||||
backends::InMemoryBackend, Database, MultimapTableDefinition, ReadableTable, TableDefinition,
|
||||
@@ -562,7 +582,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">async fn </span>run0(<span class="kw-2">&mut </span><span class="self">self</span>) -> anyhow::Result<()> {
|
||||
<span class="kw">async fn </span>run0(<span class="kw-2">&mut </span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="kw">let </span>expiry_us = <span class="self">self</span>.options.eviction.as_micros() <span class="kw">as </span>u64;
|
||||
<span class="kw">while let </span><span class="prelude-val">Some</span>(msg) = <span class="self">self</span>.recv.recv().<span class="kw">await </span>{
|
||||
<span class="comment">// if we get a snapshot message here we don't need to do a write transaction
|
||||
@@ -575,8 +595,8 @@
|
||||
};
|
||||
<span class="macro">trace!</span>(<span class="string">"batch"</span>);
|
||||
<span class="self">self</span>.recv.push_back(msg).unwrap();
|
||||
<span class="kw">let </span>transaction = <span class="self">self</span>.db.begin_write()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>tables = Tables::new(<span class="kw-2">&</span>transaction)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>transaction = <span class="self">self</span>.db.begin_write().context(<span class="string">"tx begin"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>tables = Tables::new(<span class="kw-2">&</span>transaction).context(<span class="string">"new tables"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>timeout = tokio::time::sleep(<span class="self">self</span>.options.max_batch_time);
|
||||
<span class="kw">let </span>expired = Timestamp::now() - expiry_us;
|
||||
<span class="macro">tokio::pin!</span>(timeout);
|
||||
@@ -584,7 +604,7 @@
|
||||
<span class="macro">tokio::select!</span> {
|
||||
<span class="kw">_ </span>= <span class="self">self</span>.cancel.cancelled() => {
|
||||
drop(tables);
|
||||
transaction.commit()<span class="question-mark">?</span>;
|
||||
transaction.commit().context(<span class="string">"tx commit"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">return </span><span class="prelude-val">Ok</span>(());
|
||||
}
|
||||
<span class="kw">_ </span>= <span class="kw-2">&mut </span>timeout => <span class="kw">break</span>,
|
||||
@@ -592,7 +612,7 @@
|
||||
<span class="kw">match </span>msg {
|
||||
Message::Get { key, res } => {
|
||||
<span class="macro">trace!</span>(<span class="string">"get {}"</span>, key);
|
||||
<span class="kw">let </span>packet = get_packet(<span class="kw-2">&</span>tables.signed_packets, <span class="kw-2">&</span>key).context(<span class="string">"get packet failed"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>packet = get_packet(<span class="kw-2">&</span>tables.signed_packets, <span class="kw-2">&</span>key)<span class="question-mark">?</span>;
|
||||
res.send(packet).ok();
|
||||
}
|
||||
Message::Upsert { packet, res } => {
|
||||
@@ -604,15 +624,17 @@
|
||||
<span class="kw">continue</span>;
|
||||
} <span class="kw">else </span>{
|
||||
<span class="comment">// remove the packet from the update time index
|
||||
</span>tables.update_time.remove(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes())<span class="question-mark">?</span>;
|
||||
</span>tables.update_time.remove(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes()).context(<span class="string">"remove packet"</span>)<span class="question-mark">?</span>;
|
||||
<span class="bool-val">true
|
||||
</span>}
|
||||
} <span class="kw">else </span>{
|
||||
<span class="bool-val">false
|
||||
</span>};
|
||||
<span class="kw">let </span>value = packet.serialize();
|
||||
tables.signed_packets.insert(key.as_bytes(), <span class="kw-2">&</span>value[..])<span class="question-mark">?</span>;
|
||||
tables.update_time.insert(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes())<span class="question-mark">?</span>;
|
||||
tables.signed_packets
|
||||
.insert(key.as_bytes(), <span class="kw-2">&</span>value[..]).context(<span class="string">"insert packet"</span>)<span class="question-mark">?</span>;
|
||||
tables.update_time
|
||||
.insert(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes()).context(<span class="string">"insert timestamp"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">if </span>replaced {
|
||||
<span class="macro">inc!</span>(Metrics, store_packets_updated);
|
||||
} <span class="kw">else </span>{
|
||||
@@ -622,9 +644,9 @@
|
||||
}
|
||||
Message::Remove { key, res } => {
|
||||
<span class="macro">trace!</span>(<span class="string">"remove {}"</span>, key);
|
||||
<span class="kw">let </span>updated = <span class="kw">if let </span><span class="prelude-val">Some</span>(row) = tables.signed_packets.remove(key.as_bytes())<span class="question-mark">? </span>{
|
||||
<span class="kw">let </span>packet = SignedPacket::deserialize(row.value())<span class="question-mark">?</span>;
|
||||
tables.update_time.remove(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes())<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>updated = <span class="kw">if let </span><span class="prelude-val">Some</span>(row) = tables.signed_packets.remove(key.as_bytes()).context(<span class="string">"remove packet"</span>)<span class="question-mark">? </span>{
|
||||
<span class="kw">let </span>packet = SignedPacket::deserialize(row.value()).context(<span class="string">"deserialize packet"</span>)<span class="question-mark">?</span>;
|
||||
tables.update_time.remove(<span class="kw-2">&</span>packet.timestamp().to_bytes(), key.as_bytes()).context(<span class="string">"remove timestamp"</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">inc!</span>(Metrics, store_packets_removed);
|
||||
<span class="bool-val">true
|
||||
</span>} <span class="kw">else </span>{
|
||||
@@ -643,8 +665,8 @@
|
||||
<span class="macro">trace!</span>(<span class="string">"check expired {} at {}"</span>, key, u64::from_be_bytes(time));
|
||||
<span class="kw">if let </span><span class="prelude-val">Some</span>(packet) = get_packet(<span class="kw-2">&</span>tables.signed_packets, <span class="kw-2">&</span>key)<span class="question-mark">? </span>{
|
||||
<span class="kw">if </span>packet.timestamp() < expired {
|
||||
tables.update_time.remove(<span class="kw-2">&</span>time, key.as_bytes())<span class="question-mark">?</span>;
|
||||
<span class="kw">let _ </span>= tables.signed_packets.remove(key.as_bytes())<span class="question-mark">?</span>;
|
||||
tables.update_time.remove(<span class="kw-2">&</span>time, key.as_bytes()).context(<span class="string">"remove timestamp"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let _ </span>= tables.signed_packets.remove(key.as_bytes()).context(<span class="string">"remove packet"</span>)<span class="question-mark">?</span>;
|
||||
<span class="macro">inc!</span>(Metrics, store_packets_expired);
|
||||
}
|
||||
}
|
||||
@@ -654,7 +676,7 @@
|
||||
}
|
||||
}
|
||||
drop(tables);
|
||||
transaction.commit()<span class="question-mark">?</span>;
|
||||
transaction.commit().context(<span class="string">"tx commit"</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}
|
||||
@@ -684,10 +706,14 @@
|
||||
|
||||
<span class="kw">impl </span>Snapshot {
|
||||
<span class="kw">pub fn </span>new(db: <span class="kw-2">&</span>Database) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="kw">let </span>tx = db.begin_read()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>tx = db.begin_read().context(<span class="string">"tx begin"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self </span>{
|
||||
signed_packets: tx.open_table(SIGNED_PACKETS_TABLE)<span class="question-mark">?</span>,
|
||||
update_time: tx.open_multimap_table(UPDATE_TIME_TABLE)<span class="question-mark">?</span>,
|
||||
signed_packets: tx
|
||||
.open_table(SIGNED_PACKETS_TABLE)
|
||||
.context(<span class="string">"open table signed_packets"</span>)<span class="question-mark">?</span>,
|
||||
update_time: tx
|
||||
.open_multimap_table(UPDATE_TIME_TABLE)
|
||||
.context(<span class="string">"open table update_time"</span>)<span class="question-mark">?</span>,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -712,15 +738,17 @@
|
||||
|
||||
<span class="kw">pub fn </span>in_memory(options: Options) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="macro">info!</span>(<span class="string">"using in-memory packet database"</span>);
|
||||
<span class="kw">let </span>db = Database::builder().create_with_backend(InMemoryBackend::new())<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>db = Database::builder()
|
||||
.create_with_backend(InMemoryBackend::new())
|
||||
.context(<span class="string">"create db"</span>)<span class="question-mark">?</span>;
|
||||
<span class="self">Self</span>::open(db, options)
|
||||
}
|
||||
|
||||
<span class="kw">pub fn </span>open(db: Database, options: Options) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="comment">// create tables
|
||||
</span><span class="kw">let </span>write_tx = db.begin_write()<span class="question-mark">?</span>;
|
||||
<span class="kw">let _ </span>= Tables::new(<span class="kw-2">&</span>write_tx)<span class="question-mark">?</span>;
|
||||
write_tx.commit()<span class="question-mark">?</span>;
|
||||
</span><span class="kw">let </span>write_tx = db.begin_write().context(<span class="string">"tx begin"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let _ </span>= Tables::new(<span class="kw-2">&</span>write_tx).context(<span class="string">"tables new"</span>)<span class="question-mark">?</span>;
|
||||
write_tx.commit().context(<span class="string">"tx commit"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>(send, recv) = mpsc::channel(<span class="number">1024</span>);
|
||||
<span class="kw">let </span>send2 = send.clone();
|
||||
<span class="kw">let </span>cancel = CancellationToken::new();
|
||||
@@ -748,22 +776,29 @@
|
||||
|
||||
<span class="kw">pub async fn </span>upsert(<span class="kw-2">&</span><span class="self">self</span>, packet: SignedPacket) -> <span class="prelude-ty">Result</span><bool> {
|
||||
<span class="kw">let </span>(tx, rx) = oneshot::channel();
|
||||
<span class="self">self</span>.send.send(Message::Upsert { packet, res: tx }).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(rx.<span class="kw">await</span><span class="question-mark">?</span>)
|
||||
<span class="self">self</span>.send
|
||||
.send(Message::Upsert { packet, res: tx })
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"send"</span>)<span class="question-mark">?</span>;
|
||||
rx.<span class="kw">await</span>.context(<span class="string">"recv"</span>)
|
||||
}
|
||||
|
||||
<span class="kw">pub async fn </span>get(<span class="kw-2">&</span><span class="self">self</span>, key: <span class="kw-2">&</span>PublicKeyBytes) -> <span class="prelude-ty">Result</span><<span class="prelude-ty">Option</span><SignedPacket>> {
|
||||
<span class="kw">let </span>(tx, rx) = oneshot::channel();
|
||||
<span class="self">self</span>.send.send(Message::Get { key: <span class="kw-2">*</span>key, res: tx }).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(rx.<span class="kw">await</span><span class="question-mark">?</span>)
|
||||
<span class="self">self</span>.send
|
||||
.send(Message::Get { key: <span class="kw-2">*</span>key, res: tx })
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"send"</span>)<span class="question-mark">?</span>;
|
||||
rx.<span class="kw">await</span>.context(<span class="string">"recv"</span>)
|
||||
}
|
||||
|
||||
<span class="kw">pub async fn </span>remove(<span class="kw-2">&</span><span class="self">self</span>, key: <span class="kw-2">&</span>PublicKeyBytes) -> <span class="prelude-ty">Result</span><bool> {
|
||||
<span class="kw">let </span>(tx, rx) = oneshot::channel();
|
||||
<span class="self">self</span>.send
|
||||
.send(Message::Remove { key: <span class="kw-2">*</span>key, res: tx })
|
||||
.<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(rx.<span class="kw">await</span><span class="question-mark">?</span>)
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"send"</span>)<span class="question-mark">?</span>;
|
||||
rx.<span class="kw">await</span>.context(<span class="string">"recv"</span>)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,20 +828,23 @@
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Periodically check for expired packets and remove them.
|
||||
</span><span class="kw">async fn </span>evict_task_inner(send: mpsc::Sender<Message>, options: Options) -> anyhow::Result<()> {
|
||||
</span><span class="kw">async fn </span>evict_task_inner(send: mpsc::Sender<Message>, options: Options) -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="kw">let </span>expiry_us = options.eviction.as_micros() <span class="kw">as </span>u64;
|
||||
<span class="kw">loop </span>{
|
||||
<span class="kw">let </span>(tx, rx) = oneshot::channel();
|
||||
<span class="kw">let _ </span>= send.send(Message::Snapshot { res: tx }).<span class="kw">await</span>.ok();
|
||||
<span class="comment">// if we can't get the snapshot we exit the loop, main actor dead
|
||||
</span><span class="kw">let </span><span class="prelude-val">Ok</span>(snapshot) = rx.<span class="kw">await else </span>{
|
||||
<span class="macro">anyhow::bail!</span>(<span class="string">"failed to get snapshot"</span>);
|
||||
};
|
||||
</span><span class="kw">let </span>snapshot = rx.<span class="kw">await</span>.context(<span class="string">"failed to get snapshot"</span>)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>expired = Timestamp::now() - expiry_us;
|
||||
<span class="macro">trace!</span>(<span class="string">"evicting packets older than {}"</span>, expired);
|
||||
<span class="comment">// if getting the range fails we exit the loop and shut down
|
||||
// if individual reads fail we log the error and limp on
|
||||
</span><span class="kw">for </span>item <span class="kw">in </span>snapshot.update_time.range(..expired.to_bytes())<span class="question-mark">? </span>{
|
||||
</span><span class="kw">for </span>item <span class="kw">in </span>snapshot
|
||||
.update_time
|
||||
.range(..expired.to_bytes())
|
||||
.context(<span class="string">"read update_time"</span>)<span class="question-mark">?
|
||||
</span>{
|
||||
<span class="kw">let </span>(time, keys) = <span class="kw">match </span>item {
|
||||
<span class="prelude-val">Ok</span>(v) => v,
|
||||
<span class="prelude-val">Err</span>(e) => {
|
||||
@@ -834,7 +872,9 @@
|
||||
u64::from_be_bytes(time),
|
||||
key
|
||||
);
|
||||
send.send(Message::CheckExpired { time, key }).<span class="kw">await</span><span class="question-mark">?</span>;
|
||||
send.send(Message::CheckExpired { time, key })
|
||||
.<span class="kw">await
|
||||
</span>.context(<span class="string">"send"</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
}
|
||||
<span class="comment">// sleep for the eviction interval so we don't constantly check
|
||||
@@ -862,7 +902,7 @@
|
||||
</span>F: FnOnce() -> Fut + Send + <span class="lifetime">'static</span>,
|
||||
Fut: Future<Output = ()>,
|
||||
{
|
||||
<span class="kw">let </span>rt = tokio::runtime::Handle::try_current()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>rt = tokio::runtime::Handle::try_current().context(<span class="string">"get tokio handle"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>handle = std::thread::Builder::new()
|
||||
.name(name.into())
|
||||
.spawn(<span class="kw">move </span>|| rt.block_on(f()))
|
||||
|
||||
@@ -155,14 +155,22 @@
|
||||
<a href="#154" id="154">154</a>
|
||||
<a href="#155" id="155">155</a>
|
||||
<a href="#156" id="156">156</a>
|
||||
<a href="#157" id="157">157</a></pre></div><pre class="rust"><code><span class="kw">use </span>core::fmt;
|
||||
<a href="#157" id="157">157</a>
|
||||
<a href="#158" id="158">158</a>
|
||||
<a href="#159" id="159">159</a>
|
||||
<a href="#160" id="160">160</a>
|
||||
<a href="#161" id="161">161</a>
|
||||
<a href="#162" id="162">162</a>
|
||||
<a href="#163" id="163">163</a>
|
||||
<a href="#164" id="164">164</a>
|
||||
<a href="#165" id="165">165</a>
|
||||
<a href="#166" id="166">166</a></pre></div><pre class="rust"><code><span class="kw">use </span>core::fmt;
|
||||
<span class="kw">use </span>std::{
|
||||
collections::{btree_map, BTreeMap},
|
||||
str::FromStr,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
<span class="kw">use </span>anyhow::{anyhow, <span class="prelude-ty">Result</span>};
|
||||
<span class="kw">use </span>hickory_server::proto::{
|
||||
op::Message,
|
||||
rr::{
|
||||
@@ -171,6 +179,7 @@
|
||||
},
|
||||
serialize::binary::BinDecodable,
|
||||
};
|
||||
<span class="kw">use </span>n0_snafu::{TestError, TestResult <span class="kw">as </span><span class="prelude-ty">Result</span>, TestResultExt};
|
||||
<span class="kw">use </span>pkarr::SignedPacket;
|
||||
|
||||
<span class="attr">#[derive(
|
||||
@@ -184,8 +193,8 @@
|
||||
}
|
||||
|
||||
<span class="kw">pub fn </span>from_z32(s: <span class="kw-2">&</span>str) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>> {
|
||||
<span class="kw">let </span>bytes = z32::decode(s.as_bytes())<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bytes: [u8; <span class="number">32</span>] = bytes.try_into().map_err(|<span class="kw">_</span>| <span class="macro">anyhow!</span>(<span class="string">"invalid length"</span>))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bytes = z32::decode(s.as_bytes()).context(<span class="string">"z32"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>bytes = TryInto::<[u8; <span class="number">32</span>]>::try_into(<span class="kw-2">&</span>bytes[..]).context(<span class="string">"invalid length"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(<span class="self">Self</span>(bytes))
|
||||
}
|
||||
|
||||
@@ -225,14 +234,14 @@
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>TryFrom<PublicKeyBytes> <span class="kw">for </span>pkarr::PublicKey {
|
||||
<span class="kw">type </span>Error = anyhow::Error;
|
||||
<span class="kw">type </span>Error = TestError;
|
||||
<span class="kw">fn </span>try_from(value: PublicKeyBytes) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>, <span class="self">Self</span>::Error> {
|
||||
pkarr::PublicKey::try_from(<span class="kw-2">&</span>value.<span class="number">0</span>).map_err(anyhow::Error::from)
|
||||
pkarr::PublicKey::try_from(<span class="kw-2">&</span>value.<span class="number">0</span>).context(<span class="string">"public key"</span>)
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>FromStr <span class="kw">for </span>PublicKeyBytes {
|
||||
<span class="kw">type </span><span class="prelude-val">Err </span>= anyhow::Error;
|
||||
<span class="kw">type </span><span class="prelude-val">Err </span>= TestError;
|
||||
<span class="kw">fn </span>from_str(s: <span class="kw-2">&</span>str) -> <span class="prelude-ty">Result</span><<span class="self">Self</span>, <span class="self">Self</span>::Err> {
|
||||
<span class="self">Self</span>::from_z32(s)
|
||||
}
|
||||
@@ -246,7 +255,7 @@
|
||||
|
||||
<span class="kw">pub fn </span>signed_packet_to_hickory_message(signed_packet: <span class="kw-2">&</span>SignedPacket) -> <span class="prelude-ty">Result</span><Message> {
|
||||
<span class="kw">let </span>encoded = signed_packet.encoded_packet();
|
||||
<span class="kw">let </span>message = Message::from_bytes(<span class="kw-2">&</span>encoded)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>message = Message::from_bytes(<span class="kw-2">&</span>encoded).context(<span class="string">"decode message"</span>)<span class="question-mark">?</span>;
|
||||
<span class="prelude-val">Ok</span>(message)
|
||||
}
|
||||
|
||||
@@ -254,7 +263,7 @@
|
||||
signed_packet: <span class="kw-2">&</span>SignedPacket,
|
||||
filter: <span class="kw">impl </span>Fn(<span class="kw-2">&</span>Record) -> bool,
|
||||
) -> <span class="prelude-ty">Result</span><(Label, BTreeMap<RrKey, Arc<RecordSet>>)> {
|
||||
<span class="kw">let </span>common_zone = Label::from_utf8(<span class="kw-2">&</span>signed_packet.public_key().to_z32())<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>common_zone = Label::from_utf8(<span class="kw-2">&</span>signed_packet.public_key().to_z32()).context(<span class="string">"utf8"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>message = signed_packet_to_hickory_message(signed_packet)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>answers = message.take_answers();
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>output: BTreeMap<RrKey, Arc<RecordSet>> = BTreeMap::new();
|
||||
@@ -268,7 +277,12 @@
|
||||
<span class="kw">if </span>name.num_labels() < <span class="number">1 </span>{
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
<span class="kw">let </span>zone = name.iter().next_back().unwrap().into_label()<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>zone = name
|
||||
.iter()
|
||||
.next_back()
|
||||
.unwrap()
|
||||
.into_label()
|
||||
.context(<span class="string">"label"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">if </span>zone != common_zone {
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
@@ -276,8 +290,8 @@
|
||||
<span class="kw">continue</span>;
|
||||
}
|
||||
|
||||
<span class="kw">let </span>name_without_zone =
|
||||
Name::from_labels(name.iter().take(name.num_labels() <span class="kw">as </span>usize - <span class="number">1</span>))<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>name_without_zone = Name::from_labels(name.iter().take(name.num_labels() <span class="kw">as </span>usize - <span class="number">1</span>))
|
||||
.context(<span class="string">"labels"</span>)<span class="question-mark">?</span>;
|
||||
record.set_name(name_without_zone);
|
||||
|
||||
<span class="kw">let </span>rrkey = RrKey::new(record.name().into(), record.record_type());
|
||||
@@ -302,7 +316,11 @@
|
||||
origin: <span class="kw-2">&</span>Name,
|
||||
serial: u32,
|
||||
) -> <span class="prelude-ty">Result</span><RecordSet> {
|
||||
<span class="kw">let </span>new_name = input.name().clone().append_name(origin)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>new_name = input
|
||||
.name()
|
||||
.clone()
|
||||
.append_name(origin)
|
||||
.context(<span class="string">"append name"</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>output = RecordSet::new(new_name.clone(), input.record_type(), serial);
|
||||
<span class="comment">// TODO: less clones
|
||||
</span><span class="kw">for </span>record <span class="kw">in </span>input.records_without_rrsigs() {
|
||||
|
||||
Reference in New Issue
Block a user