refactor: move struct laye and struct tunnel to packet.h
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
// NOTE: packet hexdump or tcp segment hexdump may be too long, so we need direct output to fd, instead of using log_print
|
||||
static void log_print(int fd, const char *module, const char *fmt, ...)
|
||||
{
|
||||
static unsigned char weekday_str[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
@@ -59,7 +58,6 @@ static void log_print(int fd, const char *module, const char *fmt, ...)
|
||||
struct plugin_ctx
|
||||
{
|
||||
struct stellar *st;
|
||||
char work_dir[1024];
|
||||
int sess_exdata_idx;
|
||||
int sess_plug_id;
|
||||
int tcp_topic_id;
|
||||
@@ -98,11 +96,11 @@ static void *on_sess_new(struct session *sess, void *plugin_ctx)
|
||||
if (session_get_type(sess) == SESSION_TYPE_TCP)
|
||||
{
|
||||
memset(buff, 0, sizeof(buff));
|
||||
sprintf(buff, "%s/log/debug_plugin_%s_c2s_segment", ctx->work_dir, session_get0_readable_addr(sess));
|
||||
sprintf(buff, "./log/debug_plugin_%s_c2s_segment", session_get0_readable_addr(sess));
|
||||
ctx->c2s_tcp_seg_hexdump_fd = open(buff, O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
|
||||
memset(buff, 0, sizeof(buff));
|
||||
sprintf(buff, "%s/log/debug_plugin_%s_s2c_segment", ctx->work_dir, session_get0_readable_addr(sess));
|
||||
sprintf(buff, "./log/debug_plugin_%s_s2c_segment", session_get0_readable_addr(sess));
|
||||
ctx->s2c_tcp_seg_hexdump_fd = open(buff, O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
}
|
||||
session_exdata_set(sess, ctx->sess_exdata_idx, exdata);
|
||||
@@ -274,13 +272,6 @@ extern "C"
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
if (getcwd(ctx->work_dir, sizeof(ctx->work_dir)) == NULL)
|
||||
{
|
||||
printf("[debug plugin] getcwd failed: %s\n", strerror(errno));
|
||||
close(ctx->fd);
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_spin_init(&ctx->lock, PTHREAD_PROCESS_PRIVATE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user