types

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UseTypeMap = map[UseType]string{
	UseTypeUseNil: "翻墙节点",
	UseTypeGFW:    "翻墙节点",
}

Functions

func Scan

func Scan(src interface{}, dst interface{}) error

func Value

func Value(m interface{}) (driver.Value, error)

Types

type Clash

type Clash struct {
	Port      int `yaml:"port"`
	SocksPort int `yaml:"socks-port"`
	// RedirPort          int                      `yaml:"redir-port"`
	// Authentication     []string                 `yaml:"authentication"`
	AllowLan           bool   `yaml:"allow-lan"`
	Mode               string `yaml:"mode"`
	LogLevel           string `yaml:"log-level"`
	ExternalController string `yaml:"external-controller"`
	// ExternalUI         string                   `yaml:"external-ui"`
	// Secret             string                   `yaml:"secret"`
	// Experimental       map[string]interface{} 	`yaml:"experimental"`
	Proxy             []map[string]interface{} `yaml:"proxies"`
	ProxyGroup        []map[string]interface{} `yaml:"proxy-groups"`
	Rule              []string                 `yaml:"rules"`
	CFWByPass         []string                 `yaml:"cfw-bypass"`
	CFWLatencyTimeout int                      `yaml:"cfw-latency-timeout"`
}

type ClashRSSR

type ClashRSSR struct {
	Name          string      `json:"name"`
	Type          string      `json:"type"`
	Server        string      `json:"server"`
	Port          interface{} `json:"port"`
	Password      string      `json:"password"`
	Cipher        string      `json:"cipher"`
	Protocol      string      `json:"protocol"`
	ProtocolParam string      `json:"protocol-param"`
	OBFS          string      `json:"obfs"`
	OBFSParam     string      `json:"obfs-param"`
}

type ClashSS

type ClashSS struct {
	Name       string      `json:"name"`
	Type       string      `json:"type"`
	Server     string      `json:"server"`
	Port       interface{} `json:"port"`
	Password   string      `json:"password"`
	Cipher     string      `json:"cipher"`
	Plugin     string      `json:"plugin"`
	PluginOpts PluginOpts  `json:"plugin-opts"`
}

type ClashVmess

type ClashVmess struct {
	Name           string            `json:"name,omitempty"`
	Type           string            `json:"type,omitempty"`
	Server         string            `json:"server,omitempty"`
	Port           interface{}       `json:"port,omitempty"`
	UUID           string            `json:"uuid,omitempty"`
	AlterID        interface{}       `json:"alterId,omitempty"`
	Cipher         string            `json:"cipher,omitempty"`
	TLS            bool              `json:"tls,omitempty"`
	Network        string            `json:"network,omitempty"`
	WSPATH         string            `json:"ws-path,omitempty"`
	WSHeaders      map[string]string `json:"ws-headers,omitempty"`
	SkipCertVerify bool              `json:"skip-cert-verify,omitempty"`
}

type CrawlType

type CrawlType uint32
const (
	CrawlTypeNil           CrawlType = 0
	CrawlTypeSubscription  CrawlType = 1
	CrawlTypeXpath         CrawlType = 2
	CrawlTypeFuzzyMatching CrawlType = 3
	CrawlTypeClashProxies  CrawlType = 4
)

type CrawlerConf

type CrawlerConf struct {
	Id             uint64    `json:"id,omitempty" gorm:"primaryKey"`
	CreatedAt      uint32    `json:"created_at,omitempty" gorm:"autoCreateTime:autoCreateTime"`
	UpdatedAt      uint32    `json:"updated_at,omitempty" gorm:"autoUpdateTime:autoUpdateTime"`
	CrawlerFeature string    `` /* 182-byte string literal not displayed */
	CrawlUrl       string    `json:"crawl_url,omitempty" gorm:"type:text;comment:抓取的地址"`
	CrawlType      CrawlType `json:"crawl_type,omitempty"`
	UseType        UseType   `json:"use_type,omitempty"`
	// @gorm: type:json
	Rule *CrawlerConfRule `json:"rule,omitempty" gorm:"type:json"`
	// @grom: index: idx_next_crawl_at
	IsClosed bool `json:"is_closed,omitempty" gorm:"index:idx_next_crawl_at"`
	// @grom: index: idx_next_crawl_at
	NextAt   uint32 `json:"next_at,omitempty" gorm:"index:idx_next_crawl_at"`
	Interval uint32 `json:"interval,omitempty"`
	// @v: max=100
	Note       string `json:"note,omitempty"`
	DeathCount uint32 `json:"death_count,omitempty" gorm:"comment:连续错误的次数"`
}

