Rust library for easy HTTPS/SVCB record support
Find a file
2025-03-11 11:16:15 -05:00
src Functional, checks for SVCB and HTTPS records and returns updated URL 2025-03-11 00:38:52 -05:00
.gitignore Updated .gitignore 2025-03-11 00:39:33 -05:00
Cargo.toml Bump version v1.0.1 2025-03-11 11:16:15 -05:00
LICENSE Initial commit 2025-03-10 23:01:17 -05:00
README.md Fix Cargo.toml and README.md 2025-03-11 11:10:31 -05:00

portify

Portify is a simple way to resolve a URL with a port hint in its SVCB or HTTPS record. There's just one public async function: resolve_svcb(url: &Url), which returns an error if either the record is invalid or does not exist. This library is great for improving support of services on non-standard ports, similar to SRV record helpers.

Usage

Add the library to your project:

cargo add portify

Example

use url::Url;

#[tokio::main]
async fn main() {
    let arg = std::env::args().last().unwrap();
    let mut url = Url::parse(&arg).unwrap();
    match portify::resolve_svcb(&url) {
        Ok(u) => url = u,
        Err(_) => println!("Assuming default port for URL")
    }
    println!("{}", url);
}

License

MIT