-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (47 loc) · 960 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"bufio"
"checker/internal/checker"
"sync"
"os"
"math/rand"
)
const threads = 100
var (
proxies []string
)
func main() {
invites, err := os.Open("invites.txt")
if err != nil {
panic(err)
}
defer invites.Close()
proxyFile, err := os.Open("proxies.txt")
if err != nil {
panic(err)
}
defer proxyFile.Close()
scanner := bufio.NewScanner(proxyFile)
for scanner.Scan() {
proxy := scanner.Text()
proxies = append(proxies, proxy)
}
scanner = bufio.NewScanner(invites)
var wg sync.WaitGroup
inviteCh := make(chan string, threads)
for i := 0; i < threads; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for invite := range inviteCh {
checker.Check(invite, proxies[rand.Intn(len(proxies))])
}
}()
}
for scanner.Scan() {
invite := scanner.Text()
inviteCh <- invite
}
close(inviteCh)
wg.Wait()
}