adapter

package
v0.0.0-...-98358cc Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MPL-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedType = errors.New("unsupported type")
	ErrEmptyDate       = errors.New("empty date")
)
View Source
var (
	ErrCacheNotFound = errors.New("cache not found")
)

Functions

func Base64Decode

func Base64Decode(s string) string

func NewProxyDirect

func NewProxyDirect() constant.Proxy

Types

type AdapterCache

type AdapterCache struct {
	// contains filtered or unexported fields
}

func (*AdapterCache) Del

func (p *AdapterCache) Del(key string)

func (*AdapterCache) Load

func (p *AdapterCache) Load(key string) (any, error)

func (*AdapterCache) LoadBool

func (p *AdapterCache) LoadBool(key string) bool

func (*AdapterCache) LoadFloat64

func (p *AdapterCache) LoadFloat64(key string) float64

func (*AdapterCache) LoadUint16

func (p *AdapterCache) LoadUint16(key string) uint16

func (*AdapterCache) Reset

func (p *AdapterCache) Reset()

func (*AdapterCache) Store

func (p *AdapterCache) Store(key string, val any)

type AdapterProxy

type AdapterProxy interface {
	constant.Proxy
	Cache

	HostName() string
	Port() string

	Sub4Nico() string
	Sub4Clash() string
	Sub4V2ray() string

	ToNico() map[string]any

	UniqueId() string
	UniqueIdShort() string

	GenDialContext(u *url.URL) (constant.Conn, error)

	GetClient() *http.Client

	DoRequest(method, rawUrl string, body io.Reader, timeout time.Duration, headers map[string]string, logic func(resp *http.Response, start time.Time) error) error

	Get(url string, timeout time.Duration, headers map[string]string) ([]byte, error)

	GetTotalUpload() uint64
	GetTotalDownload() uint64
}

type AdapterType

type AdapterType int
const (
	Direct AdapterType = iota
	Reject
	Proxy
)

func CoverAdapterType

func CoverAdapterType(at constant.AdapterType) AdapterType

func ParseAdapterType

func ParseAdapterType(at string) AdapterType

func (AdapterType) String

func (at AdapterType) String() string

type Cache

type Cache interface {
	Reset()

	Store(key string, val any)

	Load(key string) (val any, err error)
	LoadBool(key string) bool
	LoadUint16(key string) uint16
	LoadFloat64(key string) float64

	Del(key string)
}

func NewAdapterCache

func NewAdapterCache() Cache

type DisneyUnlockInfo

type DisneyUnlockInfo struct {
	Unlocked bool   `json:"unlocked,omitempty"`
	Region   string `json:"region,omitempty"`
}

func (DisneyUnlockInfo) String

func (p DisneyUnlockInfo) String() string

type ExtraInfo

type ExtraInfo struct {
	Country      string `json:"country,omitempty"`
	Region       string `json:"region,omitempty"`
	City         string `json:"city,omitempty"`
	CountryCode  string `json:"country_code,omitempty"`
	CountryEmoji string `json:"country_emoji,omitempty"`

	Delay time.Duration `json:"delay,omitempty"`

	/*
		-1 无法访问
		-2 被重定向
		-3 读取包失败
	*/
	GoogleDelay time.Duration `json:"google,omitempty"`

	DownloadSpeed *SpeedInfo `json:"download_speed,omitempty"`
	UploadSpeed   *SpeedInfo `json:"upload_speed,omitempty"`

	NetflixUnlock *NetflixUnlockInfo `json:"netflix_unlock,omitempty"`
	DisneyUnlock  *DisneyUnlockInfo  `json:"disney_unlock,omitempty"`
	YoutubeUnlock *YoutubeUnlockInfo `json:"youtube_unlock,omitempty"`

	InBound *IpInfo `json:"in_bound,omitempty"`
	OutIpv4 *IpInfo `json:"out_ipv4,omitempty"`
	OutIpv6 *IpInfo `json:"out_ipv6,omitempty"`
	// contains filtered or unexported fields
}

