Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 159 additions & 0 deletions MaxMind.Db.Benchmark/Model/Anonymizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#region

using System;
using System.Text.Json.Serialization;

#endregion

namespace MaxMind.Db.Benchmark
{
/// <summary>
/// Contains anonymizer-related data associated with an IP address.
/// This data is available from the GeoIP2 Insights web service.
/// </summary>
public class Anonymizer
{
/// <summary>
/// Constructor
/// </summary>
public Anonymizer()
{
}

/// <summary>
/// Constructor
/// </summary>
public Anonymizer(
int? confidence = null,
bool isAnonymous = false,
bool isAnonymousVpn = false,
bool isHostingProvider = false,
bool isPublicProxy = false,
bool isResidentialProxy = false,
bool isTorExitNode = false,
#if NET6_0_OR_GREATER
DateOnly? networkLastSeen = null,
#endif
string? providerName = null
)
{
Confidence = confidence;
IsAnonymous = isAnonymous;
IsAnonymousVpn = isAnonymousVpn;
IsHostingProvider = isHostingProvider;
IsPublicProxy = isPublicProxy;
IsResidentialProxy = isResidentialProxy;
IsTorExitNode = isTorExitNode;
#if NET6_0_OR_GREATER
NetworkLastSeen = networkLastSeen;
#endif
ProviderName = providerName;
}

/// <summary>
/// A score ranging from 1 to 99 that represents our percent confidence
/// that the network is currently part of an actively used VPN service.
/// This is available from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("confidence")]
public int? Confidence { get; internal set; }

/// <summary>
/// This is true if the IP address belongs to any sort of anonymous
/// network. This is available from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_anonymous")]
public bool IsAnonymous { get; internal set; }

/// <summary>
/// This is true if the IP address is registered to an anonymous
/// VPN provider. This is available from the GeoIP2 Insights web
/// service.
/// </summary>
/// <remarks>
/// If a VPN provider does not register subnets under names
/// associated with them, we will likely only flag their IP ranges
/// using the IsHostingProvider property.
/// </remarks>
[JsonInclude]
[JsonPropertyName("is_anonymous_vpn")]
public bool IsAnonymousVpn { get; internal set; }

/// <summary>
/// This is true if the IP address belongs to a hosting or VPN
/// provider (see description of IsAnonymousVpn property).
/// This is available from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_hosting_provider")]
public bool IsHostingProvider { get; internal set; }

/// <summary>
/// This is true if the IP address belongs to a public proxy.
/// This is available from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_public_proxy")]
public bool IsPublicProxy { get; internal set; }

/// <summary>
/// This is true if the IP address is on a suspected anonymizing
/// network and belongs to a residential ISP. This is available
/// from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_residential_proxy")]
public bool IsResidentialProxy { get; internal set; }

/// <summary>
/// This is true if the IP address belongs to a Tor exit node.
/// This is available from the GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_tor_exit_node")]
public bool IsTorExitNode { get; internal set; }

#if NET6_0_OR_GREATER
/// <summary>
/// The last day that the network was sighted in our analysis of
/// anonymized networks. This is available from the GeoIP2 Insights
/// web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("network_last_seen")]
public DateOnly? NetworkLastSeen { get; internal set; }
#endif

/// <summary>
/// The name of the VPN provider (e.g., NordVPN, SurfShark)
/// associated with the network. This is available from the
/// GeoIP2 Insights web service.
/// </summary>
[JsonInclude]
[JsonPropertyName("provider_name")]
public string? ProviderName { get; internal set; }

/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString()
{
return $"{nameof(Confidence)}: {Confidence}, " +
$"{nameof(IsAnonymous)}: {IsAnonymous}, " +
$"{nameof(IsAnonymousVpn)}: {IsAnonymousVpn}, " +
$"{nameof(IsHostingProvider)}: {IsHostingProvider}, " +
$"{nameof(IsPublicProxy)}: {IsPublicProxy}, " +
$"{nameof(IsResidentialProxy)}: {IsResidentialProxy}, " +
$"{nameof(IsTorExitNode)}: {IsTorExitNode}, " +
#if NET6_0_OR_GREATER
$"{nameof(NetworkLastSeen)}: {NetworkLastSeen}, " +
#endif
$"{nameof(ProviderName)}: {ProviderName}";
}
}
}
49 changes: 49 additions & 0 deletions MaxMind.Db.Benchmark/Model/City.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#region

