Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorResolver(err error) (status int)
- func IsClientError(err error) bool
- type ASNQuery
- type ConfigDB
- type ConfigDNS
- type ConfigHTTP
- type ErrHostResolve
- type ErrInternalAddress
- type ErrNotFound
- type ErrRateLimitExceeded
- type Flags
- type GeoQuery
- type LookupOptions
- type Response
Constants ¶
View Source
const ( DatabaseGeoIP = "geoip" DatabaseASN = "asn" )
Variables ¶
View Source
var Databases = []string{DatabaseGeoIP, DatabaseASN}
Functions ¶
func ErrorResolver ¶
ErrorResolver is used to map internally defined errors to HTTP status codes for chix.
func IsClientError ¶
IsClientError returns true if the error is related to user input/can be corrected by the user.
Types ¶
type ASNQuery ¶
type ASNQuery struct {
AutonomousSystemNumber int `maxminddb:"autonomous_system_number"`
AutonomousSystemOrg string `maxminddb:"autonomous_system_organization"`
Network *net.IPNet
}
ASNQuery is the ASN search query to search through the ASN Maxmind DB.
type ConfigDB ¶
type ConfigDB struct {
GeoIPPath string `env:"GEOIP_PATH" long:"geoip-path" description:"path to read/store GeoIP Maxmind DB" default:"geoip.db"`
GeoIPURL string `` /* 233-byte string literal not displayed */
ASNPath string `env:"ASN_PATH" long:"asn-path" description:"path to read/store ASN Maxmind DB" default:"asn.db"`
ASNURL string `` /* 226-byte string literal not displayed */
LicenseKey string `` /* 128-byte string literal not displayed */
UpdateInterval time.Duration `env:"UPDATE_INTERVAL" long:"update-interval" description:"interval of time between database update checks" default:"12h"`
CacheSize int `` /* 142-byte string literal not displayed */
CacheExpire time.Duration `env:"CACHE_EXPIRE" long:"expire" description:"expiration time of cache" default:"1h"`
DefaultLanguage string `env:"DEFAULT_LANGUAGE" long:"lang" description:"default language to use for geolocation" default:"en"`
}
type ConfigDNS ¶
type ConfigDNS struct {
Resolvers []string `` /* 181-byte string literal not displayed */
Local bool `env:"LOCAL" long:"uselocal" description:"adds local (system) resolvers to the list of resolvers to use"`
CacheSize int `` /* 145-byte string literal not displayed */
CacheExpire time.Duration `env:"CACHE_EXPIRE" long:"expire" description:"expiration time of cache" default:"1h"`
Timeout time.Duration `` /* 133-byte string literal not displayed */
}
type ConfigHTTP ¶
type ConfigHTTP struct {
BindAddr string `env:"BIND_ADDR" long:"bind-addr" default:":8080" required:"true" description:"ip:port pair to bind to"`
TrustedProxies []string `` /* 193-byte string literal not displayed */
MaxConcurrent int `` /* 134-byte string literal not displayed */
Limit int `env:"LIMIT" long:"limit" description:"number of requests/ip/hour" default:"2000"`
HSTS bool `env:"HSTS" long:"hsts" description:"enable HTTP Strict Transport Security"`
CORS []string `env:"CORS" long:"cors" env-delim:"," default:"*" description:"CORS allowed origins"`
Metrics bool `env:"METRICS" long:"metrics" description:"enable prometheus metrics on /metrics to internal IPs"`
}
type ErrHostResolve ¶
ErrHostResolve is an error that is returned when the address didn't match an IP, and thus a hostname lookup was attempted, but failed.
func (*ErrHostResolve) Error ¶
func (e *ErrHostResolve) Error() string
func (*ErrHostResolve) Unwrap ¶
func (e *ErrHostResolve) Unwrap() error
type ErrInternalAddress ¶
type ErrInternalAddress struct {
Address string
}
ErrInternalAddress is an error that is returned when the address is an internal bogon address.
func (*ErrInternalAddress) Error ¶
func (e *ErrInternalAddress) Error() string
type ErrNotFound ¶
type ErrNotFound struct {
Address string
}
func (*ErrNotFound) Error ¶
func (e *ErrNotFound) Error() string
type ErrRateLimitExceeded ¶
type ErrRateLimitExceeded struct {
Address string
}
func (*ErrRateLimitExceeded) Error ¶
func (e *ErrRateLimitExceeded) Error() string
type Flags ¶
type Flags struct {
HTTP ConfigHTTP `group:"HTTP Server options" namespace:"http" env-namespace:"HTTP"`
DB ConfigDB `group:"DB Options" namespace:"db" env-namespace:"DB"`
DNS ConfigDNS `group:"DNS Lookup Options" namespace:"dns" env-namespace:"DNS"`
}
type GeoQuery ¶
type GeoQuery struct {
City struct {
Names map[string]string `maxminddb:"names"`
} `maxminddb:"city"`
Country struct {
Code string `maxminddb:"iso_code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"country"`
Continent struct {
Code string `maxminddb:"code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"continent"`
Location struct {
Lat float64 `maxminddb:"latitude"`
Long float64 `maxminddb:"longitude"`
MetroCode int `maxminddb:"metro_code"`
TimeZone string `maxminddb:"time_zone"`
AccuracyRadiusKM int `maxminddb:"accuracy_radius"`
} `maxminddb:"location"`
Postal struct {
Code string `maxminddb:"code"`
} `maxminddb:"postal"`
Subdivisions []struct {
Code string `maxminddb:"iso_code"`
Names map[string]string `maxminddb:"names"`
} `maxminddb:"subdivisions"`
}
GeoQuery is the struct->tag search query to search through the GeoIP Maxmind DB.
type LookupOptions ¶
type LookupOptions struct {
Languages []string `form:"languages,omitempty" json:"languages" validate:"omitempty,dive,bcp47_language_tag|alpha,min=2,max=5"`
DisableHostLookup bool `form:"disable_host_lookup,omitempty" json:"disable_host_lookup"`
}
LookupOptions are the options for the lookup service.
type Response ¶
type Response struct {
Query string `json:"query"`
Error string `json:"error,omitempty"`
Host string `json:"host,omitempty"`
// GeoIP information.
IP string `json:"ip"`
IPType int `json:"ip_type"`
Summary string `json:"summary"`
City string `json:"city"`
Subdivision string `json:"subdivision"`
Country string `json:"country"`
CountryCode string `json:"country_abbr"`
Continent string `json:"continent"`
ContinentCode string `json:"continent_abbr"`
Lat float64 `json:"latitude"`
Long float64 `json:"longitude"`
Timezone string `json:"timezone"`
PostalCode string `json:"postal_code"`
AccuracyRadiusKM int `json:"accuracy_radius_km"`
// ASN information.
Network string `json:"network"`
ASN string `json:"asn"`
ASNOrg string `json:"asn_org"`
}
Response contains the geolocation and host information for an IP/host.
Click to show internal directories.
Click to hide internal directories.