xray

package
v0.0.0-...-d0fe248 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(proxyURL string)

func CloseAll

func CloseAll()

func HysteriaToXRay

func HysteriaToXRay(cfg *HysteriaConfig, port int, protocol string) ([]byte, int, error)

func ShadowsocksToXRay

func ShadowsocksToXRay(su *ShadowsocksURL, port int) ([]byte, int, error)

func StartHysteria

func StartHysteria(u *url.URL, port int) (*core.Instance, int, error)

func StartShadowsocks

func StartShadowsocks(u *url.URL, port int) (*core.Instance, int, error)

func StartTrojan

func StartTrojan(u *url.URL, port int) (*core.Instance, int, error)

func StartVless

func StartVless(u *url.URL, port int) (*core.Instance, int, error)

StartVless starts a VLESS client and returns Xray instance and local SOCKS port

func StartVmess

func StartVmess(u *url.URL, port int) (*core.Instance, int, error)

StartVmess starts a VMess client

func StartWireGuard

func StartWireGuard(u *url.URL, port int) (*core.Instance, int, error)

func TrojanToXRay

func TrojanToXRay(u *url.URL, port int) ([]byte, int, error)

TrojanToXRay converts Trojan URL to Xray JSON configuration.

func VlessToXRay

func VlessToXRay(vu *VlessURL, port int) ([]byte, int, error)

VlessToXRay converts VLESS URL to Xray JSON configuration

func VmessToXRay

func VmessToXRay(vmess *VmessConfig, port int) ([]byte, int, error)

VmessToXRay converts VMess URL to Xray JSON configuration

func WireGuardToXRay

func WireGuardToXRay(wu *WireGuardURL, port int) ([]byte, int, error)

Types

type DNSConfig

type DNSConfig struct {
	Servers []string `json:"servers,omitempty"`
}

type FlexInt

type FlexInt int

func (*FlexInt) UnmarshalJSON

func (i *FlexInt) UnmarshalJSON(data []byte) error

func (FlexInt) Value

func (i FlexInt) Value() int

type FlexString

type FlexString string

func (*FlexString) UnmarshalJSON

func (s *FlexString) UnmarshalJSON(data []byte) error

func (FlexString) Value

func (s FlexString) Value() string

type GRPCSettings

type GRPCSettings struct {
	ServiceName string `json:"serviceName,omitempty"`
	MultiMode   bool   `json:"multiMode,omitempty"`
}

type HTTPSettings

type HTTPSettings struct {
	Path string   `json:"path,omitempty"`
	Host []string `json:"host,omitempty"`
}
type Header struct {
	Type     string      `json:"type,omitempty"`
	Request  interface{} `json:"request,omitempty"`
	Response interface{} `json:"response,omitempty"`
}

type HysteriaConfig

type HysteriaConfig struct {
	Scheme               string
	Address              string
	Port                 int
	Password             string
	Auth                 string
	HopPorts             string
	UseUDPExtension      bool
	Protocol             string
	UpMbps               int
	DownMbps             int
	Congestion           string
	Obfs                 string
	ObfsPassword         string
	SNI                  string
	ALPN                 []string
	Fingerprint          string
	AllowInsecure        bool
	PinnedPeerCertSha256 string
	VerifyPeerCertByName string
	Remark               string
	// contains filtered or unexported fields
}

HysteriaConfig stores Hysteria/Hysteria2 URL parameters. Supported schemes: hysteria://, hysteria2://, hy2://

type HysteriaSettings

type HysteriaSettings struct {
	Version             int32  `json:"version,omitempty"`
	Auth                string `json:"auth,omitempty"`
	Up                  string `json:"up,omitempty"`
	Down                string `json:"down,omitempty"`
	Congestion          string `json:"congestion,omitempty"`
	ReadIdleTimeout     uint64 `json:"read_idle_timeout,omitempty"`
	Heartbeat           uint64 `json:"health_check_timeout,omitempty"`
	DisableMTUDiscovery bool   `json:"disable_mtu_discovery,omitempty"`
	Obfs                string `json:"obfs,omitempty"`
	Password            string `json:"password,omitempty"`
}

