nghttpx: Use StringRef for tls.npn_list
This commit is contained in:
parent
de7b7fd440
commit
5dd2704051
|
@ -2445,7 +2445,7 @@ int process_options(Config *config,
|
||||||
auto &tlsconf = config->tls;
|
auto &tlsconf = config->tls;
|
||||||
|
|
||||||
if (tlsconf.npn_list.empty()) {
|
if (tlsconf.npn_list.empty()) {
|
||||||
tlsconf.npn_list = util::parse_config_str_list(DEFAULT_NPN_LIST);
|
tlsconf.npn_list = util::split_str(DEFAULT_NPN_LIST, ',');
|
||||||
}
|
}
|
||||||
if (tlsconf.tls_proto_list.empty()) {
|
if (tlsconf.tls_proto_list.empty()) {
|
||||||
tlsconf.tls_proto_list =
|
tlsconf.tls_proto_list =
|
||||||
|
|
|
@ -2305,7 +2305,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
|
||||||
LOG(WARN) << opt << ": not implemented yet";
|
LOG(WARN) << opt << ": not implemented yet";
|
||||||
return 0;
|
return 0;
|
||||||
case SHRPX_OPTID_NPN_LIST:
|
case SHRPX_OPTID_NPN_LIST:
|
||||||
config->tls.npn_list = util::parse_config_str_list(optarg);
|
config->tls.npn_list = util::split_str(optarg, ',');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case SHRPX_OPTID_TLS_PROTO_LIST:
|
case SHRPX_OPTID_TLS_PROTO_LIST:
|
||||||
|
|
|
@ -526,7 +526,7 @@ struct TLSConfig {
|
||||||
std::vector<unsigned char> alpn_prefs;
|
std::vector<unsigned char> alpn_prefs;
|
||||||
// list of supported NPN/ALPN protocol strings in the order of
|
// list of supported NPN/ALPN protocol strings in the order of
|
||||||
// preference.
|
// preference.
|
||||||
std::vector<std::string> npn_list;
|
std::vector<StringRef> npn_list;
|
||||||
// list of supported SSL/TLS protocol strings.
|
// list of supported SSL/TLS protocol strings.
|
||||||
std::vector<std::string> tls_proto_list;
|
std::vector<std::string> tls_proto_list;
|
||||||
BIO_METHOD *bio_method;
|
BIO_METHOD *bio_method;
|
||||||
|
|
|
@ -103,7 +103,7 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int set_alpn_prefs(std::vector<unsigned char> &out,
|
int set_alpn_prefs(std::vector<unsigned char> &out,
|
||||||
const std::vector<std::string> &protos) {
|
const std::vector<StringRef> &protos) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
for (const auto &proto : protos) {
|
for (const auto &proto : protos) {
|
||||||
|
@ -125,8 +125,7 @@ int set_alpn_prefs(std::vector<unsigned char> &out,
|
||||||
|
|
||||||
for (const auto &proto : protos) {
|
for (const auto &proto : protos) {
|
||||||
*ptr++ = proto.size();
|
*ptr++ = proto.size();
|
||||||
memcpy(ptr, proto.c_str(), proto.size());
|
ptr = std::copy(std::begin(proto), std::end(proto), ptr);
|
||||||
ptr += proto.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -469,8 +468,7 @@ int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
|
||||||
auto proto_len = *p;
|
auto proto_len = *p;
|
||||||
|
|
||||||
if (proto_id + proto_len <= end &&
|
if (proto_id + proto_len <= end &&
|
||||||
util::streq(StringRef{target_proto_id},
|
util::streq(target_proto_id, StringRef{proto_id, proto_len})) {
|
||||||
StringRef{proto_id, proto_len})) {
|
|
||||||
|
|
||||||
*out = reinterpret_cast<const unsigned char *>(proto_id);
|
*out = reinterpret_cast<const unsigned char *>(proto_id);
|
||||||
*outlen = proto_len;
|
*outlen = proto_len;
|
||||||
|
@ -1320,10 +1318,10 @@ int cert_lookup_tree_add_cert_from_x509(CertLookupTree *lt, size_t idx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool in_proto_list(const std::vector<std::string> &protos,
|
bool in_proto_list(const std::vector<StringRef> &protos,
|
||||||
const StringRef &needle) {
|
const StringRef &needle) {
|
||||||
for (auto &proto : protos) {
|
for (auto &proto : protos) {
|
||||||
if (util::streq(StringRef{proto}, needle)) {
|
if (util::streq(proto, needle)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ int cert_lookup_tree_add_cert_from_x509(CertLookupTree *lt, size_t idx,
|
||||||
|
|
||||||
// Returns true if |proto| is included in the
|
// Returns true if |proto| is included in the
|
||||||
// protocol list |protos|.
|
// protocol list |protos|.
|
||||||
bool in_proto_list(const std::vector<std::string> &protos,
|
bool in_proto_list(const std::vector<StringRef> &protos,
|
||||||
const StringRef &proto);
|
const StringRef &proto);
|
||||||
|
|
||||||
// Returns true if security requirement for HTTP/2 is fulfilled.
|
// Returns true if security requirement for HTTP/2 is fulfilled.
|
||||||
|
@ -179,7 +179,7 @@ bool check_http2_requirement(SSL *ssl);
|
||||||
long int create_tls_proto_mask(const std::vector<std::string> &tls_proto_list);
|
long int create_tls_proto_mask(const std::vector<std::string> &tls_proto_list);
|
||||||
|
|
||||||
int set_alpn_prefs(std::vector<unsigned char> &out,
|
int set_alpn_prefs(std::vector<unsigned char> &out,
|
||||||
const std::vector<std::string> &protos);
|
const std::vector<StringRef> &protos);
|
||||||
|
|
||||||
// Setups server side SSL_CTX. This function inspects get_config()
|
// Setups server side SSL_CTX. This function inspects get_config()
|
||||||
// and if upstream_no_tls is true, returns nullptr. Otherwise
|
// and if upstream_no_tls is true, returns nullptr. Otherwise
|
||||||
|
|
Loading…
Reference in New Issue