Exemple #1
0
 // Token: 0x06001D3E RID: 7486 RVA: 0x00083E24 File Offset: 0x00082024
 public LogInspector(IPerfmonCounters perfmonCounters, IReplayConfiguration replayConfig, string logfileBaseName, string logfileSuffix, string replayDir, FileState fileState, ILogTruncater logTruncater, ISetBroken setBroken, ISetGeneration setGeneration, IReplicaProgress replicaProgress, NetworkPath netPath, bool runningAcll) : base(replayConfig.LogInspectorPath, logfileBaseName, 0L, logfileSuffix, setBroken, replicaProgress)
 {
     this.Config          = replayConfig;
     this.m_logTruncater  = logTruncater;
     this.m_replayDir     = replayDir;
     this.m_fileState     = fileState;
     this.m_setGeneration = setGeneration;
     this.m_logVerifier   = new LogVerifier(logfileBaseName);
     ExTraceGlobals.LogInspectorTracer.TraceDebug((long)this.GetHashCode(), "LogInspector initialized - inspectDir = {0}, logfileBaseName = {1}, replayDir = {2}, fileState = {3}", new object[]
     {
         replayConfig.LogInspectorPath,
         logfileBaseName,
         replayDir,
         fileState
     });
     ExTraceGlobals.PFDTracer.TracePfd((long)this.GetHashCode(), "LogInspector initialized - inspectDir = {0}, logfileBaseName = {1}, replayDir = {2}, fileState = {3}", new object[]
     {
         replayConfig.LogInspectorPath,
         logfileBaseName,
         replayDir,
         fileState
     });
     this.Config.ReplayState.InspectorGenerationNumber = this.m_fileState.HighestGenerationPresent;
     this.m_logSource = LogSource.Construct(replayConfig, perfmonCounters, netPath, LogSource.GetLogShipTimeoutInMsec(runningAcll));
     if (0L != this.m_fileState.HighestGenerationPresent)
     {
         this.m_logContinuityChecker.Initialize(this.m_fileState.HighestGenerationPresent, this.Config.DestinationLogPath, this.Config.LogFilePrefix, logfileSuffix);
     }
 }
		public static void ReportError(NetworkPath path, Exception e)
		{
		}
        internal static bool TestHealth(string targetServer, int targetPort, int timeOutInMs, out string errMsg)
        {
            errMsg = null;
            NetworkChannel networkChannel = null;
            Exception      ex             = null;

            ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: testing {0}", targetServer);
            try
            {
                ushort num = (ushort)targetPort;
                if (num == 0)
                {
                    num = 64327;
                }
                ITcpConnector tcpConnector = Dependencies.TcpConnector;
                NetworkPath   netPath      = tcpConnector.BuildDnsNetworkPath(targetServer, (int)num);
                networkChannel = NetworkChannel.Connect(netPath, TcpChannel.GetDefaultTimeoutInMs(), false);
                TestHealthRequest testHealthRequest = new TestHealthRequest(networkChannel);
                testHealthRequest.Send();
                NetworkChannelMessage message = networkChannel.GetMessage();
                if (!(message is TestHealthReply))
                {
                    networkChannel.ThrowUnexpectedMessage(message);
                }
                ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: {0} is healthy", targetServer);
                return(true);
            }
            catch (NetworkRemoteException ex2)
            {
                ex = ex2.InnerException;
            }
            catch (NetworkTransportException ex3)
            {
                ex = ex3;
            }
            catch (Win32Exception ex4)
            {
                ex = ex4;
            }
            catch (COMException ex5)
            {
                ex = ex5;
            }
            catch (ClusCommonFailException ex6)
            {
                ex = ex6;
            }
            catch (ClusCommonTransientException ex7)
            {
                ex = ex7;
            }
            finally
            {
                if (networkChannel != null)
                {
                    networkChannel.Close();
                }
            }
            if (ex != null)
            {
                ExTraceGlobals.TcpChannelTracer.TraceError <Exception>(0L, "TcpHealthCheck: failed: {0}", ex);
                errMsg = ex.Message;
            }
            return(false);
        }
Exemple #4
0
 // Token: 0x06001D3D RID: 7485 RVA: 0x00083DFC File Offset: 0x00081FFC
 public LogInspector(IPerfmonCounters perfmonCounters, IReplayConfiguration replayConfig, string logfileBaseName, string logfileSuffix, string replayDir, FileState fileState, ILogTruncater logTruncater, ISetBroken setBroken, ISetGeneration setGeneration, IReplicaProgress replicaProgress, NetworkPath netPath) : this(perfmonCounters, replayConfig, logfileBaseName, logfileSuffix, replayDir, fileState, logTruncater, setBroken, setGeneration, replicaProgress, netPath, false)
 {
 }
