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.
This repository includes a minimal implementation of the library in the form of a command-line tool.
cargo add resolvematrix
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.
The CLI is currently available as follows:
resolvematrix is available as an RPM package through Terra for all of the same Linux distributions as described on Continuwuity's RPM installation page, except for SUSE.
To install, follow Terra's directions for adding the Terra repo on your distribution (note that no subrepos are required for this package), then run sudo dnf install resolvematrix.
resolvematrix is available from Nixpkgs. To obtain and run the CLI through Nix, you can:
- Run
nix run nixpkgs#resolvematrix, or - Add
pkgs.resolvematrixto your system configuration
resolvematrix can be compiled from source on most platforms supported by both AWS-LC (on which this tool partially depends) and the Rust compiler (with std support).
This can be accomplished by one of the following methods:
- Cloning this repository, navigating to the
cli/subdirectory, and runningcargo build --release - Running the following one-liner, without needing to clone the repository:
cargo install --git https://forgejo.ellis.link/continuwuation/resolvematrix resolvematrix-cli
$ resolvematrix continuwuity.org
Resolved continuwuity.org to base URL https://matrix.continuwuity.org:443 using step 3.2 (WellKnownHostPort)
Server is continuwuity version 26.9.1 (ddbdd1e)
Server has signing keys:
- ed25519:PwHlNsFu: 8eNx2s0zWW+heKAmOH5zKv/nCPkEpraDJfGHxDu6hFIResolvematrix is part of the Continuwuity project. Please see the Contributing guide before submitting a pull request.
Contributors are expected to follow the Continuwuity Community Guidelines.