standard commit
This commit is contained in:
66
prober/cache_prober.go
Normal file
66
prober/cache_prober.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package prober
|
||||
|
||||
import (
|
||||
"dtool/utils"
|
||||
_ "fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const query_num = 20
|
||||
|
||||
type CacheStruct struct {
|
||||
target string
|
||||
dict map[int]map[string]bool
|
||||
}
|
||||
|
||||
func RecursiveCacheProbe(ip string) CacheStruct {
|
||||
data := CacheStruct{ip, make(map[int]map[string]bool)}
|
||||
stop := 0
|
||||
time_now := strconv.FormatInt(time.Now().Unix(), 10)
|
||||
for i := 0; i < query_num; i++ {
|
||||
if stop >= 3 {
|
||||
break
|
||||
}
|
||||
subdomain := strings.Join([]string{strings.Replace(ip, ".", "-", -1), "fwd", strconv.Itoa(i), time_now}, "-")
|
||||
domain := subdomain + ".echodns.xyz."
|
||||
res, err := utils.SendQuery(ip, domain)
|
||||
if err != nil {
|
||||
//fmt.Printf("Error sending query: %s\n", err)
|
||||
stop += 1
|
||||
continue
|
||||
}
|
||||
cache_id, rdns, err := utils.ParseCNAMEChain(res)
|
||||
if err != nil {
|
||||
//fmt.Printf("Error parsing response: %s\n", err)
|
||||
stop += 1
|
||||
continue
|
||||
}
|
||||
if data.dict[cache_id] == nil {
|
||||
data.dict[cache_id] = make(map[string]bool)
|
||||
}
|
||||
data.dict[cache_id][rdns] = true
|
||||
stop = 0
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func RecursiveCacheTest(ip string, num int) {
|
||||
res := make(map[string]map[int][]string)
|
||||
temp := make(map[int][]string)
|
||||
data := RecursiveCacheProbe(ip)
|
||||
if len(data.dict) > 0 {
|
||||
for cache_id := range data.dict {
|
||||
for rdns := range data.dict[cache_id] {
|
||||
temp[cache_id] = append(temp[cache_id], rdns)
|
||||
}
|
||||
}
|
||||
}
|
||||
res[ip] = temp
|
||||
utils.OutputJSON(res, "-", " ")
|
||||
}
|
||||
|
||||
func ClientCacheProbe(ip string) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user