type HysteriaURL

type HysteriaURL struct {
	Config *HysteriaConfig
}

func ParseHysteriaURL

func ParseHysteriaURL(u *url.URL) (*HysteriaURL, error)

func (*HysteriaURL) PortString

func (h *HysteriaURL) PortString() string

func (*HysteriaURL) String

func (h *HysteriaURL) String() string

type Inbound

type Inbound struct {
	Tag      string      `json:"tag"`
	Port     int         `json:"port"`
	Listen   string      `json:"listen,omitempty"`
	Protocol string      `json:"protocol"`
	Settings interface{} `json:"settings"`
	Sniffing *Sniffing   `json:"sniffing,omitempty"`
}

type KCPSettings

type KCPSettings struct {
	MTU              int     `json:"mtu,omitempty"`
	TTI              int     `json:"tti,omitempty"`
	UplinkCapacity   int     `json:"uplinkCapacity,omitempty"`
	DownlinkCapacity int     `json:"downlinkCapacity,omitempty"`
	Congestion       bool    `json:"congestion,omitempty"`
	ReadBufferSize   int     `json:"readBufferSize,omitempty"`
	WriteBufferSize  int     `json:"writeBufferSize,omitempty"`
	Header           *Header `json:"header,omitempty"`
}

type LogConfig

type LogConfig struct {
	Access   string `json:"access,omitempty"`
	Error    string `json:"error,omitempty"`
	Loglevel string `json:"loglevel,omitempty"`
}

type Mux

type Mux struct {
	Enabled     bool   `json:"enabled"`
	Concurrency int    `json:"concurrency,omitempty"`
	Protocol    string `json:"protocol,omitempty"`
}

type Outbound

type Outbound struct {
	Tag            string          `json:"tag,omitempty"`
	Protocol       string          `json:"protocol"`
	Settings       interface{}     `json:"settings"`
	StreamSettings *StreamSettings `json:"streamSettings,omitempty"`
	Mux            *Mux            `json:"mux,omitempty"`
}

type QUICSettings

type QUICSettings struct {
	Security string  `json:"security,omitempty"`
	Key      string  `json:"key,omitempty"`
	Header   *Header `json:"header,omitempty"`
}

type RealitySettings

type RealitySettings struct {
	Show        bool   `json:"show,omitempty"`
	Fingerprint string `json:"fingerprint,omitempty"`
	ServerName  string `json:"serverName,omitempty"`
	PublicKey   string `json:"publicKey,omitempty"`
	ShortID     string `json:"shortId,omitempty"`
	SpiderX     string `json:"spiderX,omitempty"`
}

type RoutingConfig

type RoutingConfig struct {
	DomainStrategy string        `json:"domainStrategy,omitempty"`
	Rules          []RoutingRule `json:"rules,omitempty"`
}

type RoutingRule

type RoutingRule struct {
	Type        string   `json:"type"`
	OutboundTag string   `json:"outboundTag"`
	Domain      []string `json:"domain,omitempty"`
	IP          []string `json:"ip,omitempty"`
}

type Server

type Server struct {
	Instance  *core.Instance
	SocksPort int
}

type ShadowsocksConfig

type ShadowsocksConfig struct {
	Method   string
	Password string
	Address  string
	Port     int
	UoT      bool
	Remark   string
	// contains filtered or unexported fields
}

ShadowsocksConfig stores ss:// URL parameters.

type ShadowsocksURL

type ShadowsocksURL struct {
	Config *ShadowsocksConfig
}

func ParseShadowsocksURL

func ParseShadowsocksURL(u *url.URL) (*ShadowsocksURL, error)

type Sniffing

type Sniffing struct {
	Enabled      bool     `json:"enabled"`
	DestOverride []string `json:"destOverride"`
}

type SocksSetting

type SocksSetting struct {
	Auth      string `json:"auth,omitempty"`
	UDP       bool   `json:"udp,omitempty"`
	IP        string `json:"ip,omitempty"`
	UserLevel int    `json:"userLevel,omitempty"`
}

