service

package
v0.0.0-...-381d51a Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoginTokenLifeSpan = 7 * 24 * time.Hour // default is 1week

Functions

func CalcChallengeScore

func CalcChallengeScore(solveCount int, scoreExpr string) (int, error)

Types

type App

type App interface {
	TeamApp
	ChallengeApp
	CTFApp
	SubmissionApp
	ScoreFeed(chals []*model.Challenge, teams []*model.Team, submissions []*model.Submission) ([]*Challenge, []*ScoreFeedEntry, error)
	TaskSolves() (map[*model.Challenge]int64, error)
}

func New

func New(db *gorm.DB, mailer mailer.Mailer) App

type Attachment

type Attachment struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

type CTFApp

type CTFApp interface {
	GetCTFConfig() (*model.Config, error)
	SetCTFConfig(config *model.Config) error
}

type CTFStatus

type CTFStatus int
const (
	CTFNotStarted    CTFStatus = 2
	CTFRunning       CTFStatus = 1
	CTFEnded         CTFStatus = 4
	InvalidCTFSTatus CTFStatus = 0
)

func CalcCTFStatus

func CalcCTFStatus(conf *model.Config) CTFStatus

type Challenge

type Challenge struct {
	ID          uint32       `json:"id"`
	Name        string       `json:"name"`
	Flag        string       `json:"flag"`
	Category    string       `json:"category"`
	Description string       `json:"description"`
	Author      string       `json:"author"`
	Score       uint32       `json:"score"`
	Tags        []string     `json:"tags"`
	Attachments []Attachment `json:"attachments"`
	SolvedBy    []SolvedBy   `json:"solved_by"`

	Host *string `json:"host"`
	Port *int    `json:"port"`

	IsOpen    bool `json:"is_open"`
	IsRunning bool `json:"is_running"`
	IsSurvey  bool `json:"is_survey"`
}

type ChallengeApp

type ChallengeApp interface {
	GetChallengeByID(challengeID uint32) (*Challenge, error)
	ListChallengeByIDs(ids []uint32) ([]*Challenge, error)
	GetChallengeByName(name string) (*Challenge, error)
	GetRawChallengeByID(challengeID uint32) (*model.Challenge, error)
	GetRawChallengeByName(name string) (*model.Challenge, error)
	ListOpenedRawChallenges() ([]*model.Challenge, error)
	ListAllRawChallenges() ([]*model.Challenge, error)

	AddChallenge(c *Challenge) error
	OpenChallenge(challengeID uint32) error
	CloseChallenge(challengeID uint32) error
	UpdateChallenge(challengeID uint32, c *Challenge) error

	SubmitFlag(team *model.Team, ipaddress string, flag string, ctfRunning bool, submitted_at int64) (*model.Challenge, bool, bool, error)
}

type ErrorMessage

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

func NewErrorMessage

func NewErrorMessage(msg string) ErrorMessage

func (ErrorMessage) Error

func (msg ErrorMessage) Error() string

type MessageApp

type MessageApp interface {
}

type ScoreFeedEntry

type ScoreFeedEntry struct {
	Pos            int                  `json:"pos"`
	Teamname       string               `json:"team"`
	Country        string               `json:"country"`
	Score          int                  `json:"score"`
	TaskStats      map[string]*TaskStat `json:"taskStats"`
	TeamID         uint32               `json:"team_id"`
	LastSubmission int64                `json:"last_submission"`
}

/ jsonの名前めちゃくちゃに見えるけどctftimeに沿ってるはず

type SolvedBy

type SolvedBy struct {
	SolvedAt int64  `json:"solved_at"`
	TeamID   uint32 `json:"team_id"`
	TeamName string `json:"team_name"`
}

type SubmissionApp

type SubmissionApp interface {
	ListSubmissions(offset, limit int64) ([]*model.Submission, error)
	ListSubmissionByIDs(ids []uint32) ([]*model.Submission, error)
	ListValidSubmissions() ([]*model.Submission, error)
	ListTeamSubmissions(teamID uint32) ([]*model.Submission, error)
	CountSubmissions() (int64, error)
	CountValidSubmissions() (int64, error)

	GetWrongCount(teamID uint32, duration time.Duration) (int64, error)
	LockSubmission(teamID uint32, duration time.Duration) error
	CheckSubmittable(teamID uint32) (bool, error)
}

type TaskStat

type TaskStat struct {
	Score    uint32 `json:"points"`
	SolvedAt int64  `json:"time"`
}

type TeamApp

type TeamApp interface {
	Login(teamname, password, ipaddress string) (*model.LoginToken, error)
	RegisterTeam(teamname, password, email, countryCode string) (*model.Team, error)
	ListTeams() ([]*model.Team, error)
	ListAllTeams() ([]*model.Team, error)
	CountTeams() (int64, error)
	GetAdminTeam() (*model.Team, error)
	MakeTeamAdmin(t *model.Team) error
	GetTeamByID(teamID uint32) (*model.Team, error)
	GetTeamByName(teamName string) (*model.Team, error)
	GetLoginTeam(token string) (*model.Team, error)
	PasswordResetRequest(email string) error
	PasswordReset(token, newpassword string) error
	PasswordUpdate(team *model.Team, newpassword string) error
	UpdateTeamname(team *model.Team, newTeamname string) error
	UpdateEmail(team *model.Team, newEmail string) error
	UpdateCountry(team *model.Team, newCountryCode string) error
}

Jump to

Keyboard shortcuts

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