ipapi

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ipapi implements the IP API producer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProducerConfig

type ProducerConfig struct {
	// Source is the IP address API to use.
	//
	//   - "text-ipv4": Text-based IPv4 address API.
	//   - "text-ipv6": Text-based IPv6 address API.
	Source string `json:"source"`

	// URL is the URL of the IP address API.
	// If empty, the source default is used.
	URL string `json:"url"`

	// PollInterval is the interval between polling the IP address API.
	// If not positive, it defaults to 5 minutes.
	PollInterval jsonhelper.Duration `json:"poll_interval"`
}

ProducerConfig contains configuration options for the IP API producer.

func (*ProducerConfig) NewProducer

func (cfg *ProducerConfig) NewProducer(client *http.Client, logger *tslog.Logger) (producer.Producer, error)

NewProducer creates a new producer.Producer that monitors the public IP address from an IP address API.

If client is nil, http.DefaultClient is used.

type TextIPv4Source

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

TextIPv4Source obtains the public IPv4 address from a text-based IP address API.

TextIPv4Source implements producer.Source.

func NewTextIPv4Source

func NewTextIPv4Source(client *http.Client, url string) *TextIPv4Source

NewTextIPv4Source creates a new TextIPv4Source.

func (*TextIPv4Source) Snapshot

func (s *TextIPv4Source) Snapshot(ctx context.Context) (producer.Message, error)

Snapshot returns the current public IPv4 address.

Snapshot implements producer.Source.Snapshot.

type TextIPv6Source

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

TextIPv6Source obtains the public IPv6 address from a text-based IP address API.

TextIPv6Source implements producer.Source.

func NewTextIPv6Source

func NewTextIPv6Source(client *http.Client, url string) *TextIPv6Source

NewTextIPv6Source creates a new TextIPv6Source.

func (*TextIPv6Source) Snapshot

func (s *TextIPv6Source) Snapshot(ctx context.Context) (producer.Message, error)

Snapshot returns the current public IPv6 address.

Snapshot implements producer.Source.Snapshot.

Jump to

Keyboard shortcuts

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