diff --git a/config.yaml b/config.yaml index 53cd92b..4d36c6a 100644 --- a/config.yaml +++ b/config.yaml @@ -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 diff --git a/lib/utils/utils.go b/lib/utils/utils.go index 1fa8e24..3ad4fbd 100644 --- a/lib/utils/utils.go +++ b/lib/utils/utils.go @@ -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 }