增加TCP Passthrough功能实现,调通明文转发流程。

This commit is contained in:
Lu Qiuwen
2018-08-30 15:53:41 +08:00
parent e9ebe512c7
commit c15be5af0e
9 changed files with 401 additions and 244 deletions

View File

@@ -1,7 +1,7 @@
#pragma once
struct tfe_proxy;
struct kni_acceptor_ctx;
struct kni_acceptor;
struct kni_acceptor_ctx * kni_acceptor_init(struct tfe_proxy *proxy, const char *profile, void *logger);
void kni_acceptor_deinit(struct kni_acceptor_ctx *ctx);
struct kni_acceptor * kni_acceptor_init(struct tfe_proxy *proxy, const char *profile, void *logger);
void kni_acceptor_deinit(struct kni_acceptor *ctx);

View File

@@ -12,7 +12,7 @@ struct tfe_thread_ctx
{
pthread_t thr;
unsigned int thread_id;
size_t load;
unsigned int load;
struct event_base * evbase;
unsigned char running;
@@ -20,9 +20,6 @@ struct tfe_thread_ctx
struct tfe_stats stat;
struct cert_mgr * cert_mgr;
struct sess_cache * dsess_cache;
struct sess_cache * ssess_cache;
unsigned int nr_modules;
const struct tfe_plugin * modules;
};
@@ -84,7 +81,9 @@ struct tfe_stream_private
int plugin_num;
struct plugin_ctx * plug_ctx;
unsigned char passthrough; /* 1 if SSL passthrough is active */
/* TCP forward without scan or decode when the passthough is set */
bool passthough;
/* For defer connection setup */
evutil_socket_t defer_fd_downstream;
@@ -98,5 +97,5 @@ struct tfe_stream_private
static inline void * __STREAM_LOGGER(struct tfe_stream_private * _stream)
{
return _stream->proxy_ref->main_logger;
return _stream->proxy_ref->logger;
}

View File

@@ -6,6 +6,7 @@
struct ssl_mgr;
struct key_keeper;
struct kni_acceptor;
struct tfe_proxy
{
@@ -14,18 +15,19 @@ struct tfe_proxy
struct event * sev[8];
struct event * gcev;
struct tfe_config * opts;
void * main_logger;
void * logger;
unsigned int nr_work_threads;
struct tfe_thread_ctx * work_threads;
struct tfe_thread_ctx * work_threads[TFE_THREAD_MAX];
unsigned int nr_modules;
struct tfe_plugin * modules;
void * io_mod;
struct ssl_mgr * ssl_mgr_handler;
struct key_keeper * key_keeper_handler;
struct kni_acceptor * kni_acceptor_handler;
unsigned int tcp_all_passthrough;
};
struct tfe_proxy_accept_para
@@ -35,9 +37,14 @@ struct tfe_proxy_accept_para
evutil_socket_t downstream_fd;
/* Session Type */
bool is_set_session_type;
enum tfe_session_proto session_type;
bool passthrough;
};
struct tfe_thread_ctx * tfe_proxy_thread_ctx_acquire(struct tfe_proxy * ctx);
void tfe_proxy_thread_ctx_release(struct tfe_thread_ctx * thread_ctx);
struct tfe_proxy * tfe_proxy_new(const char * profile);
int tfe_proxy_fds_accept(struct tfe_proxy * ctx, const struct tfe_proxy_accept_para * para);
void tfe_proxy_run(struct tfe_proxy * proxy);

View File

@@ -3,6 +3,13 @@
#include <platform.h>
struct tfe_stream * tfe_stream_create(struct tfe_proxy * pxy, struct tfe_thread_ctx * thread_ctx);
void tfe_stream_init_by_fds(struct tfe_stream * stream, enum tfe_session_proto session_type,
evutil_socket_t fd_downstream, evutil_socket_t fd_upstream);
enum tfe_stream_option
{
TFE_STREAM_OPT_SESSION_TYPE,
TFE_STREAM_OPT_PASSTHROUGH
};
int tfe_stream_option_set(struct tfe_stream * stream, enum tfe_stream_option opt, const void * arg, size_t sz_arg);
void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downstream, evutil_socket_t fd_upstream);
void tfe_stream_destory(struct tfe_stream_private * stream);