示例#1
0
        /// <summary>
        /// Processes a DNS message.
        /// </summary>
        /// <param name="query">The query message.</param>
        /// <param name="ipAddress">The IP address.</param>
        /// <param name="protocolType">The protocol type.</param>
        /// <returns>The processed message.</returns>
        private DnsMessageBase ProcessMessage(DnsMessageBase query, IPAddress ipAddress, ProtocolType protocolType)
        {
            if (query.TSigOptions != null)
            {
                switch (query.TSigOptions.ValidationResult)
                {
                    case ReturnCode.BadKey:
                    case ReturnCode.BadSig:
                        query.IsQuery = false;
                        query.ReturnCode = ReturnCode.NotAuthoritive;
                        query.TSigOptions.Error = query.TSigOptions.ValidationResult;
                        query.TSigOptions.KeyData = null;

                        if (InvalidSignedMessageReceived != null)
                            InvalidSignedMessageReceived(this, new InvalidSignedMessageEventArgs(query));

                        return query;

                    case ReturnCode.BadTime:
                        query.IsQuery = false;
                        query.ReturnCode = ReturnCode.NotAuthoritive;
                        query.TSigOptions.Error = query.TSigOptions.ValidationResult;
                        query.TSigOptions.OtherData = new byte[6];
                        int tmp = 0;
                        TSigRecord.EncodeDateTime(query.TSigOptions.OtherData, ref tmp, DateTime.Now);

                        if (InvalidSignedMessageReceived != null)
                            InvalidSignedMessageReceived(this, new InvalidSignedMessageEventArgs(query));

                        return query;
                }
            }

            return this.processQueryDelegate(query, ipAddress, protocolType);
        }
 /// <summary>
 /// Internal constructor.
 /// </summary>
 /// <param name="message">The DNS message.</param>
 internal InvalidSignedMessageEventArgs(DnsMessageBase message)
 {
     this.Message = message;
 }