Documentation ¶
Overview ¶
Package protocol implements all the generic protocols to detect public IP addresses. Generic protocols are not tied to a particular server (e.g., Cloudflare).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSOverHTTPS ¶
type DNSOverHTTPS struct { ProviderName string // name of the protocol Is1111UsedForIP4 bool // whether 1.1.1.1 is used Param map[ipnet.Type]struct { URL Switch // the DoH server Name string // domain name to query Class dnsmessage.Class // DNS class to query } }
DNSOverHTTPS represents a generic detection protocol using DNS over HTTPS.
func (*DNSOverHTTPS) GetIP ¶
func (p *DNSOverHTTPS) GetIP(ctx context.Context, ppfmt pp.PP, ipNet ipnet.Type, use1001 bool) (netip.Addr, bool)
GetIP detects the IP address by DNS over HTTPS.
func (*DNSOverHTTPS) ShouldWeCheck1111 ¶ added in v1.9.3
func (p *DNSOverHTTPS) ShouldWeCheck1111() bool
ShouldWeCheck1111 returns whether we should check 1.1.1.1.
type Field ¶
type Field struct { ProviderName string // name of the detection protocol Is1111UsedforIP4 bool Param map[ipnet.Type]struct { URL Switch // URL of the detection page Field string // name of the field holding the IP address } }
Field represents a generic detection protocol to parse an HTTP response.
func (*Field) GetIP ¶
func (p *Field) GetIP(ctx context.Context, ppfmt pp.PP, ipNet ipnet.Type, use1001 bool) (netip.Addr, bool)
GetIP detects the IP address by parsing the HTTP response.
func (*Field) ShouldWeCheck1111 ¶ added in v1.9.3
ShouldWeCheck1111 returns whether we should check 1.1.1.1.
type HTTP ¶
type HTTP struct { ProviderName string // name of the protocol Is1111UsedForIP4 bool // whether 1.1.1.1 is used URL map[ipnet.Type]Switch // URL of the detection page }
HTTP represents a generic detection protocol to use an HTTP response directly.
func (*HTTP) GetIP ¶
func (p *HTTP) GetIP(ctx context.Context, ppfmt pp.PP, ipNet ipnet.Type, use1001 bool) (netip.Addr, bool)
GetIP detects the IP address by using the HTTP response directly.
func (*HTTP) ShouldWeCheck1111 ¶ added in v1.9.3
ShouldWeCheck1111 returns whether we should check 1.1.1.1.
type Local ¶
type Local struct { // Name of the detection protocol. ProviderName string // Whether 1.1.1.1 is used for IPv4 Is1111UsedForIP4 bool // The target IP address of the UDP packet to be sent. RemoteUDPAddr map[ipnet.Type]Switch }
Local detects the IP address by pretending to send out an UDP packet and using the source IP address assigned by the system. In most cases it will detect the IP address of the network interface toward the internet. (No actual UDP packets will be sent out.)
func (*Local) GetIP ¶
func (p *Local) GetIP(_ctx context.Context, ppfmt pp.PP, ipNet ipnet.Type, use1001 bool) (netip.Addr, bool)
GetIP detects the IP address by pretending to send an UDP packet. (No actual UDP packets will be sent out.)
func (*Local) ShouldWeCheck1111 ¶ added in v1.9.3
ShouldWeCheck1111 returns whether we should check 1.1.1.1.
type Switchable ¶ added in v1.9.3
func (Switchable) Switch ¶ added in v1.9.3
func (s Switchable) Switch(use1001 bool) string