-
Notifications
You must be signed in to change notification settings - Fork 0
/
dupecheck.go
51 lines (45 loc) · 1.06 KB
/
dupecheck.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
package main
import (
"log"
"net/http"
"os"
"strings"
"github.com/getlantern/cloudflare"
"github.com/getlantern/peerscanner/cf"
)
func main() {
allRecs := map[string]map[string][]cloudflare.Record{
"fallbacks": make(map[string][]cloudflare.Record),
"fl-": make(map[string][]cloudflare.Record),
"peers": make(map[string][]cloudflare.Record),
"roundrobin": make(map[string][]cloudflare.Record),
}
u := cf.New("getiantem.org", os.Getenv("CFL_USER"), os.Getenv("CFL_API_KEY"))
u.Client.Http.Transport = &http.Transport{
DisableKeepAlives: true,
}
recs, err := u.GetAllRecords()
if err != nil {
log.Fatalf("Unable to get records: %v", err)
}
for _, r := range recs {
for k, ar := range allRecs {
if strings.Contains(r.Name, k) {
fb := ar[r.Value]
if fb == nil {
fb = []cloudflare.Record{r}
} else {
fb = append(fb, r)
}
ar[r.Value] = fb
}
}
}
for k, ar := range allRecs {
for ip, recs := range ar {
if len(recs) > 1 {
log.Printf("%v appears %d times in %v", ip, len(recs), k)
}
}
}
}