-
Notifications
You must be signed in to change notification settings - Fork 0
/
domains_json_provider.go
58 lines (43 loc) · 1.42 KB
/
domains_json_provider.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
package main
import (
"github.com/pkg/errors"
"encoding/json"
)
type DomainsJsonProvider struct {
}
func NewDomainsJsonProvider() *DomainsJsonProvider {
return new(DomainsJsonProvider)
}
func (provider *DomainsJsonProvider) Get() ([]string, error) {
domains := []string{}
urls := []string{
"https://raw.githubusercontent.com/ClippingGorilla/ClippingGorilla/master/ClippingGorilla/src/main/resources/mailblacklist/blacklist.json",
"https://raw.githubusercontent.com/yclas/yclas/master/oc/banned_domains.json",
"https://raw.githubusercontent.com/PHPAuth/PHPAuth/master/files/domains.json",
"https://raw.githubusercontent.com/ivolo/disposable-email-domains/master/index.json",
"https://raw.githubusercontent.com/fnando/validators/master/data/disposable.json",
"https://raw.githubusercontent.com/nojacko/email-data-disposable/master/data/disposable.json",
}
for _, url := range urls {
providerDomains, _ := provider.getSingle(url)
for _, domain := range providerDomains {
domains = append(domains, domain)
}
}
return domains, nil
}
func (provider *DomainsJsonProvider) getSingle(url string) ([]string, error) {
var domains []string
content, response, err := getURL(url)
if err != nil {
return []string{}, err
}
if response.StatusCode != 200 {
return []string{}, errors.New(content)
}
err = json.Unmarshal([]byte(content), &domains)
if err != nil {
return []string{}, err
}
return domains, nil
}