nghttpx: Use StringRef for tls.npn_list

This commit is contained in:
Tatsuhiro Tsujikawa 2016-10-02 22:19:31 +09:00
parent de7b7fd440
commit 5dd2704051
5 changed files with 10 additions and 12 deletions

View File

@ -2445,7 +2445,7 @@ int process_options(Config *config,
auto &tlsconf = config->tls;
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()) {
tlsconf.tls_proto_list =

View File

@ -2305,7 +2305,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
LOG(WARN) << opt << ": not implemented yet";
return 0;
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;
case SHRPX_OPTID_TLS_PROTO_LIST:

View File

@ -526,7 +526,7 @@ struct TLSConfig {
std::vector<unsigned char> alpn_prefs;
// list of supported NPN/ALPN protocol strings in the order of
// preference.
std::vector<std::string> npn_list;
std::vector<StringRef> npn_list;
// list of supported SSL/TLS protocol strings.
std::vector<std::string> tls_proto_list;
BIO_METHOD *bio_method;

View File

@ -103,7 +103,7 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
} // namespace
int set_alpn_prefs(std::vector<unsigned char> &out,
const std::vector<std::string> &protos) {
const std::vector<StringRef> &protos) {
size_t len = 0;
for (const auto &proto : protos) {
@ -125,8 +125,7 @@ int set_alpn_prefs(std::vector<unsigned char> &out,
for (const auto &proto : protos) {
*ptr++ = proto.size();
memcpy(ptr, proto.c_str(), proto.size());
ptr += proto.size();
ptr = std::copy(std::begin(proto), std::end(proto), ptr);
}
return 0;
@ -469,8 +468,7 @@ int alpn_select_proto_cb(SSL *ssl, const unsigned char **out,
auto proto_len = *p;
if (proto_id + proto_len <= end &&
util::streq(StringRef{target_proto_id},
StringRef{proto_id, proto_len})) {
util::streq(target_proto_id, StringRef{proto_id, proto_len})) {
*out = reinterpret_cast<const unsigned char *>(proto_id);
*outlen = proto_len;
@ -1320,10 +1318,10 @@ int cert_lookup_tree_add_cert_from_x509(CertLookupTree *lt, size_t idx,
return 0;
}
bool in_proto_list(const std::vector<std::string> &protos,
bool in_proto_list(const std::vector<StringRef> &protos,
const StringRef &needle) {
for (auto &proto : protos) {
if (util::streq(StringRef{proto}, needle)) {
if (util::streq(proto, needle)) {
return true;
}
}

View File

@ -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
// 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);
// 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);
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()
// and if upstream_no_tls is true, returns nullptr. Otherwise