standard commit

This commit is contained in:
MDK
2023-08-03 15:25:17 +08:00
parent 38be845348
commit 4fcf28804c
12 changed files with 466 additions and 87 deletions

37
cmd/cache.go Normal file
View File

@@ -0,0 +1,37 @@
package cmd
import (
"dtool/prober"
"dtool/scheduler"
"dtool/utils"
"github.com/spf13/cobra"
)
var query_cnt int
var inputfile string
var outputfile string
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 {
scheduler.CreateTask(prober.RecursiveCacheProbe, inputfile, outputfile, 10)
}
}
func init() {
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")
rootCmd.AddCommand(cacheCmd)
}

25
cmd/domain.go Normal file
View File

@@ -0,0 +1,25 @@
package cmd
import (
"github.com/spf13/cobra"
)
var input string
var output string
var domainCmd = &cobra.Command{
Use: "domain",
Short: "query the ip and nameserver information",
Long: "query the ip and nameserver information",
Run: getDomainInfo,
}
func getDomainInfo(cmd *cobra.Command, args []string) {
}
func init() {
domainCmd.Flags().StringVarP(&input, "input", "i", "", "")
domainCmd.Flags().StringVarP(&output, "output", "o", "", "")
domainCmd.MarkFlagsRequiredTogether("input", "output")
rootCmd.AddCommand(domainCmd)
}

View File

@@ -2,9 +2,7 @@ package cmd
import (
"dtool/prober"
_ "dtool/prober"
"dtool/utils"
_ "dtool/utils"
"errors"
"github.com/spf13/cobra"

20
cmd/version.go Normal file
View File

@@ -0,0 +1,20 @@
package cmd
import (
"github.com/spf13/cobra"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "get server version with version.bind",
Long: "get server version with version.bind chaos txt request",
Run: version,
}
func version(cmd *cobra.Command, args []string) {
}
func init() {
rootCmd.AddCommand(versionCmd)
}