From c56fd73def3eb407155ecebc28af84ea83dc99e5 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Wed, 3 Apr 2024 10:22:00 +0400 Subject: [PATCH 1/4] Fixed unused variable warining. --- ngx_rtmp_eval.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ngx_rtmp_eval.c b/ngx_rtmp_eval.c index a92a86318..6c2143f07 100644 --- a/ngx_rtmp_eval.c +++ b/ngx_rtmp_eval.c @@ -84,12 +84,11 @@ static void ngx_rtmp_eval_append_var(void *ctx, ngx_buf_t *b, ngx_rtmp_eval_t **e, ngx_str_t *name, ngx_log_t *log) { - ngx_uint_t k; ngx_str_t v; ngx_rtmp_eval_t *ee; for (; *e; ++e) { - for (k = 0, ee = *e; ee->handler; ++k, ++ee) { + for (ee = *e; ee->handler; ++ee) { if (ee->name.len == name->len && ngx_memcmp(ee->name.data, name->data, name->len) == 0) { From 6f9fa49a2fdc02916a27bd58887c4644e2acae44 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Wed, 3 Apr 2024 11:09:46 +0400 Subject: [PATCH 2/4] Added propagation of the "wildcard" flag to c->listening. The change repeats nginx commit cb149fa03367 and is needed for stream pass module to be able to pass connections to rtmp. --- ngx_rtmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ngx_rtmp.c b/ngx_rtmp.c index 7d504a042..cde743202 100644 --- a/ngx_rtmp.c +++ b/ngx_rtmp.c @@ -645,6 +645,8 @@ ngx_rtmp_optimize_servers(ngx_conf_t *cf, ngx_array_t *ports) ls->ipv6only = addr[i].ipv6only; #endif + ls->wildcard = addr[i].wildcard; + mport = ngx_palloc(cf->pool, sizeof(ngx_rtmp_port_t)); if (mport == NULL) { return NGX_CONF_ERROR; From 2fb11dffaedc5af66b1442b0315c54a4b9da585d Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Wed, 3 Apr 2024 11:24:47 +0400 Subject: [PATCH 3/4] SSL shutdown for rtmps. While rtmp module does not support SSL, starting from nginx 1.25.5 an SSL connection can be passed from nginx stream pass module. Such connections should be shut down on connection closure. An rtmps example: rtmp { server { listen 1935; # rtmp application foo { live on; } } } stream { server { listen 1936 ssl; # rtmps ssl_certificate example.com.crt; ssl_certificate_key example.com.key; pass 127.0.0.1:1935; } } --- ngx_rtmp_init.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ngx_rtmp_init.c b/ngx_rtmp_init.c index 3f54169dd..459406d30 100644 --- a/ngx_rtmp_init.c +++ b/ngx_rtmp_init.c @@ -258,6 +258,17 @@ ngx_rtmp_close_connection(ngx_connection_t *c) ngx_log_debug0(NGX_LOG_DEBUG_RTMP, c->log, 0, "close connection"); +#if (NGX_SSL) + + if (c->ssl) { + if (ngx_ssl_shutdown(c) == NGX_AGAIN) { + c->ssl->handler = ngx_rtmp_close_connection; + return; + } + } + +#endif + #if (NGX_STAT_STUB) (void) ngx_atomic_fetch_add(ngx_stat_active, -1); #endif From 6c7719d0ba32e00b563ec70bd43dad11960fa9c4 Mon Sep 17 00:00:00 2001 From: Roman Arutyunyan Date: Tue, 24 Dec 2024 14:27:05 +0400 Subject: [PATCH 4/4] Fixed compilation with clang. Thanks to Dmitry Tsidilin. --- ngx_rtmp_handler.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ngx_rtmp_handler.c b/ngx_rtmp_handler.c index f42a3bbf9..b3f12e046 100644 --- a/ngx_rtmp_handler.c +++ b/ngx_rtmp_handler.c @@ -570,7 +570,10 @@ ngx_rtmp_prepare_message(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, { ngx_chain_t *l; u_char *p, *pp; - ngx_int_t hsize, thsize, nbufs; + ngx_int_t hsize, thsize; +#if (NGX_DEBUG) + ngx_int_t nbufs; +#endif uint32_t mlen, timestamp, ext_timestamp; static uint8_t hdrsize[] = { 12, 8, 4, 1 }; u_char th[7]; @@ -591,10 +594,14 @@ ngx_rtmp_prepare_message(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h, /* detect packet size */ mlen = 0; +#if (NGX_DEBUG) nbufs = 0; +#endif for(l = out; l; l = l->next) { mlen += (l->buf->last - l->buf->pos); +#if (NGX_DEBUG) ++nbufs; +#endif } fmt = 0;