clang-format-5.0

This commit is contained in:
Tatsuhiro Tsujikawa 2017-11-23 14:19:12 +09:00
parent fee3151fd2
commit ff200bfcf3
33 changed files with 167 additions and 154 deletions

View File

@ -70,7 +70,9 @@
#define NGHTTP2_MAX_PADLEN 256 #define NGHTTP2_MAX_PADLEN 256
/* Union of extension frame payload */ /* Union of extension frame payload */
typedef union { nghttp2_ext_altsvc altsvc; } nghttp2_ext_frame_payload; typedef union {
nghttp2_ext_altsvc altsvc;
} nghttp2_ext_frame_payload;
void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd); void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd);

View File

@ -211,7 +211,9 @@ typedef struct {
#define HD_MAP_SIZE 128 #define HD_MAP_SIZE 128
typedef struct { nghttp2_hd_entry *table[HD_MAP_SIZE]; } nghttp2_hd_map; typedef struct {
nghttp2_hd_entry *table[HD_MAP_SIZE];
} nghttp2_hd_map;
struct nghttp2_hd_deflater { struct nghttp2_hd_deflater {
nghttp2_hd_context ctx; nghttp2_hd_context ctx;

View File

@ -35,7 +35,9 @@
/* Implementation of priority queue */ /* Implementation of priority queue */
typedef struct { size_t index; } nghttp2_pq_entry; typedef struct {
size_t index;
} nghttp2_pq_entry;
typedef struct { typedef struct {
/* The pointer to the pointer to the item stored */ /* The pointer to the pointer to the item stored */

View File

@ -36,7 +36,9 @@ typedef struct nghttp2_queue_cell {
struct nghttp2_queue_cell *next; struct nghttp2_queue_cell *next;
} nghttp2_queue_cell; } nghttp2_queue_cell;
typedef struct { nghttp2_queue_cell *front, *back; } nghttp2_queue; typedef struct {
nghttp2_queue_cell *front, *back;
} nghttp2_queue;
void nghttp2_queue_init(nghttp2_queue *queue); void nghttp2_queue_init(nghttp2_queue *queue);
void nghttp2_queue_free(nghttp2_queue *queue); void nghttp2_queue_free(nghttp2_queue *queue);

View File

@ -548,9 +548,8 @@ static int session_new(nghttp2_session **session_ptr,
if (nghttp2_enable_strict_preface) { if (nghttp2_enable_strict_preface) {
nghttp2_inbound_frame *iframe = &(*session_ptr)->iframe; nghttp2_inbound_frame *iframe = &(*session_ptr)->iframe;
if (server && if (server && ((*session_ptr)->opt_flags &
((*session_ptr)->opt_flags & NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC) == NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC) == 0) {
0) {
iframe->state = NGHTTP2_IB_READ_CLIENT_MAGIC; iframe->state = NGHTTP2_IB_READ_CLIENT_MAGIC;
iframe->payloadleft = NGHTTP2_CLIENT_MAGIC_LEN; iframe->payloadleft = NGHTTP2_CLIENT_MAGIC_LEN;
} else { } else {
@ -5602,8 +5601,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
iframe->max_niv = iframe->max_niv =
iframe->frame.hd.length / NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH + 1; iframe->frame.hd.length / NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH + 1;
iframe->iv = nghttp2_mem_malloc( iframe->iv = nghttp2_mem_malloc(mem, sizeof(nghttp2_settings_entry) *
mem, sizeof(nghttp2_settings_entry) * iframe->max_niv); iframe->max_niv);
if (!iframe->iv) { if (!iframe->iv) {
return NGHTTP2_ERR_NOMEM; return NGHTTP2_ERR_NOMEM;

View File

@ -366,8 +366,9 @@ static void check_queued(nghttp2_stream *stream) {
} }
} }
if (queued == 0) { if (queued == 0) {
fprintf(stderr, "stream(%p)=%d, stream->queued == 1, and " fprintf(stderr,
"!stream_active(), but no descendants is queued\n", "stream(%p)=%d, stream->queued == 1, and "
"!stream_active(), but no descendants is queued\n",
stream, stream->stream_id); stream, stream->stream_id);
assert(0); assert(0);
} }
@ -378,9 +379,10 @@ static void check_queued(nghttp2_stream *stream) {
} }
} else { } else {
if (stream_active(stream) || !nghttp2_pq_empty(&stream->obq)) { if (stream_active(stream) || !nghttp2_pq_empty(&stream->obq)) {
fprintf(stderr, "stream(%p) = %d, stream->queued == 0, but " fprintf(stderr,
"stream_active(stream) == %d and " "stream(%p) = %d, stream->queued == 0, but "
"nghttp2_pq_size(&stream->obq) = %zu\n", "stream_active(stream) == %d and "
"nghttp2_pq_size(&stream->obq) = %zu\n",
stream, stream->stream_id, stream_active(stream), stream, stream->stream_id, stream_active(stream),
nghttp2_pq_size(&stream->obq)); nghttp2_pq_size(&stream->obq));
assert(0); assert(0);

View File

@ -2156,7 +2156,7 @@ int HttpServer::run() {
} }
SSL_CTX_set_tmp_ecdh(ssl_ctx, ecdh); SSL_CTX_set_tmp_ecdh(ssl_ctx, ecdh);
EC_KEY_free(ecdh); EC_KEY_free(ecdh);
// #endif // OPENSSL_VERSION_NUBMER < 0x10002000L // #endif // OPENSSL_VERSION_NUBMER < 0x10002000L
#endif // OPENSSL_NO_EC #endif // OPENSSL_NO_EC

View File

@ -273,6 +273,6 @@ ByteRef make_byte_ref(BlockAllocator &alloc, size_t size) {
return {dst, size}; return {dst, size};
} }
} // namespace aria2 } // namespace nghttp2
#endif // ALLOCATOR_H #endif // ALLOCATOR_H

View File

@ -155,7 +155,7 @@ void print_nv(nghttp2_nv *nva, size_t nvlen) {
print_nv(nva); print_nv(nva);
} }
} }
} // namelen } // namespace
void print_timer() { void print_timer() {
auto millis = get_timer(); auto millis = get_timer();
@ -327,8 +327,9 @@ void print_frame(print_type ptype, const nghttp2_frame *frame) {
break; break;
case NGHTTP2_GOAWAY: case NGHTTP2_GOAWAY:
print_frame_attr_indent(); print_frame_attr_indent();
fprintf(outfile, "(last_stream_id=%d, error_code=%s(0x%02x), " fprintf(outfile,
"opaque_data(%u)=[%s])\n", "(last_stream_id=%d, error_code=%s(0x%02x), "
"opaque_data(%u)=[%s])\n",
frame->goaway.last_stream_id, frame->goaway.last_stream_id,
nghttp2_http2_strerror(frame->goaway.error_code), nghttp2_http2_strerror(frame->goaway.error_code),
frame->goaway.error_code, frame->goaway.error_code,

View File

@ -140,4 +140,4 @@ const bool priority_spec::valid() const { return valid_; }
} // namespace client } // namespace client
} // namespace asio_http2 } // namespace asio_http2
} // nghttp2 } // namespace nghttp2

View File

@ -756,4 +756,4 @@ void session_impl::read_timeout(const boost::posix_time::time_duration &t) {
} // namespace client } // namespace client
} // namespace asio_http2 } // namespace asio_http2
} // nghttp2 } // namespace nghttp2

View File

@ -45,8 +45,9 @@ session_tls_impl::~session_tls_impl() {}
void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) { void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
auto self = std::static_pointer_cast<session_tls_impl>(shared_from_this()); auto self = std::static_pointer_cast<session_tls_impl>(shared_from_this());
boost::asio::async_connect( boost::asio::async_connect(
socket(), endpoint_it, [self](const boost::system::error_code &ec, socket(), endpoint_it,
tcp::resolver::iterator endpoint_it) { [self](const boost::system::error_code &ec,
tcp::resolver::iterator endpoint_it) {
if (self->stopped()) { if (self->stopped()) {
return; return;
} }

View File

@ -169,6 +169,6 @@ private:
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2
} // namespace nghttp } // namespace nghttp2
#endif // ASIO_SERVER_HTTP2_HANDLER_H #endif // ASIO_SERVER_HTTP2_HANDLER_H

View File

@ -1828,12 +1828,10 @@ Options:
-c, --clients=<N> -c, --clients=<N>
Number of concurrent clients. With -r option, this Number of concurrent clients. With -r option, this
specifies the maximum number of connections to be made. specifies the maximum number of connections to be made.
Default: )" Default: )" << config.nclients << R"(
<< config.nclients << R"(
-t, --threads=<N> -t, --threads=<N>
Number of native threads. Number of native threads.
Default: )" Default: )" << config.nthreads << R"(
<< config.nthreads << R"(
-i, --input-file=<PATH> -i, --input-file=<PATH>
Path of a file with multiple URIs are separated by EOLs. Path of a file with multiple URIs are separated by EOLs.
This option will disable URIs getting from command-line. This option will disable URIs getting from command-line.
@ -1859,8 +1857,7 @@ Options:
(2**<N>)-1. For SPDY, if <N> is strictly less than 16, (2**<N>)-1. For SPDY, if <N> is strictly less than 16,
this option is ignored. Otherwise 2**<N> is used for this option is ignored. Otherwise 2**<N> is used for
SPDY. SPDY.
Default: )" Default: )" << config.connection_window_bits << R"(
<< config.connection_window_bits << R"(
-H, --header=<HEADER> -H, --header=<HEADER>
Add/Override a header to the requests. Add/Override a header to the requests.
--ciphers=<SUITE> --ciphers=<SUITE>
@ -1880,8 +1877,7 @@ Options:
Available protocols: )"; Available protocols: )";
#endif // !HAVE_SPDYLAY #endif // !HAVE_SPDYLAY
out << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"( and out << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"( and
)" )" << NGHTTP2_H1_1 << R"(
<< NGHTTP2_H1_1 << R"(
Default: )" Default: )"
<< NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"( << NGHTTP2_CLEARTEXT_PROTO_VERSION_ID << R"(
-d, --data=<PATH> -d, --data=<PATH>
@ -1964,8 +1960,7 @@ Options:
NPN. The parameter must be delimited by a single comma NPN. The parameter must be delimited by a single comma
only and any white spaces are treated as a part of only and any white spaces are treated as a part of
protocol string. protocol string.
Default: )" Default: )" << DEFAULT_NPN_LIST << R"(
<< DEFAULT_NPN_LIST << R"(
--h1 Short hand for --npn-list=http/1.1 --h1 Short hand for --npn-list=http/1.1
--no-tls-proto=http/1.1, which effectively force --no-tls-proto=http/1.1, which effectively force
http/1.1 for both http and https URI. http/1.1 for both http and https URI.
@ -1993,8 +1988,7 @@ Options:
The <DURATION> argument is an integer and an optional unit (e.g., 1s The <DURATION> argument is an integer and an optional unit (e.g., 1s
is 1 second and 500ms is 500 milliseconds). Units are h, m, s or ms is 1 second and 500ms is 500 milliseconds). Units are h, m, s or ms
(hours, minutes, seconds and milliseconds, respectively). If a unit (hours, minutes, seconds and milliseconds, respectively). If a unit
is omitted, a second is used as unit.)" is omitted, a second is used as unit.)" << std::endl;
<< std::endl;
} }
} // namespace } // namespace
@ -2762,14 +2756,14 @@ int main(int argc, char **argv) {
finished in )" finished in )"
<< util::format_duration(duration) << ", " << rps << " req/s, " << util::format_duration(duration) << ", " << rps << " req/s, "
<< util::utos_funit(bps) << R"(B/s << util::utos_funit(bps) << R"(B/s
requests: )" << stats.req_todo requests: )" << stats.req_todo << " total, "
<< " total, " << stats.req_started << " started, " << stats.req_done << stats.req_started << " started, " << stats.req_done << " done, "
<< " done, " << stats.req_status_success << " succeeded, " << stats.req_status_success << " succeeded, " << stats.req_failed
<< stats.req_failed << " failed, " << stats.req_error << " failed, " << stats.req_error << " errored, "
<< " errored, " << stats.req_timedout << R"( timeout << stats.req_timedout << R"( timeout
status codes: )" status codes: )" << stats.status[2] << " 2xx, "
<< stats.status[2] << " 2xx, " << stats.status[3] << " 3xx, " << stats.status[3] << " 3xx, " << stats.status[4] << " 4xx, "
<< stats.status[4] << " 4xx, " << stats.status[5] << R"( 5xx << stats.status[5] << R"( 5xx
traffic: )" << util::utos_funit(stats.bytes_total) traffic: )" << util::utos_funit(stats.bytes_total)
<< "B (" << stats.bytes_total << ") total, " << "B (" << stats.bytes_total << ") total, "
<< util::utos_funit(stats.bytes_head) << "B (" << stats.bytes_head << util::utos_funit(stats.bytes_head) << "B (" << stats.bytes_head
@ -2777,12 +2771,12 @@ traffic: )" << util::utos_funit(stats.bytes_total)
<< "%), " << util::utos_funit(stats.bytes_body) << "B (" << "%), " << util::utos_funit(stats.bytes_body) << "B ("
<< stats.bytes_body << R"() data << stats.bytes_body << R"() data
min max mean sd +/- sd min max mean sd +/- sd
time for request: )" time for request: )" << std::setw(10)
<< std::setw(10) << util::format_duration(ts.request.min) << " " << util::format_duration(ts.request.min) << " " << std::setw(10)
<< std::setw(10) << util::format_duration(ts.request.max) << " " << util::format_duration(ts.request.max) << " " << std::setw(10)
<< std::setw(10) << util::format_duration(ts.request.mean) << " " << util::format_duration(ts.request.mean) << " " << std::setw(10)
<< std::setw(10) << util::format_duration(ts.request.sd) << util::format_duration(ts.request.sd) << std::setw(9)
<< std::setw(9) << util::dtos(ts.request.within_sd) << "%" << util::dtos(ts.request.within_sd) << "%"
<< "\ntime for connect: " << std::setw(10) << "\ntime for connect: " << std::setw(10)
<< util::format_duration(ts.connect.min) << " " << std::setw(10) << util::format_duration(ts.connect.min) << " " << std::setw(10)
<< util::format_duration(ts.connect.max) << " " << std::setw(10) << util::format_duration(ts.connect.max) << " " << std::setw(10)

