A handy Matrix server resolution library
Find a file
theS1LV3R 1883740c13
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
fix: Remove wrapping [] from input IP addresses
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)
2026-07-26 02:02:38 +00:00
.forgejo/workflows feat: Add MSRV enforced by CI 2026-04-12 15:45:30 +01:00
examples chore: Add example for builder pattern 2026-06-26 19:52:00 +01:00
src fix: Remove wrapping [] from input IP addresses 2026-07-26 02:02:38 +00:00
.gitignore chore: Initial commit 2026-03-17 16:45:55 +00:00
.pre-commit-config.yaml chore: Fix docs 2026-03-19 11:24:54 +00:00
Cargo.lock chore: Release resolvematrix version 1.2.0 2026-07-11 22:41:22 -04:00
Cargo.toml fix!: Improve cargo features 2026-07-26 03:30:31 +02:00
committed.toml chore: Add committed config 2026-03-19 11:19:20 +00:00
LICENSE chore: Initial commit 2026-03-17 16:45:55 +00:00
README.md docs: Update README to include contributing and CoC guidelines 2026-06-26 20:26:34 +01:00
README.tpl docs: Update README to include contributing and CoC guidelines 2026-06-26 20:26:34 +01:00
rust-toolchain.toml chore: Add rust-toolchain.toml 2026-04-12 15:38:38 +01:00

resolvematrix

Dependency status crates.io docs.rs MPL-2.0 license

forgejo.ellis.link Issues Pull Requests GitHub mirror

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.