Exemple #5
0
 internal static LogSource Construct(IReplayConfiguration config, IPerfmonCounters perfmonCounters, NetworkPath initialNetworkPath, int timeoutMs)
 {
     return(new LogCopyClient(config, perfmonCounters, initialNetworkPath, timeoutMs));
 }
 // Token: 0x0600223A RID: 8762 RVA: 0x0009F97A File Offset: 0x0009DB7A
 public LogCopyClient(IReplayConfiguration config, IPerfmonCounters perfmonCounters, NetworkPath initialNetworkPath, int timeoutMs)
 {
     this.m_config             = config;
     this.m_perfmonCounters    = perfmonCounters;
     this.m_defaultTimeoutInMs = timeoutMs;
     this.m_sourceAddr         = config.SourceMachine;
     this.m_initialNetworkPath = initialNetworkPath;
 }
Exemple #7
0
        public NetworkPath ChoosePath(string targetNodeName, string selectedNetworkName)
        {
            this.m_rwLock.AcquireWriterLock(-1);
            NetworkPath result;

            try
            {
                int num = this.Nodes.IndexOfKey(targetNodeName);
                if (num < 0)
                {
                    NetworkManager.TraceDebug("Node {0} is not in the DAG", new object[]
                    {
                        targetNodeName
                    });
                    result = null;
                }
                else
                {
                    ExchangeNetworkNode exchangeNetworkNode = this.Nodes.Values[num];
                    if (exchangeNetworkNode.ClusterState == AmNodeState.Down)
                    {
                        NetworkManager.TraceDebug("Node {0} is reported as down.", new object[]
                        {
                            exchangeNetworkNode.Name
                        });
                        result = null;
                    }
                    else
                    {
                        ExchangeNetwork exchangeNetwork  = null;
                        NetworkEndPoint networkEndPoint  = null;
                        NetworkEndPoint networkEndPoint2 = null;
                        if (selectedNetworkName != null)
                        {
                            exchangeNetwork = this.UseNetwork(selectedNetworkName, exchangeNetworkNode, num, out networkEndPoint, out networkEndPoint2);
                        }
                        else
                        {
                            if (this.m_preferredNets != null)
                            {
                                exchangeNetwork = this.ChooseNetwork(this.m_preferredNets, exchangeNetworkNode, num, out networkEndPoint, out networkEndPoint2);
                            }
                            if (exchangeNetwork == null && this.m_regularNets != null)
                            {
                                exchangeNetwork = this.ChooseNetwork(this.m_regularNets, exchangeNetworkNode, num, out networkEndPoint, out networkEndPoint2);
                            }
                        }
                        if (exchangeNetwork == null)
                        {
                            NetworkManager.TraceDebug("All paths to Node {0} are down", new object[]
                            {
                                targetNodeName
                            });
                            result = null;
                        }
                        else
                        {
                            IPAddress ipaddress = networkEndPoint2.IPAddress;
                            if (ipaddress.IsIPv6LinkLocal)
                            {
                                if (networkEndPoint.IPAddress.AddressFamily != AddressFamily.InterNetworkV6)
                                {
                                    NetworkManager.TraceError("Target {0} has linkLocal v6 addr {1} which is unreachable on outbound ip {2}", new object[]
                                    {
                                        targetNodeName,
                                        ipaddress,
                                        networkEndPoint.IPAddress
                                    });
                                    return(null);
                                }
                                byte[] addressBytes = ipaddress.GetAddressBytes();
                                ipaddress = new IPAddress(addressBytes, networkEndPoint.IPAddress.ScopeId);
                            }
                            result = new NetworkPath(targetNodeName, ipaddress, (int)this.m_mgr.ReplicationPort, networkEndPoint.IPAddress)
                            {
                                NetworkName = exchangeNetwork.Name,
                                CrossSubnet = (networkEndPoint.Subnet != networkEndPoint2.Subnet)
                            };
                        }
                    }
                }
            }
            finally
            {
                this.m_rwLock.ReleaseWriterLock();
            }
            return(result);
        }
        // Token: 0x0600184D RID: 6221 RVA: 0x00063F20 File Offset: 0x00062120
        internal static bool TryOpenChannel(NetworkPath netPath, int timeoutInMs, out TcpClientChannel channel, out NetworkTransportException networkEx)
        {
            channel   = null;
            networkEx = null;
            Exception       ex              = null;
            Socket          socket          = null;
            Stream          stream          = null;
            NegotiateStream negotiateStream = null;
            ReplayStopwatch replayStopwatch = new ReplayStopwatch();

            replayStopwatch.Start();
            try
            {
                socket = new Socket(netPath.TargetEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                if (netPath.Purpose == NetworkPath.ConnectionPurpose.Seeding)
                {
                    socket.ReceiveBufferSize = RegistryParameters.SeedingNetworkTransferSize;
                    socket.SendBufferSize    = RegistryParameters.SeedingNetworkTransferSize;
                }
                else
                {
                    socket.ReceiveBufferSize = RegistryParameters.LogCopyNetworkTransferSize;
                    socket.SendBufferSize    = RegistryParameters.LogCopyNetworkTransferSize;
                }
                if (netPath.HasSourceEndpoint())
                {
                    socket.Bind(netPath.SourceEndPoint);
                }
                TcpClientChannel.ConnectAbandon connectAbandon = new TcpClientChannel.ConnectAbandon(socket);
                IAsyncResult asyncResult = socket.BeginConnect(netPath.TargetEndPoint.Address, netPath.TargetEndPoint.Port, null, connectAbandon);
                if (!asyncResult.AsyncWaitHandle.WaitOne(timeoutInMs, false))
                {
                    socket = null;
                    connectAbandon.Cancel(asyncResult);
                    TcpChannel.ThrowTimeoutException(netPath.TargetNodeName, ReplayStrings.NetworkConnectionTimeout(timeoutInMs / 1000));
                }
                socket.EndConnect(asyncResult);
                long elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;
                ExTraceGlobals.TcpClientTracer.TraceDebug <long>(0L, "Connection took {0}ms", elapsedMilliseconds);
                socket.LingerState = new LingerOption(true, 0);
                if (!netPath.UseSocketStream || RegistryParameters.DisableSocketStream)
                {
                    stream = new NetworkStream(socket, false);
                }
                else
                {
                    stream = new SocketStream(socket, netPath.SocketStreamBufferPool, netPath.SocketStreamAsyncArgPool, netPath.SocketStreamPerfCounters);
                }
                negotiateStream     = new NegotiateStream(stream, false);
                stream              = null;
                elapsedMilliseconds = replayStopwatch.ElapsedMilliseconds;
                if (elapsedMilliseconds >= (long)timeoutInMs)
                {
                    TcpChannel.ThrowTimeoutException(netPath.TargetNodeName, ReplayStrings.NetworkConnectionTimeout(timeoutInMs / 1000));
                }
                int num = timeoutInMs - (int)elapsedMilliseconds;
                negotiateStream.WriteTimeout = num;
                negotiateStream.ReadTimeout  = num;
                TcpClientChannel.AuthAbandon authAbandon = new TcpClientChannel.AuthAbandon(socket, negotiateStream);
                string targetName;
                if (netPath.UseNullSpn)
                {
                    targetName = "";
                }
                else
                {
                    targetName = "HOST/" + netPath.TargetNodeName;
                }
                bool            encrypt = netPath.Encrypt;
                ProtectionLevel protectionLevel;
                if (encrypt)
                {
                    protectionLevel = ProtectionLevel.EncryptAndSign;
                }
                else if (RegistryParameters.DisableNetworkSigning)
                {
                    protectionLevel = ProtectionLevel.None;
                }
                else
                {
                    protectionLevel = ProtectionLevel.Sign;
                }
                asyncResult = negotiateStream.BeginAuthenticateAsClient(CredentialCache.DefaultNetworkCredentials, targetName, protectionLevel, TokenImpersonationLevel.Identification, null, authAbandon);
                if (!asyncResult.AsyncWaitHandle.WaitOne(num, false))
                {
                    negotiateStream = null;
                    socket          = null;
                    authAbandon.Abandon(asyncResult);
                    TcpChannel.ThrowTimeoutException(netPath.TargetNodeName, ReplayStrings.NetworkConnectionTimeout(timeoutInMs / 1000));
                }
                negotiateStream.EndAuthenticateAsClient(asyncResult);
                bool flag = false;
                if (!negotiateStream.IsAuthenticated)
                {
                    flag = true;
                }
                else if (protectionLevel != ProtectionLevel.None && !negotiateStream.IsMutuallyAuthenticated)
                {
                    if (netPath.IgnoreMutualAuth || MachineName.Comparer.Equals(netPath.TargetNodeName, Environment.MachineName))
                    {
                        ExTraceGlobals.TcpClientTracer.TraceDebug(0L, "Ignoring mutual auth since we are local");
                    }
                    else
                    {
                        flag = true;
                    }
                }
                if (!flag && encrypt && !negotiateStream.IsEncrypted)
                {
                    ExTraceGlobals.TcpClientTracer.TraceError(0L, "Encryption requested, but could not be negotiated");
                    flag = true;
                }
                if (flag)
                {
                    ExTraceGlobals.TcpClientTracer.TraceError <bool, bool, bool>(0L, "Security Negotiation failed. Auth={0},MAuth={1},Encrypt={2}", negotiateStream.IsAuthenticated, negotiateStream.IsMutuallyAuthenticated, negotiateStream.IsEncrypted);
                    NetworkManager.ThrowException(new NetworkCommunicationException(netPath.TargetNodeName, ReplayStrings.NetworkSecurityFailed));
                }
                ExTraceGlobals.TcpClientTracer.TraceDebug <long, bool, ProtectionLevel>(0L, "Authenticated Connection took {0}ms. Encrypt={1} ProtRequested={2}", replayStopwatch.ElapsedMilliseconds, negotiateStream.IsEncrypted, protectionLevel);
                channel = new TcpClientChannel(netPath.TargetNodeName, socket, negotiateStream, timeoutInMs);
                return(true);
            }
            catch (SocketException ex2)
            {
                ex = ex2;
            }
            catch (IOException ex3)
            {
                ex = ex3;
            }
            catch (AuthenticationException ex4)
            {
                ex = ex4;
            }
            catch (NetworkTransportException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (channel == null)
                {
                    if (negotiateStream != null)
                    {
                        negotiateStream.Dispose();
                    }
                    else if (stream != null)
                    {
                        stream.Dispose();
                    }
                    if (socket != null)
                    {
                        socket.Close();
                    }
                }
                else
                {
                    ReplayCrimsonEvents.NetworkConnectionSuccess.Log <string, IPEndPoint, IPEndPoint>(netPath.TargetNodeName, netPath.TargetEndPoint, channel.LocalEndpoint);
                }
            }
            ExTraceGlobals.TcpClientTracer.TraceError <Exception>(0L, "TryOpenChannel failed. Ex={0}", ex);
            ReplayCrimsonEvents.NetworkConnectionFailure.Log <string, IPEndPoint, IPEndPoint, string>(netPath.TargetNodeName, netPath.TargetEndPoint, netPath.SourceEndPoint, ex.ToString());
            if (ex is NetworkTransportException)
            {
                networkEx = (NetworkTransportException)ex;
            }
            else
            {
                networkEx = new NetworkCommunicationException(netPath.TargetNodeName, ex.Message, ex);
            }
            return(false);
        }
 public TcpClientChannel TryConnect(NetworkPath netPath, out NetworkTransportException failureEx)
 {
     return(this.TryConnect(netPath, DagNetEnvironment.ConnectTimeoutInSec * 1000, out failureEx));
 }
        public TcpClientChannel OpenChannel(string targetServerName, ISimpleBufferPool socketStreamBufferPool, IPool <SocketStreamAsyncArgs> socketStreamAsyncArgPool, SocketStream.ISocketStreamPerfCounters perfCtrs, out NetworkPath netPath)
        {
            DagNetConfig dagConfig;

            DagNetRoute[]    array            = DagNetChooser.ProposeRoutes(targetServerName, out dagConfig);
            TcpClientChannel tcpClientChannel = null;

            netPath = null;
            NetworkTransportException ex = null;

            if (array != null)
            {
                foreach (DagNetRoute dagNetRoute in array)
                {
                    netPath             = new NetworkPath(targetServerName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr);
                    netPath.CrossSubnet = dagNetRoute.IsCrossSubnet;
                    this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs);
                    netPath.ApplyNetworkPolicy(dagConfig);
                    tcpClientChannel = this.TryConnect(netPath, out ex);
                    if (tcpClientChannel != null)
                    {
                        break;
                    }
                }
            }
            if (tcpClientChannel == null)
            {
                netPath = this.BuildDnsNetworkPath(targetServerName, (int)NetworkManager.GetReplicationPort());
                this.ApplySocketStreamArgs(netPath, socketStreamBufferPool, socketStreamAsyncArgPool, perfCtrs);
                netPath.ApplyNetworkPolicy(dagConfig);
                tcpClientChannel = this.TryConnect(netPath, out ex);
                if (tcpClientChannel == null)
                {
                    throw ex;
                }
            }
            return(tcpClientChannel);
        }
Exemple #11
0
 // Token: 0x06001765 RID: 5989 RVA: 0x00060544 File Offset: 0x0005E744
 internal void ReportError(NetworkPath path)
 {
     this.m_map.ReportError(path, this);
 }