provider

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 9 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 CloseIdleConnections added in v1.15.0

func CloseIdleConnections()

CloseIdleConnections closes all idle (keep-alive) connections after the detection. This is to prevent some lingering TCP connections from disturbing the IP detection.

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

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

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

func MustNewCustomURL added in v1.15.0

func MustNewCustomURL(rawURL string) Provider

MustNewCustomURL creates a HTTP provider and panics if it fails.

func MustNewDebugConst added in v1.15.1

func MustNewDebugConst(raw string) Provider

MustNewDebugConst creates a protocol.Const 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 NewCloudflareTraceCustom added in v1.15.1

func NewCloudflareTraceCustom(url string) Provider

NewCloudflareTraceCustom creates a specialized CloudflareTrace provider with a specific URL.

func NewCustomURL added in v1.15.0

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

NewCustomURL creates a HTTP provider.

func NewDebugConst added in v1.15.1

func NewDebugConst(ppfmt pp.PP, raw string) (Provider, bool)

NewDebugConst creates a protocol.Const 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.)

func NewLocalWithInterface added in v1.15.0

func NewLocalWithInterface(iface string) Provider

NewLocalWithInterface creates a protocol.LocalWithInterface provider.

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