interfaces

package
v0.0.0-...-803134e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MFTPingRTT     = "PingRTT"
	MFTPingRequest = "PingRequest"

	MFTNATType = "NATType"
)

Variables

Functions

func Valid

func Valid(proxyType ProxyType) bool

Types

type AverageSpeedDS

type AverageSpeedDS struct {
	Value uint64
}

type GeoInfo

type GeoInfo struct {
	Org           string  `json:"organization"`
	Lon           float32 `json:"longitude"`
	Lat           float32 `json:"latitude"`
	TimeZone      string  `json:"timezone"`
	ISP           string  `json:"isp"`
	ASN           int     `json:"asn"`
	ASNOrg        string  `json:"asn_organization"`
	Country       string  `json:"country"`
	IP            string  `json:"ip"`
	ContinentCode string  `json:"continent_code"`
	CountryCode   string  `json:"country_code"`

	StackType string `json:"stackType"`
}

func (*GeoInfo) IsV6

func (gi *GeoInfo) IsV6() bool

type HTTPPingDS

type HTTPPingDS struct {
	Value uint16
}

type IPStacks

type IPStacks struct {
	IPv4 []string
	IPv6 []string
}

func (*IPStacks) Count

func (ips *IPStacks) Count() int

func (*IPStacks) Init

func (ips *IPStacks) Init() *IPStacks

type InboundGeoIPDS

type InboundGeoIPDS struct {
	MultiStacks
}

type InvalidDS

type InvalidDS struct{}

type MacroFieldType

type MacroFieldType string

type MatrixResponse

type MatrixResponse struct {
	Type    SlaveRequestMatrixType
	Payload string
}

type MaxSpeedDS

type MaxSpeedDS struct {
	Value uint64
}

type MultiStacks

type MultiStacks struct {
	Domain    string   // 域组,作为 In 时为域名,Out 时则为线路本身
	MainStack *GeoInfo // deprecating
	IPv4Stack []*GeoInfo
	IPv6Stack []*GeoInfo
}

func (*MultiStacks) Count

func (tms *MultiStacks) Count() int

func (*MultiStacks) First

func (tms *MultiStacks) First(tag string) *GeoInfo

func (*MultiStacks) FirstV2

func (tms *MultiStacks) FirstV2(tag string) *GeoInfo

func (*MultiStacks) ForEach

func (tms *MultiStacks) ForEach(assignedMain *GeoInfo) map[int][]*GeoInfo

func (*MultiStacks) Repr

func (tms *MultiStacks) Repr() string

func (*MultiStacks) V46StackCount

func (tms *MultiStacks) V46StackCount() (int, int)

func (*MultiStacks) V46StackInfo

func (tms *MultiStacks) V46StackInfo() string

type OutboundGeoIPDS

type OutboundGeoIPDS struct {
	MultiStacks
}

type PerSecondSpeedDS

type PerSecondSpeedDS struct {
	Max     uint64
	Average uint64
	Speeds  []uint64
}

type ProxyInfo

type ProxyInfo struct {
	Name    string
	Address string
	Type    ProxyType
}

func (*ProxyInfo) Map

func (pi *ProxyInfo) Map() map[string]string

type ProxyType

type ProxyType string
const (
	Shadowsocks  ProxyType = "Shadowsocks"
	ShadowsocksR ProxyType = "ShadowsocksR"
	Snell        ProxyType = "Snell"
	Socks5       ProxyType = "Socks5"
	Http         ProxyType = "Http"
	Vmess        ProxyType = "Vmess"
	Trojan       ProxyType = "Trojan"

	Vless     ProxyType = "Vless"
	Hysteria  ProxyType = "Hysteria"
	Hysteria2 ProxyType = "Hysteria2"
	Tuic      ProxyType = "Tuic"

	ProxyInvalid ProxyType = "Invalid"
)

func Parse

func Parse(proxyType string) ProxyType

type RTTPingDS

type RTTPingDS struct {
	Value uint16
}

type RequestOptions

type RequestOptions struct {
	Method  string
	URL     string
	Headers map[string]string
	Cookies map[string]string
	Body    []byte
	NoRedir bool
	Network RequestOptionsNetwork
}