type StreamSettings

type StreamSettings struct {
	Network          string            `json:"network,omitempty"`
	Security         string            `json:"security,omitempty"`
	TLSSettings      *TLSSettings      `json:"tlsSettings,omitempty"`
	TCPSettings      *TCPSettings      `json:"tcpSettings,omitempty"`
	KCPSettings      *KCPSettings      `json:"kcpSettings,omitempty"`
	WSSettings       *WSSettings       `json:"wsSettings,omitempty"`
	HTTPSettings     *HTTPSettings     `json:"httpSettings,omitempty"`
	QUICSettings     *QUICSettings     `json:"quicSettings,omitempty"`
	GRPCSettings     *GRPCSettings     `json:"grpcSettings,omitempty"`
	XTLSSettings     *TLSSettings      `json:"xtlsSettings,omitempty"`    // Added XTLS support
	RealitySettings  *RealitySettings  `json:"realitySettings,omitempty"` // Added Reality support
	XHTTPSettings    *XHTTPSettings    `json:"xhttpSettings,omitempty"`   // Added XHTTP support
	HysteriaSettings *HysteriaSettings `json:"hysteriaSettings,omitempty"`
}

type TCPSettings

type TCPSettings struct {
	Header *Header `json:"header,omitempty"`
}

type TLSSettings

type TLSSettings struct {
	ServerName           string   `json:"serverName,omitempty"`
	ALPN                 []string `json:"alpn,omitempty"`
	Fingerprint          string   `json:"fingerprint,omitempty"`
	PinnedPeerCertSha256 string   `json:"pinnedPeerCertSha256,omitempty"`
	VerifyPeerCertByName string   `json:"verifyPeerCertByName,omitempty"`
}

type TrojanConfig

type TrojanConfig struct {
	Password             string
	Address              string
	Port                 int
	Flow                 string
	Type                 string
	Security             string
	Path                 string
	Host                 string
	SNI                  string
	ALPN                 string
	Fingerprint          string
	PublicKey            string
	ShortID              string
	SpiderX              string
	ServiceName          string
	AllowInsecure        bool
	PinnedPeerCertSha256 string
	VerifyPeerCertByName string
	Remark               string
	// contains filtered or unexported fields
}

TrojanConfig stores Trojan URL parameters trojan://password@host:port?security=tls&type=tcp&sni=example.com...

type TrojanURL

type TrojanURL struct {
	Config *TrojanConfig
}

func ParseTrojanURL

func ParseTrojanURL(u *url.URL) (*TrojanURL, error)

type VlessConfig

type VlessConfig struct {
	UUID                 string
	Address              string
	Port                 int
	Encryption           string
	Flow                 string
	Type                 string
	Security             string
	Path                 string
	Host                 string
	SNI                  string
	ALPN                 string
	Fingerprint          string
	PublicKey            string
	ShortID              string
	SpiderX              string
	ServiceName          string
	AllowInsecure        bool // Controls whether to allow insecure TLS connections
	PinnedPeerCertSha256 string
	VerifyPeerCertByName string
	Remark               string
	// contains filtered or unexported fields
}

VlessConfig stores VLESS URL parameters

type VlessURL

type VlessURL struct {
	Config *VlessConfig
}

func ParseVlessURL

func ParseVlessURL(u *url.URL) (*VlessURL, error)

func (*VlessURL) Host

func (v *VlessURL) Host() string

func (*VlessURL) Name

func (v *VlessURL) Name() string

func (*VlessURL) Opaque

func (v *VlessURL) Opaque() string

func (*VlessURL) Password

func (v *VlessURL) Password() string

func (*VlessURL) Port

func (v *VlessURL) Port() string

func (*VlessURL) Protocol

func (v *VlessURL) Protocol() string

func (*VlessURL) Raw

func (v *VlessURL) Raw() *url.URL

func (*VlessURL) User

func (v *VlessURL) User() string

type VmessConfig

