parser

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllParsers

func GetAllParsers() map[string]ProxyParser

func GetAllPrefixes

func GetAllPrefixes() []string

func ParsePort

func ParsePort(portStr string) (int, error)

func ParseProxies

func ParseProxies(config ParseConfig, proxies ...string) ([]P.Proxy, error)

func ParseProxyWithRegistry

func ParseProxyWithRegistry(config ParseConfig, proxy string) (P.Proxy, error)

func RegisterParser

func RegisterParser(parser ProxyParser)

func SplitNRight

func SplitNRight(s, sep string, n int) []string

Types

type AnytlsParser

type AnytlsParser struct{}

func (*AnytlsParser) GetPrefixes

func (p *AnytlsParser) GetPrefixes() []string

func (*AnytlsParser) GetType

func (p *AnytlsParser) GetType() string

func (*AnytlsParser) Parse

func (p *AnytlsParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*AnytlsParser) SupportClash

func (p *AnytlsParser) SupportClash() bool

func (*AnytlsParser) SupportMeta

func (p *AnytlsParser) SupportMeta() bool

type Hysteria2Parser

type Hysteria2Parser struct{}

func (*Hysteria2Parser) GetPrefixes

func (p *Hysteria2Parser) GetPrefixes() []string

func (*Hysteria2Parser) GetType

func (p *Hysteria2Parser) GetType() string

func (*Hysteria2Parser) Parse

func (p *Hysteria2Parser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*Hysteria2Parser) SupportClash

func (p *Hysteria2Parser) SupportClash() bool

func (*Hysteria2Parser) SupportMeta

func (p *Hysteria2Parser) SupportMeta() bool

type HysteriaParser

type HysteriaParser struct{}

func (*HysteriaParser) GetPrefixes

func (p *HysteriaParser) GetPrefixes() []string

func (*HysteriaParser) GetType

func (p *HysteriaParser) GetType() string

func (*HysteriaParser) Parse

func (p *HysteriaParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*HysteriaParser) SupportClash

func (p *HysteriaParser) SupportClash() bool

func (*HysteriaParser) SupportMeta

func (p *HysteriaParser) SupportMeta() bool

type ParseConfig added in v1.0.0

type ParseConfig struct {
	UseUDP bool
}

type ParseErrorType

type ParseErrorType string
const (
	ErrInvalidPrefix     ParseErrorType = "invalid url prefix"
	ErrInvalidStruct     ParseErrorType = "invalid struct"
	ErrInvalidPort       ParseErrorType = "invalid port number"
	ErrCannotParseParams ParseErrorType = "cannot parse query parameters"
	ErrInvalidBase64     ParseErrorType = "invalid base64"
)

func (ParseErrorType) Error

func (e ParseErrorType) Error() string

type ProxyParser

type ProxyParser interface {
	Parse(config ParseConfig, proxy string) (P.Proxy, error)
	GetPrefixes() []string
	GetType() string
	SupportClash() bool
	SupportMeta() bool
}

func GetParser

func GetParser(prefix string) (ProxyParser, bool)

type ShadowsocksParser

type ShadowsocksParser struct{}

ShadowsocksParser Shadowsocks协议解析器

func (*ShadowsocksParser) GetPrefixes

func (p *ShadowsocksParser) GetPrefixes() []string

GetPrefixes 返回支持的协议前缀

func (*ShadowsocksParser) GetType

func (p *ShadowsocksParser) GetType() string

GetType 返回协议类型

func (*ShadowsocksParser) Parse

func (p *ShadowsocksParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

Parse 解析Shadowsocks代理

func (*ShadowsocksParser) SupportClash

func (p *ShadowsocksParser) SupportClash() bool

func (*ShadowsocksParser) SupportMeta

func (p *ShadowsocksParser) SupportMeta() bool

type ShadowsocksRParser

type ShadowsocksRParser struct{}

func (*ShadowsocksRParser) GetPrefixes

func (p *ShadowsocksRParser) GetPrefixes() []string

func (*ShadowsocksRParser) GetType

func (p *ShadowsocksRParser) GetType() string

func (*ShadowsocksRParser) Parse

func (p *ShadowsocksRParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*ShadowsocksRParser) SupportClash

func (p *ShadowsocksRParser) SupportClash() bool

func (*ShadowsocksRParser) SupportMeta

func (p *ShadowsocksRParser) SupportMeta() bool

type SocksParser

type SocksParser struct{}

func (*SocksParser) GetPrefixes

func (p *SocksParser) GetPrefixes() []string

func (*SocksParser) GetType

func (p *SocksParser) GetType() string

func (*SocksParser) Parse

func (p *SocksParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*SocksParser) SupportClash

func (p *SocksParser) SupportClash() bool

func (*SocksParser) SupportMeta

func (p *SocksParser) SupportMeta() bool

type TrojanParser

type TrojanParser struct{}

func (*TrojanParser) GetPrefixes

func (p *TrojanParser) GetPrefixes() []string

func (*TrojanParser) GetType

func (p *TrojanParser) GetType() string

func (*TrojanParser) Parse

func (p *TrojanParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*TrojanParser) SupportClash

func (p *TrojanParser) SupportClash() bool

func (*TrojanParser) SupportMeta

func (p *TrojanParser) SupportMeta() bool

type VlessParser

type VlessParser struct{}

func (*VlessParser) GetPrefixes

func (p *VlessParser) GetPrefixes() []string

func (*VlessParser) GetType

func (p *VlessParser) GetType() string

func (*VlessParser) Parse

func (p *VlessParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*VlessParser) SupportClash

func (p *VlessParser) SupportClash() bool

func (*VlessParser) SupportMeta

func (p *VlessParser) SupportMeta() bool

type VmessJson

type VmessJson struct {
	V    any    `json:"v"`
	Ps   string `json:"ps"`
	Add  string `json:"add"`
	Port any    `json:"port"`
	Id   string `json:"id"`
	Aid  any    `json:"aid"`
	Scy  string `json:"scy"`
	Net  string `json:"net"`
	Type string `json:"type"`
	Host string `json:"host"`
	Path string `json:"path"`
	Tls  string `json:"tls"`
	Sni  string `json:"sni"`
	Alpn string `json:"alpn"`
	Fp   string `json:"fp"`
}

type VmessParser

type VmessParser struct{}

func (*VmessParser) GetPrefixes

func (p *VmessParser) GetPrefixes() []string

func (*VmessParser) GetType

func (p *VmessParser) GetType() string

func (*VmessParser) Parse

func (p *VmessParser) Parse(config ParseConfig, proxy string) (P.Proxy, error)

func (*VmessParser) SupportClash

func (p *VmessParser) SupportClash() bool

func (*VmessParser) SupportMeta

func (p *VmessParser) SupportMeta() bool

Jump to

Keyboard shortcuts

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