type RequestOptionsNetwork

type RequestOptionsNetwork string
const (
	ROptionsTCP  RequestOptionsNetwork = "tcp"
	ROptionsTCP6 RequestOptionsNetwork = "tcp6"
)

func (*RequestOptionsNetwork) String

func (ron *RequestOptionsNetwork) String() string

type Script

type Script struct {
	ID            string     `yaml:"-" fw:"readonly"`
	Type          ScriptType `yaml:"type"`
	Content       string     `yaml:"content"`
	TimeoutMillis uint64     `yaml:"timeout,omitempty"`
}

type ScriptResult

type ScriptResult struct {
	Text        string
	Color       string
	Background  string
	TimeElapsed int64
}

func (*ScriptResult) Clone

func (sr *ScriptResult) Clone() *ScriptResult

type ScriptTestDS

type ScriptTestDS struct {
	Key string
	ScriptResult
}

type ScriptType

type ScriptType string
const (
	STypeMedia ScriptType = "media"
	STypeIP    ScriptType = "ip"
)

type SlaveEntrySlot

type SlaveEntrySlot struct {
	Grouping       string
	ProxyInfo      ProxyInfo
	InvokeDuration int64
	Matrices       []MatrixResponse
}

func (*SlaveEntrySlot) Get

func (ses *SlaveEntrySlot) Get(idx int) *MatrixResponse

type SlaveProgress

type SlaveProgress struct {
	Index   int
	Record  SlaveEntrySlot
	Queuing int
}

type SlaveRequest

type SlaveRequest struct {
	Basics  SlaveRequestBasics
	Options SlaveRequestOptions
	Configs SlaveRequestConfigs

	Vendor VendorType
	Nodes  []SlaveRequestNode

	RandomSequence string
	Challenge      string
}

func (*SlaveRequest) Clone

func (sr *SlaveRequest) Clone() *SlaveRequest

type SlaveRequestBasics

type SlaveRequestBasics struct {
	ID        string
	Slave     string
	SlaveName string
	Invoker   string
	Version   string
}

func (*SlaveRequestBasics) Clone

func (srb *SlaveRequestBasics) Clone() *SlaveRequestBasics

type SlaveRequestConfigs

type SlaveRequestConfigs struct {
	STUNURL           string `yaml:"stunURL,omitempty" cf:"name=🫙 STUN 地址"`
	DownloadURL       string `yaml:"downloadURL,omitempty" cf:"name=📃 测速文件"`
	DownloadDuration  int64  `yaml:"downloadDuration,omitempty" cf:"name=⏱️ 测速时长 (单位: 秒)"`
	DownloadThreading uint   `yaml:"downloadThreading,omitempty" cf:"name=🧶 测速线程数"`

	PingAverageOver uint16 `yaml:"pingAverageOver,omitempty" cf:"name=🧮 多次 Ping 求均值,value"`
	PingAddress     string `yaml:"pingAddress,omitempty" cf:"name=🏫 URL Ping 地址"`

	TaskRetry  uint     `yaml:"taskRetry,omitempty" cf:"name=🐛 测试重试次数"`
	DNSServers []string `yaml:"dnsServers,omitempty" cf:"name=💾 自定义DNS服务器,childvalue"`

	TaskTimeout uint     `yaml:"-" fw:"readonly"`
	Scripts     []Script `yaml:"-" fw:"readonly"`
}

func (*SlaveRequestConfigs) Check

func (*SlaveRequestConfigs) Clone

func (*SlaveRequestConfigs) DescriptionText

func (src *SlaveRequestConfigs) DescriptionText() string

func (*SlaveRequestConfigs) Merge

type SlaveRequestMacro

type SlaveRequestMacro interface {
	// define the macro type to match
	Type() SlaveRequestMacroType

	// define the task for the macro,
	Run(proxy Vendor, request *SlaveRequest) error
}

Macro is the atom runner for a job. Since some matrices could be combined, e.g. HTTPPing / RTTPing, so instead of triggering two similar jobs, we only run a macro job once and return attributes for multiple matrices

