fix: stream proxy patch

pull/1045/head
耗子 3 weeks ago
parent 2d2a909b06
commit 3111d772ce
No known key found for this signature in database
GPG Key ID: C964D7226D045DAA

@ -521,7 +521,7 @@ index 1c6d0372e..0c8da3018 100644
ngx_mail_proxy_internal_server_error(s); ngx_mail_proxy_internal_server_error(s);
return NGX_ERROR; return NGX_ERROR;
diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
index 6e51585f6..6dfd960ef 100644 index 0dbbc5af6..3bc99f760 100644
--- a/src/stream/ngx_stream_proxy_module.c --- a/src/stream/ngx_stream_proxy_module.c
+++ b/src/stream/ngx_stream_proxy_module.c +++ b/src/stream/ngx_stream_proxy_module.c
@@ -30,7 +30,7 @@ typedef struct { @@ -30,7 +30,7 @@ typedef struct {
@ -561,7 +561,7 @@ index 6e51585f6..6dfd960ef 100644
{ ngx_string("proxy_half_close"), { ngx_string("proxy_half_close"),
NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG, NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG,
@@ -925,7 +933,7 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) @@ -940,7 +948,7 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
return; return;
} }
@ -570,7 +570,7 @@ index 6e51585f6..6dfd960ef 100644
if (p == NULL) { if (p == NULL) {
ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
return; return;
@@ -933,8 +941,8 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) @@ -948,8 +956,8 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
cl->buf->pos = p; cl->buf->pos = p;
@ -581,15 +581,16 @@ index 6e51585f6..6dfd960ef 100644
if (p == NULL) { if (p == NULL) {
ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
return; return;
@@ -978,22 +986,22 @@ ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s) @@ -989,7 +997,7 @@ static ngx_int_t
ngx_connection_t *c, *pc; ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s)
ngx_stream_upstream_t *u; {
ngx_stream_proxy_srv_conf_t *pscf; u_char *p;
- u_char buf[NGX_PROXY_PROTOCOL_V1_MAX_HEADER]; - u_char buf[NGX_PROXY_PROTOCOL_V1_MAX_HEADER];
+ u_char buf[NGX_PROXY_PROTOCOL_MAX_HEADER]; + u_char buf[NGX_PROXY_PROTOCOL_MAX_HEADER];
ssize_t n, size;
c = s->connection; ngx_connection_t *c, *pc;
ngx_stream_upstream_t *u;
@@ -1002,15 +1010,15 @@ ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s)
ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0,
"stream proxy send PROXY protocol header"); "stream proxy send PROXY protocol header");
@ -609,7 +610,7 @@ index 6e51585f6..6dfd960ef 100644
pc = u->peer.connection; pc = u->peer.connection;
size = p - buf; size = p - buf;
@@ -2213,7 +2221,7 @@ ngx_stream_proxy_create_srv_conf(ngx_conf_t *cf) @@ -2237,7 +2245,7 @@ ngx_stream_proxy_create_srv_conf(ngx_conf_t *cf)
conf->responses = NGX_CONF_UNSET_UINT; conf->responses = NGX_CONF_UNSET_UINT;
conf->next_upstream_tries = NGX_CONF_UNSET_UINT; conf->next_upstream_tries = NGX_CONF_UNSET_UINT;
conf->next_upstream = NGX_CONF_UNSET; conf->next_upstream = NGX_CONF_UNSET;
@ -618,7 +619,7 @@ index 6e51585f6..6dfd960ef 100644
conf->local = NGX_CONF_UNSET_PTR; conf->local = NGX_CONF_UNSET_PTR;
conf->socket_keepalive = NGX_CONF_UNSET; conf->socket_keepalive = NGX_CONF_UNSET;
conf->half_close = NGX_CONF_UNSET; conf->half_close = NGX_CONF_UNSET;
@@ -2269,7 +2277,7 @@ ngx_stream_proxy_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) @@ -2293,7 +2301,7 @@ ngx_stream_proxy_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->next_upstream, prev->next_upstream, 1); ngx_conf_merge_value(conf->next_upstream, prev->next_upstream, 1);

