xray

package
v0.0.0-...-a0c44de Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CoreHTTPRequest

func CoreHTTPRequest(inst *core.Instance, timeout time.Duration, method, dest string) (int, []byte, error)

func CoreHTTPRequestCustom

func CoreHTTPRequestCustom(inst *core.Instance, timeout time.Duration, req *http.Request) (int, []byte, error)

func MeasureDelay

func MeasureDelay(inst *core.Instance, timeout time.Duration, showBody bool, dest string, httpMethod string) (int64, int, []byte, error)

Types

type Examiner

type Examiner struct {
	Xs       *Service
	MaxDelay uint16
	Logs     bool
	ShowBody bool

	DoSpeedtest bool
	DoIPInfo    bool

	TestEndpoint           string
	TestEndpointHttpMethod string
	SpeedtestAmount        uint32
}

func (*Examiner) ExamineConfig

func (e *Examiner) ExamineConfig(link string) (Result, error)

type GeneralConfig

type GeneralConfig struct {
	Protocol       string
	Address        string
	Security       string
	Aid            string
	Host           string
	ID             string
	Network        string
	Path           string
	Port           string
	Remark         string
	TLS            string
	SNI            string
	ALPN           string
	TlsFingerprint string
	ServiceName    string
	Mode           string
	Type           string
	OrigLink       string
}

type Protocol

type Protocol interface {
	Parse(configLink string) error
	BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)
	BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)
	DetailsStr() string
	ConvertToGeneralConfig() GeneralConfig
}

func ParseXrayConfig

func ParseXrayConfig(configLink string) (Protocol, error)

type Result

type Result struct {
	ConfigLink    string   `csv:"link"` // vmess://... vless//..., etc
	Protocol      Protocol `csv:"-"`
	Status        string   `csv:"status"`   // passed, semi-passed, failed
	TLS           string   `csv:"tls"`      // none, tls, reality
	RealIPAddr    string   `csv:"ip"`       // Real ip address (req to cloudflare.com/cdn-cgi/trace)
	Delay         int64    `csv:"delay"`    // millisecond
	DownloadSpeed float32  `csv:"download"` // mbps
	UploadSpeed   float32  `csv:"upload"`   // mbps
	IpAddrLoc     string   `csv:"location"` // IP address location
	IpAddrCity    string   `csv:"location"` // IP address location
}

type Service

type Service struct {
	Inbound Protocol

	// Log
	Verbose  bool
	LogType  applog.LogType
	LogLevel commlog.Severity

	AllowInsecure bool
}

func NewXrayService

func NewXrayService(verbose bool, allowInsecure bool, opts ...ServiceOption) *Service

func (*Service) MakeXrayInstance

func (x *Service) MakeXrayInstance(outbound Protocol) (*core.Instance, error)

type ServiceOption

type ServiceOption = func(c *Service)

func WithCustomLogLevel

func WithCustomLogLevel(logType applog.LogType, LogLevel commlog.Severity) ServiceOption

func WithInbound

func WithInbound(inbound Protocol) ServiceOption

type Shadowsocks

type Shadowsocks struct {
	Address    string
	Port       string
	Encryption string
	Password   string
	Remark     string
	OrigLink   string // Original link
}

func (*Shadowsocks) BuildInboundDetourConfig

func (s *Shadowsocks) BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)

func (*Shadowsocks) BuildOutboundDetourConfig

func (s *Shadowsocks) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)

func (*Shadowsocks) ConvertToGeneralConfig

func (s *Shadowsocks) ConvertToGeneralConfig() GeneralConfig

func (*Shadowsocks) DetailsStr

func (s *Shadowsocks) DetailsStr() string

func (*Shadowsocks) Parse

func (s *Shadowsocks) Parse(configLink string) error

type Socks

type Socks struct {
	Remark   string
	Address  string // HOST:PORT
	Port     string
	Username string // Username
	Password string // Password
	OrigLink string // Original link
}

func (*Socks) BuildInboundDetourConfig

func (s *Socks) BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)

func (*Socks) BuildOutboundDetourConfig

func (s *Socks) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)

func (*Socks) ConvertToGeneralConfig

func (s *Socks) ConvertToGeneralConfig() GeneralConfig

func (*Socks) DetailsStr

func (s *Socks) DetailsStr() string

func (*Socks) Parse

func (s *Socks) Parse(configLink string) error

type Subscription

type Subscription struct {
	Remark      string
	Url         string
	UserAgent   string
	Method      string
	ConfigLinks []string
}

TODO: Make a database to store subscriptions

func (*Subscription) FetchAll

func (s *Subscription) FetchAll() ([]string, error)

func (*Subscription) RemoveDuplicate

