mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-18 13:04:37 +03:00
improve export config
This commit is contained in:
10
.github/workflows/build-qv2ray-cmake.yml
vendored
10
.github/workflows/build-qv2ray-cmake.yml
vendored
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@ namespace NekoRay {
|
||||
|
||||
// Common
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfig(const QSharedPointer<ProxyEntity> &ent, bool forTest) {
|
||||
QSharedPointer<BuildConfigResult>
|
||||
BuildConfig(const QSharedPointer<ProxyEntity> &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<BuildConfigStatus> &status) {
|
||||
@@ -78,7 +79,8 @@ namespace NekoRay {
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfigV2Ray(const QSharedPointer<ProxyEntity> &ent, bool forTest) {
|
||||
QSharedPointer<BuildConfigResult>
|
||||
BuildConfigV2Ray(const QSharedPointer<ProxyEntity> &ent, bool forTest, bool forExport) {
|
||||
auto result = QSharedPointer<BuildConfigResult>(new BuildConfigResult);
|
||||
auto status = QSharedPointer<BuildConfigStatus>(new BuildConfigStatus);
|
||||
status->ent = ent;
|
||||
@@ -525,7 +527,8 @@ namespace NekoRay {
|
||||
|
||||
// SingBox
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfigSingBox(const QSharedPointer<ProxyEntity> &ent, bool forTest) {
|
||||
QSharedPointer<BuildConfigResult>
|
||||
BuildConfigSingBox(const QSharedPointer<ProxyEntity> &ent, bool forTest, bool forExport) {
|
||||
auto result = QSharedPointer<BuildConfigResult>(new BuildConfigResult);
|
||||
auto status = QSharedPointer<BuildConfigStatus>(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)},
|
||||
|
||||
@@ -41,11 +41,14 @@ namespace NekoRay {
|
||||
QJsonArray outbounds;
|
||||
};
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfig(const QSharedPointer<ProxyEntity> &ent, bool forTest);
|
||||
QSharedPointer<BuildConfigResult> BuildConfig(const QSharedPointer<ProxyEntity> &ent,
|
||||
bool forTest, bool forExport);
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfigV2Ray(const QSharedPointer<ProxyEntity> &ent, bool forTest);
|
||||
QSharedPointer<BuildConfigResult> BuildConfigV2Ray(const QSharedPointer<ProxyEntity> &ent,
|
||||
bool forTest, bool forExport);
|
||||
|
||||
QSharedPointer<BuildConfigResult> BuildConfigSingBox(const QSharedPointer<ProxyEntity> &ent, bool forTest);
|
||||
QSharedPointer<BuildConfigResult> BuildConfigSingBox(const QSharedPointer<ProxyEntity> &ent,
|
||||
bool forTest, bool forExport);
|
||||
|
||||
QString BuildChain(int chainId, const QSharedPointer<BuildConfigStatus> &status);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -114,7 +114,7 @@ void MainWindow::speedtest_current_group(int mode) {
|
||||
QList<NekoRay::sys::ExternalProcess *> 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;
|
||||
|
||||
Reference in New Issue
Block a user