using MaxMind.Db;
using System.Collections.Generic;
using System.Text.Json.Serialization;

#endregion

namespace MaxMind.Db.Benchmark
{
/// <summary>
/// City-level data associated with an IP address.
/// </summary>
/// <remarks>
/// Do not use any of the city names as a database or dictionary
/// key. Use the <see cred="GeoNameId" /> instead.
/// </remarks>
public class City : NamedEntity
{
/// <summary>
/// Constructor
/// </summary>
public City()
{
}

/// <summary>
/// Constructor
/// </summary>
[Constructor]
public City(int? confidence = null,
[Parameter("geoname_id")] long? geoNameId = null,
IReadOnlyDictionary<string, string>? names = null,
IReadOnlyList<string>? locales = null)
: base(geoNameId, names, locales)
{
Confidence = confidence;
}

/// <summary>
/// A value from 0-100 indicating MaxMind's confidence that the city
/// is correct. This value is only set when using the Insights
/// web service or the Enterprise database.
/// </summary>
[JsonInclude]
[JsonPropertyName("confidence")]
public int? Confidence { get; internal set; }
}
}
48 changes: 48 additions & 0 deletions MaxMind.Db.Benchmark/Model/Continent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#region

using MaxMind.Db;
using System.Collections.Generic;
using System.Text.Json.Serialization;

#endregion

namespace MaxMind.Db.Benchmark
{
/// <summary>
/// Contains data for the continent record associated with an IP address.
/// Do not use any of the continent names as a database or dictionary
/// key. Use the <see cred="GeoNameId" /> or <see cred="Code" />
/// instead.
/// </summary>
public class Continent : NamedEntity
{
/// <summary>
/// Constructor
/// </summary>
public Continent()
{
}

/// <summary>
/// Constructor
/// </summary>
[Constructor]
public Continent(
string? code = null,
[Parameter("geoname_id")] long? geoNameId = null,
IReadOnlyDictionary<string, string>? names = null,
IReadOnlyList<string>? locales = null)
: base(geoNameId, names, locales)
{
Code = code;
}

/// <summary>
/// A two character continent code like "NA" (North America) or "OC"
/// (Oceania).
/// </summary>
[JsonInclude]
[JsonPropertyName("code")]
public string? Code { get; internal set; }
}
}
75 changes: 75 additions & 0 deletions MaxMind.Db.Benchmark/Model/Country.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#region

using MaxMind.Db;
using System.Collections.Generic;
using System.Text.Json.Serialization;

#endregion

namespace MaxMind.Db.Benchmark
{
/// <summary>
/// Contains data for the country record associated with an IP address.
/// Do not use any of the country names as a database or dictionary
/// key. Use the <see cred="GeoNameId" /> or <see cred="IsoCode" />
/// instead.
/// </summary>
public class Country : NamedEntity
{
/// <summary>
/// Constructor
/// </summary>
public Country()
{
}

/// <summary>
/// Constructor
/// </summary>
[Constructor]
public Country(
int? confidence = null,
[Parameter("geoname_id")] long? geoNameId = null,
[Parameter("is_in_european_union")] bool isInEuropeanUnion = false,
[Parameter("iso_code")] string? isoCode = null,
IReadOnlyDictionary<string, string>? names = null,
IReadOnlyList<string>? locales = null)
: base(geoNameId, names, locales)
{
Confidence = confidence;
IsoCode = isoCode;
IsInEuropeanUnion = isInEuropeanUnion;
}

/// <summary>
/// A value from 0-100 indicating MaxMind's confidence that the country
/// is correct. This value is only set when using the Insights
/// web service or the Enterprise database.
/// </summary>
[JsonInclude]
[JsonPropertyName("confidence")]
public int? Confidence { get; internal set; }

/// <summary>
/// This is true if the country is a member state of the
/// European Union. This is available from all location
/// services and databases.
/// </summary>
[JsonInclude]
[JsonPropertyName("is_in_european_union")]
public bool IsInEuropeanUnion { get; internal set; }

/// <summary>
/// The
/// <a
/// href="https://en.wikipedia.org/wiki/ISO_3166-1">
/// two-character ISO
/// 3166-1 alpha code
/// </a>
/// for the country.
/// </summary>
[JsonInclude]
[JsonPropertyName("iso_code")]
public string? IsoCode { get; internal set; }
}
}
Loading
Loading