nghttpx: Rename mruby script options

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-04 01:19:57 +09:00
parent 5967667e9e
commit d722a09581
5 changed files with 32 additions and 34 deletions

View File

@ -98,8 +98,8 @@ OPTIONS = [
"tls-ticket-key-memcached-interval",
"tls-ticket-key-memcached-max-retry",
"tls-ticket-key-memcached-max-fail",
"on-request-mruby-file",
"on-response-mruby-file",
"request-phase-file",
"response-phase-file",
"conf",
]

View File

@ -1731,14 +1731,14 @@ Process:
be used to drop root privileges.
Scripting:
--on-request-mruby-file=<PATH>
--request-phase-file=<PATH>
Set mruby script file which will be executed when
request header fields are completely received from
frontend.
--on-response-mruby-file=<PATH>
frontend. This hook is called request phase hook.
--response-phase-file=<PATH>
Set mruby script file which will be executed when
response header fields are completely received from
backend.
backend. This hook is called response phase hook.
Misc:
--conf=<PATH>
@ -1913,8 +1913,8 @@ int main(int argc, char **argv) {
89},
{SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL, required_argument, &flag,
90},
{SHRPX_OPT_ON_REQUEST_MRUBY_FILE, required_argument, &flag, 91},
{SHRPX_OPT_ON_RESPONSE_MRUBY_FILE, required_argument, &flag, 92},
{SHRPX_OPT_REQUEST_PHASE_FILE, required_argument, &flag, 91},
{SHRPX_OPT_RESPONSE_PHASE_FILE, required_argument, &flag, 92},
{nullptr, 0, nullptr, 0}};
int option_index = 0;
@ -2313,12 +2313,12 @@ int main(int argc, char **argv) {
optarg);
break;
case 91:
// --on-request-mruby-file
cmdcfgs.emplace_back(SHRPX_OPT_ON_REQUEST_MRUBY_FILE, optarg);
// --request-phase-file
cmdcfgs.emplace_back(SHRPX_OPT_REQUEST_PHASE_FILE, optarg);
break;
case 92:
// --on-response-mruby-file
cmdcfgs.emplace_back(SHRPX_OPT_ON_RESPONSE_MRUBY_FILE, optarg);
// --response-phase-file
cmdcfgs.emplace_back(SHRPX_OPT_RESPONSE_PHASE_FILE, optarg);
default:
break;
}

View File