type VmessConfig struct {
	V                    FlexInt    `json:"v"`
	PS                   string     `json:"ps"`               // Remarks
	Add                  string     `json:"add"`              // Address
	Port                 FlexInt    `json:"port"`             // Port
	ID                   string     `json:"id"`               // UUID
	Aid                  FlexInt    `json:"aid"`              // AlterID
	Net                  string     `json:"net"`              // Transport protocol
	Type                 string     `json:"type"`             // Camouflage type
	Host                 string     `json:"host"`             // Camouflage domain
	Path                 string     `json:"path"`             // WebSocket path
	TLS                  FlexString `json:"tls"`              // TLS
	SNI                  string     `json:"sni"`              // TLS SNI
	Alpn                 string     `json:"alpn"`             // ALPN
	Flow                 string     `json:"flow"`             // XTLS Flow
	Fp                   string     `json:"fp"`               // Fingerprint
	PbK                  string     `json:"pbk"`              // PublicKey (Reality)
	Sid                  string     `json:"sid"`              // ShortID (Reality)
	SpX                  string     `json:"spx"`              // SpiderX (Reality)
	Security             string     `json:"security"`         // Encryption method
	XHTTPVer             string     `json:"xver"`             // XHTTP version, "h2" or "h3"
	AllowInsecure        bool       `json:"skip_cert_verify"` // Controls whether to allow insecure TLS connections
	PinnedPeerCertSha256 string     `json:"pcs"`              // SHA-256 pin for the peer certificate
	VerifyPeerCertByName string     `json:"vcn"`              // Certificate name accepted by Xray
	// contains filtered or unexported fields
}

VmessConfig stores VMess URL parameters

type VmessURL

type VmessURL struct {
	Config *VmessConfig
}

func ParseVmessURL

func ParseVmessURL(u *url.URL) (*VmessURL, error)

func (*VmessURL) Host

func (v *VmessURL) Host() string

func (*VmessURL) Name

func (v *VmessURL) Name() string

func (*VmessURL) Opaque

func (v *VmessURL) Opaque() string

func (*VmessURL) Password

func (v *VmessURL) Password() string

func (*VmessURL) Port

func (v *VmessURL) Port() string

func (*VmessURL) Protocol

func (v *VmessURL) Protocol() string

func (*VmessURL) Raw

func (v *VmessURL) Raw() *url.URL

func (*VmessURL) User

func (v *VmessURL) User() string

type WSSettings

type WSSettings struct {
	Path    string            `json:"path,omitempty"`
	Host    string            `json:"host,omitempty"` // Added independent Host field
	Headers map[string]string `json:"headers,omitempty"`
}

Updated WSSettings structure

type WireGuardConfig

type WireGuardConfig struct {
	SecretKey      string
	PublicKey      string
	Endpoint       string
	Address        []string
	AllowedIPs     []string
	Reserved       []int
	KeepAlive      int
	MTU            int
	Workers        int
	DomainStrategy string
	Remark         string
	// contains filtered or unexported fields
}

WireGuardConfig stores WireGuard URL parameters. Example: wireguard://secretKey@host:port?publicKey=xxx&address=10.0.0.2/32&allowedIPs=0.0.0.0/0,::/0

type WireGuardURL

type WireGuardURL struct {
	Config *WireGuardConfig
}

func ParseWireGuardURL

func ParseWireGuardURL(u *url.URL) (*WireGuardURL, error)

type XHTTPSettings

type XHTTPSettings struct {
	Host    string            `json:"host,omitempty"`
	Path    string            `json:"path,omitempty"`
	Method  string            `json:"method,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Version string            `json:"version,omitempty"` // "h2" or "h3"
}

Added new XHTTP settings structure

type XRayConfig

type XRayConfig struct {
	Log       *LogConfig     `json:"log,omitempty"`
	DNS       *DNSConfig     `json:"dns,omitempty"`
	Routing   *RoutingConfig `json:"routing,omitempty"`
	Inbounds  []Inbound      `json:"inbounds"`
	Outbounds []Outbound     `json:"outbounds"`
}

General configuration structure, matching the Xray configuration format

Jump to

Keyboard shortcuts

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