nghttpx: Add --include option to read additional configuration from given file
This commit is contained in:
parent
6307f96fb3
commit
3097547491
10
src/shrpx.cc
10
src/shrpx.cc
|
@ -1502,6 +1502,11 @@ Misc:
|
|||
--conf=<PATH>
|
||||
Load configuration from <PATH>.
|
||||
Default: )" << get_config()->conf_path.get() << R"(
|
||||
--include=<PATH>
|
||||
Load additional configurations from <PATH>. File <PATH>
|
||||
is read when configuration parser encountered this
|
||||
option. This option can be used multiple times, or even
|
||||
recursively.
|
||||
-v, --version
|
||||
Print version and exit.
|
||||
-h, --help Print this help and exit.
|
||||
|
@ -1648,6 +1653,7 @@ int main(int argc, char **argv) {
|
|||
{SHRPX_OPT_HEADER_FIELD_BUFFER, required_argument, &flag, 80},
|
||||
{SHRPX_OPT_MAX_HEADER_FIELDS, required_argument, &flag, 81},
|
||||
{SHRPX_OPT_ADD_REQUEST_HEADER, required_argument, &flag, 82},
|
||||
{SHRPX_OPT_INCLUDE, required_argument, &flag, 83},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
|
||||
int option_index = 0;
|
||||
|
@ -2010,6 +2016,10 @@ int main(int argc, char **argv) {
|
|||
// --add-request-header
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_ADD_REQUEST_HEADER, optarg);
|
||||
break;
|
||||
case 83:
|
||||
// --include
|
||||
cmdcfgs.emplace_back(SHRPX_OPT_INCLUDE, optarg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1219,6 +1219,10 @@ int parse_config(const char *opt, const char *optarg) {
|
|||
return parse_uint(&mod_config()->max_header_fields, opt, optarg);
|
||||
}
|
||||
|
||||
if (util::strieq(opt, SHRPX_OPT_INCLUDE)) {
|
||||
return load_config(optarg);
|
||||
}
|
||||
|
||||
if (util::strieq(opt, "conf")) {
|
||||
LOG(WARN) << "conf: ignored";
|
||||
|
||||
|
@ -1248,7 +1252,8 @@ int load_config(const char *filename) {
|
|||
for (i = 0; i < size && line[i] != '='; ++i)
|
||||
;
|
||||
if (i == size) {
|
||||
LOG(ERROR) << "Bad configuration format at line " << linenum;
|
||||
LOG(ERROR) << "Bad configuration format in " << filename << " at line "
|
||||
<< linenum;
|
||||
return -1;
|
||||
}
|
||||
line[i] = '\0';
|
||||
|
|
|
@ -165,6 +165,7 @@ constexpr char SHRPX_OPT_OCSP_UPDATE_INTERVAL[] = "ocsp-update-interval";
|
|||
constexpr char SHRPX_OPT_NO_OCSP[] = "no-ocsp";
|
||||
constexpr char SHRPX_OPT_HEADER_FIELD_BUFFER[] = "header-field-buffer";
|
||||
constexpr char SHRPX_OPT_MAX_HEADER_FIELDS[] = "max-header-fields";
|
||||
constexpr char SHRPX_OPT_INCLUDE[] = "include";
|
||||
|
||||
union sockaddr_union {
|
||||
sockaddr_storage storage;
|
||||
|
|
Loading…
Reference in New Issue