From e7b7b037f635d4c2b35b6d1e731e83166b41bcb1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 16 Oct 2018 22:33:44 +0900 Subject: [PATCH] nghttpx: Convert shrpx_cookie_secure to enum class --- src/shrpx_config.cc | 6 +++--- src/shrpx_config.h | 10 +++++----- src/shrpx_http.cc | 6 +++--- src/shrpx_http.h | 2 +- src/shrpx_worker.cc | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index 0b2ee031..5cab7ca5 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -927,11 +927,11 @@ int parse_downstream_params(DownstreamParams &out, } else if (util::istarts_with_l(param, "affinity-cookie-secure=")) { auto valstr = StringRef{first + str_size("affinity-cookie-secure="), end}; if (util::strieq_l("auto", valstr)) { - out.affinity.cookie.secure = COOKIE_SECURE_AUTO; + out.affinity.cookie.secure = SessionAffinityCookieSecure::AUTO; } else if (util::strieq_l("yes", valstr)) { - out.affinity.cookie.secure = COOKIE_SECURE_YES; + out.affinity.cookie.secure = SessionAffinityCookieSecure::YES; } else if (util::strieq_l("no", valstr)) { - out.affinity.cookie.secure = COOKIE_SECURE_NO; + out.affinity.cookie.secure = SessionAffinityCookieSecure::NO; } else { LOG(ERROR) << "backend: affinity-cookie-secure: value must be one of " "auto, yes, and no"; diff --git a/src/shrpx_config.h b/src/shrpx_config.h index d8476479..afb5284a 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -378,14 +378,14 @@ enum class SessionAffinity { COOKIE, }; -enum shrpx_cookie_secure { +enum class SessionAffinityCookieSecure { // Secure attribute of session affinity cookie is determined by the // request scheme. - COOKIE_SECURE_AUTO, + AUTO, // Secure attribute of session affinity cookie is always set. - COOKIE_SECURE_YES, + YES, // Secure attribute of session affinity cookie is always unset. - COOKIE_SECURE_NO, + NO, }; struct AffinityConfig { @@ -397,7 +397,7 @@ struct AffinityConfig { // Path which a cookie is applied to. StringRef path; // Secure attribute - shrpx_cookie_secure secure; + SessionAffinityCookieSecure secure; } cookie; }; diff --git a/src/shrpx_http.cc b/src/shrpx_http.cc index bc860b0c..baafdc77 100644 --- a/src/shrpx_http.cc +++ b/src/shrpx_http.cc @@ -199,12 +199,12 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name, return StringRef{iov.base, p}; } -bool require_cookie_secure_attribute(shrpx_cookie_secure secure, +bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure, const StringRef &scheme) { switch (secure) { - case COOKIE_SECURE_AUTO: + case SessionAffinityCookieSecure::AUTO: return scheme == "https"; - case COOKIE_SECURE_YES: + case SessionAffinityCookieSecure::YES: return true; default: return false; diff --git a/src/shrpx_http.h b/src/shrpx_http.h index dfa5477a..37be7e16 100644 --- a/src/shrpx_http.h +++ b/src/shrpx_http.h @@ -76,7 +76,7 @@ StringRef create_affinity_cookie(BlockAllocator &balloc, const StringRef &name, // Returns true if |secure| indicates that Secure attribute should be // set. -bool require_cookie_secure_attribute(shrpx_cookie_secure secure, +bool require_cookie_secure_attribute(SessionAffinityCookieSecure secure, const StringRef &scheme); } // namespace http diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index 9ecdff00..02f188f6 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -77,8 +77,8 @@ DownstreamAddrGroup::~DownstreamAddrGroup() {} using DownstreamKey = std::tuple>, - bool, SessionAffinity, StringRef, StringRef, int, int64_t, - int64_t>; + bool, SessionAffinity, StringRef, StringRef, + SessionAffinityCookieSecure, int64_t, int64_t>; namespace { DownstreamKey create_downstream_key(