mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
* refactor: migrate from grpc to protorpc * fix * fix * fix * cleanup * Update mainwindow_grpc.cpp * Update RPC.cpp * fix --------- Co-authored-by: parhelia512 <0011d3@gmail.com>
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#ifndef Q_MOC_RUN
|
|
#include "libcore.pb.h"
|
|
#endif
|
|
#include <QString>
|
|
#include "3rdparty/protorpc/rpc_client.h"
|
|
|
|
namespace API {
|
|
enum GeoRuleSetType {ip, site};
|
|
|
|
class Client {
|
|
public:
|
|
explicit Client(std::function<void(const QString &)> onError, const QString &host, int port);
|
|
|
|
// QString returns is error string
|
|
|
|
QString Start(bool *rpcOK, const libcore::LoadConfigReq &request);
|
|
|
|
QString Stop(bool *rpcOK);
|
|
|
|
libcore::QueryStatsResp QueryStats();
|
|
|
|
libcore::TestResp Test(bool *rpcOK, const libcore::TestReq &request);
|
|
|
|
void StopTests(bool *rpcOK);
|
|
|
|
libcore::QueryURLTestResponse QueryURLTest(bool *rpcOK);
|
|
|
|
QStringList GetGeoList(bool *rpcOK, GeoRuleSetType mode, const QString& basePath);
|
|
|
|
QString CompileGeoSet(bool *rpcOK, GeoRuleSetType mode, std::string category, const QString& basePath);
|
|
|
|
QString SetSystemDNS(bool *rpcOK, bool clear) const;
|
|
|
|
libcore::ListConnectionsResp ListConnections(bool *rpcOK) const;
|
|
|
|
QString CheckConfig(bool *rpcOK, const QString& config) const;
|
|
|
|
bool IsPrivileged(bool *rpcOK) const;
|
|
|
|
libcore::SpeedTestResponse SpeedTest(bool *rpcOK, const libcore::SpeedTestRequest &request);
|
|
|
|
libcore::QuerySpeedTestResponse QueryCurrentSpeedTests(bool *rpcOK);
|
|
|
|
private:
|
|
std::function<std::unique_ptr<protorpc::Client>()> make_rpc_client;
|
|
std::function<void(const QString &)> onError;
|
|
};
|
|
|
|
inline Client *defaultClient;
|
|
} // namespace API
|