about summary refs log tree commit diff
path: root/src/challenge.go
blob: 0203378eba4e2a72ee410a3b9cb3cef6f821b4be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main

import "time"

type Challenge struct {
	Name string
	Description string
	Flag string // this should never leave the server
	FoundFlag time.Time
	FlagTries uint
	Container string // this could, but is not required as well
	Category string
}

// TODO: The name "Stripped" is a bit inaccurate now. Rename.
type StrippedChallenge struct {
	Name string `json:"name"`
	Description string `json:"description"`
	Category string `json:"category"`
	FoundFlag int64 `json:"foundFlag"`
	FlagTries uint `json:"flagTries"`
	ContainsLaunchable bool `json:"ContainsLaunchable"`
	IPAddress string `json:"IPAddress"`
}

func stripChallenge(c Challenge) (StrippedChallenge) {
	return StrippedChallenge{
		Name: c.Name,
		Description: c.Description,
		Category: c.Category,
		FoundFlag: c.FoundFlag.Unix(),
		FlagTries: c.FlagTries,
		ContainsLaunchable: c.Container != "",
		IPAddress: getAddressForChallengeContainer(c.Container),
	}
}