nghttpx: Fix bug that backend tls keyword did not work with -s option

This commit is contained in:
Tatsuhiro Tsujikawa 2016-03-27 17:11:44 +09:00
parent c9aba4ea0c
commit 757bcf1310
2 changed files with 17 additions and 1 deletions

View File

@ -2088,6 +2088,8 @@ void process_options(int argc, char **argv,
// non-catch-all patterns to catch-all pattern.
DownstreamAddrGroupConfig catch_all(StringRef::from_lit("/"));
auto proto = PROTO_NONE;
auto tls = false;
auto tls_seen = false;
for (auto &g : addr_groups) {
if (proto == PROTO_NONE) {
proto = g.proto;
@ -2097,10 +2099,22 @@ void process_options(int argc, char **argv,
"be the same for all backends.";
exit(EXIT_FAILURE);
}
if (!tls_seen) {
tls = g.tls;
tls_seen = true;
} else if (tls != g.tls) {
LOG(ERROR) << SHRPX_OPT_BACKEND
<< ": <PATTERN> was ignored with --http2-proxy, and tls "
"must be enabled or disabled for all backends.";
exit(EXIT_FAILURE);
}
std::move(std::begin(g.addrs), std::end(g.addrs),
std::back_inserter(catch_all.addrs));
}
catch_all.proto = proto;
catch_all.tls = tls;
std::vector<DownstreamAddrGroupConfig>().swap(addr_groups);
std::vector<WildcardPattern>().swap(mod_config()->wildcard_patterns);
// maybe not necessary?

View File

@ -343,7 +343,9 @@ struct DownstreamAddrConfig {
struct DownstreamAddrGroupConfig {
DownstreamAddrGroupConfig(const StringRef &pattern)
: pattern(pattern.c_str(), pattern.size()), proto(PROTO_HTTP1) {}
: pattern(pattern.c_str(), pattern.size()),
proto(PROTO_HTTP1),
tls(false) {}
ImmutableString pattern;
std::vector<DownstreamAddrConfig> addrs;