config.go 544 B

123456789101112131415161718192021222324252627282930
  1. package client
  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. PSKIdentity string
  14. MTU int
  15. }
  16. func (cfg *Config) populateDefaults() *Config {
  17. newCfg := new(Config)
  18. *newCfg = *cfg
  19. cfg = newCfg
  20. if cfg.BaseContext == nil {
  21. cfg.BaseContext = context.Background()
  22. }
  23. if cfg.IdleTimeout == 0 {
  24. cfg.IdleTimeout = 90 * time.Second
  25. }
  26. return cfg
  27. }