punchy.go 553 B

123456789101112131415161718192021222324252627282930
  1. package nebula
  2. import "time"
  3. type Punchy struct {
  4. Punch bool
  5. Respond bool
  6. Delay time.Duration
  7. }
  8. func NewPunchyFromConfig(c *Config) *Punchy {
  9. p := &Punchy{}
  10. if c.IsSet("punchy.punch") {
  11. p.Punch = c.GetBool("punchy.punch", false)
  12. } else {
  13. // Deprecated fallback
  14. p.Punch = c.GetBool("punchy", false)
  15. }
  16. if c.IsSet("punchy.respond") {
  17. p.Respond = c.GetBool("punchy.respond", false)
  18. } else {
  19. // Deprecated fallback
  20. p.Respond = c.GetBool("punch_back", false)
  21. }
  22. p.Delay = c.GetDuration("punchy.delay", time.Second)
  23. return p
  24. }