mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
code fix
This commit is contained in:
@@ -3,4 +3,4 @@ file(STRINGS nekoray_version.txt NKR_VERSION)
|
|||||||
add_compile_definitions(NKR_VERSION=\"${NKR_VERSION}\")
|
add_compile_definitions(NKR_VERSION=\"${NKR_VERSION}\")
|
||||||
|
|
||||||
# Debug
|
# Debug
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DNKR_DEBUG")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DNKR_CPP_DEBUG")
|
||||||
|
|||||||
@@ -11,15 +11,16 @@ namespace NekoRay::traffic {
|
|||||||
|
|
||||||
std::unique_ptr<TrafficData> TrafficLooper::update_stats(TrafficData *item) {
|
std::unique_ptr<TrafficData> TrafficLooper::update_stats(TrafficData *item) {
|
||||||
#ifndef NKR_NO_GRPC
|
#ifndef NKR_NO_GRPC
|
||||||
|
auto interval = dataStore->traffic_loop_interval;
|
||||||
|
if (interval == 0) return nullptr;
|
||||||
auto uplink = NekoRay::rpc::defaultClient->QueryStats(item->tag, "uplink");
|
auto uplink = NekoRay::rpc::defaultClient->QueryStats(item->tag, "uplink");
|
||||||
auto downlink = NekoRay::rpc::defaultClient->QueryStats(item->tag, "downlink");
|
auto downlink = NekoRay::rpc::defaultClient->QueryStats(item->tag, "downlink");
|
||||||
|
|
||||||
|
// add diff
|
||||||
item->downlink += downlink;
|
item->downlink += downlink;
|
||||||
item->uplink += uplink;
|
item->uplink += uplink;
|
||||||
|
item->downlink_rate = downlink * 1000 / interval;
|
||||||
//?
|
item->uplink_rate = uplink * 1000 / interval;
|
||||||
item->downlink_rate = downlink * 1000 / dataStore->traffic_loop_interval;
|
|
||||||
item->uplink_rate = uplink * 1000 / dataStore->traffic_loop_interval;
|
|
||||||
|
|
||||||
// return diff
|
// return diff
|
||||||
auto ret = std::make_unique<TrafficData>(item->tag);
|
auto ret = std::make_unique<TrafficData>(item->tag);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#include "db/ProxyEntity.hpp"
|
#include "db/ProxyEntity.hpp"
|
||||||
#include "fmt/includes.h"
|
#include "fmt/includes.h"
|
||||||
#include "NaiveBean.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
// Dialogs
|
// Dialogs
|
||||||
|
|
||||||
#define Dialog_DialogBasicSettings "DialogBasicSettings"
|
#define Dialog_DialogBasicSettings "DialogBasicSettings"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ namespace NekoRay {
|
|||||||
bool flag_use_appdata = false;
|
bool flag_use_appdata = false;
|
||||||
bool flag_many = false;
|
bool flag_many = false;
|
||||||
bool flag_tray = false;
|
bool flag_tray = false;
|
||||||
|
bool flag_debug = false;
|
||||||
|
|
||||||
// Saved
|
// Saved
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ int main(int argc, char *argv[]) {
|
|||||||
QDir::setCurrent(QApplication::applicationDirPath());
|
QDir::setCurrent(QApplication::applicationDirPath());
|
||||||
if (QFile::exists("updater.old")) {
|
if (QFile::exists("updater.old")) {
|
||||||
QFile::remove("updater.old");
|
QFile::remove("updater.old");
|
||||||
QFile::remove("sing-box.exe"); // v1.11
|
|
||||||
}
|
}
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (!QFile::exists("updater")) {
|
if (!QFile::exists("updater")) {
|
||||||
@@ -52,9 +51,13 @@ int main(int argc, char *argv[]) {
|
|||||||
if (args.contains("-many")) NekoRay::dataStore->flag_many = true;
|
if (args.contains("-many")) NekoRay::dataStore->flag_many = true;
|
||||||
if (args.contains("-appdata")) NekoRay::dataStore->flag_use_appdata = true;
|
if (args.contains("-appdata")) NekoRay::dataStore->flag_use_appdata = true;
|
||||||
if (args.contains("-tray")) NekoRay::dataStore->flag_tray = true;
|
if (args.contains("-tray")) NekoRay::dataStore->flag_tray = true;
|
||||||
|
if (args.contains("-debug")) NekoRay::dataStore->flag_debug = true;
|
||||||
#ifdef NKR_CPP_USE_APPDATA
|
#ifdef NKR_CPP_USE_APPDATA
|
||||||
NekoRay::dataStore->flag_use_appdata = true;
|
NekoRay::dataStore->flag_use_appdata = true;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef NKR_CPP_DEBUG
|
||||||
|
NekoRay::dataStore->flag_debug = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
// dirs & clean
|
// dirs & clean
|
||||||
auto wd = QDir(QApplication::applicationDirPath());
|
auto wd = QDir(QApplication::applicationDirPath());
|
||||||
@@ -95,13 +98,13 @@ int main(int argc, char *argv[]) {
|
|||||||
QDir dir;
|
QDir dir;
|
||||||
bool dir_success = true;
|
bool dir_success = true;
|
||||||
if (!dir.exists("profiles")) {
|
if (!dir.exists("profiles")) {
|
||||||
dir_success = dir_success && dir.mkdir("profiles");
|
dir_success &= dir.mkdir("profiles");
|
||||||
}
|
}
|
||||||
if (!dir.exists("groups")) {
|
if (!dir.exists("groups")) {
|
||||||
dir_success = dir_success && dir.mkdir("groups");
|
dir_success &= dir.mkdir("groups");
|
||||||
}
|
}
|
||||||
if (!dir.exists(ROUTES_PREFIX_NAME)) {
|
if (!dir.exists(ROUTES_PREFIX_NAME)) {
|
||||||
dir_success = dir_success && dir.mkdir(ROUTES_PREFIX_NAME);
|
dir_success &= dir.mkdir(ROUTES_PREFIX_NAME);
|
||||||
}
|
}
|
||||||
if (!dir_success) {
|
if (!dir_success) {
|
||||||
QMessageBox::warning(nullptr, "Error", "No permission to write " + dir.absolutePath());
|
QMessageBox::warning(nullptr, "Error", "No permission to write " + dir.absolutePath());
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "ThemeManager.hpp"
|
#include <QStyle>
|
||||||
|
#include <QApplication>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
|
|
||||||
|
#include "ThemeManager.hpp"
|
||||||
|
|
||||||
ThemeManager *themeManager = new ThemeManager;
|
ThemeManager *themeManager = new ThemeManager;
|
||||||
|
|
||||||
extern QString ReadFileText(const QString &path);
|
extern QString ReadFileText(const QString &path);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QStyle>
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
class ThemeManager {
|
class ThemeManager {
|
||||||
public:
|
public:
|
||||||
QString system_style_name = "";
|
QString system_style_name = "";
|
||||||
|
|||||||
@@ -385,9 +385,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
args.push_back(IS_NEKO_BOX ? "nekobox" : "nekoray");
|
args.push_back(IS_NEKO_BOX ? "nekobox" : "nekoray");
|
||||||
args.push_back("-port");
|
args.push_back("-port");
|
||||||
args.push_back(Int2String(NekoRay::dataStore->core_port));
|
args.push_back(Int2String(NekoRay::dataStore->core_port));
|
||||||
#ifdef NKR_DEBUG
|
if (NekoRay::dataStore->flag_debug) args.push_back("-debug");
|
||||||
args.push_back("-debug");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Start core
|
// Start core
|
||||||
core_process = new NekoRay::sys::CoreProcess(core_path, args);
|
core_process = new NekoRay::sys::CoreProcess(core_path, args);
|
||||||
|
|||||||
Reference in New Issue
Block a user