From 1baee8c1e73dfe7babeb1fe09cafee8bcb357918 Mon Sep 17 00:00:00 2001 From: Tim Blume Date: Sat, 20 Mar 2021 02:37:12 +0100 Subject: [PATCH] fixed proxy interface --- plugins/mitmproxy/CMakeLists.txt | 3 ++- plugins/mitmproxy/mitmproxy_network.cpp | 3 +-- plugins/mitmproxy/mitmproxy_network.h | 16 +++++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/mitmproxy/CMakeLists.txt b/plugins/mitmproxy/CMakeLists.txt index 11bacca..25aa9c8 100644 --- a/plugins/mitmproxy/CMakeLists.txt +++ b/plugins/mitmproxy/CMakeLists.txt @@ -1,5 +1,6 @@ SET(CMAKE_AUTOMOC ON) -add_library(mitmproxy_plugin MODULE mitmproxy_network.cpp mitmproxy_network.h mitmproxy.json) +add_compile_definitions(IS_HTTP_PROXY_INTERFACE) +add_library(mitmproxy_plugin SHARED mitmproxy_network.cpp mitmproxy_network.h mitmproxy.json) target_include_directories(mitmproxy_plugin PRIVATE ../../include/) target_link_libraries(mitmproxy_plugin PRIVATE Qt5::Core cppzmq) set_target_properties(mitmproxy_plugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR}) diff --git a/plugins/mitmproxy/mitmproxy_network.cpp b/plugins/mitmproxy/mitmproxy_network.cpp index a79c610..49cbd73 100644 --- a/plugins/mitmproxy/mitmproxy_network.cpp +++ b/plugins/mitmproxy/mitmproxy_network.cpp @@ -22,9 +22,8 @@ void mitmproxyPlugin::reconnect() this->connect(); } -void mitmproxyPlugin::process(std::string path) +void mitmproxyPlugin::process() { - this->path = path; connect(); while(true) { zmq::message_t response; diff --git a/plugins/mitmproxy/mitmproxy_network.h b/plugins/mitmproxy/mitmproxy_network.h index faa0a1f..16fd361 100644 --- a/plugins/mitmproxy/mitmproxy_network.h +++ b/plugins/mitmproxy/mitmproxy_network.h @@ -13,7 +13,7 @@ mitmproxy base plugin This plugin implements the interface for the basic mitmproxy plugin. */ -class mitmproxyPlugin : public QObject, http::ProxyInterface +class mitmproxyPlugin : public QObject, public http::ProxyInterface { Q_OBJECT Q_PLUGIN_METADATA(IID HTTPProxyInterfaceIID FILE "mitmproxy.json") @@ -23,16 +23,22 @@ private: zmq::context_t context; zmq::socket_t *socket; std::set accepted_flows; - std::string path; bool is_connected = false; void connect(); void reconnect(); + public: - //! called in a custom thread, may block. - void process(std::string path) override; //! returns, whether the proxy is currently connected bool connected() override; //! disconnects the handle void disconnect() override; - // options/settings + +public slots: + //! called in a custom thread, may block. + void process(); + +signals: + void finished(); + void error(QString err); + void message(http::Flow flow); };