-
Notifications
You must be signed in to change notification settings - Fork 207
Expand file tree
/
Copy pathAnonymousPlusResponse.java
More file actions
193 lines (175 loc) · 7.94 KB
/
AnonymousPlusResponse.java
File metadata and controls
193 lines (175 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package com.maxmind.geoip2.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.annotation.JsonSerialize;
import tools.jackson.databind.ser.std.ToStringSerializer;
import com.maxmind.db.MaxMindDbConstructor;
import com.maxmind.db.MaxMindDbIpAddress;
import com.maxmind.db.MaxMindDbNetwork;
import com.maxmind.db.MaxMindDbParameter;
import com.maxmind.db.Network;
import com.maxmind.geoip2.JsonSerializable;
import com.maxmind.geoip2.NetworkDeserializer;
import java.net.InetAddress;
import java.time.LocalDate;
/**
* This class provides the GeoIP Anonymous Plus model.
*
* @param ipAddress The IP address that the data in the model is for.
* @param isAnonymous Whether the IP address belongs to any sort of anonymous network.
* @param isAnonymousVpn Whether the IP address is registered to an anonymous VPN provider. If a
* VPN provider does not register subnets under names associated with them,
* we will likely only flag their IP ranges using isHostingProvider.
* @param isHostingProvider Whether the IP address belongs to a hosting or VPN provider (see
* description of isAnonymousVpn).
* @param isPublicProxy Whether the IP address belongs to a public proxy.
* @param isResidentialProxy Whether the IP address is on a suspected anonymizing network and
* belongs to a residential ISP.
* @param isTorExitNode Whether the IP address is a Tor exit node.
* @param network The network associated with the record. In particular, this is the largest
* network where all the fields besides IP address have the same value.
* @param anonymizerConfidence A score ranging from 1 to 99 that is our percent confidence that
* the network is currently part of an actively used VPN service.
* @param networkLastSeen The last day that the network was sighted in our analysis of anonymized
* networks.
* @param providerName The name of the VPN provider (e.g., NordVPN, SurfShark, etc.) associated
* with the network.
*/
public record AnonymousPlusResponse(
@JsonProperty("ip_address")
@MaxMindDbIpAddress
InetAddress ipAddress,
@JsonProperty("is_anonymous")
@MaxMindDbParameter(name = "is_anonymous", useDefault = true)
boolean isAnonymous,
@JsonProperty("is_anonymous_vpn")
@MaxMindDbParameter(name = "is_anonymous_vpn", useDefault = true)
boolean isAnonymousVpn,
@JsonProperty("is_hosting_provider")
@MaxMindDbParameter(name = "is_hosting_provider", useDefault = true)
boolean isHostingProvider,
@JsonProperty("is_public_proxy")
@MaxMindDbParameter(name = "is_public_proxy", useDefault = true)
boolean isPublicProxy,
@JsonProperty("is_residential_proxy")
@MaxMindDbParameter(name = "is_residential_proxy", useDefault = true)
boolean isResidentialProxy,
@JsonProperty("is_tor_exit_node")
@MaxMindDbParameter(name = "is_tor_exit_node", useDefault = true)
boolean isTorExitNode,
@JsonProperty("network")
@JsonDeserialize(using = NetworkDeserializer.class)
@MaxMindDbNetwork
Network network,
@JsonProperty("anonymizer_confidence")
@MaxMindDbParameter(name = "anonymizer_confidence")
Integer anonymizerConfidence,
@JsonProperty("network_last_seen")
@MaxMindDbParameter(name = "network_last_seen")
LocalDate networkLastSeen,
@JsonProperty("provider_name")
@MaxMindDbParameter(name = "provider_name")
String providerName
) implements JsonSerializable {
/**
* Constructs an instance of {@code AnonymousPlusResponse} with date parsing
* from MaxMind database.
*
* @param ipAddress the IP address being checked
* @param isAnonymous whether the IP address belongs to any sort of anonymous network
* @param isAnonymousVpn whether the IP address belongs to an anonymous VPN system
* @param isHostingProvider whether the IP address belongs to a hosting provider
* @param isPublicProxy whether the IP address belongs to a public proxy system
* @param isResidentialProxy whether the IP address belongs to a residential proxy system
* @param isTorExitNode whether the IP address is a Tor exit node
* @param network the network associated with the record
* @param anonymizerConfidence confidence that the network is a VPN.
* @param networkLastSeen the last sighting of the network.
* @param providerName the name of the VPN provider.
*/
@MaxMindDbConstructor
public AnonymousPlusResponse(
@MaxMindDbIpAddress InetAddress ipAddress,
@MaxMindDbParameter(name = "is_anonymous", useDefault = true)
boolean isAnonymous,
@MaxMindDbParameter(name = "is_anonymous_vpn", useDefault = true)
boolean isAnonymousVpn,
@MaxMindDbParameter(name = "is_hosting_provider", useDefault = true)
boolean isHostingProvider,
@MaxMindDbParameter(name = "is_public_proxy", useDefault = true)
boolean isPublicProxy,
@MaxMindDbParameter(name = "is_residential_proxy", useDefault = true)
boolean isResidentialProxy,
@MaxMindDbParameter(name = "is_tor_exit_node", useDefault = true)
boolean isTorExitNode,
@MaxMindDbNetwork Network network,
@MaxMindDbParameter(name = "anonymizer_confidence") Integer anonymizerConfidence,
@MaxMindDbParameter(name = "network_last_seen") String networkLastSeen,
@MaxMindDbParameter(name = "provider_name") String providerName
) {
this(
ipAddress,
isAnonymous,
isAnonymousVpn,
isHostingProvider,
isPublicProxy,
isResidentialProxy,
isTorExitNode,
network,
anonymizerConfidence,
networkLastSeen != null ? LocalDate.parse(networkLastSeen) : null,
providerName
);
}
/**
* @return The IP address that the data in the model is for.
* @deprecated Use {@link #ipAddress()} instead. This method will be removed in 6.0.0.
*/
@Deprecated(since = "5.0.0", forRemoval = true)
@JsonProperty("ip_address")
public String getIpAddress() {
return ipAddress().getHostAddress();
}
/**
* @return The network associated with the record. In particular, this is
* the largest network where all the fields besides IP address have the
* same value.
* @deprecated Use {@link #network()} instead. This method will be removed in 6.0.0.
*/
@Deprecated(since = "5.0.0", forRemoval = true)
@JsonProperty
@JsonSerialize(using = ToStringSerializer.class)
public Network getNetwork() {
return network();
}
/**
* @return A score ranging from 1 to 99 that is our percent confidence that the network is
* currently part of an actively used VPN service.
* @deprecated Use {@link #anonymizerConfidence()} instead. This method will be removed
* in 6.0.0.
*/
@Deprecated(since = "5.0.0", forRemoval = true)
@JsonProperty
public Integer getAnonymizerConfidence() {
return anonymizerConfidence();
}
/**
* @return The last day that the network was sighted in our analysis of anonymized networks.
* @deprecated Use {@link #networkLastSeen()} instead. This method will be removed in 6.0.0.
*/
@Deprecated(since = "5.0.0", forRemoval = true)
@JsonProperty
public LocalDate getNetworkLastSeen() {
return networkLastSeen();
}
/**
* @return The name of the VPN provider (e.g., NordVPN, SurfShark, etc.) associated with the
* network.
* @deprecated Use {@link #providerName()} instead. This method will be removed in 6.0.0.
*/
@Deprecated(since = "5.0.0", forRemoval = true)
@JsonProperty
public String getProviderName() {
return providerName();
}
}