2018-08-23 11:23:05 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <tfe_stream.h>
|
|
|
|
|
#include <event2/event.h>
|
2018-08-27 21:10:45 +08:00
|
|
|
#include <ssl_stream.h>
|
|
|
|
|
|
|
|
|
|
struct ssl_mgr;
|
|
|
|
|
struct key_keeper;
|
2018-08-30 15:53:41 +08:00
|
|
|
struct kni_acceptor;
|
2018-10-05 14:34:51 +08:00
|
|
|
enum TFE_STAT_FIELD
|
|
|
|
|
{
|
|
|
|
|
STAT_SIGPIPE,
|
|
|
|
|
TFE_STAT_MAX
|
|
|
|
|
};
|
2018-08-27 21:10:45 +08:00
|
|
|
|
2018-09-21 16:11:54 +08:00
|
|
|
struct tfe_proxy_tcp_options
|
|
|
|
|
{
|
|
|
|
|
int sz_rcv_buffer;
|
|
|
|
|
int sz_snd_buffer;
|
|
|
|
|
int so_keepalive;
|
|
|
|
|
int tcp_keepidle;
|
|
|
|
|
int tcp_keepintvl;
|
|
|
|
|
int tcp_keepcnt;
|
2018-09-21 19:06:44 +08:00
|
|
|
int tcp_user_timeout;
|
2018-09-21 16:11:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct tfe_proxy_accept_para
|
|
|
|
|
{
|
|
|
|
|
/* Both upstream and downstream FDs */
|
|
|
|
|
evutil_socket_t upstream_fd;
|
|
|
|
|
evutil_socket_t downstream_fd;
|
|
|
|
|
|
|
|
|
|
/* Session Type */
|
|
|
|
|
bool is_set_session_type;
|
|
|
|
|
enum tfe_stream_proto session_type;
|
|
|
|
|
bool passthrough;
|
2018-10-19 19:50:27 +08:00
|
|
|
|
|
|
|
|
/* addition info */
|
|
|
|
|
unsigned int keyring_id;
|
2018-09-21 16:11:54 +08:00
|
|
|
};
|
|
|
|
|
|
2018-08-27 21:10:45 +08:00
|
|
|
struct tfe_proxy
|
|
|
|
|
{
|
|
|
|
|
char name[TFE_SYMBOL_MAX];
|
|
|
|
|
struct event_base * evbase;
|
|
|
|
|
struct event * sev[8];
|
|
|
|
|
struct event * gcev;
|
|
|
|
|
|
2018-08-30 15:53:41 +08:00
|
|
|
void * logger;
|
2018-10-05 13:31:10 +08:00
|
|
|
void * fs_handle;
|
2018-08-27 21:10:45 +08:00
|
|
|
unsigned int nr_work_threads;
|
2018-08-30 15:53:41 +08:00
|
|
|
struct tfe_thread_ctx * work_threads[TFE_THREAD_MAX];
|
2018-08-27 21:10:45 +08:00
|
|
|
|
|
|
|
|
unsigned int nr_modules;
|
|
|
|
|
struct tfe_plugin * modules;
|
|
|
|
|
|
|
|
|
|
struct ssl_mgr * ssl_mgr_handler;
|
|
|
|
|
struct key_keeper * key_keeper_handler;
|
2018-08-30 15:53:41 +08:00
|
|
|
struct kni_acceptor * kni_acceptor_handler;
|
|
|
|
|
|
2018-09-21 16:11:54 +08:00
|
|
|
/* DEBUG OPTIONS */
|
2018-08-30 15:53:41 +08:00
|
|
|
unsigned int tcp_all_passthrough;
|
2018-09-21 16:11:54 +08:00
|
|
|
struct tfe_proxy_tcp_options tcp_options;
|
2018-10-05 14:34:51 +08:00
|
|
|
|
|
|
|
|
/* PERFOMANCE MONIOTR VARIABLES*/
|
|
|
|
|
long long stat_val[TFE_STAT_MAX];
|
|
|
|
|
int fs_id[TFE_STAT_MAX];
|
|
|
|
|
|
2018-08-27 21:10:45 +08:00
|
|
|
};
|
2018-08-23 11:23:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-30 15:53:41 +08:00
|
|
|
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);
|
|
|
|
|
|
2018-08-23 11:23:05 +08:00
|
|
|
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);
|
2018-08-27 21:10:45 +08:00
|
|
|
|