selftest

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package selftest answers the question a health page can't: not "is Xray running?" but "does a client actually get through?". For each enabled protocol it spins up a throwaway Xray client — a local SOCKS inbound in front of that protocol's outbound, pointed back at our own inbound — and sends real traffic through it to the public internet. Success means the credentials, TLS, ALPN and transport all line up end-to-end and traffic egresses through this server.

What it does NOT prove: reachability from the outside world. The probe dials the inbound over loopback, so the host's own firewall and the provider's edge (the usual reason a fresh Hysteria2/UDP port "doesn't work") are bypassed. This is the automated form of the `curl -x socks5h://…` check you'd otherwise run by hand — it catches config mismatches and dead protocols, not blocked ports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Proto  string `json:"proto"`  // model.Proto* key
	Label  string `json:"label"`  // human name for the UI
	OK     bool   `json:"ok"`     // traffic made it out and back
	Detail string `json:"detail"` // one-line explanation, always set
	ExitIP string `json:"exit_ip,omitempty"`
}

Result is one protocol's verdict.

func Run

func Run(ctx context.Context, binPath string, set *model.Settings, u model.User) []Result

Run tests every enabled protocol for user u and returns one Result each, in a stable order. binPath is the Xray binary (shared with the supervisor); an empty path yields a single error result, since there's nothing to spawn.

Jump to

Keyboard shortcuts

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