publicipgrabber

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

package designed to query api.whatismyip.com for public IP address information. this package contains the structs defining the JSON responses expected and the objects that will utilize them to pull down information.

Index

Constants

View Source
const BASE_URL string = "https://api.whatismyip.com"

base url address for all whatismyip API queries.

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicIPGrabber

type PublicIPGrabber struct {

	// information pulled down from api.whatismyip.com.
	PublicIP PublicIPInfo
	// contains filtered or unexported fields
}

structure defining a PublicIPGrabber object. this will have associated functions to query the site api.whatismyip.com and grab the public IP info.

func NewPublicIPGrabber

func NewPublicIPGrabber(optfuncs ...PublicIPGrabberOptFunc) (grabber *PublicIPGrabber, err error)

function designed to create and initialize a new PubliIPGrabber object. the user can pass in option functions to change the configuration.

func (*PublicIPGrabber) GetMyIPInformation

func (ipg *PublicIPGrabber) GetMyIPInformation() (err error)

function designed to query api.whatismyip.com and pull down the public IP address information for the machine executing the program.

type PublicIPGrabberOptFunc

type PublicIPGrabberOptFunc func(*PublicIPGrabberOptions) error

type alias defining the function structure that will be used to set the configuration options for a PublicIPGrabberOptions object.

func WithClient

func WithClient(client *http.Client) PublicIPGrabberOptFunc

function designed to set the PublicIPGrabberOptions client.

type PublicIPGrabberOptions

type PublicIPGrabberOptions struct {
	// http client that will be used to carry
	// out queries to api.whatismyip.com.
	Client *http.Client
}

structure defining the object that will be used to initialize a public ip grabber object.

type PublicIPInfo

type PublicIPInfo struct {
	// public ip address
	Ip string `json:"ip"`

	// geolocation of the server hosting the ip
	Location string `json:"geo"`

	// provider hosting the IP address
	Provider string `json:"isp"`
}

structure holding public ip information. this will be used in the PublicIPGrabber object and associated request to api.whatismyip.com.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL