Determines the SSL session cache configuration value using a priority-based selection scheme. * * This function resolves the SSL session cache configuration by evaluating multiple potential * configuration sources and selecting the one with the highest priority. The priority calculation * combines two factors: * * Configuration Name Priority (base priority): * - `proxy.config.ssl.session_ca
| 126 | * @return The SSL session cache mode value. |
| 127 | */ |
| 128 | static int |
| 129 | get_ssl_session_cache_config() |
| 130 | { |
| 131 | // |
| 132 | // TODO: in 11.x, we can simply remove this function and use only proxy.config.ssl.session_cache.mode. |
| 133 | // |
| 134 | |
| 135 | struct ConfigOption { |
| 136 | const char *name; ///< Configuration parameter name (e.g., "proxy.config.ssl.session_cache.mode"). |
| 137 | int value; ///< The configured value if explicitly set. |
| 138 | int priority; ///< The inherit priority of the config name, higher is more preferred. |
| 139 | }; |
| 140 | |
| 141 | /// The priority of the source. Higher is more preferred. |
| 142 | std::unordered_map<int, int> source_priorities = { |
| 143 | {REC_SOURCE_ENV, 0x30}, |
| 144 | {REC_SOURCE_EXPLICIT, 0x20}, |
| 145 | {REC_SOURCE_PLUGIN, 0x10}, |
| 146 | {REC_SOURCE_DEFAULT, 0x0 }, |
| 147 | {REC_SOURCE_NULL, 0x0 }, // For completeness, no record should have this set. |
| 148 | }; |
| 149 | |
| 150 | std::array<ConfigOption, 3> configs = { |
| 151 | { |
| 152 | {"proxy.config.ssl.session_cache.mode", 0, 0x3}, |
| 153 | {"proxy.config.ssl.session_cache.value", 0, 0x2}, |
| 154 | {"proxy.config.ssl.session_cache.enabled", 0, 0x1}, |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | // Loop over the config names, updating their priority score per their source. |
| 159 | auto *highest_priority_config = &configs[0]; |
| 160 | for (auto &config : configs) { |
| 161 | RecSourceT source; |
| 162 | if (RecGetRecordSource(config.name, &source) == REC_ERR_OKAY) { |
| 163 | config.priority += source_priorities[source]; |
| 164 | REC_ReadConfigInteger(config.value, config.name); |
| 165 | if (config.priority > highest_priority_config->priority) { |
| 166 | highest_priority_config = &config; |
| 167 | } |
| 168 | } else { |
| 169 | // We need to update our logic here if any of these configs are removed. |
| 170 | ink_release_assert(false); |
| 171 | } |
| 172 | } |
| 173 | return highest_priority_config->value; |
| 174 | } |
| 175 | |
| 176 | SSLConfigParams::SSLConfigParams() |
| 177 | { |
no test coverage detected