Skip to content

Commit afa69e7

Browse files
authored
Cleans up some of the filenames mess (#6144)
* Cleans up some of the filenames mess However, I did not finish eliminating all configurations. I've marked some of them deprecated, the changes to refactor all of this is too big to be safe for a v9.0.0 PR. We will revisit their removals for v10.0.0, but I'll also add a deprecation note for all of these for v9.0.0. * Replaced with constexpr, and namespace. DON'T MERGE THIS!! * Mark a few more configurations deprecated * Remove one superfluous const
1 parent e655af7 commit afa69e7

31 files changed

+176
-164
lines changed

doc/admin-guide/files/records.config.en.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2910,6 +2910,7 @@ Logging Configuration
29102910

29112911
.. ts:cv:: CONFIG proxy.config.log.config.filename STRING logging.yaml
29122912
:reloadable:
2913+
:deprecated:
29132914

29142915
This configuration value specifies the path to the
29152916
:file:`logging.yaml` configuration file. If this is a relative
@@ -3061,6 +3062,7 @@ URL Remap Rules
30613062
===============
30623063

30633064
.. ts:cv:: CONFIG proxy.config.url_remap.filename STRING remap.config
3065+
:deprecated:
30643066

30653067
Sets the name of the :file:`remap.config` file.
30663068

@@ -3191,6 +3193,7 @@ SSL Termination
31913193

31923194

31933195
.. ts:cv:: CONFIG proxy.config.ssl.server.multicert.filename STRING ssl_multicert.config
3196+
:deprecated:
31943197

31953198
The location of the :file:`ssl_multicert.config` file, relative
31963199
to the |TS| configuration directory. In the following
@@ -3259,6 +3262,7 @@ SSL Termination
32593262
file is changed with new tickets, use :option:`traffic_ctl config reload` to begin using them.
32603263

32613264
.. ts:cv:: CONFIG proxy.config.ssl.servername.filename STRING sni.yaml
3265+
:deprecated:
32623266

32633267
The filename of the :file:`sni.yaml` configuration file.
32643268
If relative, it is relative to the configuration directory.
@@ -3987,6 +3991,7 @@ SOCKS Processor
39873991
Specifies the SOCKS version (``4``) or (``5``)
39883992

39893993
.. ts:cv:: CONFIG proxy.config.socks.socks_config_file STRING socks.config
3994+
:deprecated:
39903995

39913996
The socks.config file allows you to specify ranges of IP addresses
39923997
that will not be relayed to the SOCKS server. It can also be used

include/tscore/Filenames.h

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,30 @@
2121

2222
#pragma once
2323

24-
///////////////////////////////////////////////////////////////////
25-
// Configuration file names
26-
extern const char *STORAGE_CONF_FILENAME;
27-
extern const char *RECORDS_CONF_FILENAME;
28-
29-
///////////////////////////////////////////////////////////////////
30-
// Various other file names
31-
extern const char *RECORDS_STATS_FILE;
24+
namespace ts
25+
{
26+
namespace filename
27+
{
28+
constexpr const char *STORAGE = "storage.config";
29+
constexpr const char *RECORDS = "records.config";
30+
constexpr const char *VOLUME = "volume.config";
31+
constexpr const char *PLUGIN = "plugin.config";
32+
33+
// These still need to have their corrensponding records.config settings remove
34+
constexpr const char *LOGGING = "logging.yaml";
35+
constexpr const char *CACHE = "cache.config";
36+
constexpr const char *IP_ALLOW = "ip_allow.yaml";
37+
constexpr const char *HOSTING = "hosting.config";
38+
constexpr const char *SOCKS = "socks.config";
39+
constexpr const char *PARENT = "parent.config";
40+
constexpr const char *REMAP = "remap.config";
41+
constexpr const char *SSL_MULTICERT = "ssl_multicert.config";
42+
constexpr const char *SPLITDNS = "splitdns.config";
43+
constexpr const char *SNI = "sni.yaml";
44+
45+
///////////////////////////////////////////////////////////////////
46+
// Various other file names
47+
constexpr const char *RECORDS_STATS = "records.snap";
48+
49+
} // namespace filename
50+
} // namespace ts

iocore/cache/Cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3136,7 +3136,7 @@ ink_cache_init(ts::ModuleVersion v)
31363136

31373137
Result result = theCacheStore.read_config();
31383138
if (result.failed()) {
3139-
Fatal("Failed to read cache configuration %s: %s", STORAGE_CONF_FILENAME, result.message());
3139+
Fatal("Failed to read cache configuration %s: %s", ts::filename::STORAGE, result.message());
31403140
}
31413141
}
31423142