func ParseClash4Extra

func ParseClash4Extra(m map[string]any) ExtraInfo

func (*ExtraInfo) GenNameTpl

func (p *ExtraInfo) GenNameTpl() string

CountryEmoji Country-Region-City Name

func (*ExtraInfo) GetDisneyUnlock

func (p *ExtraInfo) GetDisneyUnlock() *DisneyUnlockInfo

func (*ExtraInfo) GetDownloadSpeed

func (p *ExtraInfo) GetDownloadSpeed() *SpeedInfo

func (*ExtraInfo) GetGoogleDelay

func (p *ExtraInfo) GetGoogleDelay() time.Duration

func (*ExtraInfo) GetInBound

func (p *ExtraInfo) GetInBound() *IpInfo

func (*ExtraInfo) GetNetflixUnlock

func (p *ExtraInfo) GetNetflixUnlock() *NetflixUnlockInfo

func (*ExtraInfo) GetOutIpv4

func (p *ExtraInfo) GetOutIpv4() *IpInfo

func (*ExtraInfo) GetOutIpv6

func (p *ExtraInfo) GetOutIpv6() *IpInfo

func (*ExtraInfo) GetUploadSpeed

func (p *ExtraInfo) GetUploadSpeed() *SpeedInfo

func (*ExtraInfo) GetYouTubeUnlock

func (p *ExtraInfo) GetYouTubeUnlock() *YoutubeUnlockInfo

func (*ExtraInfo) SetDisneyUnlock

func (p *ExtraInfo) SetDisneyUnlock(s *DisneyUnlockInfo)

func (*ExtraInfo) SetDownloadSpeed

func (p *ExtraInfo) SetDownloadSpeed(s *SpeedInfo)

func (*ExtraInfo) SetGoogleDelay

func (p *ExtraInfo) SetGoogleDelay(d time.Duration)

func (*ExtraInfo) SetInBound

func (p *ExtraInfo) SetInBound(s *IpInfo)

func (*ExtraInfo) SetNetflixUnlock

func (p *ExtraInfo) SetNetflixUnlock(s *NetflixUnlockInfo)

func (*ExtraInfo) SetOutIpv4

func (p *ExtraInfo) SetOutIpv4(s *IpInfo)

func (*ExtraInfo) SetOutIpv6

func (p *ExtraInfo) SetOutIpv6(s *IpInfo)

func (*ExtraInfo) SetUploadSpeed

func (p *ExtraInfo) SetUploadSpeed(s *SpeedInfo)

func (*ExtraInfo) SetYouTubeUnlock

func (p *ExtraInfo) SetYouTubeUnlock(s *YoutubeUnlockInfo)

type IpInfo

type IpInfo struct {
	Continent     string  `json:"continent,omitempty"`
	ContinentCode string  `json:"continentCode,omitempty"`
	Country       string  `json:"country,omitempty"`
	CountryCode   string  `json:"countryCode,omitempty"`
	Region        string  `json:"region,omitempty"`
	RegionName    string  `json:"regionName,omitempty"`
	City          string  `json:"city,omitempty"`
	District      string  `json:"district,omitempty"`
	Zip           string  `json:"zip,omitempty"`
	Lat           float64 `json:"lat,omitempty"`
	Lon           float64 `json:"lon,omitempty"`
	Timezone      string  `json:"timezone,omitempty"`
	Offset        int     `json:"offset,omitempty"`
	Currency      string  `json:"currency,omitempty"`
	Isp           string  `json:"isp,omitempty"`
	Org           string  `json:"org,omitempty"`
	As            string  `json:"as.,omitempty"`
	Asname        string  `json:"asname,omitempty"`
	Reverse       string  `json:"reverse,omitempty"`
	Mobile        bool    `json:"mobile,omitempty"`
	Proxy         bool    `json:"proxy,omitempty"`
	Hosting       bool    `json:"hosting,omitempty"`
	Query         string  `json:"query,omitempty"`
}

func (IpInfo) IspInfo

