Esempio n. 1
0
        /// <summary>
        /// Request resulted in a failure.
        /// </summary>
        /// <param name="ID">Original request ID.</param>
        protected virtual void ProcessMessageFailure(ushort ID)
        {
            Rec Rec;

            lock (this.outgoingMessages)
            {
                if (this.outgoingMessages.TryGetValue(ID, out Rec))
                {
                    this.outgoingMessages.Remove(ID);
                }
                else
                {
                    return;
                }
            }

            try
            {
                DnsMessage Message = new DnsMessage(new byte[]
                {
                    (byte)(ID >> 8),
                    (byte)(ID & 255),
                    0x80,                       // Response
                    (byte)RCode.ServFail,
                    0, 0,                       // QDCOUNT
                    0, 0,                       // ANCOUNT
                    0, 0,                       // NSCOUNT
                    0, 0                        // ARCOUNT
                });

                Rec.Callback?.Invoke(this, new DnsMessageEventArgs(Message, Rec.State));
            }
            catch (Exception ex)
            {
                Log.Critical(ex);
            }
        }
 /// <summary>
 /// DNS Messge event arguments.
 /// </summary>
 /// <param name="Message">DNS Message</param>
 /// <param name="State">State object</param>
 public DnsMessageEventArgs(DnsMessage Message, object State)
 {
     this.message = Message;
     this.state   = State;
 }