failover

package
v0.0.0-...-8f9a1ec Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package failover implements the failover procedure by sending pings and checking if the VPN is up

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DroppedConMon

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

The DroppedConMon is a connection monitor that checks for an increase in rx bytes in certain intervals

func New

func New(readRxBytes func() (int64, error)) *DroppedConMon

New creates a failover monitor for the gateway and the rx bytes function reader This is a simple wrapper over `NewDroppedMonitor` to create one with the default settings If this function returns True, the connection is dropped. False means it has exited and we don't know for sure if it's dropped or not

func NewDroppedMonitor

func NewDroppedMonitor(pingInterval time.Duration, pDropped int, readRxBytes func() (int64, error)) *DroppedConMon

NewDroppedMonitor creates a new failover monitor `pingInterval` is the interval in which to send pings `pDropped` is how many pings we need to send before we deem it is dropped `readRxBytes` is a function that gets the rx bytes from the client

func (*DroppedConMon) Start

func (m *DroppedConMon) Start(ctx context.Context, gateway string, mtuSize int) (bool, error)

Start starts ticking every ping interval and check if the connection is dropped or alive This does not check Rx bytes every tick, but rather when pAlive or pDropped is reached It returns an error if there was an invalid input or a ping was failed to be sent

type Pinger

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

Pinger sends pings

func NewPinger

func NewPinger(gateway string, size int) (*Pinger, error)

NewPinger creates a new pinger with gateway `gateway` and size `size`

func (Pinger) Read

func (p Pinger) Read(deadline time.Time) error

Read reads from the ping listener with deadline `deadline`

func (Pinger) Send

func (p Pinger) Send(seq int) error

Send sends a single ping

Jump to

Keyboard shortcuts

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