internal

package
v0.0.0-...-2ca8d28 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthTypeNO 不需要认证
	AuthTypeNO = "no"

	// AuthTypeBasic 使用basic
	AuthTypeBasic = "basic"

	// AuthTypeBasicWithAny 使用basic,任意账号密码都可以
	AuthTypeBasicWithAny = "basic_any"
)

Variables

View Source
var ProxyDebug = os.Getenv("ProxyManagerDebug") == "true"

ProxyDebug 是否debug

Functions

func AssetGetContent

func AssetGetContent(fp string) []byte

func GetVersion

func GetVersion() string

func InitConf

func InitConf(confDir string)

InitConf 第一次运行 初始化配置文件目录

func ReduceHTMLSpace

func ReduceHTMLSpace(html string) string

ReduceHTMLSpace 去除html tag 间的空格字符

func SetInterval

func SetInterval(call func(), dur time.Duration) *time.Ticker

func StrMd5

func StrMd5(str string) string

Types

type Config

type Config struct {
	Title  string
	Notice string

	AliveCheckURL   string // 必填,通过检测这个url来判断代理是否正常
	AuthType        string // 可选,鉴权类型,可选值 no-不需要鉴权,basic、basic_any-任意帐号
	WrongStatusCode []int

	Port     int //  必填,服务端口
	Timeout  int // 可选,超时时间,单位秒,默认 30
	ReTry    int // 可选,重试次数,默认 2
	ReTryMax int // 可选,最大重试次数由客户端通过http header [X-Man-Retry]指定

	CheckInterval int // 可选,检测代理有效的间隔时间,单位秒,默认 1800
}

func (*Config) IsWrongCode

func (c *Config) IsWrongCode(code int) bool

type GroupNumbers

type GroupNumbers map[string]int

func (GroupNumbers) Add

func (c GroupNumbers) Add(item string, n int)

func (GroupNumbers) Get

func (c GroupNumbers) Get(item string) int

type Proxy

type Proxy struct {
	LastCheck   time.Time
	LastCheckOk time.Time
	URL         *url.URL
	Count       *proxyCount

	Weight     int
	StatusCode proxyStatus
	CheckUsed  time.Duration //
	Used       int64
	// contains filtered or unexported fields
}

Proxy 一个代理

func (*Proxy) GetUsed

func (p *Proxy) GetUsed() int64

func (*Proxy) IncrUsed

func (p *Proxy) IncrUsed()

func (*Proxy) IsOk

func (p *Proxy) IsOk() bool

IsOk 是否可用状态

func (*Proxy) String

func (p *Proxy) String() string

type ProxyList

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

func (*ProxyList) Add

func (pl *ProxyList) Add(p *Proxy) bool

func (*ProxyList) Get

func (pl *ProxyList) Get(key string) *Proxy

func (*ProxyList) MergeTo

func (pl *ProxyList) MergeTo(to *ProxyList)

func (*ProxyList) Next

func (pl *ProxyList) Next() *Proxy

func (*ProxyList) Range

func (pl *ProxyList) Range(fn func(proxyURL string, proxy *Proxy) bool)

func (*ProxyList) Remove

func (pl *ProxyList) Remove(key string) bool

func (*ProxyList) String

func (pl *ProxyList) String() string

func (*ProxyList) Total

func (pl *ProxyList) Total() int

type ProxyManager

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

ProxyManager manager server

func NewProxyManager

func NewProxyManager(configPath string) *ProxyManager

NewProxyManager init server

func (*ProxyManager) ServeHTTP

func (man *ProxyManager) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*ProxyManager) Start

func (man *ProxyManager) Start()

type ProxyPool

type ProxyPool struct {
	Count *proxyCount
	// contains filtered or unexported fields
}

ProxyPool 代理池

func (*ProxyPool) ActiveList

func (p *ProxyPool) ActiveList() map[string]*Proxy

func (*ProxyPool) GetProxyNumbers

func (p *ProxyPool) GetProxyNumbers() GroupNumbers

GetProxyNumbers 返回各种代理的数量 web页面会使用

func (*ProxyPool) String

func (p *ProxyPool) String() string

type User

type User struct {
	Name        string
	Password    string
	PasswordMd5 string
	Admin       bool
}

func (*User) Eq

func (u *User) Eq(u1 *User) bool

func (*User) PswEnc

func (u *User) PswEnc() string

func (*User) String

func (u *User) String() string

Jump to

Keyboard shortcuts

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