1234567891011121314151617181920212223242526272829303132333435 |
- #pragma once
- #include <cpr/cpr.h>
- struct Response
- {
- uint32_t statusCode;
- std::string data;
- };
- using u16milliseconds = std::chrono::duration<uint16_t, std::milli>;
- class ClashApi
- {
- public:
- ClashApi();
- ~ClashApi();
- void SetProt(int port);
- std::string GetVersion();
- ClashConfig GetConfig();
- std::optional<std::wstring> RequestConfigUpdate(std::filesystem::path configPath);
- bool UpdateProxyMode(ClashProxyMode mode);
- bool UpdateLogLevel(ClashLogLevel level);
- bool UpdateAllowLan(bool allow);
- //L"http://cp.cloudflare.com/generate_204"
- u16milliseconds GetProxyDelay(std::string_view proxyName);
- ClashProxies GetProxies();
- bool UpdateProxyGroup(std::string_view group, std::string_view selectProxy);
- private:
- cpr::Session m_cpr_session;
- int m_port;
- std::string m_api_base_url;
- };
|