ClashApi.h 767 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <cpr/cpr.h>
  3. struct Response
  4. {
  5. uint32_t statusCode;
  6. std::string data;
  7. };
  8. using u16milliseconds = std::chrono::duration<uint16_t, std::milli>;
  9. class ClashApi
  10. {
  11. public:
  12. ClashApi();
  13. ~ClashApi();
  14. void SetProt(int port);
  15. std::string GetVersion();
  16. ClashConfig GetConfig();
  17. bool RequestConfigUpdate(std::filesystem::path configPath);
  18. bool UpdateProxyMode(ClashProxyMode mode);
  19. bool UpdateLogLevel(ClashLogLevel level);
  20. bool UpdateAllowLan(bool allow);
  21. //L"http://cp.cloudflare.com/generate_204"
  22. u16milliseconds GetProxyDelay(std::string_view proxyName);
  23. ClashProxies GetProxies();
  24. //Proxy
  25. bool UpdateProxyGroup(std::string_view group , std::string_view selectProxy);
  26. private:
  27. int m_port;
  28. std::string m_api_base_url;
  29. };