Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ func (r *Runner) worker() {
r.limiter.Take()
dnsData := dnsx.ResponseData{}
// Ignoring errors as partial results are still good
queryStart := time.Now()
dnsData.DNSData, _ = r.dnsx.QueryMultiple(domain)
dnsData.QueryTime = time.Since(queryStart).Round(time.Millisecond).String()
Comment on lines +628 to +630
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Query time is dropped in wildcard-filtering output path.

dnsData.QueryTime is set at Line 630, but wildcard mode stores/loads only retryabledns.DNSData, so JSON emitted later cannot include the new field. This makes query-time output incomplete for wildcard runs.

💡 Suggested patch direction
+type storedDNSData struct {
+	DNSData   *retryabledns.DNSData `json:"dns_data"`
+	QueryTime string                `json:"query-time,omitempty"`
+}

- if err := r.storeDNSData(dnsData.DNSData); err != nil {
+ if err := r.storeDNSData(&dnsData); err != nil {
    gologger.Debug().Msgf("Failed to store DNS data for %s: %v\n", domain, err)
  }

-func (r *Runner) storeDNSData(dnsdata *retryabledns.DNSData) error {
-	dnsdata.RawResp = nil
-	data, err := dnsdata.JSON()
+func (r *Runner) storeDNSData(resp *dnsx.ResponseData) error {
+	resp.RawResp = nil
+	data, err := json.Marshal(storedDNSData{
+		DNSData:   resp.DNSData,
+		QueryTime: resp.QueryTime,
+	})
 	if err != nil {
 		return err
 	}
-	return r.hm.Set(dnsdata.Host, []byte(data))
+	return r.hm.Set(resp.Host, data)
 }

-func (r *Runner) loadStoredDNSData(host string) (*retryabledns.DNSData, error) {
+func (r *Runner) loadStoredDNSData(host string) (*storedDNSData, error) {
 	data, ok := r.hm.Get(host)
 	if !ok {
 		return nil, errors.New("dns data not found")
 	}
-
-	var dnsdata retryabledns.DNSData
-	if err := json.Unmarshal(data, &dnsdata); err != nil {
+	var stored storedDNSData
+	if err := json.Unmarshal(data, &stored); err != nil {
 		return nil, err
 	}
-
-	return &dnsdata, nil
+	return &stored, nil
 }

Also applies to: 737-742, 533-547, 922-944

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/runner/runner.go` around lines 628 - 630, The DNS query timing
(dnsData.QueryTime) is being assigned after calling r.dnsx.QueryMultiple(domain)
but wildcard-mode storage only serializes retryabledns.DNSData, so the QueryTime
string is never persisted; update the representation that gets stored/loaded
(the retryabledns.DNSData type or the code paths that serialize it) to include
QueryTime and ensure you set that field immediately after QueryMultiple returns
(locations around the dnsData assignment in runner.go and the other noted spots:
~533-547, ~628-630, ~737-742, ~922-944). Concretely, modify the
retryabledns.DNSData struct to have a QueryTime field (string or duration) or
wrap the stored payload so QueryTime is included, and set that field right after
dnsx.QueryMultiple(domain) before any save/serialize operations so wildcard runs
emit the timing in JSON.

// Just skipping nil responses (in case of critical errors)
if dnsData.DNSData == nil {
continue
Expand Down
9 changes: 5 additions & 4 deletions libs/dnsx/dnsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ type Options struct {
// ResponseData to show output result
type ResponseData struct {
*retryabledns.DNSData
IsCDNIP bool `json:"cdn,omitempty" csv:"cdn"`
CDNName string `json:"cdn-name,omitempty" csv:"cdn-name"`
CDNType string `json:"cdn-type,omitempty" csv:"cdn-type"`
ASN *AsnResponse `json:"asn,omitempty" csv:"asn"`
IsCDNIP bool `json:"cdn,omitempty" csv:"cdn"`
CDNName string `json:"cdn-name,omitempty" csv:"cdn-name"`
CDNType string `json:"cdn-type,omitempty" csv:"cdn-type"`
ASN *AsnResponse `json:"asn,omitempty" csv:"asn"`
QueryTime string `json:"query-time,omitempty" csv:"query-time"`
}
type AsnResponse struct {
AsNumber string `json:"as-number,omitempty" csv:"as_number"`
Expand Down
Loading