vpnapi

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: Unlicense Imports: 5 Imported by: 1

README

vpnapi

A Go client for vpnapi.io

Go Reference Lint Status Go Report Card

Installation

go get github.com/bitlux/vpnapi

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRateLimited = errors.New("rate limited, try again later")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client makes queries to the API.

func New

func New(apiKey string) *Client

New creates a new Client. Obtain an API key by registering at vpnapi.io.

func (*Client) Query

func (c *Client) Query(ip string) (*Response, error)

Query queries the API for details about ip.

func (*Client) SetOnRequest added in v0.0.2

func (c *Client) SetOnRequest(f func(string)) *Client

SetOnRequest sets a hook to execute before a request is made. The argument is the URL that is to be queried with the API key redacted.

func (*Client) SetOnResponse added in v0.0.2

func (c *Client) SetOnResponse(f func(string, []byte)) *Client

SetOnResponse sets a hook to execute once a response is received, before it is parsed. The arguments are the HTTP status and response body.

func (*Client) SetVerbose deprecated

func (c *Client) SetVerbose(bool) *Client

SetVerbose toggles verbose output to stdout.

Deprecated: SetVerbose has no effect

type Location

type Location struct {
	City              string `json:"city"`
	Region            string `json:"region"`
	Country           string `json:"country"`
	Continent         string `json:"contient"`
	RegionCode        string `json:"region_code"`
	CountryCode       string `json:"country_code"`
	ContinentCode     string `json:"continent_code"`
	Latitude          string `json:"latitude"`
	Longitude         string `json:"longitude"`
	TimeZone          string `json:"time_zone"`
	LocaleCode        string `json:"locale_code"`
	MetroCode         string `json:"metro_code"`
	IsInEuropeanUnion bool   `json:"is_in_european_union"`
}

The location section of a response

func (Location) String

func (l Location) String() string

type Network

type Network struct {
	Network                      string `json:"network"`
	AutonomousSystemNumber       string `json:"autonomous_system_number"`
	AutonomousSystemOrganization string `json:"autonomous_system_organization"`
}

The network section of a response

func (Network) String

func (n Network) String() string

type Response

type Response struct {
	IP       string   `json:"ip"`
	Security Security `json:"security"`
	Location Location `json:"location"`
	Network  Network  `json:"network"`
	Message  string   `json:"message"`
}

The response type returned from a query

func (Response) String

func (r Response) String() string

type Security

type Security struct {
	VPN   bool `json:"vpn"`
	Proxy bool `json:"proxy"`
	Tor   bool `json:"tor"`
	Relay bool `json:"relay"`
}

The security section of a response

func (Security) String

func (s Security) String() string

Jump to

Keyboard shortcuts

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