diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml index 23d5ab8..fd737e7 100644 --- a/.github/workflows/build-qv2ray-cmake.yml +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checking out sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Go Status run: git ls-files go | xargs cat | sha1sum > go_status - name: Cache Common Download @@ -33,7 +33,7 @@ jobs: key: CommonCache-${{ matrix.cross_os }}-${{ matrix.cross_arch }}-${{ hashFiles('libs/*.sh', 'go_status') }} - name: Install Golang if: steps.cache-common.outputs.cache-hit != 'true' - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: stable: false go-version: 1.19.2 @@ -68,7 +68,7 @@ jobs: - build-go steps: - name: Checking out sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: "recursive" - name: Install MSVC compiler @@ -90,7 +90,7 @@ jobs: path: ${{ runner.workspace }}/Qt key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }} - name: Install Qt - uses: jurplel/install-qt-action@v2.14.0 + uses: jurplel/install-qt-action@v3 with: version: ${{ matrix.qt_version }} py7zrversion: ' ' @@ -163,7 +163,7 @@ jobs: - build-go steps: - name: Checking out sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Download Artifacts uses: actions/download-artifact@v3 with: diff --git a/README.md b/README.md index 56dbb3f..33657a0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Qt based cross-platform GUI proxy configuration manager (backend: v2ray / sing-box) -Support Windows / Linux amd64 out of the box now. +Support Windows / Linux / macOS amd64 out of the box now. 基于 Qt 的跨平台代理配置管理器 (后端 v2ray / sing-box) diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index ce51b7a..d071585 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -11,11 +11,12 @@ namespace NekoRay { // Common - QSharedPointer BuildConfig(const QSharedPointer &ent, bool forTest) { + QSharedPointer + BuildConfig(const QSharedPointer &ent, bool forTest, bool forExport) { if (IS_NEKO_BOX) { - return BuildConfigSingBox(ent, forTest); + return BuildConfigSingBox(ent, forTest, forExport); } - return BuildConfigV2Ray(ent, forTest); + return BuildConfigV2Ray(ent, forTest, forExport); } QString BuildChain(int chainId, const QSharedPointer &status) { @@ -78,7 +79,8 @@ namespace NekoRay { } } - QSharedPointer BuildConfigV2Ray(const QSharedPointer &ent, bool forTest) { + QSharedPointer + BuildConfigV2Ray(const QSharedPointer &ent, bool forTest, bool forExport) { auto result = QSharedPointer(new BuildConfigResult); auto status = QSharedPointer(new BuildConfigStatus); status->ent = ent; @@ -525,7 +527,8 @@ namespace NekoRay { // SingBox - QSharedPointer BuildConfigSingBox(const QSharedPointer &ent, bool forTest) { + QSharedPointer + BuildConfigSingBox(const QSharedPointer &ent, bool forTest, bool forExport) { auto result = QSharedPointer(new BuildConfigResult); auto status = QSharedPointer(new BuildConfigStatus); status->ent = ent; @@ -719,15 +722,21 @@ namespace NekoRay { // final add routing rule QJSONARRAY_ADD(routingRules, QString2QJsonObject(dataStore->custom_route_global)["rules"].toArray()) QJSONARRAY_ADD(routingRules, status->routingRules) - result->coreConfig.insert("route", QJsonObject{ + auto routeObj = QJsonObject{ {"rules", routingRules}, {"auto_detect_interface", true}, {"geoip", QJsonObject{{"path", geoip},},}, {"geosite", QJsonObject{{"path", geosite},},} - }); + }; + if (forExport) { + routeObj.remove("geoip"); + routeObj.remove("geosite"); + routeObj.remove("auto_detect_interface"); + } + result->coreConfig.insert("route", routeObj); // api - if (!forTest && dataStore->traffic_loop_interval > 0) { + if (!forTest && !forExport && dataStore->traffic_loop_interval > 0) { result->coreConfig.insert("experimental", QJsonObject{ {"v2ray_api", QJsonObject{ {"listen", "127.0.0.1:" + Int2String(dataStore->inbound_socks_port + 10)}, diff --git a/db/ConfigBuilder.hpp b/db/ConfigBuilder.hpp index bdb811c..7e2d0ad 100644 --- a/db/ConfigBuilder.hpp +++ b/db/ConfigBuilder.hpp @@ -41,11 +41,14 @@ namespace NekoRay { QJsonArray outbounds; }; - QSharedPointer BuildConfig(const QSharedPointer &ent, bool forTest); + QSharedPointer BuildConfig(const QSharedPointer &ent, + bool forTest, bool forExport); - QSharedPointer BuildConfigV2Ray(const QSharedPointer &ent, bool forTest); + QSharedPointer BuildConfigV2Ray(const QSharedPointer &ent, + bool forTest, bool forExport); - QSharedPointer BuildConfigSingBox(const QSharedPointer &ent, bool forTest); + QSharedPointer BuildConfigSingBox(const QSharedPointer &ent, + bool forTest, bool forExport); QString BuildChain(int chainId, const QSharedPointer &status); diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 4fa2107..c959d24 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -1025,7 +1025,7 @@ void MainWindow::on_menu_export_config_triggered() { auto ent = ents.first(); QString config_core; - auto result = NekoRay::BuildConfig(ent, false); + auto result = NekoRay::BuildConfig(ent, false, true); config_core = QJsonObject2QString(result->coreConfig, true); QApplication::clipboard()->setText(config_core); diff --git a/ui/mainwindow_grpc.cpp b/ui/mainwindow_grpc.cpp index 248b6d7..0804b53 100644 --- a/ui/mainwindow_grpc.cpp +++ b/ui/mainwindow_grpc.cpp @@ -114,7 +114,7 @@ void MainWindow::speedtest_current_group(int mode) { QList ext; if (mode == libcore::TestMode::UrlTest || mode == libcore::FullTest) { - auto c = NekoRay::BuildConfig(profile, true); + auto c = NekoRay::BuildConfig(profile, true, false); // external test ??? if (!c->ext.isEmpty()) { ext = c->ext; @@ -220,7 +220,7 @@ void MainWindow::neko_start(int _id) { auto group = NekoRay::profileManager->GetGroup(ent->gid); if (group == nullptr || group->archive) return; - auto result = NekoRay::BuildConfig(ent, false); + auto result = NekoRay::BuildConfig(ent, false, false); if (!result->error.isEmpty()) { MessageBoxWarning("BuildConfig return error", result->error); return;