]> git.kaiwu.me - nginx.git/commitdiff
Stream pass: disabled passing from or to udp.
authorRoman Arutyunyan <arut@nginx.com>
Fri, 3 May 2024 16:26:05 +0000 (20:26 +0400)
committerRoman Arutyunyan <arut@nginx.com>
Fri, 3 May 2024 16:26:05 +0000 (20:26 +0400)
Passing from udp was not possible for the most part due to preread buffer
restriction.  Passing to udp could occasionally work, but the connection would
still be bound to the original listen rbtree, which prevented it from being
deleted on connection closure.

src/stream/ngx_stream_pass_module.c

index 2c1c60c6a830742b41cb1ef9c08d5a04351e4b1c..1d671087c33ad934566bc2631fade9fd30f2b601 100644 (file)
@@ -83,6 +83,11 @@ ngx_stream_pass_handler(ngx_stream_session_t *s)
 
     c->log->action = "passing connection to port";
 
+    if (c->type == SOCK_DGRAM) {
+        ngx_log_error(NGX_LOG_ERR, c->log, 0, "cannot pass udp connection");
+        goto failed;
+    }
+
     if (c->buffer && c->buffer->pos != c->buffer->last) {
         ngx_log_error(NGX_LOG_ERR, c->log, 0,
                       "cannot pass connection with preread data");
@@ -217,6 +222,10 @@ ngx_stream_pass_cleanup(void *data)
 static ngx_int_t
 ngx_stream_pass_match(ngx_listening_t *ls, ngx_addr_t *addr)
 {
+    if (ls->type == SOCK_DGRAM) {
+        return NGX_DECLINED;
+    }
+
     if (!ls->wildcard) {
         return ngx_cmp_sockaddr(ls->sockaddr, ls->socklen,
                                 addr->sockaddr, addr->socklen, 1);