Exemple #1
0
        public string SelectOperation(ref Message message)
        {
            string action = message.Headers.Action;
            string str2   = null;

            byte[] defaultId             = PeerNodeImplementation.DefaultId;
            string str3                  = PeerStrings.FindAction(action);
            Uri    via                   = null;
            Uri    uri2                  = null;
            bool   flag                  = false;
            PeerMessageProperty property = new PeerMessageProperty();

            if (str3 != null)
            {
                return(str3);
            }
            try
            {
                str2 = PeerMessageHelpers.GetHeaderString(message.Headers, "FloodMessage", "http://schemas.microsoft.com/net/2006/05/peer");
                via  = PeerMessageHelpers.GetHeaderUri(message.Headers, "PeerVia", "http://schemas.microsoft.com/net/2006/05/peer");
                uri2 = PeerMessageHelpers.GetHeaderUri(message.Headers, "PeerTo", "http://schemas.microsoft.com/net/2006/05/peer");
            }
            catch (MessageHeaderException exception)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning);
                return("Fault");
            }
            catch (SerializationException exception2)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning);
                return("Fault");
            }
            catch (XmlException exception3)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Warning);
                return("Fault");
            }
            property.PeerVia = via;
            property.PeerTo  = uri2;
            message.Properties.Add("PeerProperty", property);
            if (!(str2 == "PeerFlooder"))
            {
                return(null);
            }
            try
            {
                if (!this.messageHandler.ValidateIncomingMessage(ref message, via))
                {
                    property.SkipLocalChannels = true;
                    flag = true;
                    TurnOffSecurityHeader(message);
                }
                if (this.messageHandler.IsNotSeenBefore(message, out defaultId, out property.CacheMiss))
                {
                    property.MessageVerified = true;
                }
                else if (!flag)
                {
                    property.SkipLocalChannels = true;
                }
                if (defaultId == PeerNodeImplementation.DefaultId)
                {
                    return("Fault");
                }
            }
            catch (MessageHeaderException exception4)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception4, TraceEventType.Warning);
                return("Fault");
            }
            catch (SerializationException exception5)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception5, TraceEventType.Warning);
                return("Fault");
            }
            catch (XmlException exception6)
            {
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception6, TraceEventType.Warning);
                return("Fault");
            }
            catch (MessageSecurityException exception7)
            {
                if (!exception7.ReplayDetected)
                {
                    return("Fault");
                }
                System.ServiceModel.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception7, TraceEventType.Information);
            }
            return("FloodMessage");
        }
        public string SelectOperation(ref Message message)
        {
            string action = message.Headers.Action;
            string demux  = null;

            byte[] id        = PeerNodeImplementation.DefaultId;
            string operation = PeerStrings.FindAction(action);
            Uri    via       = null;
            Uri    to        = null;
            bool   skipped   = false;
            PeerMessageProperty peerProperty = new PeerMessageProperty();

            if (operation != null)
            {
                return(operation);
            }
            try
            {
                demux = PeerMessageHelpers.GetHeaderString(message.Headers, PeerOperationNames.Flood, PeerStrings.Namespace);
                via   = PeerMessageHelpers.GetHeaderUri(message.Headers, PeerStrings.Via, PeerStrings.Namespace);
                to    = PeerMessageHelpers.GetHeaderUri(message.Headers, PeerOperationNames.PeerTo, PeerStrings.Namespace);
            }
            catch (MessageHeaderException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                return(PeerOperationNames.Fault);
            }
            catch (SerializationException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                return(PeerOperationNames.Fault);
            }
            catch (XmlException e)
            {
                DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                return(PeerOperationNames.Fault);
            }
            peerProperty.PeerVia = via;
            peerProperty.PeerTo  = to;
            message.Properties.Add(PeerStrings.PeerProperty, peerProperty);
            if (demux == PeerOperationNames.Demuxer)
            {
                try
                {
                    if (!this.messageHandler.ValidateIncomingMessage(ref message, via))
                    {
                        peerProperty.SkipLocalChannels = true;
                        skipped = true;
                        TurnOffSecurityHeader(message);
                    }
                    if (this.messageHandler.IsNotSeenBefore(message, out id, out peerProperty.CacheMiss))
                    {
                        peerProperty.MessageVerified = true;
                    }
                    else
                    {
                        if (!skipped)
                        {
                            peerProperty.SkipLocalChannels = true;
                        }
                    }
                    //means that the message doesnt contain legal id
                    if (id == PeerNodeImplementation.DefaultId)
                    {
                        return(PeerOperationNames.Fault);
                    }
                }
                catch (MessageHeaderException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                    return(PeerOperationNames.Fault);
                }
                catch (SerializationException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                    return(PeerOperationNames.Fault);
                }
                catch (XmlException e)
                {
                    DiagnosticUtility.TraceHandledException(e, TraceEventType.Warning);
                    return(PeerOperationNames.Fault);
                }
                catch (MessageSecurityException e)
                {
                    if (!e.ReplayDetected)
                    {
                        return(PeerOperationNames.Fault);
                    }
                    else
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Information);
                    }
                }
                return(PeerOperationNames.Flood);
            }
            else
            {
                return(null);
            }
        }