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

InternalIPs checker #43

Merged
merged 2 commits into from Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 23 additions & 20 deletions client.go
Expand Up @@ -388,24 +388,25 @@ func (c *Client) Trace(host string, requestType uint16, maxrecursion int) (*Trac

// DNSData is the data for a DNS request response
type DNSData struct {
Host string `json:"host,omitempty"`
TTL int `json:"ttl,omitempty"`
Resolver []string `json:"resolver,omitempty"`
A []string `json:"a,omitempty"`
AAAA []string `json:"aaaa,omitempty"`
CNAME []string `json:"cname,omitempty"`
MX []string `json:"mx,omitempty"`
PTR []string `json:"ptr,omitempty"`
SOA []string `json:"soa,omitempty"`
NS []string `json:"ns,omitempty"`
TXT []string `json:"txt,omitempty"`
Raw string `json:"raw,omitempty"`
Internal bool `json:"internal,omitempty"`
StatusCode string `json:"status_code,omitempty"`
StatusCodeRaw int `json:"status_code_raw,omitempty"`
TraceData *TraceData `json:"trace,omitempty"`
RawResp *dns.Msg `json:"raw_resp,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
Host string `json:"host,omitempty"`
TTL int `json:"ttl,omitempty"`
Resolver []string `json:"resolver,omitempty"`
A []string `json:"a,omitempty"`
AAAA []string `json:"aaaa,omitempty"`
CNAME []string `json:"cname,omitempty"`
MX []string `json:"mx,omitempty"`
PTR []string `json:"ptr,omitempty"`
SOA []string `json:"soa,omitempty"`
NS []string `json:"ns,omitempty"`
TXT []string `json:"txt,omitempty"`
Raw string `json:"raw,omitempty"`
HasInternalIPs bool `json:"has_internal_ips"`
InternalIPs []string `json:"internal_ips,omitempty"`
StatusCode string `json:"status_code,omitempty"`
StatusCodeRaw int `json:"status_code_raw,omitempty"`
TraceData *TraceData `json:"trace,omitempty"`
RawResp *dns.Msg `json:"raw_resp,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}

// CheckInternalIPs when set to true returns if DNS response IPs
Expand All @@ -421,7 +422,8 @@ func (d *DNSData) ParseFromMsg(msg *dns.Msg) error {
switch recordType := record.(type) {
case *dns.A:
if CheckInternalIPs && internalRangeCheckerInstance != nil && internalRangeCheckerInstance.ContainsIPv4(recordType.A) {
d.Internal = true
d.HasInternalIPs = true
d.InternalIPs = append(d.InternalIPs, trimChars(recordType.A.String()))
}
d.A = append(d.A, trimChars(recordType.A.String()))
case *dns.NS:
Expand All @@ -441,7 +443,8 @@ func (d *DNSData) ParseFromMsg(msg *dns.Msg) error {
}
case *dns.AAAA:
if CheckInternalIPs && internalRangeCheckerInstance.ContainsIPv6(recordType.AAAA) {
d.Internal = true
d.HasInternalIPs = true
d.InternalIPs = append(d.InternalIPs, trimChars(recordType.AAAA.String()))
}
d.AAAA = append(d.AAAA, trimChars(recordType.AAAA.String()))
}
Expand Down