iocore/cache/CacheHosting.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "tscore/HostLookup.h"
2727
#include "tscore/Tokenizer.h"
2828
#include "tscore/Regression.h"
29+
#include "tscore/Filenames.h"
2930

3031
extern int gndisks;
3132

@@ -244,7 +245,7 @@ int fstat_wrapper(int fd, struct stat *s);
244245
int
245246
CacheHostTable::BuildTableFromString(const char *config_file_path, char *file_buf)
246247
{
247-
Note("hosting.config loading ...");
248+
Note("%s loading ...", ts::filename::HOSTING);
248249

249250
// Table build locals
250251
Tokenizer bufTok("\n");
@@ -325,7 +326,7 @@ CacheHostTable::BuildTableFromString(const char *config_file_path, char *file_bu
325326
if (gen_host_rec.Init(type)) {
326327
Warning("Problems encountered while initializing the Generic Volume");
327328
}
328-
Note("hosting.config finished loading");
329+
Note("%s finished loading", ts::filename::HOSTING);
329330
return 0;
330331
}
331332

@@ -374,7 +375,7 @@ CacheHostTable::BuildTableFromString(const char *config_file_path, char *file_bu
374375
current = current->next;
375376
ats_free(last);
376377

377-
Note("hosting.config finished loading");
378+
Note("%s finished loading", ts::filename::HOSTING);
378379
}
379380

380381
if (!generic_rec_initd) {
@@ -596,11 +597,11 @@ ConfigVolumes::read_config_file()
596597
config_path = RecConfigReadConfigPath("proxy.config.cache.volume_filename");
597598
ink_release_assert(config_path);
598599

599-
Note("volume.config loading ...");
600+
Note("%s loading ...", ts::filename::VOLUME);
600601

601602
file_buf = readIntoBuffer(config_path, "[CacheVolition]", nullptr);
602603
if (file_buf == nullptr) {
603-
Error("volume.config failed to load");
604+
Error("%s failed to load", ts::filename::VOLUME);
604605
Warning("Cannot read the config file: %s", (const char *)config_path);
605606
return;
606607
}

iocore/cache/Store.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,13 @@ Store::read_config()
325325
Span *sd = nullptr, *cur = nullptr;
326326
Span *ns;
327327
ats_scoped_fd fd;
328-
ats_scoped_str storage_path(RecConfigReadConfigPath(nullptr, STORAGE_CONF_FILENAME));
328+
ats_scoped_str storage_path(RecConfigReadConfigPath(nullptr, ts::filename::STORAGE));
329329

330-
Note("%s loading ...", STORAGE_CONF_FILENAME);
330+
Note("%s loading ...", ts::filename::STORAGE);
331331
Debug("cache_init", "Store::read_config, fd = -1, \"%s\"", (const char *)storage_path);
332332
fd = ::open(storage_path, O_RDONLY);
333333
if (fd < 0) {
334-
Error("%s failed to load", STORAGE_CONF_FILENAME);
334+
Error("%s failed to load", ts::filename::STORAGE);
335335
return Result::failure("open %s: %s", (const char *)storage_path, strerror(errno));
336336
}
337337

@@ -372,7 +372,7 @@ Store::read_config()
372372
const char *end;
373373
if ((size = ink_atoi64(e, &end)) <= 0 || *end != '\0') {
374374
delete sd;
375-
Error("%s failed to load", STORAGE_CONF_FILENAME);
375+
Error("%s failed to load", ts::filename::STORAGE);
376376
return Result::failure("failed to parse size '%s'", e);
377377
}
378378
} else if (0 == strncasecmp(HASH_BASE_STRING_KEY, e, sizeof(HASH_BASE_STRING_KEY) - 1)) {
@@ -390,7 +390,7 @@ Store::read_config()
390390
}
391391
if (!*e || !ParseRules::is_digit(*e) || 0 >= (volume_num = ink_atoi(e))) {
392392
delete sd;
393-
Error("%s failed to load", STORAGE_CONF_FILENAME);
393+
Error("%s failed to load", ts::filename::STORAGE);
394394
return Result::failure("failed to parse volume number '%s'", e);
395395
}
396396
}
@@ -442,7 +442,7 @@ Store::read_config()
442442
sd = nullptr; // these are all used.
443443
sort();
444444

