This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.go
74 lines (66 loc) · 1.88 KB
/
utils.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
package main
import (
b64 "encoding/base64"
"fmt"
"io"
urlp "net/url"
"os"
"runtime"
"strconv"
"sync/atomic"
"github.com/fatih/color"
"github.com/valyala/fasthttp"
)
var (
boldGreen = color.New(color.FgGreen, color.Bold).SprintFunc()
boldRed = color.New(color.FgRed, color.Bold).SprintFunc()
boldCyan = color.New(color.FgCyan, color.Bold).SprintFunc()
w io.Writer
)
func ReverseString(str string) (result string) {
for _, v := range str {
result = string(v) + result
}
return
}
func Decode(str string) (result string) {
rev, _ := urlp.QueryUnescape(ReverseString(string(str)))
decode, _ := b64.StdEncoding.DecodeString(rev)
return string(decode)
}
func SetHeaders(req *fasthttp.Request, cookie ...string) {
req.Header.Set("origin", url)
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36")
req.Header.Set("x-requested-with", "XMLHttpRequest")
req.Header.Set("Host", "zefoy.com")
if len(cookie) > 0 {
req.Header.Set("cookie", cookie[0])
}
}
func CheckOS() {
switch runtime.GOOS {
case "windows":
w = color.Output
case "linux":
w = os.Stdout
}
}
func Log(msg string, clr string, service string) {
switch clr {
case "green":
fmt.Fprintf(w, "[%s]: [%s]\n", color.GreenString(service), color.GreenString(msg))
case "yellow":
fmt.Fprintf(w, "[%s]: [%s]\n", color.YellowString(service), color.YellowString(msg))
case "cyan":
fmt.Fprintf(w, "[%s]: [%s]\n", boldCyan(service), boldCyan(msg))
case "boldGreen":
fmt.Fprintf(w, "[%s]: [%s]\n", boldGreen(service), boldGreen(msg))
}
}
func LogErr(msg error, service string) {
fmt.Fprintf(w, "[%s]: [%s]\n", boldRed(service), boldRed(msg))
}
func AddToCount() {
atomic.AddUint32(&count, 1)
fmt.Fprintf(w, "%s: %s\n", boldGreen("Successful requests"), boldGreen(strconv.Itoa(int(atomic.LoadUint32(&count)))))
}