auth

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth provides password hashing (Argon2id), random secret generation, and constant-time helpers used by the panel's authentication and masquerade.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure added in v0.8.0

func Configure()

Configure tunes the Argon2id cost to the host so concurrent logins can't OOM a small VPS, while keeping the strong default on roomy hosts. Call once at startup before any password is hashed. Safe to skip (defaults stand).

func DummyVerify

func DummyVerify()

DummyVerify burns roughly one Argon2id computation so that login attempts for unknown usernames take similar time to real ones (anti-enumeration).

func GenerateRealityKeys

func GenerateRealityKeys() (priv, pub string, err error)

GenerateRealityKeys returns an X25519 keypair encoded base64 raw-url, matching the format of `xray x25519`: the private key goes into the server config, the public key (pbk=) into client share links.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns a PHC-formatted Argon2id hash string.

func RandomPassword

func RandomPassword() (string, error)

RandomPassword returns a strong URL-safe random password.

func RandomSecretPath

func RandomSecretPath() (string, error)

RandomSecretPath returns a ~128-bit, URL-safe lowercase path segment.

func RandomServiceName

func RandomServiceName() (string, error)

RandomServiceName returns a random lowercase gRPC service name.

func RandomShortIDs

func RandomShortIDs() (string, error)

RandomShortIDs returns a comma-separated set of REALITY shortIds of varying even hex lengths. The server accepts any of them; share links use the first (an 8-hex-char id, the widely-compatible default).

func RandomToken

func RandomToken() (string, error)

RandomToken returns a 256-bit URL-safe opaque token (sessions).

func RandomWSPath

func RandomWSPath() (string, error)

RandomWSPath returns a random WebSocket path like "/3f9k2m".

func VerifyPassword

func VerifyPassword(encoded, password string) bool

VerifyPassword reports whether password matches the PHC-encoded hash.

Types

This section is empty.

Jump to

Keyboard shortcuts

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