-
Notifications
You must be signed in to change notification settings - Fork 749
api: GeoIP #8002
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
api: GeoIP #8002
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cbc21cf
API: GeoIP
zhaohuabing ba338ef
update api
zhaohuabing 9b7ef6a
update api
zhaohuabing 45cbc67
address comments
zhaohuabing f9e2942
add db source type
zhaohuabing c7a5b48
fix lint
zhaohuabing 4537cee
remove remote
zhaohuabing ea79be8
address comments
zhaohuabing 36fd363
fix test
zhaohuabing e296673
Merge remote-tracking branch 'origin/main' into geoip-api
zhaohuabing 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| // Copyright Envoy Gateway Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // The full text of the Apache license is available in the LICENSE file at | ||
| // the root of the repo. | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| // GeoIPProvider defines provider-specific settings. | ||
| // +kubebuilder:validation:XValidation:rule="self.type == 'MaxMind' ? has(self.maxMind) : true",message="maxMind must be set when type is MaxMind" | ||
| type GeoIPProvider struct { | ||
| // +kubebuilder:validation:Enum=MaxMind | ||
| // +kubebuilder:validation:Required | ||
| Type GeoIPProviderType `json:"type"` | ||
|
|
||
| // MaxMind configures the MaxMind provider. | ||
| // | ||
| // +optional | ||
| MaxMind *GeoIPMaxMind `json:"maxMind,omitempty"` | ||
| } | ||
|
|
||
| // GeoIPProviderType enumerates GeoIP providers supported by Envoy Gateway. | ||
| type GeoIPProviderType string | ||
|
|
||
| const ( | ||
| // GeoIPProviderTypeMaxMind configures Envoy with the MaxMind provider pointing to local files. | ||
| GeoIPProviderTypeMaxMind GeoIPProviderType = "MaxMind" | ||
| ) | ||
|
|
||
| // GeoIPMaxMind configures the MaxMind provider. | ||
| // These database files are expected to be mounted into the Envoy container, and a sidecar container can be used to update the database files. | ||
|
zhaohuabing marked this conversation as resolved.
|
||
| // +kubebuilder:validation:XValidation:rule="has(self.cityDbSource) || has(self.countryDbSource) || has(self.asnDbSource) || has(self.ispDbSource) || has(self.anonymousIpDbSource)",message="at least one MaxMind database source must be specified" | ||
| type GeoIPMaxMind struct { | ||
| // CityDBSource configures the City database source. | ||
| // | ||
| // +optional | ||
| CityDBSource *GeoIPDBSource `json:"cityDbSource,omitempty"` | ||
|
|
||
| // CountryDBSource configures the Country database source. | ||
| // | ||
| // +optional | ||
| CountryDBSource *GeoIPDBSource `json:"countryDbSource,omitempty"` | ||
|
|
||
| // ASNDBSource configures the ASN database source. | ||
| // | ||
| // +optional | ||
| ASNDBSource *GeoIPDBSource `json:"asnDbSource,omitempty"` | ||
|
|
||
| // ISPDBSource configures the ISP database source. | ||
| // | ||
| // +optional | ||
| ISPDBSource *GeoIPDBSource `json:"ispDbSource,omitempty"` | ||
|
|
||
| // AnonymousIPDBSource configures the Anonymous IP database source. | ||
| // | ||
| // +optional | ||
| AnonymousIPDBSource *GeoIPDBSource `json:"anonymousIpDbSource,omitempty"` | ||
| } | ||
|
|
||
| // GeoIPDBSource defines where a GeoIP .mmdb database can be loaded from. | ||
| type GeoIPDBSource struct { | ||
| // Local is a database source from a local file. | ||
| Local LocalGeoIPDBSource `json:"local"` | ||
| } | ||
|
|
||
| // LocalGeoIPDBSource configures a GeoIP database from a local file path. | ||
| type LocalGeoIPDBSource struct { | ||
| // Path is the path to the database file. | ||
| // | ||
| // +kubebuilder:validation:Pattern=`^.*\\.mmdb$` | ||
| Path string `json:"path"` | ||
| } | ||
|
|
||
| // GeoIPAnonymousMatch matches anonymous network signals emitted by the GeoIP provider. | ||
| // If multiple fields are specified, all specified fields must match. | ||
| // These signals are not mutually exclusive. A single IP may satisfy multiple | ||
| // flags at the same time (for example, a commercial VPN exit IP may also be | ||
| // classified as a public proxy, so both IsVPN and IsProxy can be true). | ||
| // | ||
| // +kubebuilder:validation:XValidation:rule="has(self.isAnonymous) || has(self.isVPN) || has(self.isHosting) || has(self.isTor) || has(self.isProxy)",message="at least one of isAnonymous, isVPN, isHosting, isTor, or isProxy must be specified" | ||
| type GeoIPAnonymousMatch struct { | ||
| // IsAnonymous matches whether the client IP is considered anonymous. | ||
| // | ||
| // +optional | ||
| IsAnonymous *bool `json:"isAnonymous,omitempty"` | ||
|
|
||
| // IsVPN matches whether the client IP is detected as VPN. | ||
| // | ||
| // +optional | ||
| IsVPN *bool `json:"isVPN,omitempty"` | ||
|
|
||
| // IsHosting matches whether the client IP belongs to a hosting provider. | ||
| // | ||
| // +optional | ||
| IsHosting *bool `json:"isHosting,omitempty"` | ||
|
|
||
| // IsTor matches whether the client IP belongs to a Tor exit node. | ||
| // | ||
| // +optional | ||
| IsTor *bool `json:"isTor,omitempty"` | ||
|
|
||
| // IsProxy matches whether the client IP belongs to a public proxy. | ||
| // | ||
| // +optional | ||
| IsProxy *bool `json:"isProxy,omitempty"` | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a list ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GeoLocations []GeoLocation supports OR, and GeoIPAnonymousMatch has multiple options which are ANDed, so we don't need a list here.