Exemplo n.º 1
0
		public void Initialize(Nic targetNic, IPAddress from = null, IPAddress to = null)
		{
			if (from == null)
				from = targetNic.Ip.V4.PrimaryUnicast.Network.FirstAddress;
			if (to == null)
				to = targetNic.Ip.V4.PrimaryUnicast.Network.LastAddress;

			uint firstUint = BitConverter.ToUInt32(from.GetAddressBytes().Reverse().ToArray(), 0);
			uint lastUint = BitConverter.ToUInt32(to.GetAddressBytes().Reverse().ToArray(), 0);

			//for (uint i = firstUint; i <= lastUint; i++)
			for (uint i = firstUint; i <= lastUint; i++)
			{
				var ipAddress = new IPAddress(BitConverter.GetBytes(i).Reverse().ToArray());
				var observer = new HostObserver(ipAddress, targetNic.Ip.V4.PrimaryUnicast.Address);

				observer.Options = Options.HostObserver;
				//hostChangeDetector.Options.Dns.DnsServer = targetNic.Raw.IpProperties.DnsAddresses.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);

				observer.State.ObserverSucceeded += ObserverSucceeded;
				observer.State.Activated += ObserverActivated;
				observer.State.Deactivated += ObserverDeactivated;

				_detectors.Add(observer);
			}

			Results.SetLocalNic(targetNic);
		}
Exemplo n.º 2
0
		private void ObserverSucceeded(HostObserver sender)
		{
			sender.State.ObserverSucceeded -= ObserverSucceeded;
			Application.Current.Dispatcher.InvokeAsync(() => _wasOnlineHosts.Add(sender));
		}
Exemplo n.º 3
0
		private void ObserverDeactivated(HostObserver sender)
		{
			lock (_resultLock)
			{
				_triggerTimer.Stop();
				Results.ScanDeactivated();
				if (Results.ActiveScans == 0)
				{
					State.SetDeactivated();
				}
			}
		}
Exemplo n.º 4
0
		private void ObserverActivated(HostObserver sender)
		{
			lock (_resultLock)
			{
				if (Results.ActiveScans == 0)
				{
					State.SetActivated();
				}
				Results.ScanActivated();
			}
		}