-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
129 lines (96 loc) · 2.2 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package main
import (
"bufio"
"fmt"
"os"
"strings"
"sync"
"github.com/evex-dev/promo2/src/connect"
"github.com/manifoldco/promptui"
)
var wg sync.WaitGroup
func main() {
validatePath := func(input string) error {
if _, err := os.Stat(input); err != nil {
return err
}
return nil
}
proxiesPathPrompt := promptui.Prompt{
Label: "Proxies Path",
Validate: validatePath,
}
proxiesPath, err := proxiesPathPrompt.Run()
if err != nil {
fmt.Println(err)
return
}
proxiesBody, err := os.Open(proxiesPath)
if err != nil {
fmt.Println(err)
return
}
scanner := bufio.NewScanner(proxiesBody)
var proxylist []string
for scanner.Scan() {
text := scanner.Text()
proxylist = append(proxylist, text)
}
resultPathPrompt := promptui.Prompt{
Label: "Result Path",
Validate: validatePath,
}
resultPath, err := resultPathPrompt.Run()
if err != nil {
fmt.Println(err)
return
}
for {
resultFileContent, err := getResultFileContent(resultPath);
if err != nil {
fmt.Println("\x1b[31m[-] Error: ", err, "\x1b[0m")
return
}
promosList := strings.Split(resultFileContent, "\n");
oneGenerate := func() {
defer wg.Done()
fmt.Println("\x1b[33m[=] Requesting...\x1b[0m")
promos, err := connect.GetPromoUrls(proxylist)
if err != nil {
fmt.Println("\x1b[31m[-] Error: ", err, "\x1b[0m")
return
}
promosLength := len(promos)
fmt.Println("\x1b[32m[+] Found: ", promosLength, "urls\x1b[0m")
for _, promo := range promos {
fmt.Println("\x1b[32m[+] Found: ", promo, "\x1b[0m")
}
promosList = append(promosList, promos...)
if promosLength != 0 {
resultFile, err := os.Create(resultPath)
if err != nil {
fmt.Println("\x1b[31m[-] Error: ", err, "\x1b[0m")
return
}
resultFile.WriteString(strings.Join(promosList, "\n"))
resultFile.Close()
}
}
thread := 30
for i := 0; i < thread; i++ {
wg.Add(1)
go oneGenerate()
}
wg.Wait()
}
}
func getResultFileContent(resultPath string) (string, error) {
if _, err := os.Stat(resultPath); os.IsNotExist(err) {
return "", err
}
content, err := os.ReadFile(resultPath)
if err != nil {
return "", err
}
return string(content), nil
}