lab

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDNSRecords

func GetDNSRecords(records []*DNSRecord) []string

Types

type DNSRecord

type DNSRecord struct {
	Record map[string]string
}

type FrontendConf

type FrontendConf struct {
	Vm   *virtual.Vm
	Conf virtual.InstanceConfig
}

type Lab

type Lab struct {
	M                 *sync.RWMutex
	Tag               string
	Type              LabType
	Frontends         map[uint]FrontendConf
	Exercises         map[string]*exercise.Exercise
	ExerciseConfigs   []exercise.ExerciseConfig
	DisabledExercises []string
	DnsRecords        []*DNSRecord
	DockerHost        virtual.Host
	Network           *virtual.Network
	DnsServer         *dns.Server
	DhcpServer        *dhcp.Server
	DnsAddress        string
	Vlib              *virtual.VboxLibrary
	IsVPN             bool
	GuacUsername      string
	GuacPassword      string
	VpnConfs          []string
}

func (*Lab) AddAndStartExercises

func (l *Lab) AddAndStartExercises(ctx context.Context, exerConfs ...exercise.ExerciseConfig) error

Used to add exercises to an already running lab. It configures the containers, refreshes the DNS to add the new records and then starts the new exercise containers

func (*Lab) AddExercises

func (l *Lab) AddExercises(ctx context.Context, confs ...exercise.ExerciseConfig) error

AddExercises uses exercise configs from the exercise service to configure containers and flags to be started at a later time

func (*Lab) Close

func (l *Lab) Close() error

func (*Lab) CreateNetwork

func (l *Lab) CreateNetwork(ctx context.Context, isVPN bool) error

CreateNetwork network

func (*Lab) CreateVPNConfigs

func (lab *Lab) CreateVPNConfigs(wgClient wgproto.WireguardClient, envTag string, vpnConfig VpnConfig) ([]string, []string, error)

func (*Lab) GetExercisesInfo

func (l *Lab) GetExercisesInfo() []*proto.Exercise

Returns all exercises currently in lab to be sent to the daemon

func (*Lab) InstanceInfo

func (l *Lab) InstanceInfo() []virtual.InstanceInfo

Get a list of instance information for the VMs and exercises running in the lab

func (*Lab) RdpConnPorts

func (l *Lab) RdpConnPorts() []uint

Get a list of ports for the VMs running in the lab

func (*Lab) RefreshDHCP added in v1.0.0

func (l *Lab) RefreshDHCP(ctx context.Context) error

func (*Lab) RefreshDNS

func (l *Lab) RefreshDNS(ctx context.Context) error

func (*Lab) ResetExercise

func (l *Lab) ResetExercise(ctx context.Context, exTag string) error

func (*Lab) ResetVm

func (l *Lab) ResetVm(ctx context.Context, port uint, envTag string) error

func (*Lab) Start

func (l *Lab) Start(ctx context.Context) error

func (*Lab) StartExercise

func (l *Lab) StartExercise(ctx context.Context, exTag string) error

TODO: Set status of exercise so user can see weither if it is started or stopped.

func (*Lab) StopExercise

func (l *Lab) StopExercise(ctx context.Context, exTag string) error

type LabConf

type LabConf struct {
	Vlib              *virtual.VboxLibrary
	Frontends         []virtual.InstanceConfig
	ExerciseConfs     []exercise.ExerciseConfig
	DisabledExercises []string
}

func (*LabConf) NewLab

func (lc *LabConf) NewLab(ctx context.Context, isVPN bool, labType LabType, eventTag string) (Lab, error)

Creates and starts a new virtual lab

type LabType

type LabType uint32
const (
	// LabType
	TypeBeginner LabType = iota
	TypeAdvanced
)

func (LabType) String

func (lType LabType) String() string

type VpnConfig

type VpnConfig struct {
	Host            string
	VpnAddress      string
	VPNEndpointPort int
	IpAddresses     [][]int
	LabSubnet       string
	TeamSize        int
}

Directories

Path Synopsis
network
dns
vpn

Jump to

Keyboard shortcuts

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