-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crate for DNS verification (#502)
* add dns verification library * rename library, add test * schema test * add builder * add tests * remove unused enum case * use builder internally * add all the logic to the builder, remove new function * fix position in cargo.toml
- Loading branch information
Showing
17 changed files
with
680 additions
and
82 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "geomjeungja" | ||
authors.workspace = true | ||
edition.workspace = true | ||
version.workspace = true | ||
license = "MIT OR Apache-2.0" | ||
|
||
[dependencies] | ||
async-trait = "0.1.78" | ||
hickory-resolver = { version = "0.24.0", features = ["dns-over-rustls"] } | ||
rand = "0.8.5" | ||
serde = { version = "1.0.197", features = ["derive"] } | ||
simdutf8 = { version = "0.1.4", features = ["aarch64_neon"] } | ||
thiserror = "1.0.58" | ||
tracing = "0.1.40" | ||
typed-builder = "0.18.1" | ||
|
||
[dev-dependencies] | ||
insta = { version = "1.36.1", features = ["json"] } | ||
rand_xorshift = "0.3.0" | ||
serde_json = "1.0.114" | ||
tokio = { version = "1.36.0", features = ["macros", "rt"] } | ||
|
||
[lints] | ||
workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE-APACHE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE-MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# geomjeungja | ||
|
||
Domain verification via TXT records | ||
|
||
## About | ||
|
||
Geomjeungja is a small library for verifying domain ownership via the user setting a TXT record. | ||
It is only compatible with Tokio at the moment but this might change in the future. | ||
|
||
It ships with one default verification strategy. This strategy is for validating structures looking like this: `[key]=[value]`. | ||
In case you need anything more complicated, consider implementing your own strategy. | ||
|
||
A strategy is an asynchronous fallible operation with its own context that operates over an iterator of string slices that represent the TXT records. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use geomjeungja::{Error, KeyValueStrategy, Verifier}; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() { | ||
// Create a verification strategy | ||
let verification_strategy = | ||
KeyValueStrategy::generate(&mut rand::thread_rng(), "kakunin".into()); | ||
let verifier = Verifier::builder() | ||
.fqdn("aumetra.xyz".into()) | ||
.strategy(verification_strategy) | ||
.build(); | ||
|
||
// Now we store that somewhere for later verification | ||
let serialised_strategy = serde_json::to_string(verifier.strategy()).unwrap(); | ||
|
||
// --- SOME TIME LATER --- | ||
|
||
// Now we can deserialise it because the user told us "yeah I set that" | ||
let deserialised_strategy: KeyValueStrategy = | ||
serde_json::from_str(&serialised_strategy).unwrap(); | ||
|
||
// Let's check if they didn't lie | ||
let verifier = Verifier::builder() | ||
.fqdn("aumetra.xyz".into()) | ||
.strategy(deserialised_strategy) | ||
.build(); | ||
|
||
match verifier.verify().await { | ||
Ok(()) => println!("Successfully verified. All good!"), | ||
Err(Error::Unverified) => println!("TXT records didn't contain the KV pair :("), | ||
Err(err) => eprintln!("Something errored out. Error: {err:?}"), | ||
} | ||
} |
Oops, something went wrong.