type SlaveRequestMacroType

type SlaveRequestMacroType string
const (
	MacroSpeed SlaveRequestMacroType = "SPEED"

	MacroPing   SlaveRequestMacroType = "PING"
	MacroUDP    SlaveRequestMacroType = "UDP"
	MacroScript SlaveRequestMacroType = "SCRIPT"
	MacroGeo    SlaveRequestMacroType = "GEO"

	MacroInvalid SlaveRequestMacroType = "INVALID"
)

type SlaveRequestMatrix

type SlaveRequestMatrix interface {
	// define the matrix type to match
	Type() SlaveRequestMatrixType

	// define which macro job to run
	MacroJob() SlaveRequestMacroType

	// define the function to extract attribute
	// from macro result
	Extract(SlaveRequestMatrixEntry, SlaveRequestMacro)
}

Matrix is the the atom attribute for a job e.g. to fetch the RTTPing of a node, it calls RTTPing matrix, which would initiate a ping macro and return the RTTPing attribute

type SlaveRequestMatrixEntry

type SlaveRequestMatrixEntry struct {
	Type   SlaveRequestMatrixType
	Params string
}

type SlaveRequestMatrixType

type SlaveRequestMatrixType string
const (
	MatrixAverageSpeed   SlaveRequestMatrixType = "SPEED_AVERAGE"
	MatrixMaxSpeed       SlaveRequestMatrixType = "SPEED_MAX"
	MatrixPerSecondSpeed SlaveRequestMatrixType = "SPEED_PER_SECOND"

	MatrixUDPType SlaveRequestMatrixType = "UDP_TYPE"

	MatrixInboundGeoIP  SlaveRequestMatrixType = "GEOIP_INBOUND"
	MatrixOutboundGeoIP SlaveRequestMatrixType = "GEOIP_OUTBOUND"

	MatrixScriptTest SlaveRequestMatrixType = "TEST_SCRIPT"
	MatrixHTTPPing   SlaveRequestMatrixType = "TEST_PING_CONN"
	MatrixRTTPing    SlaveRequestMatrixType = "TEST_PING_RTT"

	MatrixInvalid SlaveRequestMatrixType = "INVALID"
)

func (*SlaveRequestMatrixType) Valid

func (srmt *SlaveRequestMatrixType) Valid() bool

type SlaveRequestNode

type SlaveRequestNode struct {
	Name    string
	Payload string
}

func (*SlaveRequestNode) Clone

func (srn *SlaveRequestNode) Clone() *SlaveRequestNode

type SlaveRequestOptions

type SlaveRequestOptions struct {
	Filter   string
	Matrices []SlaveRequestMatrixEntry
}

func (*SlaveRequestOptions) Clone

type SlaveResponse

type SlaveResponse struct {
	ID               string
	MiaoSpeedVersion string

	Error    string
	Result   *SlaveTask
	Progress *SlaveProgress
}

type SlaveTask

type SlaveTask struct {
	Request SlaveRequest
	Results []SlaveEntrySlot
}

type UDPTypeDS

type UDPTypeDS struct {
	Value string
}

type Vendor

type Vendor interface {
	// returns the type of the vendor
	Type() VendorType

	// returns the status of the vendor
	Status() VendorStatus

	// build conn based on proxy info string
	Build(proxyName string, proxyInfo string) Vendor

	// tcp connections
	DialTCP(ctx context.Context, url string, network RequestOptionsNetwork) (net.Conn, error)

	// udp connections
	DialUDP(ctx context.Context, url string) (net.PacketConn, error)

	// return universal proxy info
	ProxyInfo() ProxyInfo
}

a Vendor is an interface that allow macros to trigger connections from

type VendorStatus

type VendorStatus uint
const (
	VStatusOperational VendorStatus = iota

	VStatusNotReady
)

type VendorType

type VendorType string
const (
	VendorLocal VendorType = "Local"
	VendorClash VendorType = "Clash"

	VendorInvalid VendorType = "Invalid"
)

Jump to

Keyboard shortcuts

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