webspace

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	Aliases     []lxdApi.ImageAlias `json:"aliases"`
	Fingerprint string              `json:"fingerprint"`
	Properties  map[string]string   `json:"properties"`
	Size        int64               `json:"size"`
}

Image represents an LXD image

type InterfaceAddress

type InterfaceAddress struct {
	Family  string `json:"family"`
	Address string `json:"address"`
	Netmask string `json:"netmask"`
	Scope   string `json:"scope"`
}

InterfaceAddress describes a network interface's address

type InterfaceCounters

type InterfaceCounters struct {
	BytesReceived int64 `json:"bytesReceived"`
	BytesSent     int64 `json:"bytesSent"`

	PacketsReceived int64 `json:"packetsReceived"`
	PacketsSent     int64 `json:"packetsSent"`
}

InterfaceCounters describes a network interface's statistics

type Manager

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

Manager manages webspace containers

func NewManager

func NewManager(cfg *config.Config, iam *iam.APIClient, l lxd.InstanceServer) (*Manager, error)

NewManager returns a new Manager instance

func (*Manager) Create

func (m *Manager) Create(uid int, image string, password string, sshKey string) (*Webspace, error)

Create creates a new webspace container via LXD

func (*Manager) Get

func (m *Manager) Get(uid int, userHint *iam.User) (*Webspace, error)

Get retrieves a Webspace instance from LXD

func (*Manager) GetAll

func (m *Manager) GetAll() ([]*Webspace, error)

GetAll retrieves all the webspaces

func (*Manager) Images

func (m *Manager) Images() ([]Image, error)

Images gets a list of available images to create webspaces from

func (*Manager) Shutdown

func (m *Manager) Shutdown()

Shutdown stops the webspace manager

func (*Manager) Start

func (m *Manager) Start() error

Start starts the webspace manager

type NetworkInterface

type NetworkInterface struct {
	MAC   string `json:"mac"`
	MTU   int    `json:"mtu"`
	State string `json:"state"`

	Counters  InterfaceCounters  `json:"counters"`
	Addresses []InterfaceAddress `json:"addresses"`
}

NetworkInterface describe's a webspace's network interface

type PortForward

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

PortForward represents an active port forwarding

func NewPortForward

func NewPortForward(e uint16, backendAddr *net.TCPAddr, hook PortHook) (*PortForward, error)

NewPortForward creates and starts a port forward

func (*PortForward) Run

func (f *PortForward) Run()

Run starts the port forward

func (*PortForward) Stop

func (f *PortForward) Stop()

Stop shuts down the port forward

type PortHook

type PortHook func(f *PortForward) error

PortHook represents a function to run before connecting to the backend

type PortsManager

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

PortsManager manages TCP port forwarding

func NewPortsManager

func NewPortsManager(cfg *config.Config) (*PortsManager, error)

NewPortsManager creates a new TCP port forward manager

func (*PortsManager) Add

func (p *PortsManager) Add(e uint16, backendAddr *net.TCPAddr, hook PortHook) error

Add creates a new port forwarding

func (*PortsManager) AddAll

func (p *PortsManager) AddAll(w *Webspace, addr string) error

AddAll adds / updates port forwards for a given webspace

func (*PortsManager) Remove

func (p *PortsManager) Remove(e uint16) error

Remove stops and removes a port forwarding

func (*PortsManager) Shutdown

func (p *PortsManager) Shutdown()

Shutdown stops and removes all port forwards

func (*PortsManager) Trim

func (p *PortsManager) Trim(all []*Webspace) error

Trim removes port forwards that have been deleted

type State

type State struct {
	Running           bool                        `json:"running"`
	Uptime            float64                     `json:"uptime"`
	Usage             Usage                       `json:"usage"`
	NetworkInterfaces map[string]NetworkInterface `json:"networkInterfaces"`
}

State describes a webspace's state

type Traefik

type Traefik interface {
	// ClearConfig cleans out any configuration for an instance
	ClearConfig(n string) error
	GenerateConfig(ws *Webspace, addr string) error
}

Traefik represents a method of programming Traefik router configuration

func NewTraefikKubernetes

func NewTraefikKubernetes(cfg *config.Config) (Traefik, error)