func (p IpInfo) IspInfo() string

func (IpInfo) String

func (p IpInfo) String() string

type MITM

type MITM struct {
	Has bool `json:"has,omitempty"`
}

中间人攻击相关的

type NetflixUnlockInfo

type NetflixUnlockInfo struct {
	// 自制剧解锁
	SelfMadeUnlock bool `json:"self_made_unlock,omitempty"`
	// 非自制剧解锁
	NonSelfMadeUnlock bool   `json:"non_self_made_unlock,omitempty"`
	Region            string `json:"region,omitempty"`
	MITM              MITM   `json:"mitm,omitempty"`
}

func (NetflixUnlockInfo) GetCountryCode

func (p NetflixUnlockInfo) GetCountryCode() string

func (NetflixUnlockInfo) String

func (p NetflixUnlockInfo) String() string

type ProxyAdapter

type ProxyAdapter struct {
	constant.Proxy
	Cache
	ExtraInfo
	// contains filtered or unexported fields
}

func NewProxyAdapter

func NewProxyAdapter(adapter constant.Proxy, opt any) (*ProxyAdapter, error)

func ParseClash

func ParseClash(m map[string]any) (*ProxyAdapter, error)

func ParseClashJson

func ParseClashJson(s []byte) (*ProxyAdapter, error)

func ParseClashYaml

func ParseClashYaml(s []byte) (*ProxyAdapter, error)

func ParseLinkHttp

func ParseLinkHttp(s string) (*ProxyAdapter, error)

func ParseLinkNico

func ParseLinkNico(s string) (*ProxyAdapter, error)

func ParseLinkSS

func ParseLinkSS(s string) (*ProxyAdapter, error)

func ParseLinkSSR

func ParseLinkSSR(s string) (*ProxyAdapter, error)

func ParseLinkSocket5

func ParseLinkSocket5(s string) (*ProxyAdapter, error)

func ParseLinkTrojan

func ParseLinkTrojan(s string) (*ProxyAdapter, error)

func ParseLinkVmess

func ParseLinkVmess(s string) (*ProxyAdapter, error)

func ParseV2ray

func ParseV2ray(s string) (*ProxyAdapter, error)

func (*ProxyAdapter) CheckInBound

func (p *ProxyAdapter) CheckInBound() *IpInfo

func (*ProxyAdapter) CheckIpv4

func (p *ProxyAdapter) CheckIpv4() *IpInfo

func (*ProxyAdapter) CheckIpv6

func (p *ProxyAdapter) CheckIpv6() *IpInfo

func (*ProxyAdapter) Clone

func (p *ProxyAdapter) Clone() *ProxyAdapter

func (*ProxyAdapter) DisneyUnlockTest

func (p *ProxyAdapter) DisneyUnlockTest()

func (*ProxyAdapter) DoRequest

func (p *ProxyAdapter) DoRequest(method, rawUrl string, body io.Reader, timeout time.Duration, headers map[string]string, logic func(resp *http.Response, start time.Time) error) error

func (*ProxyAdapter) DownloadSpeedTest

func (p *ProxyAdapter) DownloadSpeedTest(max int) (int64, error)

固定时间测试

func (*ProxyAdapter) GenDialContext

func (p *ProxyAdapter) GenDialContext(u *url.URL) (constant.Conn, error)

func (*ProxyAdapter) Get

func (p *ProxyAdapter) Get(url string, timeout time.Duration, headers map[string]string) ([]byte, error)

func (*ProxyAdapter) GetClient

func (p *ProxyAdapter) GetClient() *http.Client

func (*ProxyAdapter) GetTicker

func (p *ProxyAdapter) GetTicker() *TotalTracker

func (*ProxyAdapter) GetTotalDownload

func (p *ProxyAdapter) GetTotalDownload() uint64

func (*ProxyAdapter) GetTotalUpload

func (p *ProxyAdapter) GetTotalUpload() uint64

func (*ProxyAdapter) GoogleTest

func (p *ProxyAdapter) GoogleTest() (time.Duration, error)

