fixed proxy interface

This commit is contained in:
Tim Blume 2021-03-20 02:37:12 +01:00
parent f99ee2abde
commit 1baee8c1e7
3 changed files with 14 additions and 8 deletions

View file

@ -1,5 +1,6 @@
SET(CMAKE_AUTOMOC ON) 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_include_directories(mitmproxy_plugin PRIVATE ../../include/)
target_link_libraries(mitmproxy_plugin PRIVATE Qt5::Core cppzmq) target_link_libraries(mitmproxy_plugin PRIVATE Qt5::Core cppzmq)
set_target_properties(mitmproxy_plugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR}) set_target_properties(mitmproxy_plugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN_DIR})

View file

@ -22,9 +22,8 @@ void mitmproxyPlugin::reconnect()
this->connect(); this->connect();
} }
void mitmproxyPlugin::process(std::string path) void mitmproxyPlugin::process()
{ {
this->path = path;
connect(); connect();
while(true) { while(true) {
zmq::message_t response; zmq::message_t response;

View file

@ -13,7 +13,7 @@ mitmproxy base plugin
This plugin implements the interface for the basic mitmproxy 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_OBJECT
Q_PLUGIN_METADATA(IID HTTPProxyInterfaceIID FILE "mitmproxy.json") Q_PLUGIN_METADATA(IID HTTPProxyInterfaceIID FILE "mitmproxy.json")
@ -23,16 +23,22 @@ private:
zmq::context_t context; zmq::context_t context;
zmq::socket_t *socket; zmq::socket_t *socket;
std::set<std::string> accepted_flows; std::set<std::string> accepted_flows;
std::string path;
bool is_connected = false; bool is_connected = false;
void connect(); void connect();
void reconnect(); void reconnect();
public: public:
//! called in a custom thread, may block.
void process(std::string path) override;
//! returns, whether the proxy is currently connected //! returns, whether the proxy is currently connected
bool connected() override; bool connected() override;
//! disconnects the handle //! disconnects the handle
void disconnect() override; 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);
}; };