private bool CheckForInvalidIPAddress(MultiValuedProperty <IPAddress> ipList, out SetPerimeterConfig.IPAddressType ipType, out IPAddress ipAddress)
 {
     ipType    = SetPerimeterConfig.IPAddressType.IPv4;
     ipAddress = null;
     foreach (IPAddress ipaddress in ipList)
     {
         if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6)
         {
             ipAddress = ipaddress;
             ipType    = SetPerimeterConfig.IPAddressType.IPv6;
             return(true);
         }
         if (!IPAddressValidation.IsValidIPv4Address(ipaddress.ToString()))
         {
             ipAddress = ipaddress;
             ipType    = SetPerimeterConfig.IPAddressType.InvalidIPv4;
             return(true);
         }
         if (IPAddressValidation.IsReservedIPv4Address(ipaddress.ToString()))
         {
             ipAddress = ipaddress;
             ipType    = SetPerimeterConfig.IPAddressType.ReservedIPv4;
             return(true);
         }
     }
     return(false);
 }
 private static void ValidateIPAddress(IPRange ipRange, IPAddress address, Task task, bool bypassValidation)
 {
     if (!IPAddressValidation.IsValidIPv4Address(address.ToString()))
     {
         task.WriteError(new ConnectorIPRangeContainsInvalidIPv4AddressException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
     }
     if (!bypassValidation && IPAddressValidation.IsReservedIPv4Address(address.ToString()))
     {
         task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
     }
 }
 private static void ValidateSmartHostRestrictions(TenantOutboundConnector tenantOutboundConnector, Task task, bool skipIpIsNotReservedValidation)
 {
     if (tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.SmartHosts) && !MultiValuedPropertyBase.IsNullOrEmpty(tenantOutboundConnector.SmartHosts))
     {
         MultiValuedProperty <IPRange> multiValuedProperty = null;
         bool flag = false;
         using (MultiValuedProperty <SmartHost> .Enumerator enumerator = tenantOutboundConnector.SmartHosts.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 SmartHost smartHost = enumerator.Current;
                 if (smartHost.IsIPAddress)
                 {
                     if (smartHost.Address.AddressFamily != AddressFamily.InterNetwork || !IPAddressValidation.IsValidIPv4Address(smartHost.Address.ToString()))
                     {
                         task.WriteError(new SmartHostsIPValidationFailedException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                     }
                     if (!skipIpIsNotReservedValidation)
                     {
                         if (IPAddressValidation.IsReservedIPv4Address(smartHost.Address.ToString()))
                         {
                             task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                         }
                         if (!flag)
                         {
                             if (!HygieneDCSettings.GetFfoDCPublicIPAddresses(out multiValuedProperty))
                             {
                                 task.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                             }
                             flag = true;
                         }
                         if (!MultiValuedPropertyBase.IsNullOrEmpty(multiValuedProperty))
                         {
                             if (multiValuedProperty.Any((IPRange ffoDCIP) => ffoDCIP.Contains(smartHost.Address)))
                             {
                                 task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }