mirror of
https://github.com/daeuniverse/dae.git
synced 2025-01-05 21:11:55 +07:00
fix: CNAME ans should also be flipped
This commit is contained in:
parent
868f8fd0e8
commit
e203ad1590
@ -132,12 +132,18 @@ func (c *ControlPlane) DnsRespHandler(data []byte) (newData []byte, err error) {
|
||||
return nil, fmt.Errorf("unpack dns pkt: %w", err)
|
||||
}
|
||||
FlipDnsQuestionCase(&msg)
|
||||
// Check healthy.
|
||||
// Check healthy resp.
|
||||
if !msg.Response || msg.RCode != dnsmessage.RCodeSuccess || len(msg.Questions) == 0 {
|
||||
return data, nil
|
||||
}
|
||||
// Check req type.
|
||||
q := msg.Questions[0]
|
||||
// If first answer is CNAME type, replace the Name with flipping-backed Name.
|
||||
if len(msg.Answers) > 0 &&
|
||||
msg.Answers[0].Header.Type == dnsmessage.TypeCNAME &&
|
||||
strings.EqualFold(msg.Answers[0].Header.Name.String(), q.Name.String()) {
|
||||
msg.Answers[0].Header.Name.Data = q.Name.Data
|
||||
}
|
||||
// Check req type.
|
||||
switch q.Type {
|
||||
case dnsmessage.TypeA, dnsmessage.TypeAAAA:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user