docks

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HubFeedAnnouncement = 1
	HubFeedStatus       = 2
	HubFeedDistrust     = 3 // TODO
)
View Source
const (
	// Informational
	MsgTypeInfo          uint8 = 1
	MsgTypeLoad          uint8 = 2
	MsgTypeStats         uint8 = 3
	MsgTypePublicHubFeed uint8 = 4

	// Diagnostics
	MsgTypeEcho      uint8 = 16
	MsgTypeSpeedtest uint8 = 17

	// User Access
	MsgTypeUserAuth uint8 = 32

	// Tunneling
	MsgTypeHop    uint8 = 40
	MsgTypeTunnel uint8 = 41
	MsgTypePing   uint8 = 42

	// Admin/Mod Access
	MsgTypeAdminAuth uint8 = 64

	// Mgmt
	MsgTypeEstablishRoute uint8 = 72
	MsgTypeShutdown       uint8 = 73
)

Message type constants

View Source
const (
	CONV_MONKEY uint8 = 0
	CONV_MUX    uint8 = 1
)
View Source
const (
	CraneMsgTypeNewLine           uint8 = 1
	CraneMsgTypeDiscardLine       uint8 = 2
	CraneMsgTypeAddLineSpace      uint8 = 3
	CraneMsgTypeHubAnnouncement   uint8 = 4
	CraneMsgTypeHubStatus         uint8 = 5
	CraneMsgTypeVerification      uint8 = 6
	CraneMsgTypePublishConnection uint8 = 7
	CraneMsgError                 uint8 = 8
	CraneMsgClose                 uint8 = 9
)
View Source
const (
	BackOffStart = 32 * time.Microsecond
	BackOffLimit = 100 * time.Millisecond
)
View Source
const (
	QOTD = "Privacy is not an option, and it shouldn't be the price we accept for just getting on the Internet.\nGary Kovacs\n"
)

Variables

View Source
var (
	CraneStatusStopped          int8 = -1
	CraneStatusPrivate          int8 = 0
	CraneStatusPublishRequested int8 = 1
	CraneStatusPublishVerifying int8 = 2
	CraneStatusPublished        int8 = 3
)

Crane Status Options

View Source
var (
	ErrInternalError = errors.New("internal error")
)

Functions

func AssignCrane

func AssignCrane(hubID string, crane *Crane)

func EstablishRoute

func EstablishRoute(id *cabin.Identity, dst *hub.Hub)

func GetAllControllers

func GetAllControllers() map[string]*CraneController

func LaunchShip

func LaunchShip(ctx context.Context, h *hub.Hub, transport *hub.Transport, ip net.IP) (ships.Ship, error)

func RegisterCraneHooks

func RegisterCraneHooks(announcement, status, publish, discontinue craneHookFunc)

RegisterCraneHooks allows the manager to hook into important crane functions without creating an import loop

func RetractCraneByDestination

func RetractCraneByDestination(hubID string)

func RetractCraneByID

func RetractCraneByID(craneID string) (connectedHub *hub.Hub)

Types

type API

type API struct {
	api.APIBase
}

API provides the interface that nodes communicate with

func NewAPI

func NewAPI(version int, server, initiator bool) *API

NewAPI returns a new Instance of the Port17 API.

func NewClient

func NewClient(version int, dst *hub.Hub) (*API, error)

NewClient is used to create the initial hop to a node and returns a new Port17 API.

func (*API) Echo

func (portAPI *API) Echo(data []byte) ([]byte, error)

Echo send the given data to the connected node and returns the received data.

func (*API) Hop

func (portAPI *API) Hop(version int, dst *hub.Hub) (*API, error)

Hop creates a new connection from the connected node to another one and returns a new Port17 API instance for that node.

func (*API) Info

func (portAPI *API) Info() (*info.Info, error)

Info calls and returns node information of the connected node.

func (*API) PublicHubFeed

func (portAPI *API) PublicHubFeed() *api.Call

func (*API) Tunnel

func (portAPI *API) Tunnel(domain string, ip net.IP, protocol packet.IPProtocol, port uint16) (tunnel *api.Call, err error)

func (*API) UserAuth

func (portAPI *API) UserAuth(code *access.Code) error

Info calls and returns node information of the connected node.

type Conveyor

type Conveyor interface {
	AttachConveyorBelts(lineID string, fromShip, toShip, fromShore, toShore chan *container.Container)
	Run()
}

Conveyor transports and processes containers between the ship (with its crane) to the shore.