func (*ProxyAdapter) HostName

func (p *ProxyAdapter) HostName() string

func (*ProxyAdapter) Name

func (p *ProxyAdapter) Name() string

func (*ProxyAdapter) NetflixUnlockTest

func (p *ProxyAdapter) NetflixUnlockTest()

func (*ProxyAdapter) Port

func (p *ProxyAdapter) Port() string

func (*ProxyAdapter) RegisterTotalTracker

func (p *ProxyAdapter) RegisterTotalTracker(tracker Tracker) *ProxyAdapter

func (*ProxyAdapter) Security

func (p *ProxyAdapter) Security() string

func (*ProxyAdapter) SetName

func (p *ProxyAdapter) SetName(name string) *ProxyAdapter

func (*ProxyAdapter) Sub4Clash

func (p *ProxyAdapter) Sub4Clash() string

func (*ProxyAdapter) Sub4Nico

func (p *ProxyAdapter) Sub4Nico() string

func (*ProxyAdapter) Sub4V2ray

func (p *ProxyAdapter) Sub4V2ray() string

func (*ProxyAdapter) ToClash

func (p *ProxyAdapter) ToClash() map[string]any

func (*ProxyAdapter) ToNico

func (p *ProxyAdapter) ToNico() map[string]any
func (p *ProxyAdapter) ToNicoLink() string

func (*ProxyAdapter) UniqueId

func (p *ProxyAdapter) UniqueId() string

func (*ProxyAdapter) UniqueIdShort

func (p *ProxyAdapter) UniqueIdShort() string

func (*ProxyAdapter) UploadSpeedTest

func (p *ProxyAdapter) UploadSpeedTest(max int) (int64, error)

func (*ProxyAdapter) YoutubeUnlockTest

func (p *ProxyAdapter) YoutubeUnlockTest()

type ProxyDirect

type ProxyDirect struct {
	*outbound.Direct
}

func (*ProxyDirect) Alive

func (p *ProxyDirect) Alive() bool

func (*ProxyDirect) DelayHistory

func (p *ProxyDirect) DelayHistory() []constant.DelayHistory

func (*ProxyDirect) Dial

func (p *ProxyDirect) Dial(metadata *constant.Metadata) (constant.Conn, error)

func (*ProxyDirect) DialUDP

func (p *ProxyDirect) DialUDP(metadata *constant.Metadata) (constant.PacketConn, error)

func (*ProxyDirect) Health

func (p *ProxyDirect) Health() float64

func (*ProxyDirect) HealthCheck

func (p *ProxyDirect) HealthCheck(ctx context.Context)

func (*ProxyDirect) LastDelay

func (p *ProxyDirect) LastDelay() uint16

func (*ProxyDirect) LastSpeed

func (p *ProxyDirect) LastSpeed() int64

func (*ProxyDirect) URLTest

func (p *ProxyDirect) URLTest(ctx context.Context, url string) (uint16, error)

type ProxyList

type ProxyList []AdapterProxy

func (ProxyList) All

func (ss ProxyList) All(fn func(value AdapterProxy) bool) bool

All will return true if all callbacks return true. It follows the same logic as the all() function in Python.

If the list is empty then true is always returned.

func (ProxyList) Any

func (ss ProxyList) Any(fn func(value AdapterProxy) bool) bool

Any will return true if any callbacks return true. It follows the same logic as the any() function in Python.

If the list is empty then false is always returned.

func (ProxyList) Append

func (ss ProxyList) Append(elements ...AdapterProxy) ProxyList

Append will return a new slice with the elements appended to the end.

It is acceptable to provide zero arguments.

func (ProxyList) Bottom

func (ss ProxyList) Bottom(n int) (top ProxyList)

Bottom will return n elements from bottom

that means that elements is taken from the end of the slice for this [1,2,3] slice with n == 2 will be returned [3,2] if the slice has less elements then n that'll return all elements if n < 0 it'll return empty slice.

func (ProxyList) Contains

