This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/plugin/business/decrypt-mirroring/src/decrypt_mirror_plugin.cpp

56 lines
1.5 KiB
C++

#include "mirror_stream.h"
#include <tfe_stream.h>
#include <tfe_plugin.h>
#include <assert.h>
extern unsigned int tfe_proxy_get_work_thread_count(void);
int decrypt_mirror_init(struct tfe_proxy * proxy)
{
const char* filepath="./conf/tfe/decrypt_mirror.conf";
int ret=0;
int thread_num = tfe_proxy_get_work_thread_count();
ret=mirror_stream_init(thread_num, filepath);
return ret;
}
int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id,
enum tfe_conn_dir dir, void ** pme)
{
int ret=0;
ret=mirror_stream_open(thread_id, stream->addr, pme);
return ret;
}
enum tfe_stream_action decrypt_mirror_on_data_cb(const struct tfe_stream * stream, unsigned int thread_id,
enum tfe_conn_dir dir, const unsigned char * data, size_t len, void ** pme)
{
mirror_stream_write(dir, data,len, pme, thread_id);
return ACTION_FORWARD_DATA;
}
void decrypt_mirror_on_close_cb(const struct tfe_stream * stream, unsigned int thread_id,
enum tfe_stream_close_reason reason, void ** pme)
{
mirror_stream_close(pme, thread_id);
return;
}
void decrypt_mirror_deinit(struct tfe_proxy * proxy)
{
return;
}
struct tfe_plugin decrypt_mirror_spec={
.symbol=NULL,
.type = TFE_PLUGIN_TYPE_BUSINESS,
.on_init = decrypt_mirror_init,
.on_deinit = decrypt_mirror_deinit,
.on_open = decrypt_mirror_on_open_cb,
.on_data = decrypt_mirror_on_data_cb,
.on_close = decrypt_mirror_on_close_cb};
TFE_PLUGIN_REGISTER(decrypt_mirror,decrypt_mirror_spec)