Documentation
¶
Index ¶
- Constants
- Variables
- type AWSGeoInfo
- type AWSIPInfo
- type AWSProvider
- func (p *AWSProvider) DownloadUrl() string
- func (p *AWSProvider) FileName() string
- func (p *AWSProvider) GetLocation(ip string) (*Location, error)
- func (p *AWSProvider) LastUpdate() time.Time
- func (p *AWSProvider) MaybeUpdate() error
- func (p *AWSProvider) MaybeUpdateContext(ctx context.Context) error
- func (p *AWSProvider) NeedUpdate() bool
- func (p *AWSProvider) Ready() bool
- func (p *AWSProvider) SetFileName(name string)
- func (p *AWSProvider) SetReady(ready bool)
- type GCPGeoInfo
- type GCPIPInfo
- type GCPProvider
- func (p *GCPProvider) DownloadUrl() string
- func (p *GCPProvider) FileName() string
- func (p *GCPProvider) GetLocation(ip string) (*Location, error)
- func (p *GCPProvider) LastUpdate() time.Time
- func (p *GCPProvider) MaybeUpdate() error
- func (p *GCPProvider) MaybeUpdateContext(ctx context.Context) error
- func (p *GCPProvider) NeedUpdate() bool
- func (p *GCPProvider) Ready() bool
- func (p *GCPProvider) SetFileName(name string)
- func (p *GCPProvider) SetReady(ready bool)
- type GeoProvider
- type IP2CProvider
- func (p *IP2CProvider) DownloadUrl() string
- func (p *IP2CProvider) FileName() string
- func (p *IP2CProvider) GetLocation(ip string) (*Location, error)
- func (p *IP2CProvider) LastUpdate() time.Time
- func (p *IP2CProvider) MaybeUpdate() error
- func (p *IP2CProvider) MaybeUpdateContext(ctx context.Context) error
- func (p *IP2CProvider) NeedUpdate() bool
- func (p *IP2CProvider) Ready() bool
- func (p *IP2CProvider) SetFileName(string)
- func (p *IP2CProvider) SetReady(bool)
- type IPFilter
- func (f *IPFilter) AddProvider(download bool, path string)
- func (f *IPFilter) AllowIP(ip string) (bool, error)
- func (f *IPFilter) AllowLocation(loc *Location) bool
- func (f *IPFilter) Empty() bool
- func (f *IPFilter) GetLocation(ip string) *Location
- func (f *IPFilter) GetProviders() []GeoProvider
- func (f *IPFilter) NeedGeoInfo() bool
- func (f *IPFilter) StartUpdateDataFile(c chan struct{})
- func (f *IPFilter) UpdateDataFile()
- func (f *IPFilter) UpdateDataFileContext(ctx context.Context)
- type Location
- type MaxMindProvider
- func (p *MaxMindProvider) DownloadUrl() string
- func (p *MaxMindProvider) FileName() string
- func (p *MaxMindProvider) GetLocation(ip string) (*Location, error)
- func (p *MaxMindProvider) LastUpdate() time.Time
- func (p *MaxMindProvider) MaybeUpdate() error
- func (p *MaxMindProvider) MaybeUpdateContext(ctx context.Context) error
- func (p *MaxMindProvider) NeedUpdate() bool
- func (p *MaxMindProvider) Ready() bool
- func (p *MaxMindProvider) SetFileName(name string)
- func (p *MaxMindProvider) SetReady(ready bool)
Constants ¶
View Source
const ( AWSGeoUrl = "https://ip-ranges.amazonaws.com/ip-ranges.json" AWSExpired = 7 * 24 * time.Hour AWSFile = "aws-ip.json" )
View Source
const ( GCPGeoUrl = "https://gstatic.nkn.org/ipranges/cloud.json" GCPExpired = 7 * 24 * time.Hour GCPFile = "gcp-ip.json" )
View Source
const ( Geolite2Url = "https://githubusercontent.nkn.org/leo108/geolite2-db/master/Country.mmdb" MaxMindExpired = 30 * 24 * time.Hour MaxMindFile = "geolite2-country.mmdb" )
View Source
const ( GeoIPRetry = 3 IP2CUrl = "http://ip2c.org/" )
Variables ¶
View Source
var AWSRegionMapping = map[string]string{
"us-east-1": "US",
"us-east-2": "US",
"us-west-1": "US",
"us-west-2": "US",
"af-south-1": "ZA",
"ap-east-1": "HK",
"ap-south-1": "IN",
"ap-northeast-1": "JP",
"ap-northeast-2": "KR",
"ap-northeast-3": "JP",
"ap-southeast-1": "SG",
"ap-southeast-2": "AU",
"ca-central-1": "CA",
"eu-central-1": "DE",
"eu-west-1": "IE",
"eu-west-2": "GB",
"eu-west-3": "FR",
"eu-south-1": "IT",
"eu-north-1": "SE",
"me-south-1": "BH",
"sa-east-1": "BR",
}
View Source
var GCPScopeMapping = map[string]string{
"asia-east1": "TW",
"asia-east2": "HK",
"asia-northeast1": "JP",
"asia-northeast2": "JP",
"asia-northeast3": "KR",
"asia-south1": "IN",
"asia-southeast1": "SG",
"asia-southeast2": "ID",
"australia-southeast1": "AU",
"europe-north1": "FI",
"europe-west1": "BE",
"europe-west2": "GB",
"europe-west3": "DE",
"europe-west4": "NL",
"europe-west6": "CH",
"northamerica-northeast1": "CA",
"southamerica-east1": "BR",
"us-central1": "US",
"us-east1": "US",
"us-east4": "US",
"us-west1": "US",
"us-west2": "US",
"us-west3": "US",
"us-west4": "US",
}
Functions ¶
This section is empty.
Types ¶
type AWSGeoInfo ¶
type AWSProvider ¶
type AWSProvider struct { Info *AWSGeoInfo // contains filtered or unexported fields }
func NewAWSProvider ¶
func NewAWSProvider(path string) *AWSProvider
func (*AWSProvider) DownloadUrl ¶
func (p *AWSProvider) DownloadUrl() string
func (*AWSProvider) FileName ¶
func (p *AWSProvider) FileName() string
func (*AWSProvider) GetLocation ¶
func (p *AWSProvider) GetLocation(ip string) (*Location, error)
func (*AWSProvider) LastUpdate ¶
func (p *AWSProvider) LastUpdate() time.Time
func (*AWSProvider) MaybeUpdate ¶
func (p *AWSProvider) MaybeUpdate() error
func (*AWSProvider) MaybeUpdateContext ¶
func (p *AWSProvider) MaybeUpdateContext(ctx context.Context) error
func (*AWSProvider) NeedUpdate ¶
func (p *AWSProvider) NeedUpdate() bool
func (*AWSProvider) Ready ¶
func (p *AWSProvider) Ready() bool
func (*AWSProvider) SetFileName ¶
func (p *AWSProvider) SetFileName(name string)
func (*AWSProvider) SetReady ¶
func (p *AWSProvider) SetReady(ready bool)
type GCPGeoInfo ¶
type GCPProvider ¶
type GCPProvider struct { Info *GCPGeoInfo // contains filtered or unexported fields }
func NewGCPProvider ¶
func NewGCPProvider(path string) *GCPProvider
func (*GCPProvider) DownloadUrl ¶
func (p *GCPProvider) DownloadUrl() string
func (*GCPProvider) FileName ¶
func (p *GCPProvider) FileName() string
func (*GCPProvider) GetLocation ¶
func (p *GCPProvider) GetLocation(ip string) (*Location, error)
func (*GCPProvider) LastUpdate ¶
func (p *GCPProvider) LastUpdate() time.Time
func (*GCPProvider) MaybeUpdate ¶
func (p *GCPProvider) MaybeUpdate() error
func (*GCPProvider) MaybeUpdateContext ¶
func (p *GCPProvider) MaybeUpdateContext(ctx context.Context) error
func (*GCPProvider) NeedUpdate ¶
func (p *GCPProvider) NeedUpdate() bool
func (*GCPProvider) Ready ¶
func (p *GCPProvider) Ready() bool
func (*GCPProvider) SetFileName ¶
func (p *GCPProvider) SetFileName(name string)
func (*GCPProvider) SetReady ¶
func (p *GCPProvider) SetReady(ready bool)
type GeoProvider ¶
type IP2CProvider ¶
type IP2CProvider struct { }
func NewIP2CProvider ¶
func NewIP2CProvider() *IP2CProvider
func (*IP2CProvider) DownloadUrl ¶
func (p *IP2CProvider) DownloadUrl() string
func (*IP2CProvider) FileName ¶
func (p *IP2CProvider) FileName() string
func (*IP2CProvider) GetLocation ¶
func (p *IP2CProvider) GetLocation(ip string) (*Location, error)
func (*IP2CProvider) LastUpdate ¶
func (p *IP2CProvider) LastUpdate() time.Time
func (*IP2CProvider) MaybeUpdate ¶
func (p *IP2CProvider) MaybeUpdate() error
func (*IP2CProvider) MaybeUpdateContext ¶
func (p *IP2CProvider) MaybeUpdateContext(ctx context.Context) error
func (*IP2CProvider) NeedUpdate ¶
func (p *IP2CProvider) NeedUpdate() bool
func (*IP2CProvider) Ready ¶
func (p *IP2CProvider) Ready() bool
func (*IP2CProvider) SetFileName ¶
func (p *IP2CProvider) SetFileName(string)
func (*IP2CProvider) SetReady ¶
func (p *IP2CProvider) SetReady(bool)
type IPFilter ¶
type IPFilter struct { Allow []Location `json:"allow"` Disallow []Location `json:"disallow"` // contains filtered or unexported fields }
func (*IPFilter) AddProvider ¶
func (*IPFilter) AllowLocation ¶
func (*IPFilter) GetLocation ¶
func (*IPFilter) GetProviders ¶
func (f *IPFilter) GetProviders() []GeoProvider
func (*IPFilter) NeedGeoInfo ¶
func (*IPFilter) StartUpdateDataFile ¶
func (f *IPFilter) StartUpdateDataFile(c chan struct{})
func (*IPFilter) UpdateDataFile ¶
func (f *IPFilter) UpdateDataFile()
func (*IPFilter) UpdateDataFileContext ¶
type Location ¶
type MaxMindProvider ¶
type MaxMindProvider struct { DB *geoip2.Reader // contains filtered or unexported fields }
func NewMaxMindProvider ¶
func NewMaxMindProvider(path string) *MaxMindProvider
func (*MaxMindProvider) DownloadUrl ¶
func (p *MaxMindProvider) DownloadUrl() string
func (*MaxMindProvider) FileName ¶
func (p *MaxMindProvider) FileName() string
func (*MaxMindProvider) GetLocation ¶
func (p *MaxMindProvider) GetLocation(ip string) (*Location, error)
func (*MaxMindProvider) LastUpdate ¶
func (p *MaxMindProvider) LastUpdate() time.Time
func (*MaxMindProvider) MaybeUpdate ¶
func (p *MaxMindProvider) MaybeUpdate() error
func (*MaxMindProvider) MaybeUpdateContext ¶
func (p *MaxMindProvider) MaybeUpdateContext(ctx context.Context) error
func (*MaxMindProvider) NeedUpdate ¶
func (p *MaxMindProvider) NeedUpdate() bool
func (*MaxMindProvider) Ready ¶
func (p *MaxMindProvider) Ready() bool
func (*MaxMindProvider) SetFileName ¶
func (p *MaxMindProvider) SetFileName(name string)
func (*MaxMindProvider) SetReady ¶
func (p *MaxMindProvider) SetReady(ready bool)
Click to show internal directories.
Click to hide internal directories.