-
Notifications
You must be signed in to change notification settings - Fork 207
Add Anonymous Plus support #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import com.maxmind.geoip2.exception.GeoIp2Exception; | ||
| import com.maxmind.geoip2.model.AnonymousIpResponse; | ||
| import com.maxmind.geoip2.model.AnonymousPlusResponse; | ||
| import com.maxmind.geoip2.model.AsnResponse; | ||
| import com.maxmind.geoip2.model.CityResponse; | ||
| import com.maxmind.geoip2.model.ConnectionTypeResponse; | ||
|
|
@@ -59,6 +60,27 @@ AnonymousIpResponse anonymousIp(InetAddress ipAddress) throws IOException, | |
| Optional<AnonymousIpResponse> tryAnonymousIp(InetAddress ipAddress) throws IOException, | ||
| GeoIp2Exception; | ||
|
|
||
| /** | ||
| * Look up an IP address in a GeoIP2 Anonymous Plus. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some spots we say |
||
| * | ||
| * @param ipAddress IPv4 or IPv6 address to lookup. | ||
| * @return a AnonymousPlusResponse for the requested IP address. | ||
| * @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP | ||
| * @throws java.io.IOException if there is an IO error | ||
| */ | ||
| AnonymousPlusResponse anonymousPlus(InetAddress ipAddress) throws IOException, | ||
| GeoIp2Exception; | ||
|
|
||
| /** | ||
| * Look up an IP address in a GeoIP2 Anonymous Plus. | ||
| * | ||
| * @param ipAddress IPv4 or IPv6 address to lookup. | ||
| * @return a AnonymousPlusResponse for the requested IP address or empty if it is not in the DB. | ||
| * @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP | ||
| * @throws java.io.IOException if there is an IO error | ||
| */ | ||
| Optional<AnonymousPlusResponse> tryAnonymousPlus(InetAddress ipAddress) throws IOException, | ||
| GeoIp2Exception; | ||
|
|
||
| /** | ||
| * Look up an IP address in a GeoIP2 IP Risk database. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
src/main/java/com/maxmind/geoip2/model/AnonymousPlusResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| package com.maxmind.geoip2.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JacksonInject; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
| import com.maxmind.db.MaxMindDbConstructor; | ||
| import com.maxmind.db.MaxMindDbParameter; | ||
| import com.maxmind.db.Network; | ||
| import com.maxmind.geoip2.NetworkDeserializer; | ||
| import java.time.LocalDate; | ||
|
|
||
| /** | ||
| * This class provides the GeoIP Anonymous Plus model. | ||
| */ | ||
| public class AnonymousPlusResponse extends AnonymousIpResponse { | ||
| private final Integer anonymizerConfidence; | ||
| private final LocalDate networkLastSeen; | ||
| private final String providerName; | ||
|
|
||
| /** | ||
| * Constructs an instance of {@code AnonymousPlusResponse} with the specified values. | ||
| * | ||
| * @param anonymizerConfidence confidence that the network is a VPN. | ||
| * @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 networkLastSeen the last sighting of the network. | ||
| * @param providerName the name of the VPN provider. | ||
| */ | ||
| public AnonymousPlusResponse( | ||
| @JsonProperty("anonymizer_confidence") Integer anonymizerConfidence, | ||
| @JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress, | ||
| @JsonProperty("is_anonymous") Boolean isAnonymous, | ||
| @JsonProperty("is_anonymous_vpn") Boolean isAnonymousVpn, | ||
| @JsonProperty("is_hosting_provider") Boolean isHostingProvider, | ||
| @JsonProperty("is_public_proxy") Boolean isPublicProxy, | ||
| @JsonProperty("is_residential_proxy") Boolean isResidentialProxy, | ||
| @JsonProperty("is_tor_exit_node") Boolean isTorExitNode, | ||
| @JacksonInject("network") @JsonDeserialize(using = NetworkDeserializer.class) | ||
| @JsonProperty("network") Network network, | ||
| @JsonProperty("network_last_seen") LocalDate networkLastSeen, | ||
| @JsonProperty("provider_name") String providerName | ||
| ) { | ||
| super(ipAddress, isAnonymous, isAnonymousVpn, isHostingProvider, isPublicProxy, | ||
| isResidentialProxy, isTorExitNode, network); | ||
|
|
||
| this.anonymizerConfidence = anonymizerConfidence; | ||
| this.networkLastSeen = networkLastSeen; | ||
| this.providerName = providerName; | ||
| } | ||
|
|
||
| /** | ||
| * Constructs an instance of {@code AnonymousPlusResponse} with the specified values. | ||
| * | ||
| * @param anonymizerConfidence confidence that the network is a VPN. | ||
| * @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 networkLastSeen the last sighting of the network. | ||
| * @param providerName the name of the VPN provider. | ||
| */ | ||
| @MaxMindDbConstructor | ||
| public AnonymousPlusResponse( | ||
| @MaxMindDbParameter(name = "anonymizer_confidence") Integer anonymizerConfidence, | ||
| @MaxMindDbParameter(name = "ip_address") String ipAddress, | ||
| @MaxMindDbParameter(name = "is_anonymous") Boolean isAnonymous, | ||
| @MaxMindDbParameter(name = "is_anonymous_vpn") Boolean isAnonymousVpn, | ||
| @MaxMindDbParameter(name = "is_hosting_provider") Boolean isHostingProvider, | ||
| @MaxMindDbParameter(name = "is_public_proxy") Boolean isPublicProxy, | ||
| @MaxMindDbParameter(name = "is_residential_proxy") Boolean isResidentialProxy, | ||
| @MaxMindDbParameter(name = "is_tor_exit_node") Boolean isTorExitNode, | ||
| @MaxMindDbParameter(name = "network") Network network, | ||
| @MaxMindDbParameter(name = "network_last_seen") String networkLastSeen, | ||
| @MaxMindDbParameter(name = "provider_name") String providerName | ||
| ) { | ||
| this(anonymizerConfidence, ipAddress, isAnonymous, isAnonymousVpn, | ||
| isHostingProvider, isPublicProxy, isResidentialProxy, isTorExitNode, network, | ||
| networkLastSeen != null ? LocalDate.parse(networkLastSeen) : null, | ||
| providerName); | ||
| } | ||
|
|
||
| /** | ||
| * Constructs an instance of {@code AnonymousPlusResponse} from the values in the | ||
| * response and the specified IP address and network. | ||
| * | ||
| * @param response the response to copy | ||
| * @param ipAddress the IP address being checked | ||
| * @param network the network associated with the record | ||
| */ | ||
| public AnonymousPlusResponse( | ||
| AnonymousPlusResponse response, | ||
| String ipAddress, | ||
| Network network | ||
| ) { | ||
| this( | ||
| response.getAnonymizerConfidence(), | ||
| ipAddress, | ||
| response.isAnonymous(), | ||
| response.isAnonymousVpn(), | ||
| response.isHostingProvider(), | ||
| response.isPublicProxy(), | ||
| response.isResidentialProxy(), | ||
| response.isTorExitNode(), | ||
| network, | ||
| response.getNetworkLastSeen(), | ||
| response.getProviderName() | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @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. | ||
| */ | ||
| @JsonProperty | ||
| public Integer getAnonymizerConfidence() { | ||
| return anonymizerConfidence; | ||
| } | ||
|
|
||
| /** | ||
| * @return The last day that the network was sighted in our analysis of anonymized networks. | ||
| */ | ||
| @JsonProperty | ||
| public LocalDate getNetworkLastSeen() { | ||
| return networkLastSeen; | ||
| } | ||
|
|
||
| /** | ||
| * @return The name of the VPN provider (e.g., NordVPN, SurfShark, etc.) associated with the | ||
| * network. | ||
| */ | ||
| @JsonProperty | ||
| public String getProviderName() { | ||
| return providerName; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule maxmind-db
updated
57 files
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.