View File

@ -1624,9 +1624,9 @@ StringRef path_join(BlockAllocator &balloc, const StringRef &base_path,
const StringRef &base_query, const StringRef &rel_path, const StringRef &base_query, const StringRef &rel_path,
const StringRef &rel_query) { const StringRef &rel_query) {
auto res = make_byte_ref( auto res = make_byte_ref(
balloc, balloc, std::max(static_cast<size_t>(1), base_path.size()) +
std::max(static_cast<size_t>(1), base_path.size()) + rel_path.size() + 1 + rel_path.size() + 1 +
std::max(base_query.size(), rel_query.size()) + 1); std::max(base_query.size(), rel_query.size()) + 1);
auto p = res.base; auto p = res.base;
if (rel_path.empty()) { if (rel_path.empty()) {

View File

@ -48,7 +48,9 @@
namespace nghttp2 { namespace nghttp2 {
typedef struct { int dump_header_table; } inflate_config; typedef struct {
int dump_header_table;
} inflate_config;
static inflate_config config; static inflate_config config;

View File

@ -89,7 +89,11 @@ enum {
namespace { namespace {
constexpr auto anchors = std::array<Anchor, 5>{{ constexpr auto anchors = std::array<Anchor, 5>{{
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1}, {3, 0, 201},
{5, 0, 101},
{7, 0, 1},
{9, 7, 1},
{11, 3, 1},
}}; }};
} // namespace } // namespace

View File

@ -174,8 +174,7 @@ Options:
--mime-types-file=<PATH> --mime-types-file=<PATH>
Path to file that contains MIME media types and the Path to file that contains MIME media types and the
extensions that represent them. extensions that represent them.
Default: )" Default: )" << config.mime_types_file << R"(
<< config.mime_types_file << R"(
--no-content-length --no-content-length
Don't send content-length header field. Don't send content-length header field.
--version Display version information and exit. --version Display version information and exit.

View File

@ -1890,8 +1890,7 @@ Connections:
Performance: Performance:
-n, --workers=<N> -n, --workers=<N>
Set the number of worker threads. Set the number of worker threads.
Default: )" Default: )" << config->num_worker << R"(
<< config->num_worker << R"(
--single-thread --single-thread
Run everything in one thread inside the worker process. Run everything in one thread inside the worker process.
This feature is provided for better debugging This feature is provided for better debugging
@ -2073,8 +2072,7 @@ SSL/TLS:
--client-ciphers=<SUITE> --client-ciphers=<SUITE>
Set allowed cipher list for backend connection. The Set allowed cipher list for backend connection. The
format of the string is described in OpenSSL ciphers(1). format of the string is described in OpenSSL ciphers(1).
Default: )" Default: )" << config->tls.client.ciphers << R"(
<< config->tls.client.ciphers << R"(
--ecdh-curves=<LIST> --ecdh-curves=<LIST>
Set supported curve list for frontend connections. Set supported curve list for frontend connections.
<LIST> is a colon separated list of curve NID or names <LIST> is a colon separated list of curve NID or names
@ -2130,8 +2128,8 @@ SSL/TLS:
NPN. The parameter must be delimited by a single comma NPN. The parameter must be delimited by a single comma
only and any white spaces are treated as a part of only and any white spaces are treated as a part of
protocol string. protocol string.
Default: )" Default: )" << DEFAULT_NPN_LIST
<< DEFAULT_NPN_LIST << R"( << R"(
--verify-client --verify-client
Require and verify client certificate. Require and verify client certificate.
--verify-client-cacert=<PATH> --verify-client-cacert=<PATH>
@ -2157,12 +2155,13 @@ SSL/TLS:
TLSv1.2 or above. The available versions are: TLSv1.2 or above. The available versions are:
)" )"
#ifdef TLS1_3_VERSION #ifdef TLS1_3_VERSION
"TLSv1.3, " "TLSv1.3, "
#endif // TLS1_3_VERSION #endif // TLS1_3_VERSION
"TLSv1.2, TLSv1.1, and TLSv1.0" "TLSv1.2, TLSv1.1, and TLSv1.0"
R"( R"(
Default: )" Default: )"
<< DEFAULT_TLS_MIN_PROTO_VERSION << R"( << DEFAULT_TLS_MIN_PROTO_VERSION
<< R"(
--tls-max-proto-version=<VER> --tls-max-proto-version=<VER>
Specify maximum SSL/TLS protocol. The name matching is Specify maximum SSL/TLS protocol. The name matching is
done in case-insensitive manner. The versions between done in case-insensitive manner. The versions between
@ -2172,10 +2171,10 @@ SSL/TLS:
message "unknown protocol". The available versions are: message "unknown protocol". The available versions are:
)" )"
#ifdef TLS1_3_VERSION #ifdef TLS1_3_VERSION
"TLSv1.3, " "TLSv1.3, "
#endif // TLS1_3_VERSION #endif // TLS1_3_VERSION
"TLSv1.2, TLSv1.1, and TLSv1.0" "TLSv1.2, TLSv1.1, and TLSv1.0"
R"( R"(
Default: )" Default: )"
<< DEFAULT_TLS_MAX_PROTO_VERSION << R"( << DEFAULT_TLS_MAX_PROTO_VERSION << R"(
--tls-ticket-key-file=<PATH> --tls-ticket-key-file=<PATH>
@ -2531,8 +2530,7 @@ Logging:
Set path to write error log. To reopen file, send USR1 Set path to write error log. To reopen file, send USR1
signal to nghttpx. stderr will be redirected to the signal to nghttpx. stderr will be redirected to the
error log file unless --errorlog-syslog is used. error log file unless --errorlog-syslog is used.
Default: )" Default: )" << config->logging.error.file << R"(
<< config->logging.error.file << R"(
--errorlog-syslog --errorlog-syslog
Send error log to syslog. If this option is used, Send error log to syslog. If this option is used,
--errorlog-file option is ignored. --errorlog-file option is ignored.
@ -2664,8 +2662,8 @@ HTTP:
Specify the port number which appears in Location header Specify the port number which appears in Location header
field when redirect to HTTPS URI is made due to field when redirect to HTTPS URI is made due to
"redirect-if-not-tls" parameter in --backend option. "redirect-if-not-tls" parameter in --backend option.
Default: )" Default: )" << config->http.redirect_https_port
<< config->http.redirect_https_port << R"( << R"(
API: API:
--api-max-request-body=<SIZE> --api-max-request-body=<SIZE>
@ -2744,8 +2742,7 @@ Misc:
Load configuration from <PATH>. Please note that Load configuration from <PATH>. Please note that
nghttpx always tries to read the default configuration nghttpx always tries to read the default configuration
file if --conf is not given. file if --conf is not given.
Default: )" Default: )" << config->conf_path << R"(
<< config->conf_path << R"(
--include=<PATH> --include=<PATH>
Load additional configurations from <PATH>. File <PATH> Load additional configurations from <PATH>. File <PATH>
is read when configuration parser encountered this is read when configuration parser encountered this
@ -2763,8 +2760,7 @@ Misc:
The <DURATION> argument is an integer and an optional unit (e.g., 1s The <DURATION> argument is an integer and an optional unit (e.g., 1s
is 1 second and 500ms is 500 milliseconds). Units are h, m, s or ms is 1 second and 500ms is 500 milliseconds). Units are h, m, s or ms
(hours, minutes, seconds and milliseconds, respectively). If a unit (hours, minutes, seconds and milliseconds, respectively). If a unit
is omitted, a second is used as unit.)" is omitted, a second is used as unit.)" << std::endl;
<< std::endl;
} }
} // namespace } // namespace

