Documentation ¶
Index ¶
- Constants
- Variables
- func HTTPGetBody(url string, ctx context.Context) ([]byte, error)
- func HTTPGetString(url string, ctx context.Context) (string, error)
- func HTTPJSONGetField(field string) func(string, context.Context) (string, error)
- func RunProviders(ipGetters []IPGetter, timeout time.Duration) (string, error)
- type IPGetter
Constants ¶
View Source
const DefaultTimeout = 10 * time.Second
Variables ¶
View Source
var IPGetters = []IPGetter{ { ServiceURL: "https://httpbin.org/ip", GetIP: func(url string, ctx context.Context) (string, error) { s, err := HTTPJSONGetField("origin")(url, ctx) if err != nil { return "", err } return strings.Split(s, ", ")[0], nil }, }, { ServiceURL: "https://api.myip.com", GetIP: HTTPJSONGetField("ip"), }, { ServiceURL: "https://ip4.seeip.org/json", GetIP: HTTPJSONGetField("ip"), }, { ServiceURL: "https://ipv4bot.whatismyipaddress.com/", GetIP: HTTPGetString, }, { ServiceURL: "https://api.ipify.org?format=json", GetIP: HTTPJSONGetField("ip"), }, }
Functions ¶
func HTTPJSONGetField ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.