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.
- If client is nil, http.DefaultClient is used.
- If url is empty, it defaults to "https://api.ipify.org/".
func (*TextIPv4Source) Snapshot ¶
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.
- If client is nil, http.DefaultClient is used.
- If url is empty, it defaults to "https://api6.ipify.org/".
func (*TextIPv6Source) Snapshot ¶
Snapshot returns the current public IPv6 address.
Snapshot implements producer.Source.Snapshot.