internal

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisClient

func NewRedisClient(opts *redis.Options) *redis.Client

Types

type Doer

type Doer interface {
	Do(request *http.Request) (*http.Response, error)
}

type IPAcceptor

type IPAcceptor interface {
	Accept(IP string) (bool, error)
}

type IPAcceptorImpl

type IPAcceptorImpl struct {
	Storage
}

func NewIPAcceptorImpl

func NewIPAcceptorImpl(storage Storage) *IPAcceptorImpl

func (*IPAcceptorImpl) Accept

func (a *IPAcceptorImpl) Accept(ip string) (bool, error)

type InmemoryStorage

type InmemoryStorage struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func NewInmemoryStorage

func NewInmemoryStorage() *InmemoryStorage

func (*InmemoryStorage) InsertIfNotExists

func (s *InmemoryStorage) InsertIfNotExists(value string) (bool, error)

type LogLevel

type LogLevel int
const (
	LogLevelTrace LogLevel = iota
	LogLevelDebug
	LogLevelInfo
	LogLevelWarn
	LogLevelError
	LogLevelNone
)

type Logger

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

func NewLogger

func NewLogger(context string, level LogLevel) *Logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

func (*Logger) Debugln

func (l *Logger) Debugln(v ...interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Errorln

func (l *Logger) Errorln(v ...interface{})

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Infoln

func (l *Logger) Infoln(v ...interface{})

func (*Logger) Trace

func (l *Logger) Trace(v ...interface{})

func (*Logger) Tracef

func (l *Logger) Tracef(format string, v ...interface{})

func (*Logger) Traceln

func (l *Logger) Traceln(v ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, v ...interface{})

func (*Logger) Warnln

func (l *Logger) Warnln(v ...interface{})

type Pool

type Pool interface {
	Get() Doer
}

type PoolImpl

type PoolImpl struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func NewPoolImpl

func NewPoolImpl(size int, maxCallsPerIP int, wf WorkerFactory) (*PoolImpl, error)

func (*PoolImpl) Get

func (p *PoolImpl) Get() Doer

type Storage

type Storage interface {
	InsertIfNotExists(value string) (bool, error)
}

type StorageRedis

type StorageRedis struct {
	*redis.Client
	// contains filtered or unexported fields
}

func NewRedisStorage

func NewRedisStorage(
	client *redis.Client,
	expiration time.Duration,
) *StorageRedis

func (*StorageRedis) InsertIfNotExists

func (s *StorageRedis) InsertIfNotExists(value string) (bool, error)

type TorFacade

type TorFacade interface {
	Doer
	ChangeIP() (string, error)
}

type TorFacadeFactory

type TorFacadeFactory interface {
	New() (TorFacade, error)
}

type TorFacadeFactoryImpl

type TorFacadeFactoryImpl struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func NewTorFacadeFactoryImpl

func NewTorFacadeFactoryImpl() (*TorFacadeFactoryImpl, error)

func (*TorFacadeFactoryImpl) New

func (t *TorFacadeFactoryImpl) New() (TorFacade, error)

func (*TorFacadeFactoryImpl) NewBasePort

func (t *TorFacadeFactoryImpl) NewBasePort() int

func (*TorFacadeFactoryImpl) NewCtrlPort

func (t *TorFacadeFactoryImpl) NewCtrlPort() int

func (*TorFacadeFactoryImpl) NewDataDir

func (t *TorFacadeFactoryImpl) NewDataDir() (string, error)

func (*TorFacadeFactoryImpl) NewPidFile

func (t *TorFacadeFactoryImpl) NewPidFile() string

type TorFacadeImpl

type TorFacadeImpl struct {
	*tor.Tor
	// contains filtered or unexported fields
}

func NewTorFacadeImpl

func NewTorFacadeImpl(
	ctrlPort int,
	socksPort int,
	dataDir string,
	pidFile string,
) (*TorFacadeImpl, error)

func (*TorFacadeImpl) ChangeIP

func (t *TorFacadeImpl) ChangeIP() (string, error)

func (*TorFacadeImpl) Do

func (t *TorFacadeImpl) Do(request *http.Request) (*http.Response, error)

type Worker

type Worker interface {
	Doer
	Update() error
}

type WorkerFactory

type WorkerFactory interface {
	New(queue chan<- Worker) (Worker, error)
}

type WorkerFactoryImpl

type WorkerFactoryImpl struct {
	IPAcceptor
	TorFacadeFactory
}

func NewWorkerFactoryImpl

func NewWorkerFactoryImpl(IPAcceptor IPAcceptor, torFacadeFactory TorFacadeFactory) *WorkerFactoryImpl

func (*WorkerFactoryImpl) New

func (f *WorkerFactoryImpl) New(queue chan<- Worker) (Worker, error)

type WorkerImpl

type WorkerImpl struct {
	IPAcceptor
	TorFacade
	// contains filtered or unexported fields
}

func NewWorkerImpl

func NewWorkerImpl(IPAcceptor IPAcceptor, torFacade TorFacade, queue chan<- Worker) *WorkerImpl

func (*WorkerImpl) Update

func (w *WorkerImpl) Update() error

Jump to

Keyboard shortcuts

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