From f1c2b01f26f6c36f80d53247dd1ed7f836f3c9e7 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Sun, 17 May 2020 08:54:33 +0800 Subject: [PATCH 1/9] add: adapt plugin interface V2 --- 3rdparty/shadowsocksr-uvw | 2 +- SSRPlugin.cpp | 5 ++--- SSRPlugin.hpp | 7 ++++--- core/kernel/SSRInstance.cpp | 24 +++++++++++++++--------- core/kernel/SSRInstance.hpp | 6 +----- interface | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/3rdparty/shadowsocksr-uvw b/3rdparty/shadowsocksr-uvw index 857fe00..c501c16 160000 --- a/3rdparty/shadowsocksr-uvw +++ b/3rdparty/shadowsocksr-uvw @@ -1 +1 @@ -Subproject commit 857fe00910854c9a74d8d5446e9e30af6149a411 +Subproject commit c501c168c04ea48a53bafe97ebaf84831639aeed diff --git a/SSRPlugin.cpp b/SSRPlugin.cpp index 5e6524c..4d1fa3d 100644 --- a/SSRPlugin.cpp +++ b/SSRPlugin.cpp @@ -8,9 +8,9 @@ #include namespace SSRPlugin { - std::shared_ptr QvSSRPlugin::GetKernel() + std::unique_ptr QvSSRPlugin::CreateKernel() { - return kernel; + return std::make_unique(); } std::shared_ptr QvSSRPlugin::GetSerializer() @@ -29,7 +29,6 @@ namespace SSRPlugin emit PluginLog("Initialize plugin."); this->settings = settings; eventHandler = std::make_shared(this); - kernel = std::make_shared(this); serializer = std::make_shared(this); return true; } diff --git a/SSRPlugin.hpp b/SSRPlugin.hpp index 82da74e..4b1862b 100644 --- a/SSRPlugin.hpp +++ b/SSRPlugin.hpp @@ -24,7 +24,7 @@ namespace SSRPlugin // Basic metainfo of this plugin const QvPluginMetadata GetMetadata() const override { - return QvPluginMetadata{ + auto x = QvPluginMetadata{ "SSR Plugin", // "Qv2ray Development Group", // "qvplugin_ssr", // @@ -34,11 +34,13 @@ namespace SSRPlugin { SPECIAL_TYPE_KERNEL, // SPECIAL_TYPE_SERIALIZOR } // }; + x.KernelOutboundCapabilities = { { "ShadowSocksR", "shadowsocksr" } }; + return x; } // std::unique_ptr GetSettingsWidget() override; std::unique_ptr GetEditorWidget(UI_TYPE) override; - std::shared_ptr GetKernel() override; + std::unique_ptr CreateKernel() override; std::shared_ptr GetSerializer() override; std::shared_ptr GetEventHandler() override; // @@ -54,6 +56,5 @@ namespace SSRPlugin QJsonObject settings; std::shared_ptr eventHandler; std::shared_ptr serializer; - std::shared_ptr kernel; }; } // namespace SSRPlugin diff --git a/core/kernel/SSRInstance.cpp b/core/kernel/SSRInstance.cpp index e40900c..b279719 100644 --- a/core/kernel/SSRInstance.cpp +++ b/core/kernel/SSRInstance.cpp @@ -14,17 +14,25 @@ namespace SSRPlugin { } - void SSRKernelInstance::SetConnectionSettings(const QString &listenAddress, const QMap &inbound, const QJsonObject &settings) + void SSRKernelInstance::SetConnectionSettings(const QMap &options, const QJsonObject &settings) { - this->listen_address = listenAddress; - socks_local_port = inbound["socks"]; - http_local_port = inbound["http"]; - enable_udp = inbound["enable_udp"]; + this->listen_address = options[KERNEL_LISTEN_ADDRESS].toString(); + socks_local_port = options[KERNEL_SOCKS_ENABLED].toBool() ? options[KERNEL_SOCKS_PORT].toInt() : 0; + http_local_port = options[KERNEL_HTTP_ENABLED].toBool() ? options[KERNEL_HTTP_PORT].toInt() : 0; + enable_udp = options[KERNEL_SOCKS_UDP_ENABLED].toBool(); outbound.loadJson(settings); } bool SSRKernelInstance::StartKernel() { + if (socks_local_port == 0 && http_local_port == 0) + { + emit OnKernelCrashed("Both HTTP and SOCKS are not enabled"); + return false; + } + // If the socks has been disabled + if (socks_local_port == 0) + socks_local_port = http_local_port + 1; auto remotePort = outbound.port; auto remote_host = outbound.address.toStdString(); auto method = outbound.method.toStdString(); @@ -36,9 +44,7 @@ namespace SSRPlugin auto mode = static_cast(enable_udp); ssrThread = std::make_unique(socks_local_port, // remotePort, // - 60000, - 1500, - mode, + 60000, 1500, mode, // listen_address.toStdString(), // remote_host, // method, // @@ -47,7 +53,7 @@ namespace SSRPlugin obfs_param, // protocol, // protocol_param); - ssrThread->connect(ssrThread.get(), &SSRThread::onSSRThreadLog, this, &SSRKernelInstance::OnKernelLogAvaliable); + ssrThread->connect(ssrThread.get(), &SSRThread::onSSRThreadLog, this, &SSRKernelInstance::OnKernelLogAvailable); ssrThread->connect(ssrThread.get(), &SSRThread::OnDataReady, this, &SSRKernelInstance::OnKernelStatsAvailable); ssrThread->start(); if (http_local_port != 0) diff --git a/core/kernel/SSRInstance.hpp b/core/kernel/SSRInstance.hpp index 25c1fc7..6e4dda0 100644 --- a/core/kernel/SSRInstance.hpp +++ b/core/kernel/SSRInstance.hpp @@ -11,11 +11,7 @@ namespace SSRPlugin explicit SSRKernelInstance(QObject *parent = nullptr); bool StartKernel() override; bool StopKernel() override; - void SetConnectionSettings(const QString &listen_address, const QMap &inbound, const QJsonObject &settings) override; - const QList KernelOutboundCapabilities() const override - { - return { { "ShadowSocksR", "shadowsocksr" } }; - } + void SetConnectionSettings(const QMap &options, const QJsonObject &settings) override; private: int socks_local_port; diff --git a/interface b/interface index 8ec8004..4138f84 160000 --- a/interface +++ b/interface @@ -1 +1 @@ -Subproject commit 8ec800431c7ca133e3d6fa1270a263b0e0f836c1 +Subproject commit 4138f84c09167f06de2ba373dccfcf31ca5be09e From 8f8bd1d3f41d9a96d98a17e13835d1cc93f0f607 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Sun, 17 May 2020 09:16:14 +0800 Subject: [PATCH 2/9] add: adapt plugin interface V2 - 1 --- core/kernel/SSRInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/kernel/SSRInstance.cpp b/core/kernel/SSRInstance.cpp index b279719..beaf59c 100644 --- a/core/kernel/SSRInstance.cpp +++ b/core/kernel/SSRInstance.cpp @@ -32,7 +32,7 @@ namespace SSRPlugin } // If the socks has been disabled if (socks_local_port == 0) - socks_local_port = http_local_port + 1; + socks_local_port = http_local_port + 100; auto remotePort = outbound.port; auto remote_host = outbound.address.toStdString(); auto method = outbound.method.toStdString(); From e299daa858790237880e803ed9f6fa0dc663a0bc Mon Sep 17 00:00:00 2001 From: ymshenyu Date: Sun, 24 May 2020 13:48:49 +0800 Subject: [PATCH 3/9] add install target --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1281188..c77699b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,3 +49,5 @@ target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Network ${SHADOWSOCKSR_UVW_LIBRARY}) + +install(TARGETS ${PROJECT_NAME} DESTINATION share/qv2ray/plugins) From b27c1c4e30c3e5cc9fef386d344417bed6cbdff2 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Fri, 12 Jun 2020 17:42:48 +0800 Subject: [PATCH 4/9] update: update submodule --- interface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface b/interface index 4138f84..24d6cde 160000 --- a/interface +++ b/interface @@ -1 +1 @@ -Subproject commit 4138f84c09167f06de2ba373dccfcf31ca5be09e +Subproject commit 24d6cdeabb50cf753e23efea225f66c59f23c06e From 3962e42391058c244c19e7e41f8bd2aec9381650 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Fri, 19 Jun 2020 09:11:44 +0800 Subject: [PATCH 5/9] fix: fix submodule url --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index c39a32b..c6bf222 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "interface"] path = interface - url = https://github.com/Qv2ray/QvPlugin-Host/ + url = https://github.com/Qv2ray/QvPlugin-Interface/ [submodule "3rdparty/shadowsocksr-uvw"] path = 3rdparty/shadowsocksr-uvw url = https://github.com/Qv2ray/shadowsocksr-uvw From 88eac688e0cc1c0a743706ec82a1cea2ba338e5e Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Fri, 19 Jun 2020 09:12:48 +0800 Subject: [PATCH 6/9] fix: fix submodule url 2 --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index c6bf222..5a8b873 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "interface"] path = interface - url = https://github.com/Qv2ray/QvPlugin-Interface/ + url = https://github.com/Qv2ray/QvPlugin-Interface [submodule "3rdparty/shadowsocksr-uvw"] path = 3rdparty/shadowsocksr-uvw url = https://github.com/Qv2ray/shadowsocksr-uvw From 42019ad6586c730ba9096de36a55928c7a6fdf41 Mon Sep 17 00:00:00 2001 From: Qv2ray-dev <59914293+Qv2ray-dev@users.noreply.github.com> Date: Tue, 7 Jul 2020 16:08:45 +0800 Subject: [PATCH 7/9] update: update submodules --- 3rdparty/shadowsocksr-uvw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/shadowsocksr-uvw b/3rdparty/shadowsocksr-uvw index c501c16..e5f60dc 160000 --- a/3rdparty/shadowsocksr-uvw +++ b/3rdparty/shadowsocksr-uvw @@ -1 +1 @@ -Subproject commit c501c168c04ea48a53bafe97ebaf84831639aeed +Subproject commit e5f60dc816496e0c3c18a8134447020243d2388c From 258cb6c07472365e52ee90a2d4b8d131a2a461ea Mon Sep 17 00:00:00 2001 From: DuckVador Date: Thu, 9 Jul 2020 16:36:24 +0800 Subject: [PATCH 8/9] submodule: updated submodule --- 3rdparty/shadowsocksr-uvw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/shadowsocksr-uvw b/3rdparty/shadowsocksr-uvw index e5f60dc..8e0bb66 160000 --- a/3rdparty/shadowsocksr-uvw +++ b/3rdparty/shadowsocksr-uvw @@ -1 +1 @@ -Subproject commit e5f60dc816496e0c3c18a8134447020243d2388c +Subproject commit 8e0bb665bae98b8f1d8c951806d0d8c74498a144 From 115dc9f3d33e7ba85989fb6b433689f0bb32841e Mon Sep 17 00:00:00 2001 From: DuckVador Date: Thu, 9 Jul 2020 17:22:12 +0800 Subject: [PATCH 9/9] submodule: updated submodule --- 3rdparty/shadowsocksr-uvw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/shadowsocksr-uvw b/3rdparty/shadowsocksr-uvw index 8e0bb66..6c2f5e2 160000 --- a/3rdparty/shadowsocksr-uvw +++ b/3rdparty/shadowsocksr-uvw @@ -1 +1 @@ -Subproject commit 8e0bb665bae98b8f1d8c951806d0d8c74498a144 +Subproject commit 6c2f5e2bb758382a489ed3f9f444684c23c195e9