func (s *Subscription) RemoveDuplicate(verbose bool)

type Trojan

type Trojan struct {
	LinkVersion    string `json:"-"`
	Password       string // Password
	Address        string `json:"add"` // HOST:PORT
	Flow           string `json:"flow"`
	Security       string `json:"security"`   // tls
	HeaderType     string `json:"headerType"` // TCP HTTP Obfuscation
	Host           string `json:"host"`       // HTTP, WS
	Path           string `json:"path"`
	Port           string `json:"port"`
	SNI            string `json:"sni"`           // Server name indication
	ALPN           string `json:"alpn"`          // Application-Layer Protocol Negotiation
	TlsFingerprint string `json:"fp"`            // TLS fingerprint
	AllowInsecure  string `json:"allowInsecure"` // Insecure TLS
	Type           string `json:"type"`          // Network
	Remark         string // Config's name
	ServiceName    string `json:"serviceName"` // GRPC
	Mode           string `json:"mode"`        // GRPC
	OrigLink       string `json:"-"`           // Original link
}

func (*Trojan) BuildInboundDetourConfig

func (v *Trojan) BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)

func (*Trojan) BuildOutboundDetourConfig

func (t *Trojan) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)

func (*Trojan) ConvertToGeneralConfig

func (t *Trojan) ConvertToGeneralConfig() GeneralConfig

func (*Trojan) DetailsStr

func (t *Trojan) DetailsStr() string

func (*Trojan) Parse

func (t *Trojan) Parse(configLink string) error

type Vless

type Vless struct {
	LinkVersion    string `json:"-"`
	ID             string `json:"id"`  // UUID
	Address        string `json:"add"` // HOST:PORT
	Encryption     string `json:"encryption"`
	Flow           string `json:"flow"`
	Security       string `json:"security"` // reality or tls
	PublicKey      string `json:"pbk"`
	ShortIds       string `json:"sid"`        // Mandatory, the shortId list available to the client, which can be used to distinguish different clients
	SpiderX        string `json:"spx"`        // Reality path
	HeaderType     string `json:"headerType"` // TCP HTTP Obfuscation
	Host           string `json:"host"`       // HTTP, WS
	Path           string `json:"path"`
	Port           string `json:"port"`
	SNI            string `json:"sni"`         // Server name indication
	ALPN           string `json:"alpn"`        // Application-Layer Protocol Negotiation
	TlsFingerprint string `json:"fp"`          // TLS fingerprint
	Type           string `json:"type"`        // Network
	Remark         string `json:"ps"`          // Config's name
	ServiceName    string `json:"serviceName"` // GRPC
	Mode           string `json:"mode"`        // GRPC
	OrigLink       string `json:"-"`           // Original link
}

func (*Vless) BuildInboundDetourConfig

func (v *Vless) BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)

func (*Vless) BuildOutboundDetourConfig

func (v *Vless) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)

func (*Vless) ConvertToGeneralConfig

func (v *Vless) ConvertToGeneralConfig() GeneralConfig

func (*Vless) DetailsStr

func (v *Vless) DetailsStr() string

func (*Vless) Parse

func (v *Vless) Parse(configLink string) error

type Vmess

type Vmess struct {
	Version        interface{} `json:"v"`
	Address        string      `json:"add"`
	Aid            interface{} `json:"aid"` // AlterID
	Port           interface{} `json:"port"`
	Security       string      `json:"scy"`
	Host           string      `json:"host"`
	ID             string      `json:"id"`
	Network        string      `json:"net"`
	Path           string      `json:"path"`
	Remark         string      `json:"ps"` // Config's name
	TLS            string      `json:"tls"`
	AllowInsecure  interface{} `json:"allowinsecure"`
	SNI            string      `json:"sni"`  // Server name indication
	ALPN           string      `json:"alpn"` // Application-Layer Protocol Negotiation
	TlsFingerprint string      `json:"fp"`   // TLS fingerprint
	Type           string      `json:"type"` // Used for HTTP Obfuscation
	OrigLink       string      `json:"-"`    // Original link
}

func (*Vmess) BuildInboundDetourConfig

func (v *Vmess) BuildInboundDetourConfig() (*conf.InboundDetourConfig, error)

func (*Vmess) BuildOutboundDetourConfig

func (v *Vmess) BuildOutboundDetourConfig(allowInsecure bool) (*conf.OutboundDetourConfig, error)

func (*Vmess) ConvertToGeneralConfig

func (v *Vmess) ConvertToGeneralConfig() GeneralConfig

func (*Vmess) DetailsStr

func (v *Vmess) DetailsStr() string

func (*Vmess) Parse

func (v *Vmess) Parse(configLink string) error

Jump to

Keyboard shortcuts

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