comparison src/http/v2/ngx_http_v2.c @ 7656:7114d21bc2b1

HTTP/2: invalid connection preface logging (ticket #1981). Previously, invalid connection preface errors were only logged at debug level, providing no visible feedback, in particular, when a plain text HTTP/2 listening socket is erroneously used for HTTP/1.x connections. Now these are explicitly logged at the info level, much like other client-related errors.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 25 May 2020 18:33:42 +0300
parents 72b792bb3885
children c5840ca2063d
comparison
equal deleted inserted replaced
7655:bd4d1b9db0ee 7656:7114d21bc2b1
729 if ((size_t) (end - pos) < sizeof(preface) - 1) { 729 if ((size_t) (end - pos) < sizeof(preface) - 1) {
730 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_preface); 730 return ngx_http_v2_state_save(h2c, pos, end, ngx_http_v2_state_preface);
731 } 731 }
732 732
733 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) { 733 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) {
734 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 734 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
735 "invalid http2 connection preface \"%*s\"", 735 "invalid connection preface");
736 sizeof(preface) - 1, pos);
737 736
738 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); 737 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
739 } 738 }
740 739
741 return ngx_http_v2_state_preface_end(h2c, pos + sizeof(preface) - 1, end); 740 return ngx_http_v2_state_preface_end(h2c, pos + sizeof(preface) - 1, end);
752 return ngx_http_v2_state_save(h2c, pos, end, 751 return ngx_http_v2_state_save(h2c, pos, end,
753 ngx_http_v2_state_preface_end); 752 ngx_http_v2_state_preface_end);
754 } 753 }
755 754
756 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) { 755 if (ngx_memcmp(pos, preface, sizeof(preface) - 1) != 0) {
757 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 756 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
758 "invalid http2 connection preface \"%*s\"", 757 "invalid connection preface");
759 sizeof(preface) - 1, pos);
760 758
761 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR); 759 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_PROTOCOL_ERROR);
762 } 760 }
763 761
764 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 762 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,