From d722a095813a1f9957e62ab821b0e59401d20598 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 4 Sep 2015 01:19:57 +0900 Subject: [PATCH] nghttpx: Rename mruby script options --- gennghttpxfun.py | 4 ++-- src/shrpx.cc | 20 ++++++++++---------- src/shrpx_config.cc | 30 ++++++++++++++---------------- src/shrpx_config.h | 8 ++++---- src/shrpx_mruby.cc | 4 ++-- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/gennghttpxfun.py b/gennghttpxfun.py index 74732b98..3114137d 100755 --- a/gennghttpxfun.py +++ b/gennghttpxfun.py @@ -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", ] diff --git a/src/shrpx.cc b/src/shrpx.cc index 4b5b2dc8..7ef8e1ed 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -1731,14 +1731,14 @@ Process: be used to drop root privileges. Scripting: - --on-request-mruby-file= + --request-phase-file= Set mruby script file which will be executed when request header fields are completely received from - frontend. - --on-response-mruby-file= + frontend. This hook is called request phase hook. + --response-phase-file= 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= @@ -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; } diff --git a/src/shrpx_config.cc b/src/shrpx_config.cc index a923575a..09ee2e36 100644 --- a/src/shrpx_config.cc +++ b/src/shrpx_config.cc @@ -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: diff --git a/src/shrpx_config.h b/src/shrpx_config.h index 427062b5..2bbb9647 100644 --- a/src/shrpx_config.h +++ b/src/shrpx_config.h @@ -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 user; std::unique_ptr session_cache_memcached_host; std::unique_ptr tls_ticket_key_memcached_host; - std::unique_ptr on_request_mruby_file; - std::unique_ptr on_response_mruby_file; + std::unique_ptr request_phase_file; + std::unique_ptr response_phase_file; FILE *http2_upstream_dump_request_header; FILE *http2_upstream_dump_response_header; nghttp2_session_callbacks *http2_upstream_callbacks; diff --git a/src/shrpx_mruby.cc b/src/shrpx_mruby.cc index 50a5ebb0..f2f23512 100644 --- a/src/shrpx_mruby.cc +++ b/src/shrpx_mruby.cc @@ -152,8 +152,8 @@ std::unique_ptr 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);