2023-08-03 15:25:17 +08:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"dtool/prober"
|
|
|
|
|
"dtool/utils"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var query_cnt int
|
|
|
|
|
var inputfile string
|
|
|
|
|
var outputfile string
|
2023-09-26 14:12:04 +08:00
|
|
|
var goroutine_num int
|
|
|
|
|
var controlled_domain string
|
2023-08-03 15:25:17 +08:00
|
|
|
var cacheCmd = &cobra.Command{
|
|
|
|
|
Use: "cache",
|
|
|
|
|
Short: "cache related test",
|
|
|
|
|
Long: "cache related test",
|
|
|
|
|
Run: cache_test,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func cache_test(cmd *cobra.Command, args []string) {
|
|
|
|
|
if len(args) == 1 {
|
|
|
|
|
if utils.IsValidIP(args[0]) {
|
|
|
|
|
prober.RecursiveCacheTest(args[0], query_cnt)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-09-26 14:12:04 +08:00
|
|
|
prober.CreateTask(prober.RecursiveCacheProbe, controlled_domain, inputfile, outputfile, goroutine_num)
|
2023-08-03 15:25:17 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func init() {
|
2023-09-26 14:12:04 +08:00
|
|
|
cacheCmd.Flags().StringVarP(&controlled_domain, "domain", "d", "echodns.xyz", "controlled domain")
|
2023-08-03 15:25:17 +08:00
|
|
|
cacheCmd.Flags().StringVarP(&inputfile, "input", "i", "", "input file(optional)")
|
|
|
|
|
cacheCmd.Flags().StringVarP(&outputfile, "output", "o", "", "output file(optional)")
|
|
|
|
|
cacheCmd.MarkFlagsRequiredTogether("input", "output")
|
|
|
|
|
cacheCmd.Flags().IntVarP(&query_cnt, "num", "n", 20, "number of queries in one test")
|
2023-09-26 14:12:04 +08:00
|
|
|
cacheCmd.Flags().IntVarP(&goroutine_num, "concurrency", "t", 150, "number of goroutine")
|
2023-08-03 15:25:17 +08:00
|
|
|
rootCmd.AddCommand(cacheCmd)
|
|
|
|
|
}
|