func (ss ProxyList) Contains(lookingFor AdapterProxy) bool

Contains returns true if the element exists in the slice.

When using slices of pointers it will only compare by address, not value.

func (ProxyList) Diff

func (ss ProxyList) Diff(against ProxyList) (added, removed ProxyList)

Diff returns the elements that needs to be added or removed from the first slice to have the same elements in the second slice.

The order of elements is not taken into consideration, so the slices are treated sets that allow duplicate items.

The added and removed returned may be blank respectively, or contain upto as many elements that exists in the largest slice.

func (ProxyList) DropTop

func (ss ProxyList) DropTop(n int) (drop ProxyList)

DropTop will return the rest slice after dropping the top n elements if the slice has less elements then n that'll return empty slice if n < 0 it'll return empty slice.

func (ProxyList) DropWhile

func (ss ProxyList) DropWhile(f func(s AdapterProxy) bool) (ss2 ProxyList)

Drop items from the slice while f(item) is true. Afterwards, return every element until the slice is empty. It follows the same logic as the dropwhile() function from itertools in Python.

func (ProxyList) Each

func (ss ProxyList) Each(fn func(AdapterProxy)) ProxyList

Each is more condensed version of Transform that allows an action to happen on each elements and pass the original slice on.

cars.Each(func (car *Car) {
    fmt.Printf("Car color is: %s\n", car.Color)
})

Pie will not ensure immutability on items passed in so they can be manipulated, if you choose to do it this way, for example:

// Set all car colors to Red.
cars.Each(func (car *Car) {
    car.Color = "Red"
})

func (ProxyList) Equals

func (ss ProxyList) Equals(rhs ProxyList) bool

Equals compare elements from the start to the end,

if they are the same is considered the slices are equal if all elements are the same is considered the slices are equal if each slice == nil is considered that they're equal

if element realizes Equals interface it uses that method, in other way uses default compare

func (ProxyList) Extend

func (ss ProxyList) Extend(slices ...ProxyList) (ss2 ProxyList)

Extend will return a new slice with the slices of elements appended to the end.

It is acceptable to provide zero arguments.

func (ProxyList) Filter

func (ss ProxyList) Filter(condition func(AdapterProxy) bool) (ss2 ProxyList)

Filter will return a new slice containing only the elements that return true from the condition. The returned slice may contain zero elements (nil).

FilterNot works in the opposite way of Filter.

func (ProxyList) FilterNot

func (ss ProxyList) FilterNot(condition func(AdapterProxy) bool) (ss2 ProxyList)

FilterNot works the same as Filter, with a negated condition. That is, it will return a new slice only containing the elements that returned false from the condition. The returned slice may contain zero elements (nil).

func (ProxyList) FindFirstUsing

func (ss ProxyList) FindFirstUsing(fn func(value AdapterProxy) bool) int

FindFirstUsing will return the index of the first element when the callback returns true or -1 if no element is found. It follows the same logic as the findIndex() function in Javascript.

If the list is empty then -1 is always returned.

func (ProxyList) First

func (ss ProxyList) First() AdapterProxy

First returns the first element, or zero. Also see FirstOr().

func (ProxyList) FirstOr

func (ss ProxyList) FirstOr(defaultValue AdapterProxy) AdapterProxy

FirstOr returns the first element or a default value if there are no elements.

func (ProxyList) Float64s

func (ss ProxyList) Float64s() pie.Float64s

Float64s transforms each element to a float64.

func (ProxyList) Insert

func (ss ProxyList) Insert(index int, values ...AdapterProxy) ProxyList

Insert a value at an index

func (ProxyList) Ints

func (ss ProxyList) Ints() pie.Ints

Ints transforms each element to an integer.

func (ProxyList) JSONBytes

func (ss ProxyList) JSONBytes() []byte

JSONBytes returns the JSON encoded array as bytes.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (ProxyList) JSONBytesIndent

func (ss ProxyList) JSONBytesIndent(prefix, indent string) []byte

