You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

9 years ago
9 years ago
  1. package p2p
  2. import (
  3. "github.com/spf13/viper"
  4. )
  5. const (
  6. // Switch config keys
  7. configKeyDialTimeoutSeconds = "dial_timeout_seconds"
  8. configKeyHandshakeTimeoutSeconds = "handshake_timeout_seconds"
  9. configKeyMaxNumPeers = "max_num_peers"
  10. configKeyAuthEnc = "authenticated_encryption"
  11. // MConnection config keys
  12. configKeySendRate = "send_rate"
  13. configKeyRecvRate = "recv_rate"
  14. // Fuzz params
  15. configFuzzEnable = "fuzz_enable" // use the fuzz wrapped conn
  16. configFuzzMode = "fuzz_mode" // eg. drop, delay
  17. configFuzzMaxDelayMilliseconds = "fuzz_max_delay_milliseconds"
  18. configFuzzProbDropRW = "fuzz_prob_drop_rw"
  19. configFuzzProbDropConn = "fuzz_prob_drop_conn"
  20. configFuzzProbSleep = "fuzz_prob_sleep"
  21. )
  22. func setConfigDefaults(config *viper.Viper) {
  23. // Switch default config
  24. config.SetDefault(configKeyDialTimeoutSeconds, 3)
  25. config.SetDefault(configKeyHandshakeTimeoutSeconds, 20)
  26. config.SetDefault(configKeyMaxNumPeers, 50)
  27. config.SetDefault(configKeyAuthEnc, true)
  28. // MConnection default config
  29. config.SetDefault(configKeySendRate, 512000) // 500KB/s
  30. config.SetDefault(configKeyRecvRate, 512000) // 500KB/s
  31. // Fuzz defaults
  32. config.SetDefault(configFuzzEnable, false)
  33. config.SetDefault(configFuzzMode, FuzzModeDrop)
  34. config.SetDefault(configFuzzMaxDelayMilliseconds, 3000)
  35. config.SetDefault(configFuzzProbDropRW, 0.2)
  36. config.SetDefault(configFuzzProbDropConn, 0.00)
  37. config.SetDefault(configFuzzProbSleep, 0.00)
  38. }