proxycheck

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: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProxyCheck

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

func NewProxyCheck

func NewProxyCheck() *ProxyCheck

func (*ProxyCheck) AddWithClash

func (p *ProxyCheck) AddWithClash(nodeUrl string, logic func(result Result) error) error
func (p *ProxyCheck) AddWithLink(nodeUrl string, logic func(result Result) error) error

func (*ProxyCheck) Check4NodeDetail

func (p *ProxyCheck) Check4NodeDetail(proxyUrl string) *Result

func (*ProxyCheck) CheckWithClash

func (p *ProxyCheck) CheckWithClash(clashConfig string) (float64, float64, error)
func (p *ProxyCheck) CheckWithLink(nodeUrl string) (float64, float64, error)

func (*ProxyCheck) Init

func (p *ProxyCheck) Init(maxWorker int) error

func (*ProxyCheck) URLTest

func (p *ProxyCheck) URLTest(proxy constant.Proxy, rawUrl string) (delay time.Duration, speed float64, err error)

func (*ProxyCheck) WaitFinish

func (p *ProxyCheck) WaitFinish()

type Result

type Result struct {
	ProxyUrl        string
	Delay, SpeedNum float64
	Speed           string
	Err             error
}

type ResultList

type ResultList []*Result

func (ResultList) All

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

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

func (ss ResultList) Append(elements ...*Result) ResultList

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

It is acceptable to provide zero arguments.

func (ResultList) Bottom

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

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

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

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

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

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

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

func (ss ResultList) Each(fn func(*Result)) ResultList

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

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

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

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

It is acceptable to provide zero arguments.

func (ResultList) Filter

func (ss ResultList) Filter(condition func(*Result) bool) (ss2 ResultList)

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

func (ss ResultList) FilterNot(condition func(*Result) bool) (ss2 ResultList)

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

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

func (ss ResultList) First() *Result

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

func (ResultList) FirstOr

func (ss ResultList) FirstOr(defaultValue *Result) *Result

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

func (ResultList) Float64s

func (ss ResultList) Float64s() pie.Float64s

Float64s transforms each element to a float64.

func (ResultList) Insert

func (ss ResultList) Insert(index int, values ...*Result) ResultList

Insert a value at an index

func (ResultList) Ints

func (ss ResultList) Ints() pie.Ints

Ints transforms each element to an integer.

func (ResultList) JSONBytes

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

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

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

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

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

Join returns a string from joining each of the elements.

func (ResultList) Last

func (ss ResultList) Last() *Result

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

func (ResultList) LastOr

func (ss ResultList) LastOr(defaultValue *Result) *Result

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

func (ResultList) Len

func (ss ResultList) Len() int

Len returns the number of elements.

func (ResultList) Map

func (ss ResultList) Map(fn func(*Result) *Result) (ss2 ResultList)

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

func (ss ResultList) Mode() ResultList

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

func (ss *ResultList) Pop() (popped **Result)

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

func (ss ResultList) Random(source rand.Source) *Result

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

func (ResultList) Reverse

func (ss ResultList) Reverse() ResultList

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

func (ss ResultList) Send(ctx context.Context, ch chan<- *Result) ResultList

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

func (ss ResultList) SequenceUsing(creator func(int) *Result, params ...int) ResultList

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

func (ss ResultList) Shift() (*Result, ResultList)

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

func (ResultList) Shuffle

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

Shuffle returns shuffled slice by your rand.Source

func (ResultList) SortStableUsing

func (ss ResultList) SortStableUsing(less func(a, b *Result) bool) ResultList

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

func (ResultList) SortUsing

func (ss ResultList) SortUsing(less func(a, b *Result) bool) ResultList

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

func (ResultList) Strings

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

func (ss ResultList) StringsUsing(transform func(*Result) string) pie.Strings

StringsUsing transforms each element to a string.

func (ResultList) SubSlice

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

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

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

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

func (ss ResultList) Unshift(elements ...*Result) (unshift ResultList)

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

Jump to

Keyboard shortcuts

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