type ConveyorBase

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

ConveyorBase provides basic functionality for the Conveyor interface.

func (*ConveyorBase) AttachConveyorBelts

func (cb *ConveyorBase) AttachConveyorBelts(lineID string, fromShip, toShip, fromShore, toShore chan *container.Container)

AttachConveyorBelts attaches the Conveyor to a line.

type ConveyorLine

type ConveyorLine struct {
	ID uint32
	// contains filtered or unexported fields
}

func NewConveyorLine

func NewConveyorLine(crane *Crane, lineID uint32) (*ConveyorLine, error)

func (*ConveyorLine) AddConveyor

func (line *ConveyorLine) AddConveyor(conveyor Conveyor)

func (*ConveyorLine) AddLastConveyor

func (line *ConveyorLine) AddLastConveyor(conveyor LastConveyor)

type Crane

type Crane struct {
	ID string

	ConnectedHub *hub.Hub

	// controller
	Controller *CraneController
	// contains filtered or unexported fields
}

func GetAssignedCrane

func GetAssignedCrane(hubID string) *Crane

func NewCrane

func NewCrane(ship ships.Ship, id *cabin.Identity, connectedHub *hub.Hub) (*Crane, error)

func (*Crane) Start

func (crane *Crane) Start() (err error)

func (*Crane) Status

func (crane *Crane) Status() int8

func (*Crane) Stop

func (crane *Crane) Stop()

type CraneController

type CraneController struct {
	Crane *Crane

	ConnectedHubVerified *abool.AtomicBool

	Publishing *abool.AtomicBool
	// contains filtered or unexported fields
}

func NewCraneController

func NewCraneController(crane *Crane, send chan *container.Container) *CraneController

func (*CraneController) CheckAllLineSpaces

func (cControl *CraneController) CheckAllLineSpaces()

func (*CraneController) Handle

func (cControl *CraneController) Handle(c *container.Container) error

func (*CraneController) NewLine

func (cControl *CraneController) NewLine(version int) (*ConveyorLine, error)

func (*CraneController) PublishConnection

func (cControl *CraneController) PublishConnection() error

func (*CraneController) SendHubAnnouncement

func (cControl *CraneController) SendHubAnnouncement(msg []byte)

func (*CraneController) SendHubStatus

func (cControl *CraneController) SendHubStatus(msg []byte)

type EncryptionConveyor

type EncryptionConveyor struct {
	ConveyorBase
	// contains filtered or unexported fields
}

func NewEncryptionConveyor

func NewEncryptionConveyor(version int, id *cabin.Identity, dst *hub.Hub) (*EncryptionConveyor, error)

func (*EncryptionConveyor) Run

func (ec *EncryptionConveyor) Run()

type HubRelay

type HubRelay struct {
	LastConveyorBase
	// contains filtered or unexported fields
}

func (*HubRelay) Run

func (pr *HubRelay) Run()

type LastConveyor

type LastConveyor interface {
	AttachConveyorBelts(lineID string, fromShip, toShip chan *container.Container)
	Run()
}

LastConveyor is the last processing step to handle containers.

type LastConveyorBase

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

LastConveyorBase provides basic functionality for the Conveyor interface.

func (*LastConveyorBase) AttachConveyorBelts

func (cb *LastConveyorBase) AttachConveyorBelts(lineID string, fromShip, toShip chan *container.Container)

AttachConveyorBelts attaches the Conveyor to a line.

func (*LastConveyorBase) Run

func (cb *LastConveyorBase) Run()

type SimpleConveyorLine

type SimpleConveyorLine struct {
	ID string
	// contains filtered or unexported fields
}

func NewSimpleConveyorLine

func NewSimpleConveyorLine() *SimpleConveyorLine

func (*SimpleConveyorLine) AddConveyor

func (line *SimpleConveyorLine) AddConveyor(conveyor Conveyor)

func (*SimpleConveyorLine) AddLastConveyor

func (line *SimpleConveyorLine) AddLastConveyor(conveyor LastConveyor)

type TunnelRequest

type TunnelRequest struct {
	Domain   string
	IP       net.IP
	Protocol packet.IPProtocol
	Port     uint16
}

func (*TunnelRequest) Address

func (request *TunnelRequest) Address() string

func (*TunnelRequest) Network

func (request *TunnelRequest) Network() string

func (*TunnelRequest) String

func (request *TunnelRequest) String() string

Jump to

Keyboard shortcuts

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