agent

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: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTH_KEY = "au"
)
View Source
const DEFAULT_AUTH = "dev-auth-key"
View Source
const DEFAULT_SIGN = "dev-sign-key"

Variables

View Source
var (
	InvalidAuthKey        = errors.New("Invalid Authentication Key")
	InvalidTokenFormatErr = errors.New("Invalid token format")
	MissingKeyErr         = errors.New("No Authentication Key provided")
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	State *state.State

	pb.UnimplementedAgentServer

	EnvPool *env.EnvPool `json:"envpool,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(conf *Config) (*Agent, error)

func (*Agent) AddExercisesToEnv added in v0.1.0

func (a *Agent) AddExercisesToEnv(ctx context.Context, req *proto.ExerciseRequest) (*proto.StatusResponse, error)

Adds exercises to a beginner environment It appends the new exercise configs to the existing lab config within the environment. This is used for future labs that may start up. Then it adds the exercises to the existing running labs under this environment.

func (*Agent) AddExercisesToLab added in v0.1.0

func (a *Agent) AddExercisesToLab(ctx context.Context, req *proto.ExerciseRequest) (*proto.StatusResponse, error)

GRPc endpoint that adds exercises to an already running lab. It requires the lab tag, and an array of exercise tags. It starts by creating the containers needed for the exercise, then it refreshes the DNS and starts the containers afterwards. It utilizes a mutex lock to make sure that if anyone tries to run the same GRPc call twice without the first being finished, the second one will wait

func (*Agent) CloseEnvironment added in v0.1.0

func (a *Agent) CloseEnvironment(ctx context.Context, req *proto.CloseEnvRequest) (*proto.StatusResponse, error)

Closes environment and attached containers/vms, and removes the environment from the event pool

func (*Agent) CloseLab added in v0.1.0

func (a *Agent) CloseLab(ctx context.Context, req *proto.CloseLabRequest) (*proto.StatusResponse, error)

Shuts down and removes all frontends and containers related to specific lab. Then removes it from the environment's lab map.

func (*Agent) CreateEnvironment added in v0.1.0

func (a *Agent) CreateEnvironment(ctx context.Context, req *proto.CreatEnvRequest) (*proto.StatusResponse, error)

Creates a new lab environment. Should be called by the daemon when a new event is being created. Environments can be advanced or beginner environments. Advanced environments is geared towards regular CTFs where as beginner environments can be used for beginner events where the user would just need to press the connect button and a lab would be ready with all challenges running.

func (*Agent) CreateLabForEnv added in v0.1.0

func (a *Agent) CreateLabForEnv(ctx context.Context, req *proto.CreateLabRequest) (*proto.StatusResponse, error)

func (*Agent) CreateVpnConfForLab added in v0.1.0

func (a *Agent) CreateVpnConfForLab(ctx context.Context, req *proto.CreateVpnConfRequest) (*proto.CreateVpnConfResponse, error)

func (*Agent) GetHostsInLab added in v0.1.0

func (a *Agent) GetHostsInLab(ctx context.Context, req *proto.GetHostsRequest) (*proto.GetHostsResponse, error)

func (*Agent) GetLab added in v0.1.0

func (a *Agent) GetLab(ctx context.Context, req *proto.GetLabRequest) (*proto.GetLabResponse, error)

func (*Agent) ListEnvironments added in v1.0.0

func (a *Agent) ListEnvironments(ctx context.Context, req *proto.Empty) (*proto.ListEnvResponse, error)

Lists currently running, starting and closing environments.

func (*Agent) MonitorStream added in v0.1.0

func (a *Agent) MonitorStream(stream proto.Agent_MonitorStreamServer) error

Monitoring stream will respond to Pings from the server with cpu, memory and any new labs that may have come since last request

func (*Agent) NewGRPCServer

func (d *Agent) NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server

func (*Agent) Ping added in v0.1.0

func (a *Agent) Ping(ctx context.Context, req *proto.PingRequest) (*proto.PingResponse, error)

TODO Heartbeat, resource monitoring and log monitoring Used for the daemon to check the connection to the agent when initially connecting

func (*Agent) ResetExerciseInLab added in v0.1.0

func (a *Agent) ResetExerciseInLab(ctx context.Context, req *proto.ExerciseRequest) (*proto.StatusResponse, error)

Recreates and starts an exercise in a specific lab in case it should be having problems of any sorts.

func (*Agent) ResetLab added in v1.0.0

func (a *Agent) ResetLab(ctx context.Context, req *proto.ResetLabRequest) (*proto.StatusResponse, error)

Reset lab resets DHCP, DNS, exercises and frontends in lab

func (*Agent) ResetVmInLab added in v0.1.0

func (a *Agent) ResetVmInLab(ctx context.Context, req *proto.VmRequest) (*proto.StatusResponse, error)

func (*Agent) RunGuacProxy added in v0.1.0

func (a *Agent) RunGuacProxy() error

Sets up the gin framework, and uses the cors middleware to allow from all origins. It the runs the proxy on a port specified in the agent config

func (*Agent) StartExerciseInLab added in v0.1.0

func (a *Agent) StartExerciseInLab(ctx context.Context, req *proto.ExerciseRequest) (*proto.StatusResponse, error)

Starts a suspended/stopped exercise in a specific lab

func (*Agent) StopExerciseInLab added in v0.1.0

func (a *Agent) StopExerciseInLab(ctx context.Context, req *proto.ExerciseRequest) (*proto.StatusResponse, error)

Stops a running exercise for a specific lab

type Authenticator

type Authenticator interface {
	AuthenticateContext(context.Context) error
}

func NewAuthenticator

func NewAuthenticator(Skey, AKey string) Authenticator

type Config

type Config struct {
	Host               string                           `yaml:"host"`
	GrpcPort           uint                             `yaml:"grpcPort"`
	ProxyPort          uint                             `yaml:"proxyPort"`
	ListeningIp        string                           `yaml:"listening-ip,omitempty"`
	AuthKey            string                           `yaml:"auth-key"`
	SignKey            string                           `yaml:"sign-key"`
	MaxWorkers         int                              `yaml:"max-workers"`
	FileTransferRoot   string                           `yaml:"file-transfer-root"`
	OvaDir             string                           `yaml:"ova-dir"`
	StatePath          string                           `yaml:"state-path"`
	VPNService         VPNconf                          `yaml:"vpn-service"`
	DockerRepositories []dockerclient.AuthConfiguration `yaml:"docker-repositories"`
}

func NewConfigFromFile

func NewConfigFromFile(path string) (*Config, error)

TODO check vpn service conf

type IPPool added in v0.1.0

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

func (*IPPool) Get added in v0.1.0

func (ipp *IPPool) Get() (string, error)

func (*IPPool) ReleaseIP added in v0.1.0

func (ipp *IPPool) ReleaseIP(ip string)

type ProxyResponse added in v0.1.0

type ProxyResponse struct {
	Message string `json:"status,omitempty"`
}

type ServiceConfig added in v0.1.0

type ServiceConfig struct {
	Grpc       string `yaml:"grpc"`
	AuthKey    string `yaml:"auth-key"`
	SignKey    string `yaml:"sign-key"`
	TLSEnabled bool   `yaml:"tls-enabled"`
}

type VPNconf

type VPNconf struct {
	Endpoint   string `yaml:"endpoint"`
	Port       uint64 `yaml:"port"`
	AuthKey    string `yaml:"auth-key"`
	SignKey    string `yaml:"sign-key"`
	WgConfDir  string `yaml:"wg-conf-dir"`
	TLSEnabled bool   `yaml:"tls-enabled"`
}

Jump to

Keyboard shortcuts

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