-
Notifications
You must be signed in to change notification settings - Fork 2
/
alibaba.go
62 lines (60 loc) · 1.55 KB
/
alibaba.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
package main
import (
"fmt"
"bufio"
"os"
"net/http"
"net"
"sync"
"time"
)
func alibabaOss() {
fmt.Println("[\033[36;1m*\033[0m] \033[36;1mAlibaba OSS: \033[0m")
fmt.Println("====================================================")
timeout := time.Duration(to * 1000000)
var tr = &http.Transport{
MaxIdleConns: 30,
IdleConnTimeout: time.Second,
DisableKeepAlives: true,
DialContext: (&net.Dialer{
Timeout: timeout,
KeepAlive: time.Second,
}).DialContext,
}
client := &http.Client{
Transport: tr,
Timeout: timeout,
}
alijobs := make(chan string)
var wg sync.WaitGroup
for i := 0; i < concurrency; i ++ {
wg.Add(1)
go func() {
defer wg.Done()
for domain := range alijobs {
url := "http://" + domain + "." + alibabaRegion + ".aliyuncs.com"
req, err := client.Get(url)
if err != nil {
continue
}
defer req.Body.Close()
if req.StatusCode == 200 {
fmt.Println(url + " [\033[32m200\033[0m] \033[0m")
}
if fe {
if req.StatusCode == 403 {
fmt.Println(url + " [\033[31m403\033[0m] \033[0m")
}
}
}
}()
}
sc := bufio.NewScanner(os.Stdin)
for sc.Scan() {
domain := sc.Text()
alijobs <- domain
}
close(alijobs)
wg.Wait()
fmt.Println("====================================================")
}