monitor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSTUNServer = errors.New("no STUN server found")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	Type EventType
	Data interface{}
}

type EventExternalAddressChanged

type EventExternalAddressChanged struct {
	ExternalAddress string
}

type EventType

type EventType byte
const (
	EventTypeExternalAddressChanged EventType = iota + 1
)

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor is used to monitoring the link change.

func New

func New(dialer *net.Dialer, stunServer protocol.RelayServer) *Monitor

New returns the monitor instance which is used to detect the external address of the current node.

func (*Monitor) DetectExternalAddress

func (m *Monitor) DetectExternalAddress(ctx context.Context, persistent bool) (string, error)

DetectExternalAddress detect the external address of the current node.

func (*Monitor) Events

func (m *Monitor) Events() <-chan Event

func (*Monitor) ExternalAddress

func (m *Monitor) ExternalAddress() string

ExternalAddress returns the external address of current node.

func (*Monitor) Monitoring

func (m *Monitor) Monitoring(ctx context.Context, wg *sync.WaitGroup)

func (*Monitor) SetSTUNServer

func (m *Monitor) SetSTUNServer(stunServer protocol.RelayServer)

SetSTUNServer sets the latest STUN server (the same as the primary relay server).

Jump to

Keyboard shortcuts

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