NewTraefikKubernetes manages webspace configuration for Traefik via Kubernetes resources

func NewTraefikRedis

func NewTraefikRedis(cfg *config.Config) Traefik

NewTraefikRedis creates a new Traefik config manager using Redis

type TraefikKubernetes

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

TraefikKubernetes manages webspace configuration for Traefik via Kubernetes resources

func (*TraefikKubernetes) ClearConfig

func (t *TraefikKubernetes) ClearConfig(n string) error

ClearConfig cleans out any configuration for an instance

func (*TraefikKubernetes) GenerateConfig

func (t *TraefikKubernetes) GenerateConfig(ws *Webspace, addr string) error

GenerateConfig generates new Traefik configuration for a webspace

type TraefikRedis

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

TraefikRedis manages webspace configuration for Traefik via Redis

func (*TraefikRedis) ClearConfig

func (t *TraefikRedis) ClearConfig(n string) error

ClearConfig cleans out any configuration for an instance

func (*TraefikRedis) GenerateConfig

func (t *TraefikRedis) GenerateConfig(ws *Webspace, addr string) error

GenerateConfig generates new Traefik configuration for a webspace

type Usage

type Usage struct {
	CPU       int64            `json:"cpu"`
	Disks     map[string]int64 `json:"disks"`
	Memory    int64            `json:"memory"`
	Processes int64            `json:"processes"`
}

Usage describes a webspace's resource usage

type Webspace

type Webspace struct {
	UserID  int                   `json:"user"`
	Config  config.WebspaceConfig `json:"config"`
	Domains []string              `json:"domains"`
	Ports   map[uint16]uint16     `json:"ports"`
	// contains filtered or unexported fields
}

Webspace represents a webspace with all of its configuration and state

func (*Webspace) AddDomain

func (w *Webspace) AddDomain(domain string) error

AddDomain verifies and adds a new domain

func (*Webspace) AddPort

func (w *Webspace) AddPort(external uint16, internal uint16) (uint16, error)

AddPort creates a port forwarding

func (*Webspace) AwaitIP

func (w *Webspace) AwaitIP() (string, error)

AwaitIP attempts to retrieve the webspace's IP with exponential backoff

func (*Webspace) Boot

func (w *Webspace) Boot() error

Boot starts the webspace

func (*Webspace) Delete

func (w *Webspace) Delete() error

Delete deletes the webspace

func (*Webspace) EnsureStarted

func (w *Webspace) EnsureStarted() (string, error)

EnsureStarted starts a webspace if it isn't running (delaying by the startup delay) and returns its IP address after

func (*Webspace) GetDomains

func (w *Webspace) GetDomains() ([]string, error)

GetDomains gets all domains (including the default one, which can change because of usernames!)

func (*Webspace) GetIP

func (w *Webspace) GetIP(state *lxdApi.InstanceState) (string, error)

GetIP retrieves the webspace's primary IP address

func (*Webspace) GetUser

func (w *Webspace) GetUser() (*iam.User, error)

GetUser gets the IAM user associated with this webspace

func (*Webspace) InstanceName

func (w *Webspace) InstanceName() string

InstanceName uses the suffix to calculate the name of the instance

func (*Webspace) Log

func (w *Webspace) Log() (io.ReadCloser, error)

Log returns the webspace's `/dev/console` log

func (*Webspace) Reboot

func (w *Webspace) Reboot() error

Reboot restarts the webspace

func (*Webspace) RemoveDomain

func (w *Webspace) RemoveDomain(domain string) error

RemoveDomain removes an existing domain

func (*Webspace) RemovePort

func (w *Webspace) RemovePort(external uint16) error

RemovePort removes a port forwarding

func (*Webspace) Save

func (w *Webspace) Save() error

Save updates the stored LXD configuration

func (*Webspace) Shutdown

func (w *Webspace) Shutdown() error

Shutdown stops the webspace

func (*Webspace) State

func (w *Webspace) State() (State, error)

State returns information about the webspace's state

func (*Webspace) Sync

func (w *Webspace) Sync() error

Sync forces configuration for a webspace to be re-generated

Jump to

Keyboard shortcuts

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