xray

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 53 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 DialSSR added in v0.0.5

func DialSSR(u *url.URL, o *proxyclient.Options) (http.RoundTripper, error)

DialSSR creates a custom transport that dials directly to the v2ray server instead of using a local SOCKS proxy.

func DialTrojan added in v0.0.5

func DialTrojan(u *url.URL, o *proxyclient.Options) (http.RoundTripper, error)

DialTrojan creates a custom transport that dials directly to the v2ray server instead of using a local SOCKS proxy.

func DialVless added in v0.0.5

func DialVless(u *url.URL, o *proxyclient.Options) (http.RoundTripper, error)

DialVless creates a custom transport that dials directly to the v2ray server instead of using a local SOCKS proxy.

func DialVmess added in v0.0.5

func DialVmess(u *url.URL, o *proxyclient.Options) (http.RoundTripper, error)

DialVmess creates a custom transport that dials directly to the v2ray server instead of using a local SOCKS proxy.

func SSRToXRay

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

SSRToXRay converts SSR URL to Xray JSON configuration

func StartSSR

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

StartSSR starts SSR client and returns Xray instance and local SOCKS port

func StartTrojan

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

StartTrojan starts a Trojan client and returns Xray instance and local SOCKS port

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 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

Types

type DNSConfig

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

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 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 SSRConfig

type SSRConfig struct {
	Server        string
	Port          int
	Method        string
	Password      string
	Protocol      string
	ProtocolParam string
	Obfs          string
	ObfsParam     string
	Name          string
	// contains filtered or unexported fields
}

SSRConfig stores ShadowsocksR URL parameters

type SSRURL added in v0.0.3

type SSRURL struct {
	Config *SSRConfig
}

func ParseSSRURL added in v0.0.3

func ParseSSRURL(u *url.URL) (*SSRURL, error)

func (*SSRURL) Host added in v0.0.3

func (v *SSRURL) Host() string

func (*SSRURL) Name added in v0.0.10

func (v *SSRURL) Name() string

func (*SSRURL) Opaque added in v0.0.4

func (v *SSRURL) Opaque() string

func (*SSRURL) Password added in v0.0.4

func (v *SSRURL) Password() string

func (*SSRURL) Port added in v0.0.3

func (v *SSRURL) Port() string

func (*SSRURL) Protocol added in v0.0.4

func (v *SSRURL) Protocol() string

func (*SSRURL) Raw added in v0.0.3

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

func (*SSRURL) User added in v0.0.4

func (v *SSRURL) User() string

type Server

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

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
}

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"`
	AllowInsecure bool     `json:"allowInsecure,omitempty"`
	Fingerprint   string   `json:"fingerprint,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
	ServiceName   string
	AllowInsecure bool // Controls whether to allow insecure TLS connections
	Remark        string
	// contains filtered or unexported fields
}

TrojanConfig stores Trojan URL parameters

type TrojanURL added in v0.0.4

type TrojanURL struct {
	Config *TrojanConfig
}

func ParseTrojanURL added in v0.0.4

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

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

func (*TrojanURL) Host added in v0.0.4

func (v *TrojanURL) Host() string

func (*TrojanURL) Name added in v0.0.10

func (v *TrojanURL) Name() string

func (*TrojanURL) Opaque added in v0.0.4

func (v *TrojanURL) Opaque() string

func (*TrojanURL) Password added in v0.0.4

func (v *TrojanURL) Password() string

func (*TrojanURL) Port added in v0.0.4

func (v *TrojanURL) Port() string

func (*TrojanURL) Protocol added in v0.0.4

func (v *TrojanURL) Protocol() string

func (*TrojanURL) Raw added in v0.0.4

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

func (*TrojanURL) User added in v0.0.4

func (v *TrojanURL) User() string

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
	Remark        string
	// contains filtered or unexported fields
}

VlessConfig stores VLESS URL parameters

type VlessURL added in v0.0.3

type VlessURL struct {
	Config *VlessConfig
}

func ParseVlessURL added in v0.0.3

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

ParseVlessURL parses VLESS URL vless://uuid@host:port?encryption=none&type=tcp&security=tls&sni=example.com...

func (*VlessURL) Host added in v0.0.3

func (v *VlessURL) Host() string

func (*VlessURL) Name added in v0.0.10

func (v *VlessURL) Name() string

func (*VlessURL) Opaque added in v0.0.4

func (v *VlessURL) Opaque() string

func (*VlessURL) Password added in v0.0.4

func (v *VlessURL) Password() string

func (*VlessURL) Port added in v0.0.3

func (v *VlessURL) Port() string

func (*VlessURL) Protocol added in v0.0.4

func (v *VlessURL) Protocol() string

func (*VlessURL) Raw added in v0.0.3

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

func (*VlessURL) User added in v0.0.4

func (v *VlessURL) User() string

type VmessConfig

type VmessConfig struct {
	V             proxyclient.Int    `json:"v"`
	PS            string             `json:"ps"`               // Remarks
	Add           string             `json:"add"`              // Address
	Port          proxyclient.Int    `json:"port"`             // Port
	ID            string             `json:"id"`               // UUID
	Aid           proxyclient.Int    `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           proxyclient.String `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
	// contains filtered or unexported fields
}

VmessConfig stores VMess URL parameters

type VmessURL added in v0.0.3

type VmessURL struct {
	Config *VmessConfig
}

func ParseVmessURL added in v0.0.3

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

func (*VmessURL) Host added in v0.0.3

func (v *VmessURL) Host() string

func (*VmessURL) Name added in v0.0.10

func (v *VmessURL) Name() string

func (*VmessURL) Opaque added in v0.0.4

func (v *VmessURL) Opaque() string

func (*VmessURL) Password added in v0.0.4

func (v *VmessURL) Password() string

func (*VmessURL) Port added in v0.0.3

func (v *VmessURL) Port() string

func (*VmessURL) Protocol added in v0.0.4

func (v *VmessURL) Protocol() string

func (*VmessURL) Raw added in v0.0.3

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

func (*VmessURL) User added in v0.0.4

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 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