Exemple #1
0
        /// <summary>
        /// Add IP/Host name pair that shall be poisoned
        /// </summary>
        /// <param name="pHostName"></param>
        /// <param name="pIPAddress"></param>
        public void addRecord(String pHostName, String pIPAddress)
        {
            String lHostNamePattern  = @"[\d\w\.-_]+\.[\w]{2,3}$";
            String lIPAddressPattern = @"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$";

            /*
             * Check IP and host name have a correct structure
             */
            if (String.IsNullOrEmpty(pHostName))
            {
                throw new Exception("You didn't define a host name");
            }
            else if (String.IsNullOrEmpty(pIPAddress))
            {
                throw new Exception("You didn't define a IP address");
            }
            else if (!Regex.Match(pHostName, lHostNamePattern, RegexOptions.IgnoreCase).Success)
            {
                throw new Exception("Something is wrong with the host name!");
            }
            else if (!Regex.Match(pIPAddress, lIPAddressPattern, RegexOptions.IgnoreCase).Success)
            {
                throw new Exception("Something is wrong with the IP address!");
            }
            else
            {
                cDomain.addRecord(pHostName, pIPAddress);
            }
        }