captain

package
v1.6.20 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const GossipOpType string = "gossip"

GossipOpType is the type ID of the gossip operation.

View Source
const GossipQueryOpType string = "gossip/query"

GossipQueryOpType is the type ID of the gossip query operation.

View Source
const PublishOpType string = "publish"

PublishOpType is the type ID of the publish operation.

View Source
const SPNConnectedEvent = "spn connect"

SPNConnectedEvent is the name of the event that is fired when the SPN has connected and is ready.

Variables

View Source
var (
	// CfgOptionEnableSPNKey is the configuration key for the SPN module.
	CfgOptionEnableSPNKey = "spn/enable"

	// CfgOptionHomeHubPolicyKey is the configuration key for the SPN home policy.
	CfgOptionHomeHubPolicyKey = "spn/homePolicy"

	// CfgOptionDNSExitHubPolicyKey is the configuration key for the SPN DNS exit policy.
	CfgOptionDNSExitHubPolicyKey = "spn/dnsExitPolicy"

	// CfgOptionUseCommunityNodesKey is the configuration key for whether to use community nodes.
	CfgOptionUseCommunityNodesKey = "spn/useCommunityNodes"

	// NonCommunityVerifiedOwners holds a list of verified owners that are not
	// considered "community".
	NonCommunityVerifiedOwners = []string{"Safing"}

	// CfgOptionTrustNodeNodesKey is the configuration key for whether additional trusted nodes.
	CfgOptionTrustNodeNodesKey = "spn/trustNodes"
)
View Source
var (
	// ErrAllHomeHubsExcluded is returned when all available home hubs were excluded.
	ErrAllHomeHubsExcluded = errors.New("all home hubs are excluded")

	// ErrReInitSPNSuggested is returned when no home hub can be found, even without rules.
	ErrReInitSPNSuggested = errors.New("SPN re-init suggested")
)
View Source
var DisableAccount bool

DisableAccount disables using any account related SPN functionality. Attempts to use the same will result in errors.

Functions

func AddToDebugInfo

func AddToDebugInfo(di *debug.Info)

AddToDebugInfo adds the SPN status to the given debug.Info.

func ClientReady

func ClientReady() bool

ClientReady signifies if the SPN client is fully ready to handle connections.

func EstablishCrane

func EstablishCrane(callerCtx context.Context, dst *hub.Hub) (*docks.Crane, error)

EstablishCrane establishes a crane to another Hub.

func EstablishPublicLane

func EstablishPublicLane(ctx context.Context, dst *hub.Hub) (*docks.Crane, *terminal.Error)

EstablishPublicLane establishes a crane to another Hub and publishes it.

func GetDNSExitHubPolicy

func GetDNSExitHubPolicy() (endpoints.Endpoints, error)

GetDNSExitHubPolicy return the current DNS exit policy.

func IsExcepted

func IsExcepted(ip net.IP) bool

IsExcepted checks if the given IP is currently excepted from the SPN.

func TriggerHubStatusMaintenance

func TriggerHubStatusMaintenance()

TriggerHubStatusMaintenance queues the Hub status update task to be executed.

Types

type BootstrapFile

type BootstrapFile struct {
	Main BootstrapFileEntry
}

BootstrapFile is used for sideloading bootstrap data.

type BootstrapFileEntry

type BootstrapFileEntry struct {
	Hubs []string
}

BootstrapFileEntry is the bootstrap data structure for one map.

type Captain added in v1.6.19

type Captain struct {
	EventSPNConnected *mgr.EventMgr[struct{}]
	// contains filtered or unexported fields
}

Captain is the main module of the SPN.

func New added in v1.6.19

func New(instance instance) (*Captain, error)

New returns a new Captain module.

func (*Captain) Manager added in v1.6.19

func (c *Captain) Manager() *mgr.Manager

Manager returns the module manager.

func (*Captain) SetSleep added in v1.6.19

func (c *Captain) SetSleep(enabled bool)

SetSleep sets the sleep mode of the module.

func (*Captain) Start added in v1.6.19

func (c *Captain) Start() error

Start starts the module.

func (*Captain) States added in v1.6.19

