config.hpp 637 B

12345678910111213141516171819202122232425262728293031
  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. extern Config g_config;
  24. bool config_parse(const std::string configstr, const std::string &myname);
  25. #endif