Documentation ¶
Overview ¶
Package getmyip returns public and outbound IP addresses of current machine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultGeolocationToken = GeolocationAccessTokens{ ServiceProviderIpapi: "", }
DefaultGeolocationToken contains access tokens for various Geolocation API, you may bring your own license by overriding this variable, leave it value empty if it requires no license.
Functions ¶
func GetOutboundIP ¶
GetOutboundIP retrieves preferred outbound IP address of current machine.
func GetPublicIP ¶
GetPublicIP retrieves public IP address of current machine by calling various online services.
Types ¶
type Geolocation ¶ added in v0.0.3
type Geolocation struct { CountryCode string `json:"country_code,omitempty"` CountryFlag string `json:"country_flag,omitempty"` Country string `json:"country,omitempty"` Region string `json:"region,omitempty"` City string `json:"city,omitempty"` Latitude string `json:"latitude,omitempty"` Longitude string `json:"longitude,omitempty"` Carrier string `json:"carrier,omitempty"` ISP string `json:"isp,omitempty"` ASN string `json:"asn,omitempty"` }
Geolocation describes the deduced geographic position and ISP info of an IP address.
type GeolocationAccessTokens ¶ added in v0.0.3
type GeolocationAccessTokens map[GeolocationServiceProvider]string
GeolocationAccessTokens represents a mapping between geolocation service provider and access token to its service.
type GeolocationResult ¶ added in v0.0.3
type GeolocationResult map[GeolocationServiceProvider]*Geolocation
GeolocationResult represents a collection of geolocation result from various service providers.
func GetGeolocation ¶ added in v0.0.3
func GetGeolocation(ip net.IP, tokens ...GeolocationAccessTokens) (GeolocationResult, error)
GetGeolocation returns deduced geographic position of a given IP address from licensed service providers.
func (GeolocationResult) String ¶ added in v0.0.3
func (g GeolocationResult) String() string
type GeolocationServiceProvider ¶ added in v0.0.3
type GeolocationServiceProvider string
GeolocationServiceProvider represents the name of service provider of Geolocation API.
const ( ServiceProviderIpregistry GeolocationServiceProvider = "ipregistry" ServiceProviderIpify GeolocationServiceProvider = "ipify" ServiceProviderIpapi GeolocationServiceProvider = "ipapi" ServiceProviderIpdata GeolocationServiceProvider = "ipdata" )
Name of service provider of Geolocation API