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

[Fix]<RawResponse> #21

Merged
merged 1 commit into from
Sep 19, 2023
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
9 changes: 9 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ rules:
- (.*\.)?bard\.google\.com
resolvers: "shecan"
resolverParams: ea.com.

- name: Test
matcher: regex
matcherParams:
- (.*\.)?test.domain.com
raw:
A: |
test.domain.com 60 IN CNAME google.403.
google.403. 60 IN A 127.0.0.1
23 changes: 15 additions & 8 deletions lib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,23 @@ func handleRawResponse(requestHostname string, r *rule.Rule, req *dns.Msg, w dns
log.Error().Msgf("%s not supported in the config, continue using default handler", dns.TypeToString[req.Question[0].Qtype])
return false
}
msg, err := dns.NewRR(formatString(*raw, mapper))
if err != nil {
log.Debug().Msgf("cannot parse raw response: %v", err)
return false
result := make([]dns.RR, 0)
rawList := strings.Split(*raw, "\n")
for _, value := range rawList {
msg, err := dns.NewRR(formatString(value, mapper))
if err != nil {
log.Debug().Msgf("cannot parse raw response: %v", err)
return false
}

if msg != nil {

result = append(result, msg)

}
}
if msg != nil {
result := make([]dns.RR, 0)
result = append(result, msg)
if len(result) > 0 {
req.Answer = result
log.Info().Msgf("cannot parse raw response: %v", req)
_ = w.WriteMsg(req)
return true
}
Expand Down