JSONBytesIndent returns the JSON encoded array as bytes with indent applied.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array. See json.MarshalIndent for details.

func (ProxyList) JSONString

func (ss ProxyList) JSONString() string

JSONString returns the JSON encoded array as a string.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array.

func (ProxyList) JSONStringIndent

func (ss ProxyList) JSONStringIndent(prefix, indent string) string

JSONStringIndent returns the JSON encoded array as a string with indent applied.

One important thing to note is that it will treat a nil slice as an empty slice to ensure that the JSON value return is always an array. See json.MarshalIndent for details.

func (ProxyList) Join

func (ss ProxyList) Join(glue string) (s string)

Join returns a string from joining each of the elements.

func (ProxyList) Last

func (ss ProxyList) Last() AdapterProxy

Last returns the last element, or zero. Also see LastOr().

func (ProxyList) LastOr

func (ss ProxyList) LastOr(defaultValue AdapterProxy) AdapterProxy

LastOr returns the last element or a default value if there are no elements.

func (ProxyList) Len

func (ss ProxyList) Len() int

Len returns the number of elements.

func (ProxyList) Map

func (ss ProxyList) Map(fn func(AdapterProxy) AdapterProxy) (ss2 ProxyList)

Map will return a new slice where each element has been mapped (transformed). The number of elements returned will always be the same as the input.

Be careful when using this with slices of pointers. If you modify the input value it will affect the original slice. Be sure to return a new allocated object or deep copy the existing one.

func (ProxyList) Mode

func (ss ProxyList) Mode() ProxyList

Mode returns a new slice containing the most frequently occuring values.

The number of items returned may be the same as the input or less. It will never return zero items unless the input slice has zero items.

func (*ProxyList) Pop

func (ss *ProxyList) Pop() (popped *AdapterProxy)

Pop the first element of the slice

Usage Example:

type knownGreetings []string
greetings := knownGreetings{"ciao", "hello", "hola"}
for greeting := greetings.Pop(); greeting != nil; greeting = greetings.Pop() {
    fmt.Println(*greeting)
}

func (ProxyList) Random

func (ss ProxyList) Random(source rand.Source) AdapterProxy

Random returns a random element by your rand.Source, or zero

func (ProxyList) Reverse

func (ss ProxyList) Reverse() ProxyList

Reverse returns a new copy of the slice with the elements ordered in reverse. This is useful when combined with Sort to get a descending sort order:

ss.Sort().Reverse()

func (ProxyList) Send

func (ss ProxyList) Send(ctx context.Context, ch chan<- AdapterProxy) ProxyList

Send sends elements to channel in normal act it sends all elements but if func canceled it can be less

it locks execution of gorutine it doesn't close channel after work returns sended elements if len(this) != len(old) considered func was canceled

func (ProxyList) SequenceUsing

func (ss ProxyList) SequenceUsing(creator func(int) AdapterProxy, params ...int) ProxyList

SequenceUsing generates slice in range using creator function

There are 3 variations to generate:

  1. [0, n).
  2. [min, max).
  3. [min, max) with step.

if len(params) == 1 considered that will be returned slice between 0 and n, where n is the first param, [0, n). if len(params) == 2 considered that will be returned slice between min and max, where min is the first param, max is the second, [min, max). if len(params) > 2 considered that will be returned slice between min and max with step, where min is the first param, max is the second, step is the third one, [min, max) with step, others params will be ignored

func (ProxyList) Shift

func (ss ProxyList) Shift() (AdapterProxy, ProxyList)

Shift will return two values: the shifted value and the rest slice.

func (ProxyList) Shuffle

func (ss ProxyList) Shuffle(source rand.Source) ProxyList

Shuffle returns shuffled slice by your rand.Source

func (ProxyList) SortStableUsing

func (ss ProxyList) SortStableUsing(less func(a, b AdapterProxy) bool) ProxyList

SortStableUsing works similar to sort.SliceStable. However, unlike sort.SliceStable the slice returned will be reallocated as to not modify the input slice.

func (ProxyList) SortUsing

