amigo

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

README

##Develop info

in order to build the JS file following commands has to be runned:

cd resources/private/js
npm run install
npm run watch

Now run amigo

cd app
go run main.go

Documentation

Index

Constants

View Source
const (
	ID_KEY       = "I"
	TEAMNAME_KEY = "TN"
)

Variables

View Source
var (
	ErrReadBodyTooLarge     = errors.New("request body is too large")
	ErrUnauthorized         = errors.New("requires authentication")
	ErrInvalidTokenFormat   = errors.New("invalid token format")
	ErrInvalidFlag          = errors.New("invalid flag")
	ErrIncorrectCredentials = errors.New("Credentials does not match")
	ErrTeamNameEmpty        = errors.New("Team name can NOT be empty")
	ErrTeamNameToLarge      = errors.New("Team name is too long")
	ErrTeamNameCharacters   = errors.New("Team name should NOT contain non-alphanumeric characters")
	ErrEmailEmpty           = errors.New("Email can NOT be empty")
	ErrEmailToLarge         = errors.New("Email is NOT within the defined character limit")
	ErrEmailCharacters      = errors.New("Non alphabetic characters are NOT allowed in email address such as - , { [ _   ")
	ErrProtectedEvent       = errors.New("UNABLE TO SIGNUP: WRONG SECRET KEY FOR PROTECTED EVENT ! \n ASK EVENT ADMINISTRATOR FOR SECRET KEY FOR THIS EVENT ! ")
)

Functions

func GETEndpoint

func GETEndpoint(next http.HandlerFunc) http.HandlerFunc

Check if the request method is GET

func GetWd

func GetWd() string

Get working directory of the project

func JSONEndpoint

func JSONEndpoint(next http.HandlerFunc) http.HandlerFunc

Check if the content-type of the request is in json

func POSTEndpoint

func POSTEndpoint(next http.HandlerFunc) http.HandlerFunc

Check if the request method is POST

Types

type Amigo

type Amigo struct {
	TeamStore store.Event

	FrontEndData *FrontendData
	// contains filtered or unexported fields
}

func NewAmigo

func NewAmigo(ts store.Event, chals []store.ChildrenChalConfig, reCaptchaKey string, wgClient wg.WireguardClient, opts ...AmigoOpt) *Amigo

func (*Amigo) GetFrontendData

func (am *Amigo) GetFrontendData() *FrontendData

func (*Amigo) Handler

func (am *Amigo) Handler(hooks Hooks, guacHandler http.Handler) http.Handler

func (*Amigo) PauseSignup

func (am *Amigo) PauseSignup(pause bool)

func (*Amigo) SetNotification

func (am *Amigo) SetNotification(n Notification)

type AmigoOpt

type AmigoOpt func(*Amigo)

func WithEventName

func WithEventName(eventName string) AmigoOpt

func WithMaxReadBytes

func WithMaxReadBytes(b int64) AmigoOpt

type Category

type Category struct {
	CategoryName string      `json:"category"`
	Challenges   []Challenge `json:"chals"`
}

Contains a list of Challenges relative the CategoryName

type Challenge

type Challenge struct {
	Name   string `json:"name"`
	Tag    string `json:"tag"`
	Points uint   `json:"points"`
}

Challenge name and the points relative that challenge

type ChallengeCP

type ChallengeCP struct {
	ChalInfo        store.ChildrenChalConfig `json:"challenge"`
	IsUserCompleted bool                     `json:"isUserCompleted"`
	TeamsCompleted  []TeamsCompleted         `json:"teamsCompleted"`
	IsDisabledChal  bool                     `json:"isChalDisabled"`
}

Challenge for Challenges Page. It contains the challenge information, which team has solved that challenge and if the current user has solve that challenge

type Client

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

type FrontendData

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

func NewFrontendData

func NewFrontendData(ts store.TeamStore, chals ...store.ChildrenChalConfig) *FrontendData

func (*FrontendData) RunFrontendData

func (fd *FrontendData) RunFrontendData()

func (*FrontendData) UpdateChallenges

func (fd *FrontendData) UpdateChallenges(chals []store.ChildrenChalConfig)

type Hooks

type Hooks struct {
	AssignLab         func(t *store.Team) error
	ResetExercise     func(t *store.Team, challengeTag string) error
	StartStopExercise func(t *store.Team, challengeTag string, state bool) error
	ResetFrontend     func(t *store.Team) error
	ResumeTeamLab     func(t *store.Team) error
}

type Hosts

type Hosts struct {
	Domain string
	IP     string
}

type Message

type Message struct {
	Message       string      `json:"msg"`
	Values        interface{} `json:"values"`
	IsLabAssigned bool        `json:"isLabAssigned"`
}

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

type Notification

type Notification struct {
	Message       string
	LoggedInUsers bool
}

type Recaptcha

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

func NewRecaptcha

func NewRecaptcha(secret string) Recaptcha

func (*Recaptcha) Verify

func (r *Recaptcha) Verify(response string) bool

Verifies if current request have valid re-captcha response and returns true or false This method also records any errors in validation.

type Scoreboard

type Scoreboard struct {
	Category []Category `json:"challenges"`
	TeamRow  []TeamRow  `json:"teams"`
}

type TeamRow

type TeamRow struct {
	Id              string       `json:"id"`
	Name            string       `json:"name"`
	TotalPoints     uint         `json:"tpoints"`
	ChalCompletions []*time.Time `json:"completions"`
	ChalPoints      []uint       `json:"points"`
	IsUser          bool         `json:"is_user"`
}

func TeamInfo

func TeamInfo(t *store.Team, chalCategories []Category) TeamRow

type TeamsCompleted

type TeamsCompleted struct {
	TeamName    string     `json:"teamName"`
	CompletedAt *time.Time `json:"completedAt"`
}

Jump to

Keyboard shortcuts

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