driver

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	tunnel.FragmentCallback

	// Preflight initializes the driver state and check whether can the driver go forward.
	Preflight() error

	// Drive starts the driver and serve the application traffics.
	Drive(ctx context.Context)

	// Enable enables the driver to serve the application.
	Enable()

	// Disable disables the driver to serve the application and all packets
	// will be dropped if the device in disabled status.
	Disable()

	// Summarize summarizes the driver current state and returns the state and
	// mesh summary.
	Summarize() *Summary

	// Terminate closes the PairMesh engine.
	Terminate()
}

func New

func New(cfg *config.Config, dev device.Device, apiClient *api.Client) Driver

New constructs the engines instance.

type MockDriver

type MockDriver struct {
	NodeDriver
}

MockDriver is a wrapper of NodeDriver for testing use.

func (*MockDriver) SetPeerID

func (d *MockDriver) SetPeerID(id protocol.PeerID)

type NodeDriver

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

NodeDriver implements the Driver interface. NodeDriver is mainly used to control the overall procedure of peerly application. 1. Initialize all resources in the Initialize function. 2. Some long-running routines:

  • Renew credential goroutine will keep the credential up to date.
  • Read tunnel device data goroutine will read the data from tunnel device.
  • Write tunnel device data goroutine will write the data to the tunnel device.

3. Filter out data via filter.

func (*NodeDriver) Disable

func (d *NodeDriver) Disable()

Disable implements the Driver interface

func (*NodeDriver) Drive

func (d *NodeDriver) Drive(ctx context.Context)

Drive implement the Driver interface and will start all background threads to drive the application followup process.

func (*NodeDriver) Enable

func (d *NodeDriver) Enable()

Enable implements the Driver interface

func (*NodeDriver) FindServerIDWithPeerID

func (d *NodeDriver) FindServerIDWithPeerID(res *protocol.PeerGraphResponse) protocol.ServerID

func (*NodeDriver) OnForward

func (d *NodeDriver) OnForward(_ *relay.Client, typ message.PacketType, msg proto.Message) error

func (*NodeDriver) OnFragment

func (d *NodeDriver) OnFragment(data []byte)

OnFragment implements the mesh.PacketCallback

func (*NodeDriver) OnProbeResponse

func (d *NodeDriver) OnProbeResponse(_ *relay.Client, _ message.PacketType, msg proto.Message) error

func (*NodeDriver) OnSyncPeer

func (d *NodeDriver) OnSyncPeer(_ *relay.Client, _ message.PacketType, msg proto.Message) error

func (*NodeDriver) Preflight

func (d *NodeDriver) Preflight() error

func (*NodeDriver) SetPeerID

func (d *NodeDriver) SetPeerID(id protocol.PeerID)

func (*NodeDriver) Summarize

func (d *NodeDriver) Summarize() *Summary

Summarize implements the Driver interface.

func (*NodeDriver) Terminate

func (d *NodeDriver) Terminate()

Terminate implements the Driver interface

type Profile

type Profile struct {
	UserID uint64 `json:"user_id"`
	Name   string `json:"name"`
	IPv4   string `json:"ipv4"`
}

func (*Profile) Equal

func (p *Profile) Equal(rhs *Profile) bool

Equal returns true if the p equals rhs.

type Summary

type Summary struct {
	Enabled bool          `json:"enabled"`
	Status  string        `json:"status"`
	Profile *Profile      `json:"profile"`
	Mesh    *mesh.Summary `json:"mesh"`
}

func (*Summary) Equal

func (s *Summary) Equal(rhs *Summary) bool

Equal returns true if the s equals rhs.

type SummaryChangedCallback

type SummaryChangedCallback func()

Jump to

Keyboard shortcuts

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