/// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            var head = $";; ->>HEADER<<- opcode: {OPCode}, status: {DnsResponseCodeText.GetErrorText(ResponseCode)}, id: {Id}";
            var flags = new string[] {
                        HasQuery ? "qr" : "",
                        HasAuthorityAnswer ? "aa" : "",
                        RecursionDesired ? "rd" : "",
                        RecursionAvailable ? "ra" : "",
                        ResultTruncated ? "tc" : "",
                        IsCheckingDisabled ? "cd" : "",
                        IsAuthenticData ? "ad" : ""
                    };

            var flagsString = string.Join(" ", flags.Where(p => p != ""));
            return $"{head}\r\n;; flags: {flagsString}; QUERY: {QuestionCount}, " +
                $"ANSWER: {AnswerCount}, AUTORITY: {NameServerCount}, ADDITIONAL: {AdditionalCount}";
        }
Exemplo n.º 2
0
        public void AuditException(Exception ex)
        {
            var aggEx = ex as AggregateException;

            if (ex is DnsResponseException dnsEx)
            {
                _auditWriter.AppendLine($";; Error: {DnsResponseCodeText.GetErrorText(dnsEx.Code)} {dnsEx.InnerException?.Message ?? dnsEx.Message}");
            }
            else if (aggEx != null)
            {
                _auditWriter.AppendLine($";; Error: {aggEx.InnerException?.Message ?? aggEx.Message}");
            }
            else
            {
                _auditWriter.AppendLine($";; Error: {ex.Message}");
            }

            if (Debugger.IsAttached)
            {
                _auditWriter.AppendLine(ex.ToString());
            }
        }
Exemplo n.º 3
0
 public void AuditResponseError(DnsResponseCode responseCode)
 {
     _auditWriter.AppendLine($";; ERROR: {DnsResponseCodeText.GetErrorText(responseCode)}");
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DnsResponseException"/> class
 /// with a custom <paramref name="message"/> and the given <paramref name="code"/>.
 /// </summary>
 public DnsResponseException(DnsResponseCode code, string message, Exception innerException) : base(message, innerException)
 {
     Code     = code;
     DnsError = DnsResponseCodeText.GetErrorText(Code);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DnsResponseException"/> class
 /// with <see cref="Code"/> set to <see cref="DnsResponseCode.Unassigned"/>
 /// and a custom <paramref name="message"/> and inner <see cref="Exception"/>.
 /// </summary>
 public DnsResponseException(string message, Exception innerException) : base(message, innerException)
 {
     Code     = DnsResponseCode.Unassigned;
     DnsError = DnsResponseCodeText.GetErrorText(Code);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DnsResponseException"/> class
 /// with the standard error text for the given <paramref name="code"/>.
 /// </summary>
 public DnsResponseException(DnsResponseCode code) : base(DnsResponseCodeText.GetErrorText(code))
 {
     Code     = code;
     DnsError = DnsResponseCodeText.GetErrorText(Code);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DnsResponseException"/> class
 /// with <see cref="Code"/> set to <see cref="DnsResponseCode.Unassigned"/>.
 /// </summary>
 public DnsResponseException() : base(DnsResponseCodeText.Unassigned)
 {
     Code     = DnsResponseCode.Unassigned;
     DnsError = DnsResponseCodeText.GetErrorText(Code);
 }