@ -690,14 +690,14 @@ enum {
SHRPX_OPTID_NO_VIA,
SHRPX_OPTID_NPN_LIST,
SHRPX_OPTID_OCSP_UPDATE_INTERVAL,
SHRPX_OPTID_ON_REQUEST_MRUBY_FILE,
SHRPX_OPTID_ON_RESPONSE_MRUBY_FILE,
SHRPX_OPTID_PADDING,
SHRPX_OPTID_PID_FILE,
SHRPX_OPTID_PRIVATE_KEY_FILE,
SHRPX_OPTID_PRIVATE_KEY_PASSWD_FILE,
SHRPX_OPTID_READ_BURST,
SHRPX_OPTID_READ_RATE,
SHRPX_OPTID_REQUEST_PHASE_FILE,
SHRPX_OPTID_RESPONSE_PHASE_FILE,
SHRPX_OPTID_RLIMIT_NOFILE,
SHRPX_OPTID_STREAM_READ_TIMEOUT,
SHRPX_OPTID_STREAM_WRITE_TIMEOUT,
@ -1019,6 +1019,11 @@ int option_lookup_token(const char *name, size_t namelen) {
break;
case 18:
switch (name[17]) {
case 'e':
if (util::strieq_l("request-phase-fil", name, 17)) {
return SHRPX_OPTID_REQUEST_PHASE_FILE;
}
break;
case 'r':
if (util::strieq_l("add-request-heade", name, 17)) {
return SHRPX_OPTID_ADD_REQUEST_HEADER;
@ -1037,6 +1042,9 @@ int option_lookup_token(const char *name, size_t namelen) {
if (util::strieq_l("no-location-rewrit", name, 18)) {
return SHRPX_OPTID_NO_LOCATION_REWRITE;
}
if (util::strieq_l("response-phase-fil", name, 18)) {
return SHRPX_OPTID_RESPONSE_PHASE_FILE;
}
if (util::strieq_l("tls-ticket-key-fil", name, 18)) {
return SHRPX_OPTID_TLS_TICKET_KEY_FILE;
}
@ -1091,11 +1099,6 @@ int option_lookup_token(const char *name, size_t namelen) {
return SHRPX_OPTID_BACKEND_TLS_SNI_FIELD;
}
break;
case 'e':
if (util::strieq_l("on-request-mruby-fil", name, 20)) {
return SHRPX_OPTID_ON_REQUEST_MRUBY_FILE;
}
break;
case 'r':
if (util::strieq_l("tls-ticket-key-ciphe", name, 20)) {
return SHRPX_OPTID_TLS_TICKET_KEY_CIPHER;
@ -1113,11 +1116,6 @@ int option_lookup_token(const char *name, size_t namelen) {
break;
case 22:
switch (name[21]) {
case 'e':
if (util::strieq_l("on-response-mruby-fil", name, 21)) {
return SHRPX_OPTID_ON_RESPONSE_MRUBY_FILE;
}
break;
case 'i':
if (util::strieq_l("backend-http-proxy-ur", name, 21)) {
return SHRPX_OPTID_BACKEND_HTTP_PROXY_URI;
@ -1950,12 +1948,12 @@ int parse_config(const char *opt, const char *optarg,
case SHRPX_OPTID_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL:
return parse_uint(&mod_config()->tls_ticket_key_memcached_max_fail, opt,
optarg);
case SHRPX_OPTID_ON_REQUEST_MRUBY_FILE:
mod_config()->on_request_mruby_file = strcopy(optarg);
case SHRPX_OPTID_REQUEST_PHASE_FILE:
mod_config()->request_phase_file = strcopy(optarg);
return 0;
case SHRPX_OPTID_ON_RESPONSE_MRUBY_FILE:
mod_config()->on_response_mruby_file = strcopy(optarg);
case SHRPX_OPTID_RESPONSE_PHASE_FILE:
mod_config()->response_phase_file = strcopy(optarg);
return 0;
case SHRPX_OPTID_CONF:

View File

@ -183,8 +183,8 @@ constexpr char SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_RETRY[] =
"tls-ticket-key-memcached-max-retry";
constexpr char SHRPX_OPT_TLS_TICKET_KEY_MEMCACHED_MAX_FAIL[] =
"tls-ticket-key-memcached-max-fail";
constexpr char SHRPX_OPT_ON_REQUEST_MRUBY_FILE[] = "on-request-mruby-file";
constexpr char SHRPX_OPT_ON_RESPONSE_MRUBY_FILE[] = "on-response-mruby-file";
constexpr char SHRPX_OPT_REQUEST_PHASE_FILE[] = "request-phase-file";
constexpr char SHRPX_OPT_RESPONSE_PHASE_FILE[] = "response-phase-file";
union sockaddr_union {
sockaddr_storage storage;
@ -316,8 +316,8 @@ struct Config {
std::unique_ptr<char[]> user;
std::unique_ptr<char[]> session_cache_memcached_host;
std::unique_ptr<char[]> tls_ticket_key_memcached_host;
std::unique_ptr<char[]> on_request_mruby_file;
std::unique_ptr<char[]> on_response_mruby_file;
std::unique_ptr<char[]> request_phase_file;
std::unique_ptr<char[]> response_phase_file;
FILE *http2_upstream_dump_request_header;
FILE *http2_upstream_dump_response_header;
nghttp2_session_callbacks *http2_upstream_callbacks;

View File

@ -152,8 +152,8 @@ std::unique_ptr<MRubyContext> create_mruby_context() {
init_module(mrb);
auto req_file = get_config()->on_request_mruby_file.get();
auto res_file = get_config()->on_response_mruby_file.get();
auto req_file = get_config()->request_phase_file.get();
auto res_file = get_config()->response_phase_file.get();
auto req_proc = compile(mrb, req_file);