445-
Note("%s finished loading", STORAGE_CONF_FILENAME);
445+
Note("%s finished loading", ts::filename::STORAGE);
446446

447447
return Result::ok();
448448
}

iocore/dns/SplitDNS.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "tscore/ink_platform.h"
3232
#include "tscore/Tokenizer.h"
33+
#include "tscore/Filenames.h"
3334

3435
#ifdef SPLIT_DNS
3536
#include <sys/types.h>
@@ -130,15 +131,15 @@ SplitDNSConfig::reconfigure()
130131
return;
131132
}
132133

133-
Note("splitdns.config loading ...");
134+
Note("%s loading ...", ts::filename::SPLITDNS);
134135

135136
SplitDNS *params = new SplitDNS;
136137

137138
params->m_SplitDNSlEnable = gsplit_dns_enabled;
138139
params->m_DNSSrvrTable = new DNS_table("proxy.config.dns.splitdns.filename", modulePrefix, &sdns_dest_tags);
139140

140141
if (nullptr == params->m_DNSSrvrTable || (0 == params->m_DNSSrvrTable->getEntryCount())) {
141-
Error("splitdns.config failed to load");
142+
Error("%s failed to load", ts::filename::SPLITDNS);
142143
Warning("No NAMEDs provided! Disabling SplitDNS");
143144
gsplit_dns_enabled = 0;
144145
delete params;
@@ -159,7 +160,7 @@ SplitDNSConfig::reconfigure()
159160
SplitDNSConfig::print();
160161
}
161162

162-
Note("splitdns.config finished loading");
163+
Note("%s finished loading", ts::filename::SPLITDNS);
163164
}
164165

