3

I'm setting up th excludedIPAddresses section of the Sitecore.Analytics.ExcludeRobots.config file, and I had one question on format. In the file, it shows for "supported values and formats" having semicolons at the end of the value for IP address and IP range. However, in the Sitecore documentation - https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/xdb/robot_detection/configure_the_robot_detection_component#_Excluding_user_agents - it doesn't show semicolons between each line. Also, in the existing file it lists a lot of user agents that are excluded and are just one agent per line.

Is the parser for this using the new line character to do the separation?

1 Answer 1

2

Yes is using new line character for separation

Here is the code for parsing exludedIPAddresses

Sitecore.Web.IPAddresses.IPList
/// <summary>
/// Tries the parse string.
/// </summary>
/// <param name="list">The string list.</param>
/// <param name="result">The result.</param>
/// <returns>IPList object.</returns>
public static bool TryParse(string list, out IPList result)
{
    result = null;
    if (string.IsNullOrEmpty(list))
    {
        return false;
    }
    string[] array = list.Split(new char[]
    {
        '\n'
    });
    if (array.Length == 0)
    {
        return false;
    }
    result = new IPList();
    string[] array2 = array;
    for (int i = 0; i < array2.Length; i++)
    {
        string text = array2[i];
        string text2 = text.Trim();
        if (!text2.IsNullOrEmpty() && !text2.StartsWith("#", StringComparison.InvariantCulture))
        {
            IPSubnet subnet;
            IPRange range;
            if (IPSubnet.TryParse(text2, out subnet))
            {
                result.Add(subnet);
            }
            else if (IPRange.TryParse(text2, out range))
            {
                result.Add(range);
            }
            else
            {
                IPAddress address;
                if (!IPAddress.TryParse(text2, out address))
                {
                    Log.Warn("Failed to initialize IPList. String {0} is not looks like valid value for IPAddress, IPRange or IPSubnet".FormatWith(new object[]
                    {
                        text2
                    }), new object());
                    result = null;
                    return false;
                }
                result.Add(address);
            }
        }
    }
    return true;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.