config.hpp 632 B

123456789101112131415161718192021222324252627282930
  1. #ifndef __CONFIG_HPP__
  2. #define __CONFIG_HPP__
  3. #include <string>
  4. #include <vector>
  5. #include <cstdint>
  6. // The per-node config
  7. struct NodeConfig {
  8. std::string name;
  9. std::string pubkey; // a 128-character hex string
  10. std::string listenhost, listenport;
  11. std::string clistenhost, clistenport;
  12. uint8_t weight;
  13. };
  14. // The global config
  15. struct Config {
  16. // global params
  17. uint16_t msgsize;
  18. // config for each node
  19. std::vector<NodeConfig> nodes;
  20. // Which node is this one?
  21. size_t mynodenum;
  22. };
  23. bool config_parse(Config &config, const std::string configstr,
  24. const std::string &myname);
  25. #endif