From aa9d6793abf64d0762904b043243222a6db03c4b Mon Sep 17 00:00:00 2001 From: maride Date: Sun, 6 Oct 2019 16:02:47 +0200 Subject: Add non-protected handler for statistics, /api/getStats --- src/challenge.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/challenge.go') diff --git a/src/challenge.go b/src/challenge.go index 0203378..1d0a210 100644 --- a/src/challenge.go +++ b/src/challenge.go @@ -23,6 +23,12 @@ type StrippedChallenge struct { IPAddress string `json:"IPAddress"` } +type StatsStrippedChallenge struct { + Name string `json:"name"` + FoundFlag int64 `json:"foundFlag"` + FlagTries uint `json:"flagTries"` +} + func stripChallenge(c Challenge) (StrippedChallenge) { return StrippedChallenge{ Name: c.Name, @@ -34,3 +40,11 @@ func stripChallenge(c Challenge) (StrippedChallenge) { IPAddress: getAddressForChallengeContainer(c.Container), } } + +func stripChallengeForStatistics(c Challenge) (StatsStrippedChallenge) { + return StatsStrippedChallenge{ + Name: c.Name, + FoundFlag: c.FoundFlag.Unix(), + FlagTries: c.FlagTries, + } +} -- cgit 1.4.1