mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-18 20:50:09 +08:00
wait for the core to start &&
add some logs
This commit is contained in:
parent
019e1cb5ba
commit
9c6e0d6f03
2
3rdparty/protorpc/rpc_client.cc
vendored
2
3rdparty/protorpc/rpc_client.cc
vendored
@ -43,7 +43,7 @@ const ::protorpc::Error Client::callMethod(
|
|||||||
if(!conn_.IsValid()) {
|
if(!conn_.IsValid()) {
|
||||||
if(!conn_.DialTCP(host_.c_str(), port_)) {
|
if(!conn_.DialTCP(host_.c_str(), port_)) {
|
||||||
return ::protorpc::Error::New(
|
return ::protorpc::Error::New(
|
||||||
std::string("protorpc.Client.callMethod: DialTCP fail, ") +
|
std::string("protorpc.Client.callMethod: DialTCP fail, method ") + method + " ," +
|
||||||
std::string("host: ") + host_ + std::string(":") + std::to_string(static_cast<long long>(port_))
|
std::string("host: ") + host_ + std::string(":") + std::to_string(static_cast<long long>(port_))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,11 +9,15 @@ namespace API {
|
|||||||
this->onError = std::move(onError);
|
this->onError = std::move(onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECK(method) \
|
||||||
|
if (!Configs::dataStore->core_running) MW_show_log("Cannot invoke method" + QString(method) + ", core is not running");
|
||||||
|
|
||||||
#define NOT_OK \
|
#define NOT_OK \
|
||||||
*rpcOK = false; \
|
*rpcOK = false; \
|
||||||
onError(QString("LibcoreService error: %1\n").arg(QString::fromStdString(err.String())));
|
onError(QString("LibcoreService error: %1\n").arg(QString::fromStdString(err.String())));
|
||||||
|
|
||||||
QString Client::Start(bool *rpcOK, const libcore::LoadConfigReq &request) {
|
QString Client::Start(bool *rpcOK, const libcore::LoadConfigReq &request) {
|
||||||
|
CHECK("Start")
|
||||||
libcore::ErrorResp reply;
|
libcore::ErrorResp reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
auto err = make_rpc_client()->CallMethod("LibcoreService.Start", &req, &resp);
|
auto err = make_rpc_client()->CallMethod("LibcoreService.Start", &req, &resp);
|
||||||
@ -29,6 +33,7 @@ namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Client::Stop(bool *rpcOK) {
|
QString Client::Stop(bool *rpcOK) {
|
||||||
|
CHECK("Stop")
|
||||||
libcore::EmptyReq request;
|
libcore::EmptyReq request;
|
||||||
libcore::ErrorResp reply;
|
libcore::ErrorResp reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -45,6 +50,7 @@ namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libcore::QueryStatsResp Client::QueryStats() {
|
libcore::QueryStatsResp Client::QueryStats() {
|
||||||
|
CHECK("QueryStats")
|
||||||
libcore::EmptyReq request;
|
libcore::EmptyReq request;
|
||||||
libcore::QueryStatsResp reply;
|
libcore::QueryStatsResp reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -59,6 +65,7 @@ namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
libcore::TestResp Client::Test(bool *rpcOK, const libcore::TestReq &request) {
|
libcore::TestResp Client::Test(bool *rpcOK, const libcore::TestReq &request) {
|
||||||
|
CHECK("Test")
|
||||||
libcore::TestResp reply;
|
libcore::TestResp reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
auto err = make_rpc_client()->CallMethod("LibcoreService.Test", &req, &resp);
|
auto err = make_rpc_client()->CallMethod("LibcoreService.Test", &req, &resp);
|
||||||
@ -74,6 +81,7 @@ namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Client::StopTests(bool *rpcOK) {
|
void Client::StopTests(bool *rpcOK) {
|
||||||
|
CHECK("StopTests")
|
||||||
const libcore::EmptyReq request;
|
const libcore::EmptyReq request;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
auto err = make_rpc_client()->CallMethod("LibcoreService.StopTest", &req, &resp);
|
auto err = make_rpc_client()->CallMethod("LibcoreService.StopTest", &req, &resp);
|
||||||
@ -87,6 +95,7 @@ namespace API {
|
|||||||
|
|
||||||
libcore::QueryURLTestResponse Client::QueryURLTest(bool *rpcOK)
|
libcore::QueryURLTestResponse Client::QueryURLTest(bool *rpcOK)
|
||||||
{
|
{
|
||||||
|
CHECK("QueryURLTest")
|
||||||
libcore::EmptyReq request;
|
libcore::EmptyReq request;
|
||||||
libcore::QueryURLTestResponse reply;
|
libcore::QueryURLTestResponse reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -187,6 +196,7 @@ namespace API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Client::SetSystemDNS(bool *rpcOK, const bool clear) const {
|
QString Client::SetSystemDNS(bool *rpcOK, const bool clear) const {
|
||||||
|
CHECK("SetSystemDNS")
|
||||||
libcore::SetSystemDNSRequest request;
|
libcore::SetSystemDNSRequest request;
|
||||||
request.clear = clear;
|
request.clear = clear;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -203,6 +213,7 @@ namespace API {
|
|||||||
|
|
||||||
libcore::ListConnectionsResp Client::ListConnections(bool* rpcOK) const
|
libcore::ListConnectionsResp Client::ListConnections(bool* rpcOK) const
|
||||||
{
|
{
|
||||||
|
CHECK("ListConnections")
|
||||||
libcore::EmptyReq request;
|
libcore::EmptyReq request;
|
||||||
libcore::ListConnectionsResp reply;
|
libcore::ListConnectionsResp reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -220,6 +231,7 @@ namespace API {
|
|||||||
|
|
||||||
QString Client::CheckConfig(bool* rpcOK, const QString& config) const
|
QString Client::CheckConfig(bool* rpcOK, const QString& config) const
|
||||||
{
|
{
|
||||||
|
CHECK("CheckConfig")
|
||||||
libcore::LoadConfigReq request;
|
libcore::LoadConfigReq request;
|
||||||
libcore::ErrorResp reply;
|
libcore::ErrorResp reply;
|
||||||
request.core_config = config.toStdString();
|
request.core_config = config.toStdString();
|
||||||
@ -241,6 +253,7 @@ namespace API {
|
|||||||
|
|
||||||
bool Client::IsPrivileged(bool* rpcOK) const
|
bool Client::IsPrivileged(bool* rpcOK) const
|
||||||
{
|
{
|
||||||
|
CHECK("IsPrivileged")
|
||||||
libcore::EmptyReq request;
|
libcore::EmptyReq request;
|
||||||
libcore::IsPrivilegedResponse reply;
|
libcore::IsPrivilegedResponse reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
@ -260,6 +273,7 @@ namespace API {
|
|||||||
|
|
||||||
libcore::SpeedTestResponse Client::SpeedTest(bool *rpcOK, const libcore::SpeedTestRequest &request)
|
libcore::SpeedTestResponse Client::SpeedTest(bool *rpcOK, const libcore::SpeedTestRequest &request)
|
||||||
{
|
{
|
||||||
|
CHECK("SpeedTest")
|
||||||
libcore::SpeedTestResponse reply;
|
libcore::SpeedTestResponse reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
auto err = make_rpc_client()->CallMethod("LibcoreService.SpeedTest", &req, &resp);
|
auto err = make_rpc_client()->CallMethod("LibcoreService.SpeedTest", &req, &resp);
|
||||||
@ -276,6 +290,7 @@ namespace API {
|
|||||||
|
|
||||||
libcore::QuerySpeedTestResponse Client::QueryCurrentSpeedTests(bool *rpcOK)
|
libcore::QuerySpeedTestResponse Client::QueryCurrentSpeedTests(bool *rpcOK)
|
||||||
{
|
{
|
||||||
|
CHECK("QueryCurrentSpeedTests")
|
||||||
const libcore::EmptyReq request;
|
const libcore::EmptyReq request;
|
||||||
libcore::QuerySpeedTestResponse reply;
|
libcore::QuerySpeedTestResponse reply;
|
||||||
std::string resp, req = spb::pb::serialize<std::string>(request);
|
std::string resp, req = spb::pb::serialize<std::string>(request);
|
||||||
|
|||||||
@ -157,6 +157,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
},
|
},
|
||||||
DS_cores);
|
DS_cores);
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
for (int i=0;i<20;i++)
|
||||||
|
{
|
||||||
|
QThread::msleep(100);
|
||||||
|
if (Configs::dataStore->core_running) break;
|
||||||
|
}
|
||||||
|
if (!Configs::dataStore->core_running) qDebug() << "[Warn] Core is taking too much time to start";
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!Configs::dataStore->font.isEmpty()) {
|
if (!Configs::dataStore->font.isEmpty()) {
|
||||||
auto font = qApp->font();
|
auto font = qApp->font();
|
||||||
font.setFamily(Configs::dataStore->font);
|
font.setFamily(Configs::dataStore->font);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user