2019-08-01 18:16:27 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"code.hackerspace.pl/hscloud/bgpwtf/cccampix/verifier/model"
|
|
|
|
"github.com/sethvargo/go-password/password"
|
|
|
|
)
|
|
|
|
|
|
|
|
type secretGen struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func newSecretGen() (processor, error) {
|
|
|
|
return &secretGen{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *secretGen) Name() string {
|
|
|
|
return "SecretGen"
|
|
|
|
}
|
|
|
|
|
2019-08-22 16:13:13 +00:00
|
|
|
func (p *secretGen) NextRun(now time.Time, lastFailed bool) time.Time {
|
2019-08-01 18:16:27 +00:00
|
|
|
return now.Add(1 * time.Minute)
|
|
|
|
}
|
|
|
|
|
|
|
|
func gen() model.SessionConfig {
|
|
|
|
secret := password.MustGenerate(16, 4, 0, false, true)
|
|
|
|
return model.SessionConfig{
|
|
|
|
BGPSecret: secret,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *secretGen) RunAll(ctx context.Context, m model.Model) error {
|
|
|
|
return m.ConfigureMissingSessions(ctx, gen)
|
|
|
|
}
|