A handy Matrix server resolution library
- Rust 100%
|
All checks were successful
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m9s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 4m47s
Checks / Prek / Pre-commit & Formatting (push) Successful in 41s
Checks / Prek / Clippy and Cargo Tests (push) Successful in 1m54s
This was causing IPv6 hosts to fail to parse properly, and therefore
giving results like `Named("[2a0b", "<redacted>]")` instead of
`Literal("[2a0b:<redacted>]:8448")`
Root cause: `IpAddr::from_str` expects an IP address without the brackets.
Simple fix is to add a test case with brackets, and a few lines of code
to remove the brackets if they exist.
See-Also:
- [Start of conversation](https://matrix.to/#/!ksTlboXVgcyWjv5GrlEeKyQuJ8ZCprnwQx2b6-BQ44Q/%24ycrGAve619dUbXgiQO-OFTvXMXNy28ltyCSSek_5NpY?via=wolfgirl.pet&via=explodie.org&via=matrix.org)
- [End of conversation](https://matrix.to/#/!ksTlboXVgcyWjv5GrlEeKyQuJ8ZCprnwQx2b6-BQ44Q/%24zKpTlRDwvymvwUcGhgqO4Agcj0eqEgDf6WFc6Q6i9D4?via=wolfgirl.pet&via=explodie.org&via=matrix.org)
|
||
|---|---|---|
| .forgejo/workflows | ||
| examples | ||
| src | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| Cargo.lock | ||
| Cargo.toml | ||
| committed.toml | ||
| LICENSE | ||
| README.md | ||
| README.tpl | ||
| rust-toolchain.toml | ||
resolvematrix
resolvematrix is a Rust library providing the ability to resolve Matrix server-to-server endpoints from the server name.
It conforms to the Server discovery chapter of the Matrix specification.
The library is tested against the https://resolvematrix.dev suite and other live Matrix servers.
This library depends on hickory-resolver, reqwest, serde and (indirectly) tokio.
Usage
cargo add resolvematrix
Example
use resolvematrix::server::{MatrixResolver, MatrixResolverBuilder};
// Create a new resolver
let resolver = Arc::new(MatrixResolver::new()?);
// Or to use custom options:
// MatrixResolverBuilder::new().cache_ttl(Duration::from_secs(10)).build()?
// Resolve a server name
let server_name = "matrix.org";
let resolution = resolver.resolve_server(server_name).await?;
eprintln!("Resolved server: {resolution:?}");
let client = resolver.create_client().unwrap();
let url = format!("{}/_matrix/federation/v1/version", resolution.base_url());
let response = client.get(&url).send().await;
For more examples, see the examples directory.
Contributing
Resolvematrix is part of the Continuwuity project. Please see the Contributing guide before submitting a pull request.
Code of Conduct
Contributors are expected to follow the Continuwuity Community Guidelines.