type CrawlerConfList

type CrawlerConfList []*CrawlerConf

func (CrawlerConfList) All

func (ss CrawlerConfList) All(fn func(value *CrawlerConf) 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 (CrawlerConfList) Any

func (ss CrawlerConfList) Any(fn func(value *CrawlerConf) 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 (CrawlerConfList) Append

func (ss CrawlerConfList) Append(elements ...*CrawlerConf) CrawlerConfList

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

It is acceptable to provide zero arguments.

func (CrawlerConfList) Bottom

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

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 (CrawlerConfList) Contains

func (ss CrawlerConfList) Contains(lookingFor *CrawlerConf) 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 (CrawlerConfList) Diff

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

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 (CrawlerConfList) DropTop

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

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 (CrawlerConfList) Each

func (ss CrawlerConfList) Each(fn func(*CrawlerConf)) CrawlerConfList

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 (CrawlerConfList) Equals

func (ss CrawlerConfList) Equals(rhs CrawlerConfList) 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 (CrawlerConfList) Extend

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

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

It is acceptable to provide zero arguments.

func (CrawlerConfList) Filter

func (ss CrawlerConfList) Filter(condition func(*CrawlerConf) bool) (ss2 CrawlerConfList)

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 (CrawlerConfList) FilterNot

func (ss CrawlerConfList) FilterNot(condition func(*CrawlerConf) bool) (ss2 CrawlerConfList)

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 (CrawlerConfList) FindFirstUsing

func (ss CrawlerConfList) FindFirstUsing(fn func(value *CrawlerConf) 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 (CrawlerConfList) First

func (ss CrawlerConfList) First() *CrawlerConf

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

func (CrawlerConfList) FirstOr

func (ss CrawlerConfList) FirstOr(defaultValue *CrawlerConf) *CrawlerConf

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

func (CrawlerConfList) Float64s

func (ss CrawlerConfList) Float64s() pie.Float64s

Float64s transforms each element to a float64.

func (CrawlerConfList) Insert

func (ss CrawlerConfList) Insert(index int, values ...*CrawlerConf) CrawlerConfList

Insert a value at an index

func (CrawlerConfList) Ints

func (ss CrawlerConfList) Ints() pie.Ints

Ints transforms each element to an integer.

func (CrawlerConfList) JSONBytes

func (ss CrawlerConfList) 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 (CrawlerConfList) JSONBytesIndent

func (ss CrawlerConfList) 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 (CrawlerConfList) JSONString

func (ss CrawlerConfList) 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 (CrawlerConfList) JSONStringIndent

func (ss CrawlerConfList) 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 (CrawlerConfList) Join

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

Join returns a string from joining each of the elements.

func (CrawlerConfList) Last

func (ss CrawlerConfList) Last() *CrawlerConf

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

func (CrawlerConfList) LastOr

func (ss CrawlerConfList) LastOr(defaultValue *CrawlerConf) *CrawlerConf

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

func (CrawlerConfList) Len

func (ss CrawlerConfList) Len() int

Len returns the number of elements.

func (CrawlerConfList) Map

func (ss CrawlerConfList) Map(fn func(*CrawlerConf) *CrawlerConf) (ss2 CrawlerConfList)

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 (CrawlerConfList) Mode

func (ss CrawlerConfList) Mode() CrawlerConfList

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 (*CrawlerConfList) Pop

func (ss *CrawlerConfList) Pop() (popped **CrawlerConf)

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 (CrawlerConfList) Random

func (ss CrawlerConfList) Random(source rand.Source) *CrawlerConf

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

func (CrawlerConfList) Reverse

func (ss CrawlerConfList) Reverse() CrawlerConfList

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 (CrawlerConfList) Send

func (ss CrawlerConfList) Send(ctx context.Context, ch chan<- *CrawlerConf) CrawlerConfList

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 (CrawlerConfList) SequenceUsing

func (ss CrawlerConfList) SequenceUsing(creator func(int) *CrawlerConf, params ...int) CrawlerConfList

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 (CrawlerConfList) Shift

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

func (CrawlerConfList) Shuffle

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

Shuffle returns shuffled slice by your rand.Source

func (CrawlerConfList) SortStableUsing

func (ss CrawlerConfList) SortStableUsing(less func(a, b *CrawlerConf) bool) CrawlerConfList

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

func (CrawlerConfList) SortUsing

func (ss CrawlerConfList) SortUsing(less func(a, b *CrawlerConf) bool) CrawlerConfList

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

func (CrawlerConfList) Strings

func (ss CrawlerConfList) 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 (CrawlerConfList) StringsUsing

func (ss CrawlerConfList) StringsUsing(transform func(*CrawlerConf) string) pie.Strings

StringsUsing transforms each element to a string.

func (CrawlerConfList) SubSlice

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

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 (CrawlerConfList) Top

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

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 (CrawlerConfList) Unshift

func (ss CrawlerConfList) Unshift(elements ...*CrawlerConf) (unshift CrawlerConfList)

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

type CrawlerConfRule added in v0.0.7

type CrawlerConfRule struct {
	UseProxy bool   `json:"use_proxy,omitempty"`
	Xpath    string `json:"xpath,omitempty"`
}

func (*CrawlerConfRule) Scan added in v0.0.7

func (m *CrawlerConfRule) Scan(value interface{}) error

func (*CrawlerConfRule) Value added in v0.0.7

func (m *CrawlerConfRule) Value() (driver.Value, error)

type EventName added in v0.0.8

type EventName string
const (
	SendMsg EventName = "send_msg"
	DelMsg  EventName = "del_msg"
)

type MsgType added in v0.0.8

type MsgType string
const (
	MsgTypeProxyCheck MsgType = "proxy_check"
)

type PluginOpts

type PluginOpts struct {
	Mode string `json:"mode"`
	Host string `json:"host"`
}

type ProxyNode

type ProxyNode struct {
	Id        uint64 `json:"id,omitempty"`
	CreatedAt uint32 `json:"created_at,omitempty" gorm:"autoCreateTime:autoCreateTime"`
	UpdatedAt uint32 `json:"updated_at,omitempty" gorm:"autoUpdateTime:autoUpdateTime"`

	UrlFeature        string           `` /* 185-byte string literal not displayed */
	Url               string           `json:"url,omitempty" gorm:"type:text;comment:节点的地址"`
	ProxyNodeType     ProxyNodeType    `json:"proxy_node_type,omitempty"`
	ProxySpeed        float64          `json:"proxy_speed,omitempty"`
	ProxyNetworkDelay float64          `json:"proxy_network_delay,omitempty"`
	NextCheckAt       uint32           `json:"next_check_at,omitempty" gorm:"index:idx_next_check_at"`
	CheckInterval     uint32           `json:"check_interval,omitempty"`
	CrawlId           uint64           `json:"crawl_id,omitempty"`
	DeathCount        uint32           `json:"death_count,omitempty" gorm:"index:idx_alive"`
	IsClose           bool             `json:"is_close,omitempty" gorm:"index:idx_next_check_at;index:idx_alive"`
	LastCrawlerAt     uint32           `json:"last_crawler_at,omitempty"`
	AvailableCount    uint64           `json:"available_count,omitempty" gorm:"index:idx_alive"`
	UseType           UseType          `json:"use_type,omitempty"`
	CountryCode       string           `json:"country_code,omitempty" gorm:"type:varchar(100);节点的国家ISO-Code"`
	CountryCn         string           `json:"country_cn,omitempty" gorm:"type:varchar(50);comment:节点的国家(中文)"`
	Detail            *ProxyNodeDetail `json:"detail,omitempty" gorm:"type:json;comment:节点信息详情"`
}

type ProxyNodeDetail added in v0.0.7

type ProxyNodeDetail struct {
	OriginalNodeName string `json:"original_node_name,omitempty"`
	RawUrl           string `json:"raw_url,omitempty"`
}

func (*ProxyNodeDetail) Scan added in v0.0.7

func (m *ProxyNodeDetail) Scan(value interface{}) error

func (*ProxyNodeDetail) Value added in v0.0.7

func (m *ProxyNodeDetail) Value() (driver.Value, error)

type ProxyNodeList

type ProxyNodeList []*ProxyNode

func (ProxyNodeList) All

func (ss ProxyNodeList) All(fn func(value *ProxyNode) 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 (ProxyNodeList) Any

func (ss ProxyNodeList) Any(fn func(value *ProxyNode) 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 (ProxyNodeList) Append

func (ss ProxyNodeList) Append(elements ...*ProxyNode) ProxyNodeList

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

It is acceptable to provide zero arguments.

func (ProxyNodeList) Bottom

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

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 (ProxyNodeList) Contains

func (ss ProxyNodeList) Contains(lookingFor *ProxyNode) 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 (ProxyNodeList) Diff

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

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 (ProxyNodeList) DropTop

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

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 (ProxyNodeList) Each

func (ss ProxyNodeList) Each(fn func(*ProxyNode)) ProxyNodeList

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 (ProxyNodeList) Equals

func (ss ProxyNodeList) Equals(rhs ProxyNodeList) 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 (ProxyNodeList) Extend

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

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

It is acceptable to provide zero arguments.

func (ProxyNodeList) Filter

func (ss ProxyNodeList) Filter(condition func(*ProxyNode) bool) (ss2 ProxyNodeList)

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 (ProxyNodeList) FilterNot

func (ss ProxyNodeList) FilterNot(condition func(*ProxyNode) bool) (ss2 ProxyNodeList)

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 (ProxyNodeList) FindFirstUsing

func (ss ProxyNodeList) FindFirstUsing(fn func(value *ProxyNode) 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 (ProxyNodeList) First

func (ss ProxyNodeList) First() *ProxyNode

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

func (ProxyNodeList) FirstOr

func (ss ProxyNodeList) FirstOr(defaultValue *ProxyNode) *ProxyNode

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

func (ProxyNodeList) Float64s

func (ss ProxyNodeList) Float64s() pie.Float64s

Float64s transforms each element to a float64.

func (ProxyNodeList) Insert

func (ss ProxyNodeList) Insert(index int, values ...*ProxyNode) ProxyNodeList

Insert a value at an index

func (ProxyNodeList) Ints

func (ss ProxyNodeList) Ints() pie.Ints

Ints transforms each element to an integer.

func (ProxyNodeList) JSONBytes

func (ss ProxyNodeList) 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 (ProxyNodeList) JSONBytesIndent

func (ss ProxyNodeList) 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 (ProxyNodeList) JSONString

func (ss ProxyNodeList) 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 (ProxyNodeList) JSONStringIndent

func (ss ProxyNodeList) 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 (ProxyNodeList) Join

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

Join returns a string from joining each of the elements.

func (ProxyNodeList) Last

func (ss ProxyNodeList) Last() *ProxyNode

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

func (ProxyNodeList) LastOr

func (ss ProxyNodeList) LastOr(defaultValue *ProxyNode) *ProxyNode

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

func (ProxyNodeList) Len

func (ss ProxyNodeList) Len() int

Len returns the number of elements.

func (ProxyNodeList) Map

func (ss ProxyNodeList) Map(fn func(*ProxyNode) *ProxyNode) (ss2 ProxyNodeList)

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 (ProxyNodeList) Mode

func (ss ProxyNodeList) Mode() ProxyNodeList

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 (*ProxyNodeList) Pop

func (ss *ProxyNodeList) Pop() (popped **ProxyNode)

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 (ProxyNodeList) Random

func (ss ProxyNodeList) Random(source rand.Source) *ProxyNode

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

func (ProxyNodeList) Reverse

func (ss ProxyNodeList) Reverse() ProxyNodeList

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 (ProxyNodeList) Send

func (ss ProxyNodeList) Send(ctx context.Context, ch chan<- *ProxyNode) ProxyNodeList

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 (ProxyNodeList) SequenceUsing

func (ss ProxyNodeList) SequenceUsing(creator func(int) *ProxyNode, params ...int) ProxyNodeList

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 (ProxyNodeList) Shift

func (ss ProxyNodeList) Shift() (*ProxyNode, ProxyNodeList)

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

func (ProxyNodeList) Shuffle

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

Shuffle returns shuffled slice by your rand.Source

func (ProxyNodeList) SortStableUsing

func (ss ProxyNodeList) SortStableUsing(less func(a, b *ProxyNode) bool) ProxyNodeList

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

func (ProxyNodeList) SortUsing

func (ss ProxyNodeList) SortUsing(less func(a, b *ProxyNode) bool) ProxyNodeList

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

func (ProxyNodeList) Strings

func (ss ProxyNodeList) 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 (ProxyNodeList) StringsUsing

func (ss ProxyNodeList) StringsUsing(transform func(*ProxyNode) string) pie.Strings

StringsUsing transforms each element to a string.

func (ProxyNodeList) SubSlice

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

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 (ProxyNodeList) Top

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

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 (ProxyNodeList) Unshift

func (ss ProxyNodeList) Unshift(elements ...*ProxyNode) (unshift ProxyNodeList)

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

type ProxyNodeType

type ProxyNodeType uint32
const (
	ProxyNodeTypeNil    ProxyNodeType = 0
	ProxyNodeTypeVmess  ProxyNodeType = 1
	ProxyNodeTypeTrojan ProxyNodeType = 2
	ProxyNodeTypeVless  ProxyNodeType = 3
	ProxyNodeTypeSS     ProxyNodeType = 4
	ProxyNodeTypeSSR    ProxyNodeType = 5
	ProxyNodeTypeSocket ProxyNodeType = 6
	ProxyNodeTypeHttp   ProxyNodeType = 7
	ProxyNodeTypeSnell  ProxyNodeType = 8
)

type SSD

type SSD struct {
	Airport      string  `json:"airport"`
	Port         int     `json:"port"`
	Encryption   string  `json:"encryption"`
	Password     string  `json:"password"`
	TrafficUsed  float64 `json:"traffic_used"`
	TrafficTotal float64 `json:"traffic_total"`
	Expiry       string  `json:"expiry"`
	URL          string  `json:"url"`
	Servers      []struct {
		ID            int     `json:"id"`
		Server        string  `json:"server"`
		Ratio         float64 `json:"ratio"`
		Remarks       string  `json:"remarks"`
		Port          string  `json:"port"`
		Encryption    string  `json:"encryption"`
		Password      string  `json:"password"`
		Plugin        string  `json:"plugin"`
		PluginOptions string  `json:"plugin_options"`
	} `json:"servers"`
}

type TohruFeed

type TohruFeed struct {
	Id        uint64 `json:"id,omitempty"`
	CreatedAt uint32 `json:"created_at,omitempty" gorm:"autoCreateTime:autoCreateTime"`
	UpdatedAt uint32 `json:"updated_at,omitempty" gorm:"autoUpdateTime:autoUpdateTime"`

	UserId       string `json:"user_id,omitempty" gorm:"unique_index:idx_user_id;not null;comment:用户的唯一标识"`
	UserPassword string `json:"user_password,omitempty" gorm:"unique_index:idx_user_id;not_null;comment:用户密码"`

	UpCount   uint64 `json:"up_count,omitempty" gorm:"comment:用户上传的数量"`
	LastIp    string `json:"last_ip,omitempty" gorm:"type:varchar(100);comment:用户最后一次通过api请求的IP"`
	IsDisable bool   `json:"is_disable,omitempty" gorm:"comment:是否禁用"`
	SubCount  uint32 `json:"sub_count,omitempty" gorm:"comment:使用订阅的次数,当重新获取token后会重置"`
}

type TokenInfo added in v0.0.7

type TokenInfo struct {
	UserName  string `json:"user_name"`
	Password  string `json:"password"`
	CreatedAt uint32 `json:"created_at"`
	UUID      string `json:"uuid"`
}

type Trojan

type Trojan struct {
	Name     string      `json:"name"`
	Type     string      `json:"type"`
	Server   string      `json:"server"`
	Password string      `json:"password"`
	Sni      string      `json:"sni,omitempty"`
	Port     interface{} `json:"port"`
}

type UseType

type UseType uint32
const (
	UseTypeUseNil UseType = 0
	UseTypeGFW    UseType = 1
)

type Vmess

type Vmess struct {
	Add  string      `json:"add"`
	Aid  interface{} `json:"aid"`
	Host string      `json:"host"`
	ID   string      `json:"id"`
	Net  string      `json:"net"`
	Path string      `json:"path"`
	Port interface{} `json:"port"`
	PS   string      `json:"ps"`
	TLS  string      `json:"tls"`
	Type string      `json:"type"`
	V    interface{} `json:"v"`
}

Jump to

Keyboard shortcuts

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