Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve ip addr #317

Merged
merged 1 commit into from
Nov 27, 2024
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
4 changes: 4 additions & 0 deletions cdncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (c *Client) CheckDNSResponse(dnsResponse *retryabledns.DNSData) (matched bo
return false, "", "", err
}

func (c *Client) GetDnsData(domain string) (*retryabledns.DNSData, error) {
return c.retriabledns.Resolve(domain)
}

func mapKeys(m map[string][]string) string {
keys := make([]string, 0, len(m))
for k := range m {
Expand Down
10 changes: 7 additions & 3 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,22 @@ func (r *Runner) processInputItemSingle(item string, output chan Output) {
var provider, itemType string
var err error

var targetIp string
if iputils.IsIP(item) {
targetIP := net.ParseIP(item)
matched, provider, itemType, err = r.cdnclient.Check(targetIP)
matched, provider, itemType, err = r.cdnclient.Check(net.ParseIP(item))
targetIp = item
} else {
matched, provider, itemType, err = r.cdnclient.CheckDomainWithFallback(item)
if dnsData, err := r.cdnclient.GetDnsData(item); err == nil && len(dnsData.A) > 0 {
targetIp = dnsData.A[0]
}
}
if err != nil && r.options.Verbose {
gologger.Error().Msgf("Could not check domain cdn %s: %s", item, err)
}

data.itemType = itemType
data.IP = item
data.IP = targetIp
data.Timestamp = time.Now()

if r.options.Exclude {
Expand Down
Loading