165166
/* --------------------------------------------------------------
@@ -476,7 +477,7 @@ SplitDNSRecord::Init(matcher_line *line_info)
476477
}
477478

478479
if (!ats_is_ip(&m_servers.x_server_ip[0].sa)) {
479-
return Result::failure("%s No server specified in splitdns.config at line %d", modulePrefix, line_num);
480+
return Result::failure("%s No server specified in %s at line %d", modulePrefix, ts::filename::SPLITDNS, line_num);
480481
}
481482

482483
DNSHandler *dnsH = new DNSHandler;
@@ -505,7 +506,7 @@ SplitDNSRecord::Init(matcher_line *line_info)
505506
if (line_info->num_el > 0) {
506507
const char *tmp = ProcessModifiers(line_info);
507508
if (tmp != nullptr) {
508-
return Result::failure("%s %s at line %d in splitdns.config", modulePrefix, tmp, line_num);
509+
return Result::failure("%s %s at line %d in %s", modulePrefix, tmp, line_num, ts::filename::SPLITDNS);
509510
}
510511
}
511512

iocore/net/QUICMultiCertConfigLoader.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "QUICConfig.h"
3030
#include "QUICConnection.h"
3131
#include "QUICTypes.h"
32+
#include "tscore/Filenames.h"
3233
// #include "QUICGlobals.h"
3334

3435
#define QUICConfDebug(fmt, ...) Debug("quic_conf", fmt, ##__VA_ARGS__)
@@ -128,7 +129,7 @@ QUICMultiCertConfigLoader::init_server_ssl_ctx(std::vector<X509 *> &cert_list, c
128129
#if TS_USE_TLS_SET_CIPHERSUITES
129130
if (params->server_tls13_cipher_suites != nullptr) {
130131
if (!SSL_CTX_set_ciphersuites(ctx, params->server_tls13_cipher_suites)) {
131-
Error("invalid tls server cipher suites in records.config");
132+
Error("invalid tls server cipher suites in %s", ts::filename::RECORDS);
132133
goto fail;
133134
}
134135
}
@@ -141,7 +142,7 @@ QUICMultiCertConfigLoader::init_server_ssl_ctx(std::vector<X509 *> &cert_list, c
141142
#else
142143
if (!SSL_CTX_set1_curves_list(ctx, params->server_groups_list)) {
143144
#endif
144-
Error("invalid groups list for server in records.config");
145+
Error("invalid groups list for server in %s", ts::filename::RECORDS);
145146
goto fail;
146147
}
147148
}

iocore/net/SSLClientUtils.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "tscore/ink_config.h"
2323
#include "records/I_RecHttp.h"
2424
#include "tscore/ink_platform.h"
25+
#include "tscore/Filenames.h"
2526
#include "tscore/X509HostnameValidator.h"
2627

2728
#include "P_Net.h"
@@ -158,15 +159,15 @@ SSLInitClientContext(const SSLConfigParams *params)
158159
SSL_CTX_set_options(client_ctx, params->ssl_client_ctx_options);
159160
if (params->client_cipherSuite != nullptr) {
160161
if (!SSL_CTX_set_cipher_list(client_ctx, params->client_cipherSuite)) {
161-
SSLError("invalid client cipher suite in records.config");
162+
SSLError("invalid client cipher suite in %s", ts::filename::RECORDS);
162163
goto fail;
163164
}
164165
}
165166

166167
#if TS_USE_TLS_SET_CIPHERSUITES
167168
if (params->client_tls13_cipher_suites != nullptr) {
168169
if (!SSL_CTX_set_ciphersuites(client_ctx, params->client_tls13_cipher_suites)) {
169-
SSLError("invalid tls client cipher suites in records.config");
170+
SSLError("invalid tls client cipher suites in %s", ts::filename::RECORDS);
170171
goto fail;
171172
}
172173
}
@@ -179,7 +180,7 @@ SSLInitClientContext(const SSLConfigParams *params)
179180
#else
180181
if (!SSL_CTX_set1_curves_list(client_ctx, params->client_groups_list)) {
181182
#endif
182-
SSLError("invalid groups list for client in records.config");
183+
SSLError("invalid groups list for client in %s", ts::filename::RECORDS);
183184
goto fail;
184185
}
185186
}

iocore/net/SSLUtils.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "tscore/I_Layout.h"
2828
#include "tscore/ink_cap.h"
2929
#include "tscore/ink_mutex.h"
30+
#include "tscore/Filenames.h"
3031
#include "records/I_RecHttp.h"
3132

3233
#include "P_Net.h"
@@ -962,7 +963,7 @@ SSLPrivateKeyHandler(SSL_CTX *ctx, const SSLConfigParams *params, const std::str
962963
SSLConfigParams::load_ssl_file_cb(completeServerKeyPath);
963964
}
964965
} else {
965-
SSLError("empty SSL private key path in records.config");
966+
SSLError("empty SSL private key path in %s", ts::filename::RECORDS);
966967
return false;
967968
}
968969

@@ -1328,7 +1329,7 @@ SSLMultiCertConfigLoader::init_server_ssl_ctx(std::vector<X509 *> &cert_list, co
13281329
} else {
13291330
// disable client cert support
13301331
server_verify_client = SSL_VERIFY_NONE;
1331-
Error("illegal client certification level %d in records.config", server_verify_client);
1332+
Error("illegal client certification level %d in %s", server_verify_client, ts::filename::RECORDS);
13321333
}
13331334
SSL_CTX_set_verify(ctx, server_verify_client, ssl_verify_client_callback);
13341335
SSL_CTX_set_verify_depth(ctx, params->verify_depth); // might want to make configurable at some point.
@@ -1340,15 +1341,15 @@ SSLMultiCertConfigLoader::init_server_ssl_ctx(std::vector<X509 *> &cert_list, co
13401341

13411342
if (params->cipherSuite != nullptr) {
13421343
if (!SSL_CTX_set_cipher_list(ctx, params->cipherSuite)) {
1343-
SSLError("invalid cipher suite in records.config");
1344+
SSLError("invalid cipher suite in %s", ts::filename::RECORDS);
13441345
goto fail;
13451346
}
13461347
}
13471348

13481349
#if TS_USE_TLS_SET_CIPHERSUITES
13491350
if (params->server_tls13_cipher_suites != nullptr) {
13501351
if (!SSL_CTX_set_ciphersuites(ctx, params->server_tls13_cipher_suites)) {
1351-
SSLError("invalid tls server cipher suites in records.config");
1352+
SSLError("invalid tls server cipher suites in %s", ts::filename::RECORDS);
13521353
goto fail;
13531354
}
13541355
}
@@ -1361,7 +1362,7 @@ SSLMultiCertConfigLoader::init_server_ssl_ctx(std::vector<X509 *> &cert_list, co
13611362
#else
13621363
if (!SSL_CTX_set1_curves_list(ctx, params->server_groups_list)) {
13631364
#endif
1364-
SSLError("invalid groups list for server in records.config");
1365+
SSLError("invalid groups list for server in %s", ts::filename::RECORDS);
13651366
goto fail;
13661367
}
13671368
}
@@ -1590,7 +1591,7 @@ SSLMultiCertConfigLoader::load(SSLCertLookup *lookup)
15901591

15911592
const matcher_tags sslCertTags = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, false};
15921593

1593-
Note("ssl_multicert.config loading ...");
1594+
Note("%s loading ...", ts::filename::SSL_MULTICERT);
15941595

15951596
if (params->configFilePath) {
15961597
file_buf = readIntoBuffer(params->configFilePath, __func__, nullptr);

lib/records/RecCore.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ RecCoreInit(RecModeT mode_type, Diags *_diags)
219219

220220
ink_mutex_init(&g_rec_config_lock);
221221

222-
g_rec_config_fpath = ats_stringdup(RecConfigReadConfigPath(nullptr, RECORDS_CONF_FILENAME));
222+
g_rec_config_fpath = ats_stringdup(RecConfigReadConfigPath(nullptr, ts::filename::RECORDS));
223223
if (RecFileExists(g_rec_config_fpath) == REC_ERR_FAIL) {
224-
RecLog(DL_Warning, "Could not find '%s', system will run with defaults\n", RECORDS_CONF_FILENAME);
224+
RecLog(DL_Warning, "Could not find '%s', system will run with defaults\n", ts::filename::RECORDS);
225225
file_exists = false;
226226
}
227227

@@ -1257,7 +1257,7 @@ std::string
12571257
RecConfigReadPersistentStatsPath()
12581258
{
12591259
std::string rundir(RecConfigReadRuntimeDir());
1260-
return Layout::relative_to(rundir, RECORDS_STATS_FILE);
1260+
return Layout::relative_to(rundir, ts::filename::RECORDS_STATS);
12611261
}
12621262

12631263
void

0 commit comments

Comments
 (0)