#define PROXY_DECLARE_DATA __declspec(dllimport)
#endif
-/* Following 3 from health check */
+/* Following 4 from health check */
APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *));
APR_DECLARE_OPTIONAL_FN(void, hc_select_exprs, (request_rec *, const char *));
+APR_DECLARE_OPTIONAL_FN(int, hc_valid_expr, (request_rec *, const char *));
APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param,
(apr_pool_t *, server_rec *, proxy_worker *,
const char *, const char *, void *));
static APR_OPTIONAL_FN_TYPE(hc_show_exprs) *hc_show_exprs_f = NULL;
static APR_OPTIONAL_FN_TYPE(hc_select_exprs) *hc_select_exprs_f = NULL;
+static APR_OPTIONAL_FN_TYPE(hc_valid_expr) *hc_valid_expr_f = NULL;
/*
set_worker_hc_param_f = APR_RETRIEVE_OPTIONAL_FN(set_worker_hc_param);
hc_show_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_show_exprs);
hc_select_exprs_f = APR_RETRIEVE_OPTIONAL_FN(hc_select_exprs);
+ hc_valid_expr_f = APR_RETRIEVE_OPTIONAL_FN(hc_valid_expr);
return OK;
}
wsel->s->lbset = ival;
}
}
+ if ((val = apr_table_get(params, "w_hi"))) {
+ int ival = atoi(val);
+ if (ival >= HCHECK_WATHCHDOG_INTERVAL) {
+ wsel->s->interval = apr_time_from_sec(ival);
+ }
+ }
+ if ((val = apr_table_get(params, "w_hp"))) {
+ int ival = atoi(val);
+ if (ival >= 1) {
+ wsel->s->passes = ival;
+ }
+ }
+ if ((val = apr_table_get(params, "w_hf"))) {
+ int ival = atoi(val);
+ if (ival >= 1) {
+ wsel->s->fails = ival;
+ }
+ }
+ if ((val = apr_table_get(params, "w_hm"))) {
+ proxy_hcmethods_t *method = proxy_hcmethods;
+ for (; method->name; method++) {
+ if (!ap_casecmpstr(method->name, val) && method->implemented)
+ wsel->s->method = method->method;
+ }
+ }
+ if ((val = apr_table_get(params, "w_hu"))) {
+ if (strlen(val) && strlen(val) < sizeof(wsel->s->hcuri))
+ strcpy(wsel->s->hcuri, val);
+ else
+ *wsel->s->hcuri = '\0';
+ }
+ if (hc_valid_expr_f && (val = apr_table_get(params, "w_he"))) {
+ if (strlen(val) && hc_valid_expr_f(r, val) && strlen(val) < sizeof(wsel->s->hcexpr))
+ strcpy(wsel->s->hcexpr, val);
+ else
+ *wsel->s->hcexpr = '\0';
+ }
+
/* if enabling, we need to reset all lb params */
if (bsel && !was_usable && PROXY_WORKER_IS_USABLE(wsel)) {
bsel->s->need_reset = 1;
}
ap_rprintf(r, "<option value='%s' %s >%s</option>\n",
ap_escape_html(r->pool, elts[i].key),
- (!ap_casecmpstr(elts[i].key, expr)) ? "selected" : "",
+ (!strcmp(elts[i].key, expr)) ? "selected" : "",
ap_escape_html(r->pool, elts[i].key));
}
}
+static int hc_valid_expr(request_rec *r, const char *expr)
+{
+ const apr_table_entry_t *elts;
+ const apr_array_header_t *hdr;
+ int i;
+ sctx_t *ctx = (sctx_t *) ap_get_module_config(r->server->module_config,
+ &proxy_hcheck_module);
+ if (apr_is_empty_table(ctx->conditions))
+ return 0;
+
+ hdr = apr_table_elts(ctx->conditions);
+ elts = (const apr_table_entry_t *) hdr->elts;
+ for (i = 0; i < hdr->nelts; ++i) {
+ if (!elts[i].key) {
+ continue;
+ }
+ if (!strcmp(elts[i].key, expr))
+ return 1;
+ }
+ return 0;
+}
+
static const char *hc_get_body(request_rec *r)
{
apr_off_t length;
APR_REGISTER_OPTIONAL_FN(set_worker_hc_param);
APR_REGISTER_OPTIONAL_FN(hc_show_exprs);
APR_REGISTER_OPTIONAL_FN(hc_select_exprs);
+ APR_REGISTER_OPTIONAL_FN(hc_valid_expr);
ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST);
ap_hook_expr_lookup(hc_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE);
}