client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

client is a tamed client that attaches itself to the running tailscale daemon. It receives events and maintains peer's membership (map) by sending & receiving heartbeat pings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.RWMutex // Lock to prevent concurrent modification, mainly peers map

	*Option
	// contains filtered or unexported fields
}

Client is TailScale as Membership Discovery client client connected to the tailScale daemon running on the machine. In addition to the connection to tailScale client daemon, this also tracks the peerStatus by sending heartbeat pings to all peers and collecting their status periodically

func Start

func Start(ctx context.Context, options *Option) (*Client, error)

Start starts a tailScale client attached to machine's running daemon

func (*Client) ActivePeers

func (c *Client) ActivePeers() []PeerStatus

ActivePeers returns a list of active peers from the current snapshot of peers

func (*Client) AllPeers

func (c *Client) AllPeers() []PeerStatus

ActivePeers returns a list of current snapshot of peers

type LoggerFunc

type LoggerFunc func(format string, args ...interface{})

LoggerFunc provides logging interface for tamed client

type Notify

type Notify struct {
	ipn.Notify
	PingRequest *PingRequest
	PeerRemoved *PeerRemoved
}

type Option

type Option struct {
	InactivityTimeLimit           time.Duration // Time after which a node is considered inactive
	HeartbeatInterval             time.Duration // Interval between subsequent heartbeats
	InactivePeerHeartBeatInterval time.Duration // Time after which an inactive peer should be pinged
	TailScaleSocket               string
	ListenerCh                    chan Notify
	Logger                        LoggerFunc
	StartServer                   bool
}

Set of options, mainly targeted to membership

func DefaultOptions

func DefaultOptions() *Option

type PeerRemoved

type PeerRemoved struct {
	*ipnstate.PeerStatus
}

type PeerStatus

type PeerStatus struct {
	IpnPeerStatus    ipnstate.PeerStatus
	IpnPingResult    ipnstate.PingResult // Might be default if no ping response was ever received
	LastPingRequest  time.Time
	LastPingResponse time.Time
	// contains filtered or unexported fields
}

PeerStatus contains information about a single peer

func (*PeerStatus) HasBeenPinged

func (ps *PeerStatus) HasBeenPinged() bool

Returns true if response from this Peer has ever been received

func (*PeerStatus) IP

func (ps *PeerStatus) IP() string

TailScale IP of the Peer

func (*PeerStatus) LatencyInSeconds

func (ps *PeerStatus) LatencyInSeconds() float64

Latency to ping the Peer. If peer has been inactive then returns math.MaxFloat64

func (*PeerStatus) String

func (ps *PeerStatus) String() string

type PingRequest

type PingRequest struct {
	*ipnstate.PeerStatus
	CurrentPingAt time.Time
	PrevPingAt    time.Time
}

func Ping

func Ping(ps *PeerStatus) *PingRequest

Ping sends a ping request to the peer

Jump to

Keyboard shortcuts

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