|
| 1 | +package com.maxmind.geoip2.record; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 4 | +import com.maxmind.db.MaxMindDbConstructor; |
| 5 | +import com.maxmind.db.MaxMindDbParameter; |
| 6 | +import com.maxmind.geoip2.JsonSerializable; |
| 7 | +import java.time.LocalDate; |
| 8 | + |
| 9 | +/** |
| 10 | + * <p> |
| 11 | + * Contains data for the anonymizer record associated with an IP address. |
| 12 | + * </p> |
| 13 | + * <p> |
| 14 | + * This record is returned by the GeoIP2 Precision Insights web service. |
| 15 | + * </p> |
| 16 | + * |
| 17 | + * @param confidence A score ranging from 1 to 99 that is our percent confidence that the |
| 18 | + * network is currently part of an actively used VPN service. This is only |
| 19 | + * available from the GeoIP2 Precision Insights web service. |
| 20 | + * @param isAnonymous Whether the IP address belongs to any sort of anonymous network. |
| 21 | + * @param isAnonymousVpn Whether the IP address is registered to an anonymous VPN provider. If a |
| 22 | + * VPN provider does not register subnets under names associated with them, |
| 23 | + * we will likely only flag their IP ranges using isHostingProvider. |
| 24 | + * @param isHostingProvider Whether the IP address belongs to a hosting or VPN provider (see |
| 25 | + * description of isAnonymousVpn). |
| 26 | + * @param isPublicProxy Whether the IP address belongs to a public proxy. |
| 27 | + * @param isResidentialProxy Whether the IP address is on a suspected anonymizing network and |
| 28 | + * belongs to a residential ISP. |
| 29 | + * @param isTorExitNode Whether the IP address is a Tor exit node. |
| 30 | + * @param networkLastSeen The last day that the network was sighted in our analysis of anonymized |
| 31 | + * networks. This is only available from the GeoIP2 Precision Insights web |
| 32 | + * service. |
| 33 | + * @param providerName The name of the VPN provider (e.g., NordVPN, SurfShark, etc.) associated |
| 34 | + * with the network. This is only available from the GeoIP2 Precision Insights |
| 35 | + * web service. |
| 36 | + */ |
| 37 | +public record Anonymizer( |
| 38 | + @JsonProperty("confidence") |
| 39 | + @MaxMindDbParameter(name = "confidence") |
| 40 | + Integer confidence, |
| 41 | + |
| 42 | + @JsonProperty("is_anonymous") |
| 43 | + @MaxMindDbParameter(name = "is_anonymous", useDefault = true) |
| 44 | + boolean isAnonymous, |
| 45 | + |
| 46 | + @JsonProperty("is_anonymous_vpn") |
| 47 | + @MaxMindDbParameter(name = "is_anonymous_vpn", useDefault = true) |
| 48 | + boolean isAnonymousVpn, |
| 49 | + |
| 50 | + @JsonProperty("is_hosting_provider") |
| 51 | + @MaxMindDbParameter(name = "is_hosting_provider", useDefault = true) |
| 52 | + boolean isHostingProvider, |
| 53 | + |
| 54 | + @JsonProperty("is_public_proxy") |
| 55 | + @MaxMindDbParameter(name = "is_public_proxy", useDefault = true) |
| 56 | + boolean isPublicProxy, |
| 57 | + |
| 58 | + @JsonProperty("is_residential_proxy") |
| 59 | + @MaxMindDbParameter(name = "is_residential_proxy", useDefault = true) |
| 60 | + boolean isResidentialProxy, |
| 61 | + |
| 62 | + @JsonProperty("is_tor_exit_node") |
| 63 | + @MaxMindDbParameter(name = "is_tor_exit_node", useDefault = true) |
| 64 | + boolean isTorExitNode, |
| 65 | + |
| 66 | + @JsonProperty("network_last_seen") |
| 67 | + @MaxMindDbParameter(name = "network_last_seen") |
| 68 | + LocalDate networkLastSeen, |
| 69 | + |
| 70 | + @JsonProperty("provider_name") |
| 71 | + @MaxMindDbParameter(name = "provider_name") |
| 72 | + String providerName |
| 73 | +) implements JsonSerializable { |
| 74 | + |
| 75 | + /** |
| 76 | + * Constructs an {@code Anonymizer} record with {@code null} values for all the nullable |
| 77 | + * fields and {@code false} for all boolean fields. |
| 78 | + */ |
| 79 | + public Anonymizer() { |
| 80 | + this(null, false, false, false, false, false, false, (LocalDate) null, null); |
| 81 | + } |
| 82 | + |
| 83 | + /** |
| 84 | + * Constructs an instance of {@code Anonymizer} with date parsing from MaxMind database. |
| 85 | + * |
| 86 | + * @param confidence confidence that the network is a VPN |
| 87 | + * @param isAnonymous whether the IP address belongs to any sort of anonymous network |
| 88 | + * @param isAnonymousVpn whether the IP address belongs to an anonymous VPN system |
| 89 | + * @param isHostingProvider whether the IP address belongs to a hosting provider |
| 90 | + * @param isPublicProxy whether the IP address belongs to a public proxy system |
| 91 | + * @param isResidentialProxy whether the IP address belongs to a residential proxy system |
| 92 | + * @param isTorExitNode whether the IP address is a Tor exit node |
| 93 | + * @param networkLastSeen the last sighting of the network |
| 94 | + * @param providerName the name of the VPN provider |
| 95 | + */ |
| 96 | + @MaxMindDbConstructor |
| 97 | + public Anonymizer( |
| 98 | + @MaxMindDbParameter(name = "confidence") Integer confidence, |
| 99 | + @MaxMindDbParameter(name = "is_anonymous", useDefault = true) boolean isAnonymous, |
| 100 | + @MaxMindDbParameter(name = "is_anonymous_vpn", useDefault = true) boolean isAnonymousVpn, |
| 101 | + @MaxMindDbParameter(name = "is_hosting_provider", useDefault = true) |
| 102 | + boolean isHostingProvider, |
| 103 | + @MaxMindDbParameter(name = "is_public_proxy", useDefault = true) boolean isPublicProxy, |
| 104 | + @MaxMindDbParameter(name = "is_residential_proxy", useDefault = true) |
| 105 | + boolean isResidentialProxy, |
| 106 | + @MaxMindDbParameter(name = "is_tor_exit_node", useDefault = true) |
| 107 | + boolean isTorExitNode, |
| 108 | + @MaxMindDbParameter(name = "network_last_seen") String networkLastSeen, |
| 109 | + @MaxMindDbParameter(name = "provider_name") String providerName |
| 110 | + ) { |
| 111 | + this( |
| 112 | + confidence, |
| 113 | + isAnonymous, |
| 114 | + isAnonymousVpn, |
| 115 | + isHostingProvider, |
| 116 | + isPublicProxy, |
| 117 | + isResidentialProxy, |
| 118 | + isTorExitNode, |
| 119 | + networkLastSeen != null ? LocalDate.parse(networkLastSeen) : null, |
| 120 | + providerName |
| 121 | + ); |
| 122 | + } |
| 123 | +} |
0 commit comments