relayurl

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package relayurl applies NIP-42-flavored URL normalization for the purpose of comparing a client-supplied AUTH `relay` tag against the relay's configured Auth.RelayURL. NIP-42 says: "URL normalization techniques can be applied. For most cases just checking if the domain name is correct should be enough."

Two match modes are supported, picked by the operator:

  • ModeStrict (default): canonicalize scheme + host (lowercase, strip default ports) and a trailing-slash-stripped path. Path is significant. Safe for shared-host / multi-tenant deployments.

  • ModeHost: drop the path entirely. Any AUTH addressed at the right (canonicalized) scheme + host succeeds. Closer to the "domain name is correct should be enough" reading. Use this if clients in the wild append fingerprint suffixes to your URL and you don't share a host with another relay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(s string) string

Canonical returns the strict-mode normalized form. Kept exported for callers (e.g. logs/diagnostics) that want a stable form.

func Match

func Match(got, want string, mode Mode) bool

Match reports whether two relay URLs refer to the same relay under the given mode.

Types

type Mode

type Mode int

Mode controls how strictly URLs are compared. The zero value (ModeStrict) keeps path significant; ModeHost ignores it.

const (
	ModeStrict Mode = iota
	ModeHost
)

func ParseMode

func ParseMode(s string) Mode

ParseMode maps a config string ("", "strict", "host") to a Mode. Unknown values fall back to ModeStrict — fail-safe: stricter matching is the safer error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL