middleware

package
v0.0.0-...-03d4f27 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool <-chan *Proxy

func NewPool

func NewPool(ctx context.Context, col *mongo.Collection, filter bson.M) (Pool, error)

type Proxies

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

Proxies represents a pool of proxies

type Proxy

type Proxy struct {
	ID       uint   `json:"id"`       // A proxy ID
	List     string `json:"list"`     // The list name, ie: storm_80_main
	URL      string `json:"url"`      // The proxy URL, ie: http://167.36.78.9:6897
	Location string `json:"location"` // The proxy location, ie: de
	Type     string `json:"type"`     // A proxy type, ie: http, socks or backconnect
	Active   bool   `json:"active"`   // If it's active or not
}

Proxy represents a proxy server

func FetchProxies

func FetchProxies(ctx context.Context, col *mongo.Collection, filter bson.M) ([]*Proxy, error)

FetchProxies loads proxies from the DB and returns a channel of proxies

type ProxyPoolManager

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

ProxyPoolManager manage a collection of pool of proxies

func NewPoolManager

func NewPoolManager() *ProxyPoolManager

func (*ProxyPoolManager) CreateProxies

func (m *ProxyPoolManager) CreateProxies(
	ctx context.Context,
	col *mongo.Collection,
	target string,
	filter bson.M) error

CreateProxies creates a new pool if it does not exist

func (*ProxyPoolManager) GetProxies

func (m *ProxyPoolManager) GetProxies(target string) *Proxies

GetProxies get a pool given a target name

func (*ProxyPoolManager) ProxyFunc

func (m *ProxyPoolManager) ProxyFunc(r *http.Request) (*url.URL, error)

ProxyFunc will return a new proxy with each call

Jump to

Keyboard shortcuts

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