blob: cefa1ccc8fac6a109963b4b175e7cddcbd5ddb4d [file] [log] [blame]
Sergiusz Bazanski1fad2e52019-08-01 20:16:27 +02001package main
2
3import (
4 "context"
5 "time"
6
7 "code.hackerspace.pl/hscloud/bgpwtf/cccampix/verifier/model"
8 "github.com/sethvargo/go-password/password"
9)
10
11type secretGen struct {
12}
13
14func newSecretGen() (processor, error) {
15 return &secretGen{}, nil
16}
17
18func (p *secretGen) Name() string {
19 return "SecretGen"
20}
21
22func (p *secretGen) NextRun(now time.Time) time.Time {
23 return now.Add(1 * time.Minute)
24}
25
26func gen() model.SessionConfig {
27 secret := password.MustGenerate(16, 4, 0, false, true)
28 return model.SessionConfig{
29 BGPSecret: secret,
30 }
31}
32
33func (p *secretGen) RunAll(ctx context.Context, m model.Model) error {
34 return m.ConfigureMissingSessions(ctx, gen)
35}