provider

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package provider implements protocols to detect public IP addresses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Name

func Name(p Provider) string

Name gets the protocol name. It returns "none" for nil.

Types

type Provider

type Provider interface {
	Name() string

	ShouldWeCheck1111() bool

	GetIP(ctx context.Context, ppfmt pp.PP, ipNet ipnet.Type, use1001 bool) (netip.Addr, bool)
}

Provider is the abstraction of a protocol to detect public IP addresses.

func MustNewCustom added in v1.10.0

func MustNewCustom(rawURL string) Provider

MustNewCustom creates a HTTP provider and panics if it fails.

func NewCloudflareDOH

func NewCloudflareDOH() Provider

NewCloudflareDOH creates a new provider that queries whoami.cloudflare. via Cloudflare DNS over HTTPS. If use1001 is true, 1.0.0.1 is used instead of 1.1.1.1.

func NewCloudflareTrace

func NewCloudflareTrace() Provider

NewCloudflareTrace creates a specialized CloudflareTrace provider that parses https://1.1.1.1/cdn-cgi/trace. If use1001 is true, 1.0.0.1 is used instead of 1.1.1.1.

func NewCustom added in v1.10.0

func NewCustom(ppfmt pp.PP, rawURL string) (Provider, bool)

NewCustom creates a HTTP provider.

func NewIpify

func NewIpify() Provider

NewIpify creates a specialized HTTP provider that uses the ipify service.

func NewLocal

func NewLocal() Provider

NewLocal creates a specialized Local provider that uses Cloudflare as the remote server. (No actual UDP packets will be sent to Cloudflare.)

Directories

Path Synopsis
Package protocol implements all the generic protocols to detect public IP addresses.
Package protocol implements all the generic protocols to detect public IP addresses.

Jump to

Keyboard shortcuts

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