func (ss ProxyList) SortUsing(less func(a, b AdapterProxy) bool) ProxyList

SortUsing works similar to sort.Slice. However, unlike sort.Slice the slice returned will be reallocated as to not modify the input slice.

func (ProxyList) Strings

func (ss ProxyList) Strings() pie.Strings

Strings transforms each element to a string.

If the element type implements fmt.Stringer it will be used. Otherwise it will fallback to the result of:

fmt.Sprintf("%v")

func (ProxyList) StringsUsing

func (ss ProxyList) StringsUsing(transform func(AdapterProxy) string) pie.Strings

StringsUsing transforms each element to a string.

func (ProxyList) SubSlice

func (ss ProxyList) SubSlice(start int, end int) (subSlice ProxyList)

SubSlice will return the subSlice from start to end(excluded)

Condition 1: If start < 0 or end < 0, nil is returned. Condition 2: If start >= end, nil is returned. Condition 3: Return all elements that exist in the range provided, if start or end is out of bounds, zero items will be placed.

func (ProxyList) Top

func (ss ProxyList) Top(n int) (top ProxyList)

Top will return n elements from head of the slice if the slice has less elements then n that'll return all elements if n < 0 it'll return empty slice.

func (ProxyList) Unshift

func (ss ProxyList) Unshift(elements ...AdapterProxy) (unshift ProxyList)

Unshift adds one or more elements to the beginning of the slice and returns the new slice.

type Rule

type Rule interface {
	Match(metadata *constant.Metadata) bool
	Key() string
	Export() RuleInfo
	AdapterType() AdapterType
	Type() RuleType
}

type RuleInfo

type RuleInfo struct {
	Rule    string `json:"rule,omitempty" yaml:"rule,omitempty"`
	Payload string `json:"payload,omitempty" yaml:"payload,omitempty"`
	Adapter string `json:"adapter,omitempty" yaml:"adapter,omitempty"`
}

type RuleType

type RuleType int
const (
	Domain RuleType = iota
	DomainKey
	DomainSuffix
	ScrIp
	SrcIPCIDR
	SrcPort
	DstIp
	DstIPCIDR
	DstPort
	Process
	ProcessPath
	ProcessDir
)

func (RuleType) String

func (rt RuleType) String() string

type SpeedInfo

type SpeedInfo struct {
	SpeedRecord []int `json:"speed_record,omitempty"`
}

func (*SpeedInfo) AvgSpeed

func (p *SpeedInfo) AvgSpeed() float64

func (*SpeedInfo) MaxSpeed

func (p *SpeedInfo) MaxSpeed() float64

func (*SpeedInfo) MinSpeed

func (p *SpeedInfo) MinSpeed() float64

type TotalTracker

type TotalTracker struct {
	// contains filtered or unexported fields
}

func NewTotalTracker

func NewTotalTracker() *TotalTracker

func (*TotalTracker) Download

func (p *TotalTracker) Download() uint64

func (*TotalTracker) IncrDownload

func (p *TotalTracker) IncrDownload(size uint64)

func (*TotalTracker) IncrUpload

func (p *TotalTracker) IncrUpload(size uint64)

func (*TotalTracker) RegisterTotalTracker

func (p *TotalTracker) RegisterTotalTracker(tracker Tracker)

func (*TotalTracker) Upload

func (p *TotalTracker) Upload() uint64

type Tracker

type Tracker interface {
	IncrDownload(size uint64)
	IncrUpload(size uint64)

	Download() uint64
	Upload() uint64
}

type YoutubeUnlockInfo

type YoutubeUnlockInfo struct {
	Unlocked bool `json:"unlocked,omitempty"`

	LinkWay     string `json:"link_way,omitempty"`
	CacheRegion string `json:"cache_region,omitempty"`
	Region      string `json:"region,omitempty"`
	ISP         string `json:"isp,omitempty"`
}

func (YoutubeUnlockInfo) String

func (p YoutubeUnlockInfo) String() string

Jump to

Keyboard shortcuts

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