예제 #1
0
 public void GetIPAddresses_CIDRRange_Succeeds()
 {
     IPRange range = new IPRange("192.168.0.0/24");
     IEnumerable<IPAddress> ipAddresses = range.GetIPAddresses();
     int actualCount = ipAddresses.Count();
     Assert.IsTrue(actualCount == 256);
 }
예제 #2
0
        public static List <IPEndPoint> Find(string ipRange, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
            {
                throw new ArgumentException();
            }

            List <IPEndPoint> endpoints = new List <IPEndPoint>();

            List <IPAddress> ipAddresses = new IPRange(ipRange).GetIPAddresses().ToList();

            //optimize until we need otherwise
            ipAddresses.RemoveAll(ip => ip.ToString().Equals(LocalNetwork.GetLocalIPAddress()));
            ipAddresses.RemoveAll(ip => ip.ToString().EndsWith(".0"));

            foreach (IPAddress ipAddress in ipAddresses)
            {
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                {
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                    {
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));
                    }
                }
            }

            return(endpoints);
        }
예제 #3
0
        public static List <IPEndPoint> Find(IPAddress startingIp, IPAddress endingIp, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
            {
                throw new ArgumentException();
            }

            List <IPEndPoint> endpoints = new List <IPEndPoint>();

            List <IPAddress> ipAddresses = new IPRange(startingIp, endingIp).GetIPAddresses().ToList();

            //do not remove local IP addresses
            //we want the ability to discover other miners on the same PC

            foreach (IPAddress ipAddress in ipAddresses)
            {
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                {
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                    {
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));
                    }
                }
            }

            return(endpoints);
        }
예제 #4
0
        public static List<IPEndPoint> Find(IPAddress startingIp, IPAddress endingIp, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
                throw new ArgumentException();

            List<IPEndPoint> endpoints = new List<IPEndPoint>();

            List<IPAddress> ipAddresses = new IPRange(startingIp, endingIp).GetIPAddresses().ToList();
            
            //do not remove local IP addresses
            //we want the ability to discover other miners on the same PC

            foreach (IPAddress ipAddress in ipAddresses)
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));

            return endpoints;
        }
예제 #5
0
        public static List<IPEndPoint> Find(string ipRange, int startingPort, int endingPort, int connectTimeout = 100)
        {
            if (startingPort > endingPort)
                throw new ArgumentException();

            List<IPEndPoint> endpoints = new List<IPEndPoint>();

            List<IPAddress> ipAddresses = new IPRange(ipRange).GetIPAddresses().ToList();

            //optimize until we need otherwise
            ipAddresses.RemoveAll(ip => ip.ToString().Equals(LocalNetwork.GetLocalIPAddress()));
            ipAddresses.RemoveAll(ip => ip.ToString().EndsWith(".0"));

            foreach (IPAddress ipAddress in ipAddresses)
                for (int currentPort = startingPort; currentPort <= endingPort; currentPort++)
                    if (IsPortOpen(ipAddress, currentPort, connectTimeout))
                        endpoints.Add(new IPEndPoint(ipAddress, currentPort));

            return endpoints;
        }