internal

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Addr is the listen and serve address for the server.
	Addr string
	// LogFile is the file location to store the servers http request logs.
	LogFile string
	// Version is the current version of the program. In releases this is set as the git tag via build ldflags.
	Version string
)
View Source
var (

	// Workers controls number of max goroutines at a time for checking proxies.
	Workers int
	// Timeout sets http request timeouts for proxy checks
	Timeout time.Duration
	// Progress determines if we use progress bar when checking proxies.
	Progress bool
)
View Source
var (
	DB     *sql.DB
	DbPath string
)
View Source
var (
	DownloadTimeout time.Duration
)
View Source
var (
	//FileLimitMax sets max open file descriptors value
	FileLimitMax int
)
View Source
var (
	// MaxmindFilePath is the path to maxmind country db file. Used to resolve the geolocation of proxies.
	MaxmindFilePath string
)

Functions

func API

func API()

API is the rest api/swagger docs that listen and serves forever.

func CheckInit

func CheckInit()

CheckInit checks all proxies from GormDB to see if they are transparent or anonymous and if they work.

func DbInit

func DbInit()

DbInit initializes our db.

func DbPing

func DbPing()

DbPing pings DB and either prints "Pong" or does nothing.

func DownloadInit

func DownloadInit()

DownloadInit initializes DownloadProxies and saves results to GormDB

func IncrFdLimit

func IncrFdLimit() (int, uint64)

IncrFdLimit attempts to increase max file handles per process

func StartupMessage

func StartupMessage()

StartupMessage prints startup banner

Types

type Model

type Model struct {
	ID        uint      `json:"-" gorm:"primary_key"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Model gets embedded into Proxy

type Proxies

type Proxies []*Proxy

Proxies is a slice of Proxy

func DownloadProxies

func DownloadProxies() Proxies

DownloadProxies downloads proxies from providers.

type Proxy

type Proxy struct {
	Model
	RespTime     *string `json:"response_time"`
	CheckCount   uint    `json:"check_count" gorm:"default:0"`
	Country      string  `json:"country" `
	FailCount    uint    `json:"fail_count" gorm:"default:0"`
	LastStatus   string  `json:"last_status"`
	Proxy        string  `json:"proxy" gorm:"type:varchar(100);unique_index"`
	TimeoutCount uint    `json:"timeout_count" gorm:"default:0"`
	Source       string  `json:"source"`
	SuccessCount uint    `json:"success_count" gorm:"default:0"`
	Anonymous    bool    `json:"anonymous"`
	LosingStreak uint    `json:"-" gorm:"default:0"`
	Deleted      bool    `json:"-" gorm:"default:false"`
	Judge        string  `json:"-"`
}

Proxy represents a proxy record and is used to create the table for our db.

type TableStats

type TableStats struct {
	Anon            int   `json:"anon"`
	Good            int   `json:"good"`
	Timeout         int   `json:"timeout"`
	Total           int   `json:"total"`
	RecentlyChecked int64 `json:"recently_checked"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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