package falcon import ( "sync" "time" ) // Falcon represents a proxy checker type Falcon struct { // Proxies to verify Proxies []string // Proxy timeout (default: 5 seconds) Timeout time.Duration // Checking status Running bool // Incoming proxies *Channels wg *sync.WaitGroup } // New will return a default Falcon func New(proxies []string) *Falcon { return &Falcon{ Proxies: proxies, Timeout: time.Second * 5, Running: false, Channels: &Channels{ SOCKS5: make(chan *Lookup), SOCKS4: make(chan *Lookup), SOCKS4A: make(chan *Lookup), HTTP: make(chan *Lookup), Error: make(chan error), }, wg: &sync.WaitGroup{}, } } // Start will start the proxy checker func (f *Falcon) Start() { f.Running = true for _, proxy := range f.Proxies { if f.Running { f.wg.Add(1) go f.Verify(proxy, f.Timeout) f.wg.Done() } } f.wg.Wait() f.Running = false } // Stop will stop the proxy checker func (f *Falcon) Stop() { f.Running = false }