netcheck

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: BSD-3-Clause Imports: 24 Imported by: 17

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 {
	// DNSCache optionally specifies a DNSCache to use.
	// If nil, a DNS cache is not used.
	DNSCache *dnscache.Resolver

	// 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
	// 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 *net.UDPAddr)

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
	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) 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