netcheck

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: BSD-3-Clause Imports: 28 Imported by: 11

Documentation

Overview

Package netcheck checks the network conditions from the current host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Verbose enables verbose logging.
	Verbose bool

	// Logf optionally specifies where to log to.
	// If nil, log.Printf is used.
	Logf logger.Logf

	// TimeNow, if non-nil, is used instead of time.Now.
	TimeNow func() time.Time

	// GetSTUNConn4 optionally provides a func to return the
	// connection to use for sending & receiving IPv4 packets. If
	// nil, an emphemeral one is created as needed.
	GetSTUNConn4 func() STUNConn

	// GetSTUNConn6 is like GetSTUNConn4, but for IPv6.
	GetSTUNConn6 func() STUNConn

	// SkipExternalNetwork controls whether the client should not try
	// to reach things other than localhost. This is set to true
	// in tests to avoid probing the local LAN's router, etc.
	SkipExternalNetwork bool

	// UDPBindAddr, if non-empty, is the address to listen on for UDP.
	// It defaults to ":0".
	UDPBindAddr string
	// contains filtered or unexported fields
}

Client generates a netcheck Report.

func (*Client) GetReport

func (c *Client) GetReport(ctx context.Context, dm *tailcfg.DERPMap) (*Report, error)

GetReport gets a report.

It may not be called concurrently with itself.

func (*Client) MakeNextReportFull

func (c *Client) MakeNextReportFull()

MakeNextReportFull forces the next GetReport call to be a full (non-incremental) probe of all DERP regions.

func (*Client) ReceiveSTUNPacket

func (c *Client) ReceiveSTUNPacket(pkt []byte, src netaddr.IPPort)

type Report

type Report struct {
	UDP                   bool     // UDP works
	IPv6                  bool     // IPv6 works
	IPv4                  bool     // IPv4 works
	MappingVariesByDestIP opt.Bool // for IPv4
	HairPinning           opt.Bool // for IPv4

	// UPnP is whether UPnP appears present on the LAN.
	// Empty means not checked.
	UPnP opt.Bool
	// PMP is whether NAT-PMP appears present on the LAN.
	// Empty means not checked.
	PMP opt.Bool
	// PCP is whether PCP appears present on the LAN.
	// Empty means not checked.
	PCP opt.Bool

	PreferredDERP   int                   // or 0 for unknown
	RegionLatency   map[int]time.Duration // keyed by DERP Region ID
	RegionV4Latency map[int]time.Duration // keyed by DERP Region ID
	RegionV6Latency map[int]time.Duration // keyed by DERP Region ID

	GlobalV4 string // ip:port of global IPv4
	GlobalV6 string // [ip]:port of global IPv6

}

func (*Report) AnyPortMappingChecked added in v1.0.0

func (r *Report) AnyPortMappingChecked() bool

AnyPortMappingChecked reports whether any of UPnP, PMP, or PCP are non-empty.

func (*Report) Clone

func (r *Report) Clone() *Report

type STUNConn

type STUNConn interface {
	WriteTo([]byte, net.Addr) (int, error)
	ReadFrom([]byte) (int, net.Addr, error)
}

STUNConn is the interface required by the netcheck Client when reusing an existing UDP connection.

Jump to

Keyboard shortcuts

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