func (c *Captain) States() *mgr.StateMgr

States returns the module states.

func (*Captain) Stop added in v1.6.19

func (c *Captain) Stop() error

Stop stops the module.

type GossipMsgType

type GossipMsgType uint8

GossipMsgType is the gossip message type.

const (
	GossipHubAnnouncementMsg GossipMsgType = 1
	GossipHubStatusMsg       GossipMsgType = 2
)

Gossip Message Types.

func (GossipMsgType) String

func (msgType GossipMsgType) String() string

type GossipOp

type GossipOp struct {
	terminal.OperationBase
	// contains filtered or unexported fields
}

GossipOp is used to gossip Hub messages.

func NewGossipOp

func NewGossipOp(controller *docks.CraneControllerTerminal) (*GossipOp, *terminal.Error)

NewGossipOp start a new gossip operation.

func (*GossipOp) Deliver

func (op *GossipOp) Deliver(msg *terminal.Msg) *terminal.Error

Deliver delivers a message to the operation.

func (*GossipOp) HandleStop

func (op *GossipOp) HandleStop(err *terminal.Error) (errorToSend *terminal.Error)

HandleStop gives the operation the ability to cleanly shut down. The returned error is the error to send to the other side. Should never be called directly. Call Stop() instead.

func (*GossipOp) Type

func (op *GossipOp) Type() string

Type returns the type ID.

type GossipQueryOp

type GossipQueryOp struct {
	terminal.OperationBase
	// contains filtered or unexported fields
}

GossipQueryOp is used to query gossip messages.

func NewGossipQueryOp

func NewGossipQueryOp(t terminal.Terminal) (*GossipQueryOp, *terminal.Error)

NewGossipQueryOp starts a new gossip query operation.

func (*GossipQueryOp) Deliver

func (op *GossipQueryOp) Deliver(msg *terminal.Msg) *terminal.Error

Deliver delivers the message to the operation.

func (*GossipQueryOp) HandleStop

func (op *GossipQueryOp) HandleStop(err *terminal.Error) (errorToSend *terminal.Error)

HandleStop gives the operation the ability to cleanly shut down. The returned error is the error to send to the other side. Should never be called directly. Call Stop() instead.

func (*GossipQueryOp) Type

func (op *GossipQueryOp) Type() string

Type returns the type ID.

type PublishOp

type PublishOp struct {
	terminal.OperationBase
	// contains filtered or unexported fields
}

PublishOp is used to publish a connection.

func NewPublishOp

func NewPublishOp(controller *docks.CraneControllerTerminal, identity *cabin.Identity) (*PublishOp, *terminal.Error)

NewPublishOp start a new publish operation.

func (*PublishOp) Deliver

func (op *PublishOp) Deliver(msg *terminal.Msg) *terminal.Error

Deliver delivers a message to the operation.

func (*PublishOp) HandleStop

func (op *PublishOp) HandleStop(tErr *terminal.Error) (errorToSend *terminal.Error)

HandleStop gives the operation the ability to cleanly shut down. The returned error is the error to send to the other side. Should never be called directly. Call Stop() instead.

func (*PublishOp) Result

func (op *PublishOp) Result() <-chan *terminal.Error

Result returns the result (end error) of the operation.

func (*PublishOp) Type

func (op *PublishOp) Type() string

Type returns the type ID.

type SPNStatus

type SPNStatus struct {
	record.Base
	sync.Mutex

	Status             SPNStatusName
	HomeHubID          string
	HomeHubName        string
	ConnectedIP        string
	ConnectedTransport string
	ConnectedCountry   *geoip.CountryInfo
	ConnectedSince     *time.Time
}

SPNStatus holds SPN status information.

func GetSPNStatus

func GetSPNStatus() *SPNStatus

GetSPNStatus returns the current SPN status.

type SPNStatusName

type SPNStatusName string

SPNStatusName is a SPN status.

const (
	StatusFailed     SPNStatusName = "failed"
	StatusDisabled   SPNStatusName = "disabled"
	StatusConnecting SPNStatusName = "connecting"
	StatusConnected  SPNStatusName = "connected"
)

SPN Stati.

Jump to

Keyboard shortcuts

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