Suche ein tool womit ich mehrere FTP-Server Checken kann?
THX
Du bist nicht angemeldet und hast somit nur einen sehr eingeschränkten Zugriff auf die Features unserer Community.
Um vollen Zugriff zu erlangen musst du dir einen Account erstellen. Der Vorgang sollte nicht länger als 1 Minute dauern.
Thanked by 1 Member:
|
|
package main import ( "bufio" "flag" "log" "os" "strings" "sync" "github.com/jlaffaye/ftp" "time" ) var wg sync.WaitGroup type env struct { filepath string } type Job struct { Work string } //sending produced to channel "jobs" and after closes the channel. func (env *env) producer(jobs chan<- *Job) { file, err := os.Open(env.filepath) if err != nil { log.Fatal(err) } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { jobs <- &Job{Work: strings.TrimSpace(scanner.Text())} } if err := scanner.Err(); err != nil { log.Fatal(err) } close(jobs) } func writer(results <-chan *Job, done chan<- bool) { for { j, more := <-results if more { log.Println(true, j.Work) } else { done <- true return } } } func worker(jobs <-chan *Job, results chan<- *Job, port string) { for { j, more := <-jobs if more { c, err := ftp.Dial(j.Work+port, ftp.DialWithTimeout(5*time.Second)) if err != nil { log.Println(false, j.Work) continue } if err := c.Quit(); err != nil { continue } results <- j } else { wg.Done() return } } } func main() { var threads = flag.Int("threads", 10, "concurrent threads") var file = flag.String("filepath", "ips.txt", "path to file") var port = flag.String("port", "21", "port") flag.Parse() var jobs = make(chan *Job, 1000) var results = make(chan *Job, 1000) var done = make(chan bool, 1) for w := 1; w <= *threads; w++ { wg.Add(1) go worker(jobs, results, *port) } env := env{filepath: *file} go env.producer(jobs) go writer(results, done) wg.Wait() close(results) <-done }
Habe dir einen in Go geschrieben.
Windows compiled :
pw: toolbase
Bearbeitet von sup3ria, 18 February 2020 - 02:36 Uhr.
Thema | Forum | Themenstarter | Statistik | Letzter Beitrag |
---|