2021-01-06 21:43:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "api.h"
|
2021-01-09 10:17:50 +00:00
|
|
|
#include "proxyinterface.h"
|
2021-01-06 21:43:48 +00:00
|
|
|
#include <QObject>
|
2021-03-19 16:40:33 +00:00
|
|
|
#include <QtPlugin>
|
2021-01-06 21:43:48 +00:00
|
|
|
|
2021-03-03 16:12:12 +00:00
|
|
|
#include <set>
|
|
|
|
#include <zmq.hpp>
|
|
|
|
|
2021-03-19 16:40:33 +00:00
|
|
|
/*
|
|
|
|
mitmproxy base plugin
|
|
|
|
|
|
|
|
This plugin implements the interface for the basic mitmproxy plugin.
|
|
|
|
*/
|
2021-03-20 01:37:12 +00:00
|
|
|
class mitmproxyPlugin : public QObject, public http::ProxyInterface
|
2021-01-09 10:17:50 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2021-03-19 16:40:33 +00:00
|
|
|
Q_PLUGIN_METADATA(IID HTTPProxyInterfaceIID FILE "mitmproxy.json")
|
2021-01-09 10:17:50 +00:00
|
|
|
Q_INTERFACES(http::ProxyInterface)
|
2021-03-03 16:12:12 +00:00
|
|
|
private:
|
|
|
|
std::set<std::string> received;
|
|
|
|
zmq::context_t context;
|
|
|
|
zmq::socket_t *socket;
|
|
|
|
std::set<std::string> accepted_flows;
|
|
|
|
bool is_connected = false;
|
|
|
|
void connect();
|
|
|
|
void reconnect();
|
2021-03-20 01:37:12 +00:00
|
|
|
|
2021-01-09 10:17:50 +00:00
|
|
|
public:
|
2021-03-03 16:12:12 +00:00
|
|
|
//! returns, whether the proxy is currently connected
|
|
|
|
bool connected() override;
|
|
|
|
//! disconnects the handle
|
|
|
|
void disconnect() override;
|
2021-03-20 01:37:12 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
//! called in a custom thread, may block.
|
|
|
|
void process();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
void error(QString err);
|
|
|
|
void message(http::Flow flow);
|
2021-01-09 10:17:50 +00:00
|
|
|
};
|