1
0
Fork 0
hscloud/bgpwtf/cccampix/verifier/processor_secretgen.go

36 lines
680 B
Go
Raw Normal View History

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"
}
func (p *secretGen) NextRun(now time.Time, lastFailed bool) time.Time {
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)
}