summaryrefslogtreecommitdiff
path: root/platform/src/proxy.cpp
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2023-04-11 15:19:22 +0800
committerluwenpeng <[email protected]>2023-04-21 18:31:36 +0800
commitf741c3c025c91da2803246a8213fd5fe2d069a50 (patch)
tree98a19693a150093f163659f9c7f5a245ecd1fc06 /platform/src/proxy.cpp
parent0a3d06eed130c24557898b69f7565beb82f102c0 (diff)
TSG-14628 TFE适配TCP Option Profile库表的变更
Diffstat (limited to 'platform/src/proxy.cpp')
-rw-r--r--platform/src/proxy.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp
index 869a0bb..575bbbb 100644
--- a/platform/src/proxy.cpp
+++ b/platform/src/proxy.cpp
@@ -61,6 +61,7 @@
extern struct ssl_policy_enforcer* ssl_policy_enforcer_create(void* logger);
extern enum ssl_stream_action ssl_policy_enforce(struct ssl_stream *upstream, void* u_para);
+extern struct tcp_policy_enforcer *tcp_policy_enforcer_create(void *logger);
static int signals[] = {SIGHUP, SIGPIPE, SIGUSR1, SIGUSR2};
/* Global Resource */
@@ -165,17 +166,16 @@ int tfe_proxy_fds_accept(struct tfe_proxy *ctx, int fd_downstream, int fd_upstre
uint8_t stream_protocol_in_char = 0;
int tcp_passthrough = -1;
uint16_t size = 0;
+ int result = 0;
- int result = tfe_cmsg_get_value(cmsg, TFE_CMSG_TCP_RESTORE_PROTOCOL, (unsigned char *)&stream_protocol_in_char,
- sizeof(stream_protocol_in_char), &size);
-
+ result = tfe_cmsg_get_value(cmsg, TFE_CMSG_TCP_RESTORE_PROTOCOL, (unsigned char *)&stream_protocol_in_char, sizeof(stream_protocol_in_char), &size);
if (unlikely(result < 0))
- {
- TFE_LOG_ERROR(ctx->logger, "failed at fetch connection's protocol from cmsg: %s", strerror(-result));
- goto __errout;
- }
+ {
+ TFE_LOG_ERROR(ctx->logger, "failed at fetch connection's protocol from cmsg: %s", strerror(-result));
+ goto __errout;
+ }
- stream_protocol = (enum tfe_stream_proto)stream_protocol_in_char;
+ stream_protocol = (enum tfe_stream_proto)stream_protocol_in_char;
tfe_stream_option_set(stream, TFE_STREAM_OPT_SESSION_TYPE, &stream_protocol, sizeof(stream_protocol));
tfe_stream_cmsg_setup(stream, cmsg);
@@ -697,7 +697,12 @@ int main(int argc, char * argv[])
TFE_LOG_INFO(g_default_logger, "Plugin %s initialized. ", plugin_iter->symbol);
}
- g_default_proxy->ssl_ply_enforcer=ssl_policy_enforcer_create(g_default_logger);
+ g_default_proxy->tcp_ply_enforcer = tcp_policy_enforcer_create(g_default_logger);
+ CHECK_OR_EXIT(g_default_proxy->tcp_ply_enforcer == NULL, "Failed at creating tcp policy enforcer. Exit.");
+
+ g_default_proxy->ssl_ply_enforcer = ssl_policy_enforcer_create(g_default_logger);
+ CHECK_OR_EXIT(g_default_proxy->ssl_ply_enforcer == NULL, "Failed at creating ssl policy enforcer. Exit.");
+
ssl_manager_set_new_upstream_cb(g_default_proxy->ssl_mgr_handler, ssl_policy_enforce, g_default_proxy->ssl_ply_enforcer);
ret = tfe_proxy_work_thread_run(g_default_proxy);
CHECK_OR_EXIT(ret == 0, "Failed at creating thread. Exit.");