1
0

config.go 522 B

1234567891011121314151617181920212223242526272829
  1. package server
  2. import (
  3. "context"
  4. "time"
  5. )
  6. type Config struct {
  7. BindAddress string
  8. RemoteAddress string
  9. Timeout time.Duration
  10. IdleTimeout time.Duration
  11. BaseContext context.Context
  12. PSKCallback func([]byte) ([]byte, error)
  13. MTU int
  14. }
  15. func (cfg *Config) populateDefaults() *Config {
  16. newCfg := new(Config)
  17. *newCfg = *cfg
  18. cfg = newCfg
  19. if cfg.BaseContext == nil {
  20. cfg.BaseContext = context.Background()
  21. }
  22. if cfg.IdleTimeout == 0 {
  23. cfg.IdleTimeout = 90 * time.Second
  24. }
  25. return cfg
  26. }