-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (42 loc) · 954 Bytes
/
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
package main
import (
"bufio"
"fmt"
"io"
"net/http"
"os"
"github.com/groovy-sky/doh4a/v2/pkg/table"
)
func main() {
var aztable table.AzureTable
connStr, exist := os.LookupEnv("AzureWebJobsStorage")
if !exist {
fmt.Println("[ERR] Couldn't obtain connection string")
return
}
tableName := "table3"
err := aztable.Init(connStr, tableName)
if err != nil {
panic(err)
}
//aztable.SetEntry("test.com")
//_, blocked := aztable.GetEntry("aaa.test.com")
//fmt.Println(blocked)
url := "https://raw.githubusercontent.com/Ultimate-Hosts-Blacklist/Ultimate.Hosts.Blacklist/master/domains/domains0.list"
res, err := http.Get(url)
if err != nil {
fmt.Println("[ERR] Couldn't reach " + url)
}
defer res.Body.Close()
file := bufio.NewReader(res.Body)
for {
domain, err := file.ReadString('\n')
if err != nil {
if err != io.EOF {
fmt.Println(err)
}
break
}
aztable.SetEntry(domain[:len(domain)-1])
}
}