-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy_checker.go
More file actions
144 lines (121 loc) · 4.07 KB
/
Copy pathproxy_checker.go
File metadata and controls
144 lines (121 loc) · 4.07 KB
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
package main
import (
"bufio"
"encoding/json"
"fmt"
"net"
"net/http"
"net/url"
"os"
"sync"
"sync/atomic"
"time"
"github.com/inancgumus/screen"
)
type ResponseData struct {
IP string `json:"ip"`
}
func isIPv4(ip string) bool {
return net.ParseIP(ip).To4() != nil
}
var validProxies int32
var badProxies int32
var totalProxies int32
func printLogo() {
fmt.Printf(
`
: .. :
. -. -- .- .
:. .=. == .=. .:
--. ==. .==. .== .--
.:. -=- -==.:==:.==- -=- .:.
.--: -==::===-==-===::==- :--.
.-=-:.-================-.:-=-.
.::.. :========================: ..::.
.:-==---======================---==-:.
:-==========================-:
.:::::::---========================---:::::::.
...::--==========================--::...
.:-==========================-:.
.:-====--========================--====-:.
.. .-========================-. ..
:===-:====================:-===:
.--:. .-==-==============-==-. .:--.
.. :==-.:===-======-===:.-==: ..
--: ==- :==::==: -== :--
.:. -=: :=- -=: :=- .:.
.=. :=. .=: .=.
- -- -- -
. - - .
. .
Coded by recoo33 / savalierdev
`)
}
func updateTitle() {
for {
screen.Clear()
screen.MoveTopLeft()
printLogo()
fmt.Printf(" Valid Proxies: %d | Bad Proxies: %d | Remaining: %d\n", validProxies, badProxies, totalProxies-(validProxies+badProxies))
time.Sleep(500 * time.Millisecond)
}
}
func checkProxy(proxy string, wg *sync.WaitGroup, sem chan struct{}) {
defer wg.Done()
sem <- struct{}{}
defer func() { <-sem }()
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(&url.URL{Scheme: "http", Host: proxy}),
},
Timeout: time.Second * 3,
}
response, err := client.Post("https://location-api.f-secure.com/v1/ip-country", "", nil)
if err != nil || response.StatusCode != 200 {
atomic.AddInt32(&badProxies, 1)
return
}
defer response.Body.Close()
var data ResponseData
if err := json.NewDecoder(response.Body).Decode(&data); err != nil {
atomic.AddInt32(&badProxies, 1)
return
}
atomic.AddInt32(&validProxies, 1)
if isIPv4(data.IP) {
saveProxyToFile(proxy, "work_proxies_v4.txt")
} else {
saveProxyToFile(proxy, "work_proxies_v6.txt")
}
}
func saveProxyToFile(proxy, fileName string) {
file, err := os.OpenFile(fileName, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
panic(err)
}
defer file.Close()
file.WriteString(proxy + "\n")
}
func main() {
var threadCount int
fmt.Print("Thread: ")
fmt.Scanln(&threadCount)
printLogo()
file, err := os.Open("proxy.txt")
if err != nil {
panic(err)
}
defer file.Close()
sem := make(chan struct{}, threadCount)
var wg sync.WaitGroup
scanner := bufio.NewScanner(file)
for scanner.Scan() {
proxy := scanner.Text()
atomic.AddInt32(&totalProxies, 1)
wg.Add(1)
go checkProxy(proxy, &wg, sem)
}
// Update console
go updateTitle()
wg.Wait()
}