diff options
Diffstat (limited to 'config/game.go')
-rw-r--r-- | config/game.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/config/game.go b/config/game.go index 0eea917..5520659 100644 --- a/config/game.go +++ b/config/game.go @@ -1,5 +1,12 @@ package config +import ( + "errors" + "regexp" +) + +var reValidGameName = regexp.MustCompile(`^[\w\._]+$`) + // Game struct containers the configuration for a game type Game struct { // ChrootPath is the chroot path for the game @@ -8,4 +15,21 @@ type Game struct { FileMode string `yaml:"FileMode"` // Commands is the command list Commands []string `yaml:"Commands"` + // ScoreFile is relative to the chroot path for the game + ScoreCommands []string `yaml:"ScoreCommands"` + // Env is the environment in which to exec the commands + Env map[string]string `yaml:"Env"` +} + +func (a *Game) validate(name string) error { + // Game name + if ok := reValidGameName.MatchString(name); !ok { + return errors.New("Invalid Game name, must match regex `^[\\w\\._]+$` : " + name) + } + // ChrootPath TODO + // FileMode + // Commands + // ScoreFile + // Env + return nil } |