public static NormalizedOrganization TryParseFromSection(RawWhoisSection section)
        {
            if (organizationTypes.Contains(section.Type))
            {
                var organization = new NormalizedOrganization()
                {
                    Location = NormalizedLocation.TryParseFromSection(section),
                    Phone    = NormalizationUtils.FindFirstMatchingFieldValueInRecords(section, phoneFields)
                };

                NormalizationUtils.ExtractCommonRecordMetadata(section, section.Id, nameFields, organization);

                return(organization);
            }

            return(null);
        }
Exemplo n.º 2
0
        public static NormalizedNetwork TryParseFromSection(RawWhoisSection section)
        {
            if (networkTypes.Contains(section.Type))
            {
                var network = new NormalizedNetwork()
                {
                    Location = NormalizedLocation.TryParseFromSection(section),
                    AuthArea = NormalizationUtils.FindFirstMatchingFieldValueInRecords(section, authAreaFields),
                    OriginAS = NormalizationUtils.FindFirstMatchingFieldValueInRecords(section, originASFields),
                    Status   = NormalizationUtils.FindFirstMatchingFieldValueInRecords(section, statusFields)
                };

                var candidateRanges = NormalizationUtils.FindAllMatchingFieldValuesInRecords(section, ipRangeFields);

                if (candidateRanges != null)
                {
                    IPAddressRange range = null;

                    foreach (var candidateRange in candidateRanges)
                    {
                        if (IPAddressRange.TryParse(candidateRange, out range))
                        {
                            break;
                        }
                    }

                    network.IPRange = range;
                }
                else
                {
                    // TODO: Some networks do not have an explicit IP range but maybe we can get it from the Auth Area or from the ID?
                }

                NormalizationUtils.ExtractCommonRecordMetadata(section, section.Id, nameFields, network);

                return(network);
            }

            return(null);
        }