Skip to content

REST query responses are obfuscated when log privacy is enabled #1950

@TimQuelch

Description

@TimQuelch

Responses to the /api/query endpoint are obfuscated when log privacy config option is enabled.

Minimal config

ports:
  http: 8080

upstreams:
  groups:
    default:
      - 1.1.1.1

log:
  privacy: true

Result:

$ curl -s localhost:8080/api/query --data '{"query":"example.com","type":"A"}' | jq
{
  "reason": "RESOLVED (tcp+udp:1.1.1.1)",
  "response": "* (**.***.***.**), * (**.***.*.***), * (**.***.**.***), * (**.***.*.***), * (**.***.***.**), * (**.***.**.***)",
  "responseType": "RESOLVED",
  "returnCode": "NOERROR"
}

This looks to be because the REST server implementation uses the same formatter as the logger

  • Response: util.AnswerToString(resp.Res.Answer),
  • blocky/util/common.go

    Lines 49 to 69 in 257fe07

    // AnswerToString creates a user-friendly representation of an answer
    func AnswerToString(answer []dns.RR) string {
    answers := make([]string, len(answer))
    for i, record := range answer {
    switch v := record.(type) {
    case *dns.A:
    answers[i] = fmt.Sprintf("A (%s)", v.A)
    case *dns.AAAA:
    answers[i] = fmt.Sprintf("AAAA (%s)", v.AAAA)
    case *dns.CNAME:
    answers[i] = fmt.Sprintf("CNAME (%s)", v.Target)
    case *dns.PTR:
    answers[i] = fmt.Sprintf("PTR (%s)", v.Ptr)
    default:
    answers[i] = record.String()
    }
    }
    return Obfuscate(strings.Join(answers, ", "))
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions