Skip to content

Commit

Permalink
Stream: allow servers with no handler.
Browse files Browse the repository at this point in the history
Previously handlers were mandatory.  However they are not always needed.
For example, a server configured with ssl_reject_handshake does not need a
handler.  Such servers required a fake handler to pass the check.  Now handler
absence check is moved to runtime.  If handler is missing, the connection is
closed with 500 code.
  • Loading branch information
arut committed Jun 27, 2024
1 parent e734df6 commit 788e462
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/stream/ngx_stream_core_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ ngx_stream_core_content_phase(ngx_stream_session_t *s,
return NGX_OK;
}

if (cscf->handler == NULL) {
ngx_log_debug0(NGX_LOG_DEBUG_STREAM, c->log, 0,
"no handler for server");
ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR);
return NGX_OK;
}

cscf->handler(s);

return NGX_OK;
Expand Down Expand Up @@ -734,13 +741,6 @@ ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
conf->resolver = prev->resolver;
}

if (conf->handler == NULL) {
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
"no handler for server in %s:%ui",
conf->file_name, conf->line);
return NGX_CONF_ERROR;
}

if (conf->error_log == NULL) {
if (prev->error_log) {
conf->error_log = prev->error_log;
Expand Down

0 comments on commit 788e462

Please sign in to comment.