refactor: refactor the code for qol.go
This commit is contained in:
46
cmd/qol/qol.go
Normal file
46
cmd/qol/qol.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/afonsofrancof/sdns-proxy/internal/qol"
|
||||
"github.com/alecthomas/kong"
|
||||
)
|
||||
|
||||
type CLI struct {
|
||||
Run RunCmd `cmd:"" help:"Run measurements for given servers and domains"`
|
||||
}
|
||||
|
||||
type RunCmd struct {
|
||||
DomainsFile string `arg:"" help:"File with domains (one per line)"`
|
||||
OutputDir string `short:"o" long:"output" default:"results" help:"Output directory"`
|
||||
QueryType string `short:"t" long:"type" default:"A" help:"DNS query type"`
|
||||
Timeout time.Duration `long:"timeout" default:"5s" help:"Query timeout (informational)"`
|
||||
DNSSEC bool `long:"dnssec" help:"Enable DNSSEC"`
|
||||
Interface string `long:"iface" default:"any" help:"Capture interface (e.g., eth0, any)"`
|
||||
Servers []string `short:"s" long:"server" help:"Upstream servers (udp://..., tls://..., https://..., doq://...)"`
|
||||
}
|
||||
|
||||
func (r *RunCmd) Run() error {
|
||||
config := qol.MeasurementConfig{
|
||||
DomainsFile: r.DomainsFile,
|
||||
OutputDir: r.OutputDir,
|
||||
QueryType: r.QueryType,
|
||||
DNSSEC: r.DNSSEC,
|
||||
Interface: r.Interface,
|
||||
Servers: r.Servers,
|
||||
}
|
||||
|
||||
runner := qol.NewMeasurementRunner(config)
|
||||
return runner.Run()
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx := kong.Parse(&CLI{},
|
||||
kong.Name("dns-measurer"),
|
||||
kong.Description("DNS secure protocols measurer with metrics + full pcap capture"),
|
||||
kong.UsageOnError(),
|
||||
)
|
||||
err := ctx.Run()
|
||||
ctx.FatalIfErrorf(err)
|
||||
}
|
||||
Reference in New Issue
Block a user