View File

@ -38,12 +38,14 @@ namespace {
const std::array<APIEndpoint, 2> &apis() { const std::array<APIEndpoint, 2> &apis() {
static const auto apis = new std::array<APIEndpoint, 2>{{ static const auto apis = new std::array<APIEndpoint, 2>{{
APIEndpoint{ APIEndpoint{
StringRef::from_lit("/api/v1beta1/backendconfig"), true, StringRef::from_lit("/api/v1beta1/backendconfig"),
true,
(1 << API_METHOD_POST) | (1 << API_METHOD_PUT), (1 << API_METHOD_POST) | (1 << API_METHOD_PUT),
&APIDownstreamConnection::handle_backendconfig, &APIDownstreamConnection::handle_backendconfig,
}, },
APIEndpoint{ APIEndpoint{
StringRef::from_lit("/api/v1beta1/configrevision"), true, StringRef::from_lit("/api/v1beta1/configrevision"),
true,
(1 << API_METHOD_GET), (1 << API_METHOD_GET),
&APIDownstreamConnection::handle_configrevision, &APIDownstreamConnection::handle_configrevision,
}, },
@ -56,7 +58,8 @@ const std::array<APIEndpoint, 2> &apis() {
namespace { namespace {
// The method string. This must be same order of APIMethod. // The method string. This must be same order of APIMethod.
constexpr StringRef API_METHOD_STRING[] = { constexpr StringRef API_METHOD_STRING[] = {
StringRef::from_lit("GET"), StringRef::from_lit("POST"), StringRef::from_lit("GET"),
StringRef::from_lit("POST"),
StringRef::from_lit("PUT"), StringRef::from_lit("PUT"),
}; };
} // namespace } // namespace

View File

@ -1257,9 +1257,15 @@ void ClientHandler::write_accesslog(Downstream *downstream) {
upstream_accesslog( upstream_accesslog(
config->logging.access.format, config->logging.access.format,
LogSpec{ LogSpec{
downstream, ipaddr_, alpn_, sni_, conn_.tls.ssl, downstream,
ipaddr_,
alpn_,
sni_,
conn_.tls.ssl,
std::chrono::high_resolution_clock::now(), // request_end_time std::chrono::high_resolution_clock::now(), // request_end_time
port_, faddr_->port, config->pid, port_,
faddr_->port,
config->pid,
}); });
} }

View File

@ -2673,14 +2673,16 @@ int parse_config(Config *config, int optid, const StringRef &opt,
<< SHRPX_OPT_FRONTEND; << SHRPX_OPT_FRONTEND;
return 0; return 0;
case SHRPX_OPTID_BACKEND_NO_TLS: case SHRPX_OPTID_BACKEND_NO_TLS:
LOG(WARN) << opt << ": deprecated. backend connection is not encrypted by " LOG(WARN) << opt
"default. See also " << ": deprecated. backend connection is not encrypted by "
"default. See also "
<< SHRPX_OPT_BACKEND_TLS; << SHRPX_OPT_BACKEND_TLS;
return 0; return 0;
case SHRPX_OPTID_BACKEND_TLS_SNI_FIELD: case SHRPX_OPTID_BACKEND_TLS_SNI_FIELD:
LOG(WARN) << opt << ": deprecated. Use sni keyword in --backend option. " LOG(WARN) << opt
"For now, all sni values of all backends are " << ": deprecated. Use sni keyword in --backend option. "
"overridden by the given value " "For now, all sni values of all backends are "
"overridden by the given value "
<< optarg; << optarg;
config->tls.backend_sni_name = make_string_ref(config->balloc, optarg); config->tls.backend_sni_name = make_string_ref(config->balloc, optarg);
@ -2791,8 +2793,9 @@ int parse_config(Config *config, int optid, const StringRef &opt,
return 0; return 0;
case SHRPX_OPTID_CLIENT: case SHRPX_OPTID_CLIENT:
LOG(ERROR) << opt << ": deprecated. Use frontend=<addr>,<port>;no-tls, " LOG(ERROR) << opt
"backend=<addr>,<port>;;proto=h2;tls"; << ": deprecated. Use frontend=<addr>,<port>;no-tls, "
"backend=<addr>,<port>;;proto=h2;tls";
return -1; return -1;
case SHRPX_OPTID_INSECURE: case SHRPX_OPTID_INSECURE:
config->tls.insecure = util::strieq_l("yes", optarg); config->tls.insecure = util::strieq_l("yes", optarg);
@ -2887,8 +2890,9 @@ int parse_config(Config *config, int optid, const StringRef &opt,
return 0; return 0;
} }
case SHRPX_OPTID_TLS_PROTO_LIST: { case SHRPX_OPTID_TLS_PROTO_LIST: {
LOG(WARN) << opt << ": deprecated. Use tls-min-proto-version and " LOG(WARN) << opt
"tls-max-proto-version instead."; << ": deprecated. Use tls-min-proto-version and "
"tls-max-proto-version instead.";
auto list = util::split_str(optarg, ','); auto list = util::split_str(optarg, ',');
config->tls.tls_proto_list.resize(list.size()); config->tls.tls_proto_list.resize(list.size());
for (size_t i = 0; i < list.size(); ++i) { for (size_t i = 0; i < list.size(); ++i) {
@ -3513,8 +3517,9 @@ int parse_config(Config *config, int optid, const StringRef &opt,
case SHRPX_OPTID_REDIRECT_HTTPS_PORT: { case SHRPX_OPTID_REDIRECT_HTTPS_PORT: {
auto n = util::parse_uint(optarg); auto n = util::parse_uint(optarg);
if (n == -1 || n < 0 || n > 65535) { if (n == -1 || n < 0 || n > 65535) {
LOG(ERROR) << opt << ": bad value. Specify an integer in the range [0, " LOG(ERROR) << opt
"65535], inclusive"; << ": bad value. Specify an integer in the range [0, "
"65535], inclusive";
return -1; return -1;
} }
config->http.redirect_https_port = optarg; config->http.redirect_https_port = optarg;

View File

@ -81,6 +81,6 @@ private:
bool offline_; bool offline_;
}; };
} // namespace } // namespace shrpx
#endif // SHRPX_CONNECT_BLOCKER_H #endif // SHRPX_CONNECT_BLOCKER_H

View File

@ -207,12 +207,12 @@ int ConnectionHandler::create_single_worker() {
, ,
nb_.get() nb_.get()
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
auto cl_ssl_ctx = tls::setup_downstream_client_ssl_context( auto cl_ssl_ctx = tls::setup_downstream_client_ssl_context(
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
nb_.get() nb_.get()
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
if (cl_ssl_ctx) { if (cl_ssl_ctx) {
all_ssl_ctx_.push_back(cl_ssl_ctx); all_ssl_ctx_.push_back(cl_ssl_ctx);
@ -258,12 +258,12 @@ int ConnectionHandler::create_worker_thread(size_t num) {
, ,
nb_.get() nb_.get()
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
auto cl_ssl_ctx = tls::setup_downstream_client_ssl_context( auto cl_ssl_ctx = tls::setup_downstream_client_ssl_context(
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
nb_.get() nb_.get()
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
if (cl_ssl_ctx) { if (cl_ssl_ctx) {
all_ssl_ctx_.push_back(cl_ssl_ctx); all_ssl_ctx_.push_back(cl_ssl_ctx);

View File

@ -402,11 +402,10 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
? req.authority ? req.authority
: config->http2_proxy : config->http2_proxy
? construct_absolute_request_uri(balloc, req) ? construct_absolute_request_uri(balloc, req)
: req.path.empty() : req.path.empty() ? req.method == HTTP_OPTIONS
? req.method == HTTP_OPTIONS ? StringRef::from_lit("*")
? StringRef::from_lit("*") : StringRef::from_lit("-")
: StringRef::from_lit("-") : req.path;
: req.path;
auto p = std::begin(buf); auto p = std::begin(buf);
auto last = std::end(buf) - 2; auto last = std::end(buf) - 2;

View File

@ -62,9 +62,9 @@ using namespace nghttp2;
// Upstream log // Upstream log
#define ULOG(SEVERITY, UPSTREAM) \ #define ULOG(SEVERITY, UPSTREAM) \
(shrpx::Log(SEVERITY, __FILE__, __LINE__) \ (shrpx::Log(SEVERITY, __FILE__, __LINE__) << "[UPSTREAM:" << UPSTREAM \
<< "[UPSTREAM:" << UPSTREAM << "]" \ << "]" \
" ") " ")
// Downstream log // Downstream log
#define DLOG(SEVERITY, DOWNSTREAM) \ #define DLOG(SEVERITY, DOWNSTREAM) \

View File

@ -105,41 +105,32 @@ void test_shrpx_router_match_wildcard(void) {
router.add_route(p.pattern, p.idx, p.wildcard); router.add_route(p.pattern, p.idx, p.wildcard);
} }
CU_ASSERT(0 == CU_ASSERT(0 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/")));
StringRef::from_lit("/")));
CU_ASSERT(1 == CU_ASSERT(1 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/a")));
StringRef::from_lit("/a")));
CU_ASSERT(1 == CU_ASSERT(1 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/charlie")));
StringRef::from_lit("/charlie")));
CU_ASSERT(2 == CU_ASSERT(2 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/alpha")));
StringRef::from_lit("/alpha")));
CU_ASSERT(2 == CU_ASSERT(2 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/alpha/")));
StringRef::from_lit("/alpha/")));
CU_ASSERT(3 == CU_ASSERT(3 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/alpha/b")));
StringRef::from_lit("/alpha/b")));
CU_ASSERT(4 == CU_ASSERT(4 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/bravo")));
StringRef::from_lit("/bravo")));
CU_ASSERT(5 == CU_ASSERT(5 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/bravocharlie")));
StringRef::from_lit("/bravocharlie")));
CU_ASSERT(5 == CU_ASSERT(5 == router.match(StringRef::from_lit("nghttp2.org"),
router.match(StringRef::from_lit("nghttp2.org"), StringRef::from_lit("/bravo/")));
StringRef::from_lit("/bravo/")));
} }
void test_shrpx_router_match_prefix(void) { void test_shrpx_router_match_prefix(void) {

View File

@ -745,7 +745,7 @@ SSL_CTX *create_ssl_context(const char *private_key_file, const char *cert_file,
, ,
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
) { ) {
auto ssl_ctx = SSL_CTX_new(SSLv23_server_method()); auto ssl_ctx = SSL_CTX_new(SSLv23_server_method());
if (!ssl_ctx) { if (!ssl_ctx) {
LOG(FATAL) << ERR_error_string(ERR_get_error(), nullptr); LOG(FATAL) << ERR_error_string(ERR_get_error(), nullptr);
@ -1041,8 +1041,8 @@ SSL_CTX *create_ssl_client_context(
SSL_CTX_set_options(ssl_ctx, ssl_opts | tlsconf.tls_proto_mask); SSL_CTX_set_options(ssl_ctx, ssl_opts | tlsconf.tls_proto_mask);
SSL_CTX_set_session_cache_mode( SSL_CTX_set_session_cache_mode(ssl_ctx, SSL_SESS_CACHE_CLIENT |
ssl_ctx, SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_NO_INTERNAL_STORE); SSL_SESS_CACHE_NO_INTERNAL_STORE);
SSL_CTX_sess_set_new_cb(ssl_ctx, tls_session_client_new_cb); SSL_CTX_sess_set_new_cb(ssl_ctx, tls_session_client_new_cb);
if (nghttp2::tls::ssl_ctx_set_proto_versions( if (nghttp2::tls::ssl_ctx_set_proto_versions(
@ -1698,7 +1698,7 @@ setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
, ,
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
) { ) {
auto config = get_config(); auto config = get_config();
if (!upstream_tls_enabled(config->conn)) { if (!upstream_tls_enabled(config->conn)) {
@ -1713,7 +1713,7 @@ setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
, ,
nb nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
all_ssl_ctx.push_back(ssl_ctx); all_ssl_ctx.push_back(ssl_ctx);
@ -1731,7 +1731,7 @@ setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
, ,
nb nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
all_ssl_ctx.push_back(ssl_ctx); all_ssl_ctx.push_back(ssl_ctx);
if (cert_lookup_tree_add_ssl_ctx(cert_tree, indexed_ssl_ctx, ssl_ctx) == if (cert_lookup_tree_add_ssl_ctx(cert_tree, indexed_ssl_ctx, ssl_ctx) ==
@ -1748,7 +1748,7 @@ SSL_CTX *setup_downstream_client_ssl_context(
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
) { ) {
auto &tlsconf = get_config()->tls; auto &tlsconf = get_config()->tls;
return create_ssl_client_context( return create_ssl_client_context(

View File

@ -86,7 +86,7 @@ SSL_CTX *create_ssl_context(const char *private_key_file, const char *cert_file,
, ,
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
// Create client side SSL_CTX. This does not configure ALPN settings. // Create client side SSL_CTX. This does not configure ALPN settings.
// |next_proto_select_cb| is for NPN. // |next_proto_select_cb| is for NPN.
@ -215,14 +215,14 @@ setup_server_ssl_context(std::vector<SSL_CTX *> &all_ssl_ctx,
, ,
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
// Setups client side SSL_CTX. // Setups client side SSL_CTX.
SSL_CTX *setup_downstream_client_ssl_context( SSL_CTX *setup_downstream_client_ssl_context(
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
// Sets ALPN settings in |SSL| suitable for HTTP/2 use. // Sets ALPN settings in |SSL| suitable for HTTP/2 use.
void setup_downstream_http2_alpn(SSL *ssl); void setup_downstream_http2_alpn(SSL *ssl);

View File

@ -67,7 +67,7 @@ void drop_privileges(
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
neverbleed_t *nb neverbleed_t *nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
) { ) {
std::array<char, STRERROR_BUFSIZE> errbuf; std::array<char, STRERROR_BUFSIZE> errbuf;
auto config = get_config(); auto config = get_config();
@ -539,7 +539,7 @@ int worker_process_event_loop(WorkerProcessConfig *wpconf) {
#ifdef HAVE_NEVERBLEED #ifdef HAVE_NEVERBLEED
nb nb
#endif // HAVE_NEVERBLEED #endif // HAVE_NEVERBLEED
); );
ev_io ipcev; ev_io ipcev;
ev_io_init(&ipcev, ipc_readcb, wpconf->ipc_fd, EV_READ); ev_io_init(&ipcev, ipc_readcb, wpconf->ipc_fd, EV_READ);

View File

@ -75,7 +75,7 @@ constexpr char DEFAULT_CIPHER_LIST[] =
constexpr auto NGHTTP2_TLS_MIN_VERSION = TLS1_VERSION; constexpr auto NGHTTP2_TLS_MIN_VERSION = TLS1_VERSION;
#ifdef TLS1_3_VERSION #ifdef TLS1_3_VERSION
constexpr auto NGHTTP2_TLS_MAX_VERSION = TLS1_3_VERSION; constexpr auto NGHTTP2_TLS_MAX_VERSION = TLS1_3_VERSION;
#else // !TLS1_3_VERSION #else // !TLS1_3_VERSION
constexpr auto NGHTTP2_TLS_MAX_VERSION = TLS1_2_VERSION; constexpr auto NGHTTP2_TLS_MAX_VERSION = TLS1_2_VERSION;
#endif // !TLS1_3_VERSION #endif // !TLS1_3_VERSION

View File

@ -267,8 +267,10 @@ static void run_nghttp2_session_recv(void) {
nghttp2_frame frame; nghttp2_frame frame;
nghttp2_bufs bufs; nghttp2_bufs bufs;
nghttp2_nv nv[] = { nghttp2_nv nv[] = {
MAKE_NV(":method", "GET"), MAKE_NV(":scheme", "https"), MAKE_NV(":method", "GET"),
MAKE_NV(":authority", "example.org"), MAKE_NV(":path", "/"), MAKE_NV(":scheme", "https"),
MAKE_NV(":authority", "example.org"),
MAKE_NV(":path", "/"),
}; };
nghttp2_settings_entry iv[2]; nghttp2_settings_entry iv[2];
my_user_data ud; my_user_data ud;

View File

@ -81,8 +81,10 @@ typedef struct {
} my_user_data; } my_user_data;
static const nghttp2_nv reqnv[] = { static const nghttp2_nv reqnv[] = {
MAKE_NV(":method", "GET"), MAKE_NV(":path", "/"), MAKE_NV(":method", "GET"),
MAKE_NV(":scheme", "https"), MAKE_NV(":authority", "localhost"), MAKE_NV(":path", "/"),
MAKE_NV(":scheme", "https"),
MAKE_NV(":authority", "localhost"),
}; };
static const nghttp2_nv resnv[] = { static const nghttp2_nv resnv[] = {
@ -5876,9 +5878,8 @@ void test_nghttp2_submit_altsvc(void) {
len = nghttp2_session_mem_send(session, &data); len = nghttp2_session_mem_send(session, &data);
CU_ASSERT(len == CU_ASSERT(len == NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1 +
NGHTTP2_FRAME_HDLEN + 2 + sizeof(origin) - 1 + sizeof(field_value) - sizeof(field_value) - 1);
1);
nghttp2_frame_unpack_frame_hd(&hd, data); nghttp2_frame_unpack_frame_hd(&hd, data);