xray

package
v1.260909.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrAlreadyRunning = errors.New("xray is already running")

Functions

func GetXrayState

func GetXrayState() bool

Get Xray State

func RunXray

func RunXray(xrayJSON string) error

Run Xray instance. xrayJSON is the serialized Xray JSON configuration.

func StopXray

func StopXray() error

Stop Xray instance.

func TestXray

func TestXray(xrayJSON string) error

TestXray only builds the configuration; it does not instantiate handlers. The core builder can read local assets/certificates and apply root env values. Success does not guarantee that the configuration can start.

func XrayVersion

func XrayVersion() string

Xray's version

Types

type PingBatchItem added in v1.260728.0

type PingBatchItem struct {
	XrayJSON    string
	OutboundTag string
}

type PingBatchResult added in v1.260728.0

type PingBatchResult struct {
	Success       bool
	Delay         int64
	Error         string
	LocationJSON  *string
	LocationError string
}

func PingBatch added in v1.260728.0

func PingBatch(
	items []PingBatchItem,
	timeout int,
	targetURL string,
) ([]PingBatchResult, error)
Example
results, _ := PingBatch(
	[]PingBatchItem{{XrayJSON: `{"outbounds":[{"protocol":"freedom"}]}`}},
	5,
	"https://cp.cloudflare.com/",
)
fmt.Println(len(results))

func PingBatchWithLocation added in v1.260909.0

func PingBatchWithLocation(items []PingBatchItem, timeout int, targetURL, locationURL string) ([]PingBatchResult, error)

PingBatchWithLocation uses the same forced-outbound client for latency and optional location probes. The two probe results are independent.

Jump to

Keyboard shortcuts

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