2018-09-02 18:23:01 +08:00
|
|
|
#include "mirror_stream.h"
|
|
|
|
|
#include <tfe_stream.h>
|
2018-09-04 11:36:22 +08:00
|
|
|
#include <tfe_plugin.h>
|
|
|
|
|
#include <assert.h>
|
2018-09-02 18:23:01 +08:00
|
|
|
|
2018-12-12 16:40:04 +08:00
|
|
|
|
|
|
|
|
extern unsigned int tfe_proxy_get_work_thread_count(void);
|
|
|
|
|
|
2018-09-04 11:36:22 +08:00
|
|
|
int decrypt_mirror_init(struct tfe_proxy * proxy)
|
2018-09-02 18:23:01 +08:00
|
|
|
{
|
2018-11-19 15:00:07 +08:00
|
|
|
const char* filepath="./conf/tfe/decrypt_mirror.conf";
|
2018-12-12 16:40:04 +08:00
|
|
|
int ret=0;
|
|
|
|
|
int thread_num = tfe_proxy_get_work_thread_count();
|
2018-09-04 11:36:22 +08:00
|
|
|
ret=mirror_stream_init(thread_num, filepath);
|
2018-12-12 16:40:04 +08:00
|
|
|
return ret;
|
2018-09-02 18:23:01 +08:00
|
|
|
}
|
|
|
|
|
|
2018-09-04 11:36:22 +08:00
|
|
|
int decrypt_mirror_on_open_cb(const struct tfe_stream * stream, unsigned int thread_id,
|
|
|
|
|
enum tfe_conn_dir dir, void ** pme)
|
2018-09-02 18:23:01 +08:00
|
|
|
{
|
2018-12-12 16:40:04 +08:00
|
|
|
int ret=0;
|
2018-09-04 11:36:22 +08:00
|
|
|
ret=mirror_stream_open(thread_id, stream->addr, pme);
|
2018-12-12 16:40:04 +08:00
|
|
|
return ret;
|
2018-09-02 18:23:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2019-01-08 15:09:38 +06:00
|
|
|
mirror_stream_write(dir, data,len, pme, thread_id);
|
2018-09-02 18:23:01 +08:00
|
|
|
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)
|
|
|
|
|
{
|
2018-09-04 11:36:22 +08:00
|
|
|
mirror_stream_close(pme, thread_id);
|
2018-09-02 18:23:01 +08:00
|
|
|
return;
|
|
|
|
|
}
|
2018-11-14 15:55:51 +08:00
|
|
|
|
2018-09-04 11:36:22 +08:00
|
|
|
void decrypt_mirror_deinit(struct tfe_proxy * proxy)
|
2018-09-02 18:23:01 +08:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-11-14 15:55:51 +08:00
|
|
|
|
2018-09-04 11:36:22 +08:00
|
|
|
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)
|
|
|
|
|
|
2018-09-02 18:23:01 +08:00
|
|
|
|