mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
bug fix
This commit is contained in:
@@ -16,7 +16,6 @@ if (WIN32)
|
||||
endif ()
|
||||
|
||||
# Find Qt
|
||||
|
||||
if (NOT QT_VERSION_MAJOR)
|
||||
set(QT_VERSION_MAJOR 5)
|
||||
endif ()
|
||||
@@ -30,15 +29,11 @@ if (NKR_CROSS)
|
||||
set_property(TARGET Qt5::lupdate PROPERTY IMPORTED_LOCATION /usr/bin/lupdate)
|
||||
endif ()
|
||||
|
||||
if (NKR_PACKAGE OR NKR_PACKAGE_MACOS)
|
||||
message("[add_compile_definitions] NKR_CPP_USE_APPDATA")
|
||||
add_compile_definitions(NKR_CPP_USE_APPDATA)
|
||||
endif ()
|
||||
|
||||
# Windows
|
||||
include("cmake/fuck_windows/fuck.cmake")
|
||||
|
||||
# default prefix path
|
||||
#### default prefix path ####
|
||||
|
||||
if (NKR_PACKAGE)
|
||||
list(APPEND NKR_LIBS ${CMAKE_SOURCE_DIR}/libs/deps/package)
|
||||
else ()
|
||||
@@ -56,39 +51,63 @@ message("[CMAKE_PREFIX_PATH] ${CMAKE_PREFIX_PATH}")
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
|
||||
message("[CMAKE_FIND_ROOT_PATH] ${CMAKE_FIND_ROOT_PATH}")
|
||||
|
||||
# NKR
|
||||
#### NKR ####
|
||||
|
||||
include("cmake/print.cmake")
|
||||
include("cmake/nkr.cmake")
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
if (NKR_NO_EXTERNAL)
|
||||
add_compile_definitions(NKR_NO_EXTERNAL)
|
||||
else ()
|
||||
if (NKR_NO_GRPC)
|
||||
add_compile_definitions(NKR_NO_GRPC)
|
||||
else ()
|
||||
# My proto
|
||||
include("cmake/myproto.cmake")
|
||||
list(APPEND NKR_EXTERNAL_TARGETS myproto)
|
||||
endif ()
|
||||
if (NKR_PACKAGE OR NKR_PACKAGE_MACOS)
|
||||
nkr_add_compile_definitions(NKR_CPP_USE_APPDATA)
|
||||
endif ()
|
||||
|
||||
# yaml-cpp (static)
|
||||
#### NKR EXTERNAL ####
|
||||
|
||||
if (NKR_NO_EXTERNAL)
|
||||
set(NKR_NO_GRPC 1)
|
||||
set(NKR_NO_YAML 1)
|
||||
set(NKR_NO_ZXING 1)
|
||||
set(NKR_NO_QHOTKEY 1)
|
||||
endif ()
|
||||
|
||||
# grpc
|
||||
if (NKR_NO_GRPC)
|
||||
nkr_add_compile_definitions(NKR_NO_GRPC)
|
||||
else ()
|
||||
# My proto
|
||||
include("cmake/myproto.cmake")
|
||||
list(APPEND NKR_EXTERNAL_TARGETS myproto)
|
||||
endif ()
|
||||
|
||||
# yaml-cpp
|
||||
if (NKR_NO_YAML)
|
||||
nkr_add_compile_definitions(NKR_NO_YAML)
|
||||
else ()
|
||||
find_package(yaml-cpp CONFIG REQUIRED) # only Release is built
|
||||
list(APPEND NKR_EXTERNAL_TARGETS yaml-cpp)
|
||||
endif ()
|
||||
|
||||
# zxing-cpp
|
||||
# zxing-cpp
|
||||
if (NKR_NO_ZXING)
|
||||
nkr_add_compile_definitions(NKR_NO_ZXING)
|
||||
else ()
|
||||
find_package(ZXing CONFIG REQUIRED)
|
||||
list(APPEND NKR_EXTERNAL_TARGETS ZXing::ZXing)
|
||||
endif ()
|
||||
|
||||
# QHotkey (static submodule)
|
||||
# QHotkey (static submodule)
|
||||
if (NKR_NO_QHOTKEY)
|
||||
nkr_add_compile_definitions(NKR_NO_QHOTKEY)
|
||||
else ()
|
||||
set(QHOTKEY_INSTALL OFF)
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory(3rdparty/QHotkey)
|
||||
list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
|
||||
endif ()
|
||||
|
||||
# debug print
|
||||
#### debug print ####
|
||||
|
||||
if (DBG_CMAKE)
|
||||
print_all_variables()
|
||||
print_target_properties(myproto)
|
||||
|
||||
@@ -4,3 +4,9 @@ add_compile_definitions(NKR_VERSION=\"${NKR_VERSION}\")
|
||||
|
||||
# Debug
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DNKR_CPP_DEBUG")
|
||||
|
||||
# Func
|
||||
function(nkr_add_compile_definitions arg)
|
||||
message("[add_compile_definitions] ${ARGV}")
|
||||
add_compile_definitions(${ARGV})
|
||||
endfunction()
|
||||
|
||||
@@ -33,10 +33,11 @@ ninja
|
||||
| CMake 参数 | 默认值 | 含义 |
|
||||
|------------------|-----|-------------------------|
|
||||
| QT_VERSION_MAJOR | 5 | QT版本 |
|
||||
| NKR_NO_EXTERNAL | | 不包含外部C++依赖(如ZXing/gRPC) |
|
||||
| NKR_NO_EXTERNAL | | 不包含外部C++依赖(以下所有) |
|
||||
| NKR_NO_YAML | | 不包含yaml-cpp |
|
||||
| NKR_NO_QHOTKEY | | 不包含qhotkey |
|
||||
| NKR_NO_ZXING | | 不包含zxing |
|
||||
| NKR_NO_GRPC | | 不包含gRPC |
|
||||
| NKR_CROSS | | |
|
||||
| NKR_PACKAGE | | 打包 |
|
||||
|
||||
#### C++ 部分
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ git clone https://github.com/MatsuriDayo/nekoray.git --recursive
|
||||
|
||||
### 下载 Qt SDK
|
||||
|
||||
目前使用的版本是 Qt 5.15.2 其他版本未测试
|
||||
目前使用的版本是 Qt 5.15.7 其他版本未测试
|
||||
|
||||
在此下载 `qtbase` `qtsvg` `qttools` 的包并解压到同一个目录。
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"neko/pkg/speedtest"
|
||||
"nekobox_core/box_main"
|
||||
"reflect"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
box "github.com/sagernet/sing-box"
|
||||
@@ -38,6 +39,16 @@ func (s *server) Start(ctx context.Context, in *gen.LoadConfigReq) (out *gen.Err
|
||||
log.Println("Start:", in.CoreConfig)
|
||||
}
|
||||
|
||||
if neko_common.GetBuildTime() > 0 {
|
||||
if time.Now().Unix() >= neko_common.GetExpireTime() {
|
||||
err = errors.New("Your version is too old! Please update!! 版本太旧,请升级!")
|
||||
return
|
||||
} else if time.Now().Unix() >= (neko_common.GetExpireTime() - 30*24*60*60) {
|
||||
log.Println("Your version is too old! Please update!! 版本太旧,请升级!")
|
||||
log.Println("This version expires on " + time.Unix(neko_common.GetExpireTime(), 0).Format("2006-01-02"))
|
||||
}
|
||||
}
|
||||
|
||||
if instance != nil {
|
||||
err = errors.New("instance already started")
|
||||
return
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"libcore"
|
||||
"libcore/stun"
|
||||
"log"
|
||||
"neko/gen"
|
||||
"neko/pkg/grpc_server"
|
||||
"neko/pkg/neko_common"
|
||||
@@ -38,6 +39,16 @@ func (s *server) Start(ctx context.Context, in *gen.LoadConfigReq) (out *gen.Err
|
||||
logrus.Println("Start:", in.CoreConfig, in.TryDomains)
|
||||
}
|
||||
|
||||
if neko_common.GetBuildTime() > 0 {
|
||||
if time.Now().Unix() >= neko_common.GetExpireTime() {
|
||||
err = errors.New("Your version is too old! Please update!! 版本太旧,请升级!")
|
||||
return
|
||||
} else if time.Now().Unix() >= (neko_common.GetExpireTime() - 30*24*60*60) {
|
||||
log.Println("Your version is too old! Please update!! 版本太旧,请升级!")
|
||||
log.Println("This version expires on " + time.Unix(neko_common.GetExpireTime(), 0).Format("2006-01-02"))
|
||||
}
|
||||
}
|
||||
|
||||
if instance != nil {
|
||||
err = errors.New("instance already started")
|
||||
return
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package neko_common
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Version_v2ray string = "N/A"
|
||||
var Version_neko string = "N/A"
|
||||
@@ -16,3 +20,19 @@ const (
|
||||
)
|
||||
|
||||
var GetProxyHttpClient func() *http.Client
|
||||
|
||||
func GetBuildTime() int64 {
|
||||
if !strings.HasPrefix(Version_neko, "nekoray-") {
|
||||
return 0
|
||||
}
|
||||
ver := strings.TrimLeft(Version_neko, "nekoray-")
|
||||
buildDate := ver[strings.Index(ver, "-")+1:]
|
||||
buildTime, _ := time.Parse("2006-01-02", buildDate)
|
||||
return buildTime.Unix()
|
||||
}
|
||||
|
||||
func GetExpireTime() int64 {
|
||||
buildTime := time.Unix(GetBuildTime(), 0)
|
||||
expireTime := buildTime.AddDate(0, 6, 0) // current force update: 6 months
|
||||
return expireTime.Unix()
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef NKR_NO_EXTERNAL
|
||||
#define NKR_NO_GRPC
|
||||
#endif
|
||||
|
||||
#ifndef NKR_NO_GRPC
|
||||
|
||||
#include "go/gen/libcore.pb.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QInputDialog>
|
||||
#include <QUrlQuery>
|
||||
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_YAML
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace NekoRay::sub {
|
||||
update_counter++;
|
||||
}
|
||||
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_YAML
|
||||
|
||||
QString Node2QString(const YAML::Node &n, const QString &def = "") {
|
||||
try {
|
||||
@@ -203,7 +203,7 @@ namespace NekoRay::sub {
|
||||
|
||||
// https://github.com/Dreamacro/clash/wiki/configuration
|
||||
void RawUpdater::updateClash(const QString &str) {
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_YAML
|
||||
try {
|
||||
auto proxies = YAML::Load(str.toStdString())["proxies"];
|
||||
for (auto proxy: proxies) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "qv2ray/v2/components/proxy/QvProxyConfigurator.hpp"
|
||||
#include "qv2ray/v2/ui/LogHighlighter.hpp"
|
||||
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_ZXING
|
||||
#include "3rdparty/ZxingQtReader.hpp"
|
||||
#endif
|
||||
|
||||
@@ -766,6 +766,7 @@ void MainWindow::refresh_proxy_list_impl(const int &id, NekoRay::GroupSortAction
|
||||
case NekoRay::GroupSortMethod::ById: {
|
||||
// Clear Order
|
||||
ui->proxyListTable->order.clear();
|
||||
ui->proxyListTable->callback_save_order();
|
||||
break;
|
||||
}
|
||||
case NekoRay::GroupSortMethod::ByAddress:
|
||||
@@ -1101,7 +1102,7 @@ void MainWindow::display_qr_link(bool nkrFormat) {
|
||||
}
|
||||
|
||||
void MainWindow::on_menu_scan_qr_triggered() {
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_ZXING
|
||||
using namespace ZXingQt;
|
||||
|
||||
hide();
|
||||
@@ -1387,7 +1388,7 @@ void MainWindow::refresh_connection_list(const QJsonArray &arr) {
|
||||
|
||||
// Hotkey
|
||||
|
||||
#ifndef NKR_NO_EXTERNAL
|
||||
#ifndef NKR_NO_QHOTKEY
|
||||
|
||||
#include <QHotkey>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user