@ -1,7 +1,8 @@
diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream.h nginx-1.28.0-patched/src/stream/ngx_stream.h diff --git a/src/stream/ngx_stream.h b/src/stream/ngx_stream.h
--- nginx-1.28.0/src/stream/ngx_stream.h 2021-11-04 21:27:55.288708527 +0800 index dc05dc5ba..3b76e0117 100644
+++ nginx-1.28.0-patched/src/stream/ngx_stream.h 2021-11-04 21:28:50.768035209 +0800 --- a/src/stream/ngx_stream.h
@@ -254,6 +254,15 @@ typedef struct { +++ b/src/stream/ngx_stream.h
@@ -311,6 +311,15 @@ typedef struct {
} ngx_stream_module_t; } ngx_stream_module_t;
@ -17,7 +18,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream.h nginx-1.28.0-patched/sr
#define NGX_STREAM_MODULE 0x4d525453 /* "STRM" */ #define NGX_STREAM_MODULE 0x4d525453 /* "STRM" */
#define NGX_STREAM_MAIN_CONF 0x02000000 #define NGX_STREAM_MAIN_CONF 0x02000000
@@ -307,6 +316,7 @@ void ngx_stream_finalize_session(ngx_str @@ -371,6 +380,7 @@ void ngx_stream_finalize_session(ngx_stream_session_t *s, ngx_uint_t rc);
extern ngx_module_t ngx_stream_module; extern ngx_module_t ngx_stream_module;
extern ngx_uint_t ngx_stream_max_module; extern ngx_uint_t ngx_stream_max_module;
extern ngx_module_t ngx_stream_core_module; extern ngx_module_t ngx_stream_core_module;
@ -25,10 +26,11 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream.h nginx-1.28.0-patched/sr
typedef ngx_int_t (*ngx_stream_filter_pt)(ngx_stream_session_t *s, typedef ngx_int_t (*ngx_stream_filter_pt)(ngx_stream_session_t *s,
diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28.0-patched/src/stream/ngx_stream_proxy_module.c diff --git a/src/stream/ngx_stream_proxy_module.c b/src/stream/ngx_stream_proxy_module.c
--- nginx-1.28.0/src/stream/ngx_stream_proxy_module.c 2021-11-04 21:27:55.289708533 +0800 index 6e51585f6..0dbbc5af6 100644
+++ nginx-1.28.0-patched/src/stream/ngx_stream_proxy_module.c 2021-11-04 21:37:03.578936990 +0800 --- a/src/stream/ngx_stream_proxy_module.c
@@ -400,6 +400,7 @@ ngx_stream_proxy_handler(ngx_stream_sess +++ b/src/stream/ngx_stream_proxy_module.c
@@ -414,6 +414,7 @@ ngx_stream_proxy_handler(ngx_stream_session_t *s)
ngx_stream_proxy_srv_conf_t *pscf; ngx_stream_proxy_srv_conf_t *pscf;
ngx_stream_upstream_srv_conf_t *uscf, **uscfp; ngx_stream_upstream_srv_conf_t *uscf, **uscfp;
ngx_stream_upstream_main_conf_t *umcf; ngx_stream_upstream_main_conf_t *umcf;
@ -36,7 +38,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
c = s->connection; c = s->connection;
@@ -408,6 +409,17 @@ ngx_stream_proxy_handler(ngx_stream_sess @@ -422,6 +423,17 @@ ngx_stream_proxy_handler(ngx_stream_session_t *s)
ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0, ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0,
"proxy connection handler"); "proxy connection handler");
@ -54,7 +56,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
u = ngx_pcalloc(c->pool, sizeof(ngx_stream_upstream_t)); u = ngx_pcalloc(c->pool, sizeof(ngx_stream_upstream_t));
if (u == NULL) { if (u == NULL) {
ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR); ngx_stream_proxy_finalize(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
@@ -699,6 +711,7 @@ ngx_stream_proxy_connect(ngx_stream_sess @@ -713,6 +725,7 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
ngx_connection_t *c, *pc; ngx_connection_t *c, *pc;
ngx_stream_upstream_t *u; ngx_stream_upstream_t *u;
ngx_stream_proxy_srv_conf_t *pscf; ngx_stream_proxy_srv_conf_t *pscf;
@ -62,7 +64,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
c = s->connection; c = s->connection;
@@ -706,6 +719,8 @@ ngx_stream_proxy_connect(ngx_stream_sess @@ -720,6 +733,8 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module); pscf = ngx_stream_get_module_srv_conf(s, ngx_stream_proxy_module);
@ -71,7 +73,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
u = s->upstream; u = s->upstream;
u->connected = 0; u->connected = 0;
@@ -774,7 +789,7 @@ ngx_stream_proxy_connect(ngx_stream_sess @@ -802,7 +817,7 @@ ngx_stream_proxy_connect(ngx_stream_session_t *s)
pc->read->handler = ngx_stream_proxy_connect_handler; pc->read->handler = ngx_stream_proxy_connect_handler;
pc->write->handler = ngx_stream_proxy_connect_handler; pc->write->handler = ngx_stream_proxy_connect_handler;
@ -80,7 +82,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
} }
@@ -957,12 +957,14 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s) @@ -973,12 +988,14 @@ ngx_stream_proxy_init_upstream(ngx_stream_session_t *s)
static ngx_int_t static ngx_int_t
ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s) ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s)
{ {
@ -101,7 +103,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
c = s->connection; c = s->connection;
@@ -976,9 +993,7 @@ ngx_stream_proxy_send_proxy_protocol(ngx @@ -1006,9 +1023,7 @@ ngx_stream_proxy_send_proxy_protocol(ngx_stream_session_t *s)
return NGX_ERROR; return NGX_ERROR;
} }
@ -112,7 +114,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
pc->write->handler = ngx_stream_proxy_connect_handler; pc->write->handler = ngx_stream_proxy_connect_handler;
@@ -1053,6 +1068,9 @@ ngx_stream_proxy_ssl_init_connection(ngx @@ -1177,6 +1192,9 @@ ngx_stream_proxy_ssl_init_connection(ngx_stream_session_t *s)
ngx_connection_t *pc; ngx_connection_t *pc;
ngx_stream_upstream_t *u; ngx_stream_upstream_t *u;
ngx_stream_proxy_srv_conf_t *pscf; ngx_stream_proxy_srv_conf_t *pscf;
@ -122,7 +124,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
u = s->upstream; u = s->upstream;
@@ -1099,7 +1117,7 @@ ngx_stream_proxy_ssl_init_connection(ngx @@ -1225,7 +1243,7 @@ ngx_stream_proxy_ssl_init_connection(ngx_stream_session_t *s)
if (rc == NGX_AGAIN) { if (rc == NGX_AGAIN) {
if (!pc->write->timer_set) { if (!pc->write->timer_set) {
@ -131,7 +133,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
} }
pc->ssl->handler = ngx_stream_proxy_ssl_handshake; pc->ssl->handler = ngx_stream_proxy_ssl_handshake;
@@ -1408,6 +1426,7 @@ ngx_stream_proxy_process_connection(ngx_ @@ -1535,6 +1553,7 @@ ngx_stream_proxy_process_connection(ngx_event_t *ev, ngx_uint_t from_upstream)
ngx_stream_session_t *s; ngx_stream_session_t *s;
ngx_stream_upstream_t *u; ngx_stream_upstream_t *u;
ngx_stream_proxy_srv_conf_t *pscf; ngx_stream_proxy_srv_conf_t *pscf;
@ -139,7 +141,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
c = ev->data; c = ev->data;
s = c->data; s = c->data;
@@ -1419,6 +1438,8 @@ ngx_stream_proxy_process_connection(ngx_ @@ -1546,6 +1565,8 @@ ngx_stream_proxy_process_connection(ngx_event_t *ev, ngx_uint_t from_upstream)
return; return;
} }
@ -148,7 +150,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
c = s->connection; c = s->connection;
pc = u->peer.connection; pc = u->peer.connection;
@@ -1438,7 +1459,7 @@ ngx_stream_proxy_process_connection(ngx_ @@ -1565,7 +1586,7 @@ ngx_stream_proxy_process_connection(ngx_event_t *ev, ngx_uint_t from_upstream)
} }
if (u->connected && !c->read->delayed && !pc->read->delayed) { if (u->connected && !c->read->delayed && !pc->read->delayed) {
@ -157,7 +159,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
} }
return; return;
@@ -1600,6 +1621,9 @@ ngx_stream_proxy_process(ngx_stream_sess @@ -1727,6 +1748,9 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
ngx_log_handler_pt handler; ngx_log_handler_pt handler;
ngx_stream_upstream_t *u; ngx_stream_upstream_t *u;
ngx_stream_proxy_srv_conf_t *pscf; ngx_stream_proxy_srv_conf_t *pscf;
@ -167,7 +169,7 @@ diff -u -r -p -Naur nginx-1.28.0/src/stream/ngx_stream_proxy_module.c nginx-1.28
u = s->upstream; u = s->upstream;
@@ -1807,7 +1831,7 @@ ngx_stream_proxy_process(ngx_stream_sess @@ -1918,7 +1942,7 @@ ngx_stream_proxy_process(ngx_stream_session_t *s, ngx_uint_t from_upstream,
} }
if (!c->read->delayed && !pc->read->delayed) { if (!c->read->delayed && !pc->read->delayed) {

Loading…
Cancel
Save