daemon

package
v0.0.0-...-eeb3e7f Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	USERNAME_KEY    = "un"
	SUPERUSER_KEY   = "su"
	VALID_UNTIL_KEY = "vu"
)
View Source
const (
	MngtPort = ":5454"

	Running            = int32(0)
	Suspended          = int32(1)
	Booked             = int32(2)
	Closed             = int32(3)
	SuspendTeamS       = "Suspend Team Scheduler"
	BookEventS         = "Check Booked Event Scheduler"
	CheckOverdueEventS = "Check Overdue Event Scheduler"
)
View Source
const (
	NoVPN      = 0
	VPN        = 1
	VPNBrowser = 2
)
View Source
const (
	INACTIVITY_DURATION = 8 // in hours
)

Variables

View Source
var (
	InvalidUsernameOrPassErr = errors.New("Invalid username or password")
	InvalidTokenFormatErr    = errors.New("Invalid token format")
	TokenExpiredErr          = errors.New("Token has expired")
	UnknownUserErr           = errors.New("Unknown user")
	EmptyUserErr             = errors.New("Username cannot be empty")
	EmptyPasswdErr           = errors.New("Password cannot be empty")
)
View Source
var (
	DuplicateEventErr    = errors.New("Event with that tag already exists")
	UnknownEventErr      = errors.New("Unable to find event by that tag")
	MissingTokenErr      = errors.New("No security token provided")
	InvalidArgumentsErr  = errors.New("Invalid arguments provided")
	UnknownTeamErr       = errors.New("Unable to find team by that id")
	GrpcOptsErr          = errors.New("failed to retrieve server options")
	NoLabByTeamIdErr     = errors.New("Lab is nil, no lab found for given team id ! ")
	PortIsAllocatedError = errors.New("Given gRPC port is already allocated")
	ReservedDomainErr    = errors.New("Reserved sub domain, change event tag !  ")

	ReservedSubDomains = map[string]bool{"docs": true, "admin": true, "grpc": true, "api": true, "vpn": true}
	Version            string
)
View Source
var (
	NoPrivilegeToStressTest = errors.New("No privilege to have stress test on Haaukins !")
	NPUserMaxLabs           = 40
	NotAvailableTag         = "not available tag, there is already an event which is either running, booked or suspended"

	CapacityExceedsErr = errors.New("VPN Events can have maximum 252 people on board !")
	OutOfQuota         = errors.New("Out of quota for members, you have limited access")
)
View Source
var (
	NoFlagMngtPrivErr   = errors.New("No privilege to see/solve challenges on an event created by others !")
	LabIsNotAssignedErr = errors.New("Lab is not assigned yet ! ")
	NoPrivToUpdate      = errors.New("No privilege to change team password !")
)
View Source
var (
	NoPrivilegeToDelete     = errors.New("No privilege to delete users ")
	NoPrivilegeToList       = errors.New("No privilege to list users")
	NoUserInformation       = errors.New("No user information retrieved from the request !")
	NoDestroyOnAdmin        = errors.New("An admin account cannot destroy another admin account !")
	NoPrivilegeToChangePass = errors.New("No privilege to change passwd of user ! ")
)
View Source
var (
	NoAvailableIPsErr = errors.New("no available VPN IPs")
)

Functions

func New

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

func NewEventPool

func NewEventPool(host string) *eventPool

Types

type APICreds

type APICreds struct {
	Username string `yaml:"username,omitempty"`
	Password string `yaml:"password,omitempty"`
}

type Authenticator

type Authenticator interface {
	TokenForUser(username, password string) (string, error)
	AuthenticateContext(context.Context) (context.Context, error)
}

func NewAuthenticator

func NewAuthenticator(us store.UserStore, key string) Authenticator

type CertificateConfig

type CertificateConfig struct {
	Enabled   bool   `yaml:"enabled"`
	Directory string `yaml:"directory"`
	CertFile  string `yaml:"certfile"`
	CertKey   string `yaml:"certkey"`
	CAFile    string `yaml:"cafile"`
}

type Config

type Config struct {
	Host struct {
		Http string `yaml:"http,omitempty"`
		Grpc string `yaml:"grpc,omitempty"`
	} `yaml:"host,omitempty"`
	Port struct {
		Secure   uint `yaml:"secure,omitempty"`
		InSecure uint `yaml:"insecure,omitempty"`
	}
	Certs              CertificateConfig                `yaml:"tls,omitempty"`
	Database           ServiceConfig                    `yaml:"db-config,omitempty"`
	ExerciseService    ServiceConfig                    `yaml:"exercise-service,omitempty"`
	VPNConn            VPNConnConf                      `yaml:"vpn-service,omitempty"`
	ConfFiles          Files                            `yaml:"files,omitempty"`
	ProductionMode     bool                             `yaml:"prodmode,omitempty"`
	SigningKey         string                           `yaml:"sign-key,omitempty"`
	Rechaptcha         string                           `yaml:"recaptcha-key,omitempty"`
	APICreds           APICreds                         `yaml:"api-creds,omitempty"`
	DockerRepositories []dockerclient.AuthConfiguration `yaml:"docker-repositories,omitempty"`
	FileTransferRoot   FileTransferConf                 `yaml:"file-transfer-root,omitempty"`
}

func NewConfigFromFile

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

type FileTransferConf

type FileTransferConf struct {
	Path string `yaml:"path"`
}

type Files

type Files struct {
	OvaDir        string `yaml:"ova-directory,omitempty"`
	LogDir        string `yaml:"log-directory,omitempty"`
	EventsDir     string `yaml:"events-directory,omitempty"`
	UsersFile     string `yaml:"users-file,omitempty"`
	ExercisesFile string `yaml:"exercises-file,omitempty"`
	FrontendsFile string `yaml:"frontends-file,omitempty"`
}

type GrpcLogger

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

func (*GrpcLogger) Msg

func (l *GrpcLogger) Msg(msg string) error

type IPPool

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

func (*IPPool) Get

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

func (*IPPool) ReleaseIP

func (ipp *IPPool) ReleaseIP(ip string)

type MissingConfigErr

type MissingConfigErr struct {
	Option string
}

func (*MissingConfigErr) Error

func (m *MissingConfigErr) Error() string

type MngtPortErr

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

func (*MngtPortErr) Error

func (m *MngtPortErr) Error() string

type ServiceConfig

type ServiceConfig struct {
	Grpc       string            `yaml:"grpc,omitempty"`
	AuthKey    string            `yaml:"auth-key,omitempty"`
	SignKey    string            `yaml:"sign-key,omitempty"`
	CertConfig CertificateConfig `yaml:"tls,omitempty"`
}

type VPNConnConf

type VPNConnConf struct {
	Endpoint string            `yaml:"endpoint"`
	Port     uint64            `yaml:"port"`
	AuthKey  string            `yaml:"auth-key"`
	SignKey  string            `yaml:"sign-key"`
	Dir      string            `yaml:"client-conf-dir"`
	CertConf CertificateConfig `yaml:"tls"`
}

VPNConnConf includes configuration information for gRPC client on VPN service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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