public void Start()
 {
     Core.Instance.Log.Info("Starting EnhancedRestoreChunkConnInfoService");
     Core.Instance.MCChannel.Received
     .Where(message => message.MessageType == Messages.MessageType.ConnInfo)
     .Cast <ConnInfoMessage>().Where(message => NetworkUtilities.GetLocalIPAddresses().Contains(message.PassiveIP))
     .Subscribe(this);
 }
예제 #2
0
            public Settings(IPAddress localIP, long maxBackupSize, int chunkSize,
                            int backupChunkTimeout, double backupChunkTimeoutMultiplier,
                            int backupChunkRetries, int versionM, int versionN, int randomDelayMin,
                            int randomDelayMax, string backupDirectory, string restoreDirectory,
                            IPAddress mcIP, int mcPort, IPAddress mdbIP, int mdbPort,
                            IPAddress mdrIP, int mdrPort)
            {
                Utilities.Utilities.CreateDirectoryIfNotExists(backupDirectory);
                Utilities.Utilities.CreateDirectoryIfNotExists(restoreDirectory);

                LocalIP                      = localIP;
                MaxBackupSize                = maxBackupSize;
                ChunkSize                    = chunkSize;
                BackupChunkTimeout           = backupChunkTimeout;
                BackupChunkTimeoutMultiplier = backupChunkTimeoutMultiplier;
                BackupChunkRetries           = backupChunkRetries;
                VersionM                     = versionM;
                VersionN                     = versionN;
                RandomDelayMin               = randomDelayMin;
                RandomDelayMax               = randomDelayMax;
                BackupDirectory              = backupDirectory;
                RestoreDirectory             = restoreDirectory;

                if (!NetworkUtilities.IsMulticastAddress(mcIP))
                {
                    throw new ArgumentException("MC:IP is not a multicast address", "mcIP");
                }
                if (!NetworkUtilities.IsMulticastAddress(mdbIP))
                {
                    throw new ArgumentException("MDB:IP is not a multicast address", "mdbIP");
                }
                if (!NetworkUtilities.IsMulticastAddress(mdrIP))
                {
                    throw new ArgumentException("MDR:IP is not a multicast address", "mdrIP");
                }

                if (!localIP.Equals(IPAddress.Any) && !NetworkUtilities.GetLocalIPAddresses().Contains(localIP))
                {
                    throw new ArgumentException("LocalIP is not a local IP address", "localIP");
                }

                MCIP    = mcIP;
                MCPort  = mcPort;
                MDBIP   = mdbIP;
                MDBPort = mdbPort;
                MDRIP   = mdrIP;
                MDRPort = mdrPort;
            }
예제 #3
0
        public bool HasChunkPeer(FileChunk chunk, bool any)
        {
            if (any)
            {
                lock (_sync)
                {
                    return(_chunkPeers.Any(chunkPeer => chunkPeer.Key.Chunk == chunk.FileName));
                }
            }

            var localIps = NetworkUtilities.GetLocalIPAddresses();

            lock (_sync)
            {
                return(localIps.Any(address =>
                                    _chunkPeers.Any(chunkPeer => chunkPeer.Key.Chunk == chunk.FileName &&
                                                    chunkPeer.Key.IP == address.Address)));
            }
        }