summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2022-12-30 15:53:16 +0800
committerluwenpeng <[email protected]>2022-12-30 15:53:19 +0800
commita2a4c323848e4cc4eef29c065377d31577d92c77 (patch)
tree26369002b505cea7f2be40ac0467d4da8a41c69e
parentb2c01eaa058b6ed4c7ee1aef0b0c1595177c8070 (diff)
TSG-13204 Decrypted Traffic Steering适配第三方设备状态的切换v4.7.02-20221230release-4.7develop-4.7
-> 当第三方设备的状态从可用变为不可用时 * 当前Stream依然按照Steering的流程处理,从eventcb中退出 * 下一个新的Stream开始UnSteering -> 当第三方设备的状态从不可用变为可用时 * 当前Stream依然按照UnSteering的流程处理 * 下一个新Stream开始Steering
-rw-r--r--platform/include/internal/platform.h3
-rw-r--r--platform/src/tcp_stream.cpp26
2 files changed, 14 insertions, 15 deletions
diff --git a/platform/include/internal/platform.h b/platform/include/internal/platform.h
index 9248009..3ecfd87 100644
--- a/platform/include/internal/platform.h
+++ b/platform/include/internal/platform.h
@@ -153,6 +153,9 @@ struct tfe_stream_private
/* OFFSET FOR LOG */
size_t downstream_rx_offset;
size_t upstream_rx_offset;
+
+ /* Decrypted Traffic Steering */
+ bool is_decrypted_traffic_steering;
};
static inline void * __STREAM_LOGGER(struct tfe_stream_private * _stream)
diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp
index 279173b..46c0b33 100644
--- a/platform/src/tcp_stream.cpp
+++ b/platform/src/tcp_stream.cpp
@@ -634,9 +634,7 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
struct evbuffer * outbuf = NULL;
int inbuff_len = 0;
- if (steering_device_is_available() && (
- (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
- (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
+ if (_stream->is_decrypted_traffic_steering)
{
if (bev == _stream->conn_downstream->bev)
{
@@ -846,9 +844,7 @@ static void __stream_bev_writecb(struct bufferevent * bev, void * arg)
struct tfe_conn_private ** ref_peer_conn{};
struct ssl_stream ** ref_this_ssl_stream{};
- if (steering_device_is_available() && (
- (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
- (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
+ if (_stream->is_decrypted_traffic_steering)
{
// TODO 增加计数
TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s %s run writecb",
@@ -985,9 +981,7 @@ static void __stream_bev_eventcb(struct bufferevent * bev, short events, void *
need_close_connection = 1;
}
- if (steering_device_is_available() && (
- (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
- (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)))
+ if (_stream->is_decrypted_traffic_steering)
{
TFE_LOG_DEBUG(__STREAM_LOGGER(_stream), "decrypted traffic steering, %s %s run eventcb, %s %s",
_stream->str_stream_addr,
@@ -1251,7 +1245,7 @@ void ssl_downstream_create_on_success(future_result_t * result, void * user)
__conn_private_enable(_stream->conn_downstream);
__conn_private_enable(_stream->conn_upstream);
- if (steering_device_is_available() && _stream->proxy_ref->traffic_steering_options.enable_steering_ssl)
+ if (_stream->is_decrypted_traffic_steering)
{
__conn_private_enable(_stream->conn_fake_c);
__conn_private_enable(_stream->conn_fake_s);
@@ -1771,6 +1765,11 @@ int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downst
_stream->fd_fake_c = fd_fake_c;
_stream->fd_fake_s = fd_fake_s;
+ if (fd_fake_c > 0 && fd_fake_s > 0)
+ {
+ _stream->is_decrypted_traffic_steering = 1;
+ }
+
_stream->head.addr = tfe_stream_addr_create_by_fd(fd_downstream, CONN_DIR_DOWNSTREAM);
if (unlikely(_stream->head.addr == NULL))
{
@@ -1784,10 +1783,7 @@ int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downst
__stream_fd_option_setup(_stream, fd_downstream, CONN_DIR_DOWNSTREAM);
__stream_fd_option_setup(_stream, fd_upstream, CONN_DIR_UPSTREAM);
- if (steering_device_is_available() && (
- (STREAM_PROTO_PLAIN == _stream->session_type && _stream->proxy_ref->traffic_steering_options.enable_steering_http) ||
- (STREAM_PROTO_SSL == _stream->session_type &&_stream->proxy_ref->traffic_steering_options.enable_steering_ssl)
- ))
+ if (_stream->is_decrypted_traffic_steering)
{
__stream_fd_option_setup(_stream, fd_fake_s, CONN_DIR_DOWNSTREAM);
__stream_fd_option_setup(_stream, fd_fake_c, CONN_DIR_UPSTREAM);
@@ -1838,7 +1834,7 @@ int tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downst
__conn_private_enable(_stream->conn_downstream);
__conn_private_enable(_stream->conn_upstream);
- if (steering_device_is_available() && _stream->proxy_ref->traffic_steering_options.enable_steering_http)
+ if (_stream->is_decrypted_traffic_steering)
{
__conn_private_enable(_stream->conn_fake_s);
__conn_private_enable(_stream->conn_fake_c);