manager

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingStateDir = errors.New("missing state directory")
)

Functions

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode) (err error)

This is from a tailscale library but marked as an unstable API: https://github.com/tailscale/tailscale/blob/main/atomicfile/atomicfile.go

Types

type BGPServer

type BGPServer interface {
	Serve([]net.Listener) error
	AddPeer(*bgp.PeerConfig, []bgp.NLRI) error
	DeletePeer(net.IP) error
	GetPeerStatus(net.IP) bgp.Session
}

BgpReaderWriter is an interface for the handling of per service bgp sessions.

type Db

type Db struct {
	State []*api.ProvisionRequest
	Path  string
	// contains filtered or unexported fields
}

func NewDb

func NewDb() (*Db, error)

NewDb returns a Db struct to handle tracking the latest provisioned state of a client.

func (*Db) DeleteState

func (d *Db) DeleteState(u api.UserType) error

Delete removes the latest provisioned state from disk

func (*Db) GetState

func (d *Db) GetState(userTypes ...api.UserType) []*api.ProvisionRequest

GetState returns the latest provisioned state

func (*Db) SaveState

func (d *Db) SaveState(p *api.ProvisionRequest) error

Save writes the latest provisioned state to disk

type DbReaderWriter

type DbReaderWriter interface {
	GetState(userTypes ...api.UserType) []*api.ProvisionRequest
	DeleteState(u api.UserType) error
	SaveState(p *api.ProvisionRequest) error
}

DbReaderWriter is an interface for managing the state of services. This is used to persist the last provisioned state to disk so we can recover from it on restart/crash.

type NetlinkManager

type NetlinkManager struct {
	Routes           []*routing.Route
	Rules            []*routing.IPRule
	UnicastService   Provisioner
	MulticastService Provisioner
	DoubleZeroAddr   net.IP
	// contains filtered or unexported fields
}

func (*NetlinkManager) Close

func (n *NetlinkManager) Close() error

Close tears down any active services. This is typically called when manager is shutting down. Per-service state is not deleted from the db.

func (*NetlinkManager) Provision

func (n *NetlinkManager) Provision(pr api.ProvisionRequest) error

Provision is the entry point for all user tunnel provisioning. This currently contains logic for IBRL, edge filtering and multicast use cases. After the user tunnel is provisioned, the original request is saved to disk so we're able to handle service restarts.

func (*NetlinkManager) Recover

func (n *NetlinkManager) Recover() error

Recover attempts to recover from the last provisioned state.

func (*NetlinkManager) Remove

func (n *NetlinkManager) Remove(u api.UserType) error

Remove is the entry point for service deprovisioning.

func (*NetlinkManager) Serve

func (n *NetlinkManager) Serve(ctx context.Context) error

Serve starts the manager and attempts to recover from the last provisioned state.

func (*NetlinkManager) ServeProvision

func (n *NetlinkManager) ServeProvision(w http.ResponseWriter, r *http.Request)

ServeProvision handles local provisioning of a double zero tunnel. The following is an example payload:

`{
	"user_type": "IBRL"							[required]
	"tunnel_src": "1.1.1.1", 					[optional]
	"tunnel_dst": "2.2.2.2", 					[required]
	"tunnel_net": "10.1.1.0/31",				[required]
	"doublezero_ip": "10.0.0.0",				[required]
	"doublezero_prefixes": ["10.0.0.0/24"], 	[required]
	"bgp_local_asn": 65000,						[optional]
	"bgp_remote_asn": 65001						[optional]
}`,

func (*NetlinkManager) ServeRemove

func (n *NetlinkManager) ServeRemove(w http.ResponseWriter, r *http.Request)

func (*NetlinkManager) ServeStatus

func (n *NetlinkManager) ServeStatus(w http.ResponseWriter, r *http.Request)

func (*NetlinkManager) Status

func (n *NetlinkManager) Status() ([]*api.StatusResponse, error)

TODO: this contains some workarounds that will be removed when multicast is fully implemented. For now, we only return the status of the unicast service.

Status returns the status of all provisioned services.

type Provisioner

type Provisioner interface {
	Setup(*api.ProvisionRequest) error
	Teardown() error
	Status() (*api.StatusResponse, error) // TODO: what do we return here?
	ServiceType() services.ServiceType
}

Provisioner is an interface for all services that can be provisioned by the manager. All new services must implement this interface.

func CreateService

CreateService creates the appropriate service based on the provisioned user type.

Jump to

Keyboard shortcuts

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