diff --git a/src/core/cfg.lex b/src/core/cfg.lex index 6f63f5c9c30..e5e269ebc06 100644 --- a/src/core/cfg.lex +++ b/src/core/cfg.lex @@ -424,6 +424,7 @@ TCP_OPT_ACCEPT_HAPROXY "tcp_accept_haproxy" TCP_CLONE_RCVBUF "tcp_clone_rcvbuf" TCP_REUSE_PORT "tcp_reuse_port" TCP_WAIT_DATA "tcp_wait_data" +TCP_SCRIPT_MODE "tcp_script_mode" DISABLE_TLS "disable_tls"|"tls_disable" ENABLE_TLS "enable_tls"|"tls_enable" TLSLOG "tlslog"|"tls_log" @@ -921,6 +922,7 @@ IMPORTFILE "import_file" {TCP_REUSE_PORT} { count(); yylval.strval=yytext; return TCP_REUSE_PORT; } {TCP_WAIT_DATA} { count(); yylval.strval=yytext; return TCP_WAIT_DATA; } +{TCP_SCRIPT_MODE} { count(); yylval.strval=yytext; return TCP_SCRIPT_MODE; } {DISABLE_TLS} { count(); yylval.strval=yytext; return DISABLE_TLS; } {ENABLE_TLS} { count(); yylval.strval=yytext; return ENABLE_TLS; } {TLSLOG} { count(); yylval.strval=yytext; return TLS_PORT_NO; } diff --git a/src/core/cfg.y b/src/core/cfg.y index d1ba90e5446..7db37bbc09a 100644 --- a/src/core/cfg.y +++ b/src/core/cfg.y @@ -453,6 +453,7 @@ extern char *default_routename; %token TCP_CLONE_RCVBUF %token TCP_REUSE_PORT %token TCP_WAIT_DATA +%token TCP_SCRIPT_MODE %token DISABLE_TLS %token ENABLE_TLS %token TLSLOG @@ -1329,6 +1330,14 @@ assign_stm: #endif } | TCP_WAIT_DATA EQUAL error { yyerror("number expected"); } + | TCP_SCRIPT_MODE EQUAL intno { + #ifdef USE_TCP + ksr_tcp_script_mode=$3; + #else + warn("tcp support not compiled in"); + #endif + } + | TCP_SCRIPT_MODE EQUAL error { yyerror("number expected"); } | DISABLE_TLS EQUAL NUMBER { #ifdef USE_TLS tls_disable=$3; diff --git a/src/core/globals.h b/src/core/globals.h index 3a104391426..a4857cbf0ca 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -103,6 +103,7 @@ extern int tls_max_connections; /* maximum tls connections, hard limit */ #endif extern int ksr_tcp_accept_hep3; extern int ksr_tcp_accept_haproxy; +extern int ksr_tcp_script_mode; #ifdef USE_TLS extern int tls_disable; extern unsigned short tls_port_no; diff --git a/src/core/tcp_read.c b/src/core/tcp_read.c index 0adbf89dfda..3a22bae7c57 100644 --- a/src/core/tcp_read.c +++ b/src/core/tcp_read.c @@ -94,6 +94,10 @@ int is_msg_complete(struct tcp_req* r); int ksr_tcp_accept_hep3=0; int ksr_tcp_accept_haproxy=0; + +#define TCP_SCRIPT_MODE_CONTINUE (1<<0) +int ksr_tcp_script_mode=0; + /** * control cloning of TCP receive buffer * - needed for operations working directly inside the buffer @@ -1342,6 +1346,7 @@ static int hep3_process_msg(char* tcpbuf, unsigned int len, int receive_tcp_msg(char* tcpbuf, unsigned int len, struct receive_info* rcv_info, struct tcp_connection* con) { + int ret = 0; #ifdef TCP_CLONE_RCVBUF static char *buf = NULL; static unsigned int bsize = 0; @@ -1360,7 +1365,11 @@ int receive_tcp_msg(char* tcpbuf, unsigned int len, if(unlikely(con->req.flags&F_TCP_REQ_HEP3)) return hep3_process_msg(tcpbuf, len, rcv_info, con); - return receive_msg(tcpbuf, len, rcv_info); + ret = receive_msg(tcpbuf, len, rcv_info); + if (ksr_tcp_script_mode&TCP_SCRIPT_MODE_CONTINUE) { + return 0; + } + return ret; } /* min buffer size is BUF_SIZE */ @@ -1401,7 +1410,11 @@ int receive_tcp_msg(char* tcpbuf, unsigned int len, #endif if(unlikely(con->req.flags&F_TCP_REQ_HEP3)) return hep3_process_msg(tcpbuf, len, rcv_info, con); - return receive_msg(buf, len, rcv_info); + ret = receive_msg(buf, len, rcv_info); + if (ksr_tcp_script_mode&TCP_SCRIPT_MODE_CONTINUE) { + return 0; + } + return ret; #else /* TCP_CLONE_RCVBUF */ #ifdef READ_MSRP if(unlikely(con->req.flags&F_TCP_REQ_MSRP_FRAME)) @@ -1413,7 +1426,11 @@ int receive_tcp_msg(char* tcpbuf, unsigned int len, #endif if(unlikely(con->req.flags&F_TCP_REQ_HEP3)) return hep3_process_msg(tcpbuf, len, rcv_info, con); - return receive_msg(tcpbuf, len, rcv_info); + ret = receive_msg(tcpbuf, len, rcv_info); + if (ksr_tcp_script_mode&TCP_SCRIPT_MODE_CONTINUE) { + return 0; + } + return ret; #endif /* TCP_CLONE_RCVBUF */ }