diff src/stream/ngx_stream_core_module.c @ 8482:893b3313f53c quic

QUIC: added "quic" listen parameter in Stream. Also, introduced ngx_stream_quic_module.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 21 Jul 2020 23:08:39 +0300
parents 4f9b72a229c1
children 279ad36f2f4b
line wrap: on
line diff
--- a/src/stream/ngx_stream_core_module.c
+++ b/src/stream/ngx_stream_core_module.c
@@ -325,6 +325,9 @@ ngx_stream_core_content_phase(ngx_stream
     cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module);
 
     if (c->type == SOCK_STREAM
+#if (NGX_STREAM_QUIC)
+        && c->qs == NULL
+#endif
         && cscf->tcp_nodelay
         && ngx_tcp_nodelay(c) != NGX_OK)
     {
@@ -741,6 +744,29 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
 #endif
         }
 
+        if (ngx_strcmp(value[i].data, "quic") == 0) {
+#if (NGX_STREAM_QUIC)
+            ngx_stream_ssl_conf_t  *sslcf;
+
+            sslcf = ngx_stream_conf_get_module_srv_conf(cf,
+                                                        ngx_stream_ssl_module);
+
+            sslcf->listen = 1;
+            sslcf->file = cf->conf_file->file.name.data;
+            sslcf->line = cf->conf_file->line;
+
+            ls->quic = 1;
+            ls->type = SOCK_DGRAM;
+
+            continue;
+#else
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "the \"quic\" parameter requires "
+                               "ngx_stream_quic_module");
+            return NGX_CONF_ERROR;
+#endif
+        }
+
         if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) {
 
             if (ngx_strcmp(&value[i].data[13], "on") == 0) {
@@ -852,6 +878,12 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
         }
 #endif
 
+#if (NGX_STREAM_SSL && NGX_STREAM_QUIC)
+        if (ls->ssl && ls->quic) {
+            return "\"ssl\" parameter is incompatible with \"quic\"";
+        }
+#endif
+
         if (ls->so_keepalive) {
             return "\"so_keepalive\" parameter is incompatible with \"udp\"";
         }