wtfd

package
v0.0.0-...-be0c54d Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(username, displayname string) bool

Contains looks if a username is in the datenbank

func Login

func Login(username, passwd string) error

Login checks if password is right for username and returns the User object of it

func Server

func Server() error

Server is the main server func, start it with

log.Fatal(wtfd.Server())

Types

type Challenge

type Challenge struct {
	Name        string `json:"name"`
	Description string `json:"desc"`
	Flag        string `json:"flag"`
	Points      int    `json:"points"`
	URI         string `json:"uri"`
	DepCount    int
	MinRow      int
	Row         int
	Solution    string `json:"solution"`
	Author      string `json:"author"`
	DepIDs      []string
	Deps        []*Challenge
	HasURI      bool // This emerges from URI != ""
}

Challenge is a challenge obv

func (Challenge) AllDepsCompleted

func (c Challenge) AllDepsCompleted(u User) bool

AllDepsCompleted checks if User u has completed all Dependent challenges of c

type ChallengeJSON

type ChallengeJSON struct {
	Name        string   `json:"name"`
	Description string   `json:"desc"`
	Solution    string   `json:"solution"`
	Author      string   `json:"author"`
	Flag        string   `json:"flag"`
	Points      int      `json:"points"`
	URI         string   `json:"uri"`
	Deps        []string `json:"deps"`
	HasURI      bool     // This emerges from URI != ""
}

ChallengeJSON is Challenge as JSON

type Challenges

type Challenges []*Challenge

Challenges Array of challenges but in nice with funcitons

func (Challenges) FillChallengeURI

func (c Challenges) FillChallengeURI(host string)

FillChallengeURI Fill host into each challenge's URI field and set HasURI

func (Challenges) Find

func (c Challenges) Find(id string) (*Challenge, error)

Find finds a challenge from a string

type Config

type Config struct {
	Port             int64  `json:port`
	Key              string `json:key`
	ChallengeInfoDir string `json:"challinfodir"`
	SSHHost          string `json:"sshhost"`
}

Config stores settings loaded from config.json

type User

type User struct {
	Name        string
	Hash        []byte
	DisplayName string
	Completed   []*Challenge
	Points      int
}

User, was ist das wohl

func Get

func Get(username string) (User, error)

Get gets username based on username

func NewUser

func NewUser(name, password, displayname string) (User, error)

NewUser creates a new user object

func (*User) CalculatePoints

func (u *User) CalculatePoints()

CalculatePoints calculates Points and updates user.Points

func (*User) ComparePassword

func (u *User) ComparePassword(password string) bool

ComparePassword checks if the password is valid

func (User) HasSolvedChallenge

func (u User) HasSolvedChallenge(chall *Challenge) bool

HasSolvedChallenge returns true if u has solved chall

Jump to

Keyboard shortcuts

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