ipcheck

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ipcheck provides a client for detecting the caller's public IP address.

Index

Constants

This section is empty.

Variables

View Source
var ErrStatus = errors.New("status code error")

ErrStatus represents a non success status code error.

Functions

This section is empty.

Types

type Client

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

Client fetches the caller's public IP address from Nine's IP check endpoint.

func New

func New(options ...Option) *Client

New creates a new Client with the given options.

func (*Client) PublicIP

func (c *Client) PublicIP(ctx context.Context) (*Response, error)

PublicIP returns the caller's public IP address as reported by the endpoint.

type Option

type Option func(*Client)

Option is a function that configures a Client.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient configures the HTTP client to use.

func WithURL

func WithURL(url *url.URL) Option

WithURL configures the endpoint URL to query.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent configures the User-Agent header to use.

type Response

type Response struct {
	Blocked    bool       `json:"blocked"`
	RemoteAddr netip.Addr `json:"remoteAddr"`
}

Response is the JSON response from the IP check endpoint.

func PublicIP

func PublicIP(ctx context.Context) (*Response, error)

PublicIP returns the caller's public IP address as reported by the endpoint.

Jump to

Keyboard shortcuts

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